2010-12-06 96 views
7

是否有可能將「-yes」標誌傳遞給emacs中的「重新編譯」命令?emacs(重新編譯-y)

請原諒我完全缺乏(e)lisp專有技術。我生病了要去外面的Emacs編譯我乳膠的代碼,所以我說下面的按鍵綁定到我的.emacs:

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

是否有可能自動地回答「是」可能出現的如下提示: 「編譯過程正在運行;殺死它?(是或否)。」

另外,是否可以使窗口打開並顯示輸出以自動滾動到底部。有趣的東西通常在那裏。也許有可能在重新編譯後鏈接下面的命令:「C-x o,緩衝區結束」。

謝謝!

+1

或者,也許你可以只通過` - halt-on-error「複製到`pdflatex`(或類似的)。 – cYrus 2015-04-11 12:03:39

回答

7

下面是一些代碼來解決你的第一個問題(中斷當前編譯):

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

對於你的第二個問題(滾動編譯輸出),只需定製用戶設置compilation-scroll-output

+0

它的工作,謝謝。 – qonf 2010-12-06 11:49:52

2

我不知何故需要將kill-compilation放入Emacs 23.2的忽略錯誤中,以便在沒有進程運行時使其工作。否則,效果很好。

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

每當我嘗試使用kill-compilation乳膠/ pdflatex它沒有工作。我認爲這是因爲乳膠不響應SIGINT。

取而代之,我正在使用以下hack,它首先設置compilation緩衝區中的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) 
)