Last active
December 22, 2015 12:39
-
-
Save sabof/6474059 to your computer and use it in GitHub Desktop.
Replace the parser in newsticker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun es-xml-process-keywords (keywords) | |
(mapcar | |
(lambda (pair) | |
(let ( (keyword-name (car pair))) | |
(cons | |
(cond ( (stringp keyword-name) | |
(intern keyword-name)) | |
( (consp keyword-name) | |
(intern (cdr keyword-name))) | |
( t keyword-name)) | |
(cdr pair)))) | |
keywords)) | |
(defun es-xml-walker (node) | |
(let ((node-name (car node))) | |
(append | |
(list (cond ( (stringp node-name) | |
(intern node-name)) | |
( (consp node-name) | |
(intern (cdr node-name))) | |
( t node-name))) | |
(list (es-xml-process-keywords (cadr node))) | |
(mapcar (lambda (thing) | |
(if (consp thing) | |
(es-xml-walker thing) | |
thing)) | |
(cddr node))))) | |
(defun es-xml-convert-from-nxml (nxml-output) | |
(list (es-xml-walker nxml-output))) | |
(defalias 'es-xml-parse-region-ori (symbol-function 'xml-parse-region)) | |
(defadvice newsticker--sentinel-work (around alt-backend-for-xah activate) | |
(flet (( xml-parse-region (&rest args) | |
(if (some (apply-partially | |
'string-match | |
(mapconcat 'identity | |
(list "feedburner" | |
"armene\\.com" | |
"nytimes" | |
"guardian") | |
"\\|")) | |
command) | |
(es-xml-convert-from-nxml | |
(nxml-parse-instance)) | |
(apply 'es-xml-parse-region-ori args)))) | |
ad-do-it)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment