elisp

Compilation queue (cq.el)

Tagged:  •    •  
The following is part of my home-grown compilation environment in emacs.
  1. (defvar funclist)
  2. (defvar cq-compilation-started 'nil)
  3.  
  4. (defun cg-init ()
  5. (setq compilation-finish-functions 'cq-call) ;; this function called when compilation has finished - see compile.el
  6. (setq compilation-exit-message-function
  7. (lambda (status code msg)
  8. ;; If M-x compile exists with a 0
  9. (when (and (eq status 'exit) (zerop code))
  10. ;; then bury the *compilation* buffer, so that C-x b doesn't go there
  11. (bury-buffer "*compilation*")

XML processing in Elisp

Tagged:  •    •    •  
Recent versions Emacs has built in xml support, and there are libraries available that give you DOM and even XPath capabilities. I've started experimenting with it as I want to process Eclipse Workspaces. Ideally, I should be using XPath, but that has too many dependencies for now (it depends on parts of Semantic). So, using the xml-parse examples on EmacsWiki.org, here is some simple code to get a the "userid" attibutes from all the "to" elements of the following xml data:
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <note topic="weekend plans">
  3. <to userid="1">Tove</to>
  4. <from userid="2">Jani</from>
  5. <heading>Reminder</heading>
  6. <body>Don't forget me this weekend!</body>
  7. <to userid="3">Bob</to>
  8. <from userid="4">Sammy</from>
  9. <heading>Alas!</heading>
  10. <body>A new week!</body>
  11. </note>

Get list of files referenced in tags table

Tagged:  •  

(defun tagutils-get-file-list ()
"Returns a list of files referenced in the tags table"
(interactive)
(if (visit-tags-table-buffer)
(progn
(tags-table-files)
(mapcar 'expand-file-name (tags-table-files))))
)

Syndicate content