6

Emacs 显然可以处理多个异步子进程,否则像 org-babel 这样的多语言编程环境,举个例子,是不可能的。

但是,当我在 Dired 并启动异步 shell 命令以查看 pdf 文件(& evince),然后尝试对第二个 pdf 文件执行相同操作时,我收到以下消息:

“一个命令正在运行——杀死它?是还是不是?”

在 Dired 中,有没有办法并行运行多个异步 shell 命令?

4

3 回答 3

13

当你使用dired-do-async-shell-commandEmacs 时创建一个*Async Shell Command*缓冲区。如果你想要另一个异步命令,你需要重命名这个缓冲区,例如使用M-x rename-uniquely

您可以尝试dired-do-async-shell-command通过建议来更改其行为:

 (defadvice shell-command (after shell-in-new-buffer (command &optional output-buffer error-buffer))
    (when (get-buffer "*Async Shell Command*")
      (with-current-buffer "*Async Shell Command*"
         (rename-uniquely))))
 (ad-activate 'shell-command)

请注意,我真的建议使用 shell-command Emacs 命令,因为它是由 dired 调用的。

于 2011-08-01T07:45:24.743 回答
2

我不认为这是可能的dired-do-async-shell-command,但如果你只是想打开某个文件是某个外部应用程序,我建议使用OpenWith,它允许运行任意数量的外部进程。

于 2011-08-01T07:19:00.110 回答
0

我刚刚设置了以下内容,它删除了 dired-run-shell-command 的当前定义,以将专用缓冲区名称传递给 shell-command:

(defun dired-run-shell-command (command)
       (let ((handler
          (find-file-name-handler (directory-file-name default-directory)
                      'shell-command)))
     (if handler (apply handler 'shell-command (list command))
       (shell-command command
              (generate-new-buffer-name
               (concat "*Shell Command Output: '" command "'*")))))
       ;; Return nil for sake of nconc in dired-bunch-files.
       nil)
于 2012-04-19T07:36:55.497 回答