【发布时间】:2013-11-13 23:57:40
【问题描述】:
我有一个函数应该创建一个 ctags 文件并将其异步加载到 Emacs 中。如果在非常大的文件上调用 ctags 可能需要一段时间才能运行,并且我不希望我的函数进行任何阻塞,因此我使用 start-process。这就是它的样子:
(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))
由于某种原因,标签文件总是空白。从 shell 调用具有完全相同参数的 ctags 会生成一个非空白的工作标记文件。如何让 ctags 正确打印其输出?
【问题讨论】: