Skip to content

Instantly share code, notes, and snippets.

@sabof
Last active December 22, 2015 12:39
Show Gist options
  • Save sabof/6474059 to your computer and use it in GitHub Desktop.
Save sabof/6474059 to your computer and use it in GitHub Desktop.
Replace the parser in newsticker
(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