【问题标题】:emacs ( recompile -y )emacs ( 重新编译 -y )
【发布时间】:2010-12-06 11:23:36
【问题描述】:

是否可以将“-yes”标志传递给 emacs 中的“重新编译”命令?

请原谅我完全缺乏 (e)lisp 专业知识。我厌倦了在 Emacs 之外编译我的乳胶代码,所以我在我的 .emacs 中添加了以下键绑定:

(global-set-key (kbd "<f12>") 'recompile);

是否可以对可能出现的以下提示自动回答“是”: “一个编译进程正在运行;杀死它?(是或否)。”

另外,是否可以使打开并显示输出的窗口自动滚动到底部。有趣的东西通常在下面。也许重新编译后可以链接以下命令:“C-x o, end-of-buffer”。

谢谢!

【问题讨论】:

  • 或者您可以将-halt-on-error 传递给pdflatex(或类似的)。

标签: emacs elisp


【解决方案1】:

这里有一些代码可以解决您的第一个问题(中断当前编译):

(defun interrupt-and-recompile ()
  "Interrupt old compilation, if any, and recompile."
  (interactive)
  (ignore-errors (kill-compilation))
  (recompile))

对于第二个问题(滚动编译输出),只需自定义用户设置compilation-scroll-output。

【讨论】:

    【解决方案2】:

    此行为由compilation-always-kill 全局变量控制。通过customize-variable 对其进行自定义并将其设置为t。

    不确定哪个版本的 emacs 最先有这个,但 26 和更新的肯定有。

    【讨论】:

    • NEWS.24 说它是为 Emacs 24.3 添加的。
    【解决方案3】:

    我需要将 kill-compilation 放入 Emacs 23.2 的忽略错误中,以便在没有进程运行时让它工作。否则效果很好。

    (defun interrupt-and-recompile ()
      "Interrupt old compilation, if any, and recompile."
      (interactive)
      (ignore-errors
        (kill-compilation))
      (recompile)
    )
    

    【讨论】:

      【解决方案4】:

      每当我尝试将kill-compilation 与latex/pdflatex 一起使用时,它都不起作用。我认为这是因为乳胶不响应 SIGINT。

      相反,我使用以下 hack,它首先设置 <em>compilation</em>-buffer 的 process-kill-without-query 位,然后关闭它(这会终止正在运行的进程)。

      (defun interrupt-and-recompile ()
        "Interrupt old compilation, if any, and recompile."
        (interactive)
        (ignore-errors 
          (process-kill-without-query 
            (get-buffer-process
              (get-buffer "*compilation*"))))
        (ignore-errors 
          (kill-buffer "*compilation*"))
        (recompile)
      )
      

      【讨论】:

        【解决方案5】:

        由于与 sfeuz 相同的原因,其他解决方案对我不起作用,但我不喜欢按名称杀死硬编码缓冲区的核选项。

        这是一个简短的解决方案,通过建议是或否p自动回答该特定问题的“是”:

        ftp://download.tuxfamily.org/user42/compilation-always-kill.el

        (来源:http://www.emacswiki.org/CompilationMode)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-12-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-02-06
          相关资源
          最近更新 更多