I have a function that is supposed to create a ctags file and load it into Emacs asynchronously. ctags can take a while to run if invoked on really big files, and I don't want my function to do any blocking, thus I use start-process
. This is what it all looks like:
(defun temp-tags-file-for-file (file)
"Generate a temporary tags file for FILE.
Add the file to tags list and return the name of the file."
(if (not (boundp 'ctags-command))
(setq ctags-command "/usr/bin/ctags"))
(let* ((temp-file (make-temp-file "EMACS_TAGS"))
(proc (start-process "temp-tags-proc" nil ctags-command
"-f" temp-file file)))
(set-process-sentinel proc
(lambda (proc msg)
(when (eq (process-status proc) 'exit)
(if (boundp 'temp-tags-file)
(progn
(add-to-list 'tags-table-list
temp-tags-file)
(makunbound 'temp-tags-file))))))
(setq temp-tags-file temp-file)
temp-file))
For some reason, the tags file is always blank. Calling ctags with the exact same parameters from the shell generates a non-blank, working tags file. How do I get ctags to print its output properly?