1

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?

4

1 回答 1

1

如果ctags想要外壳,只需将其交给外壳:

(start-process "temp-tags-proc" nil shell-file-name shell-command-switch
         (format "/usr/bin/ctags ~/Dropbox/source/c/*.c -f %s"
                 (make-temp-file "EMACS_TAGS")))
于 2013-11-14T09:32:48.447 回答