【问题标题】:Multiple asynchronous shell-commands in Emacs-Dired?Emacs-Dired 中的多个异步 shell 命令?
【发布时间】:2011-08-01 07:06:03
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: shell emacs asynchronous command dired


    【解决方案1】:

    当你使用dired-do-async-shell-command时,Emacs 会创建一个*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 调用的。

    【讨论】:

    • 这是另一种有效的选择,可惜只能接受一个答案——也谢谢你。
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      我刚刚设置了以下内容,它删除了 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-08-18
        • 2012-01-13
        • 2011-01-23
        • 2010-11-30
        • 2023-03-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多