【发布时间】:2012-12-16 13:52:54
【问题描述】:
我的~/.emacs 包含以下设置,用于使用某些应用程序(Ubuntu 12.10;Emacs 24)打开某些文件:
(setq dired-guess-shell-alist-user
'(("\\.pdf\\'" "okular ? &")
("\\.djvu\\'" "okular ? &")
("\\.mp3\\'" "vlc ? &")
("\\.mp4\\'" "vlc ? &")
))
当我导航到 dired-mode 中的 .pdf 并点击 ! 时,它会在 Okular 中打开 .pdf,但 dired-buffer 分为两部分,第二部分现在是无用的 *Async Shell Command* 缓冲区包含类似的内容
okular(25393)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(25393)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(25393)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(25393)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
如何防止这个缓冲区被打开? (除了,也许,如果有一个错误,这个信息是有用的)。
我发现了相关问题here 和here,但它们似乎处理异步执行的特定命令,而不是一般的*Async Shell Command*(如果可能,我想更改异步进程的一般行为,不仅适用于某些文件类型)
【问题讨论】:
-
看看
.../lisp/simple.el源代码中的实际函数——即defun shell-command和defun async-shell-command。您甚至可以创建自己的自定义函数和/或使用defalias。当使用start-process时,第二个参数是输出缓冲区名称——使用nil作为第二个参数可以防止创建输出缓冲区。您可以将set-process-sentinel与start-process结合使用。 -
async-shell-command的文档字符串声明:... In Elisp, you will often be better served by calling 'start-process' directly, since it offers more control and does not impose the use of a shell (with its need to quote arguments).
标签: emacs asynchronous dired