smart-compile
パッケージをEmacs内にインストールします。
あなたがC-x C-m
を実行するのは初めてであれば、それは通常は十分である(デフォルトのコマンドを変更するように要求されます、あなたのソースコードをコンパイルするために使用C-x C-m
あなたや.emacs
(require 'compile)
(setq compilation-last-buffer nil)
;; save all modified buffers without asking before compilation
(setq compilation-ask-about-save nil)
(defun compile-again (ARG)
"Run the same compile as the last time.
With a prefix argument or no last time, this acts like M-x compile,
and you can reconfigure the compile args."
(interactive "p")
;; the following two lines create bug: split a new window every time
;; (if (not (get-buffer-window "*compilation*"))
;; (split-window-below))
(if (and (eq ARG 1) compilation-last-buffer)
(recompile)
(call-interactively 'smart-compile)))
(bind-key* "C-x C-m" 'compile-again)
;; create a new small frame to show the compilation info
;; will be auto closed if no error
(setq special-display-buffer-names
`(("*compilation*" . ((name . "*compilation*")
,@default-frame-alist
(left . (- 1))
(top . 0)))))
(setq compilation-finish-functions
(lambda (buf str)
(if (null (string-match ".*exited abnormally.*" str))
;;no errors, make the compilation window go away in a few seconds
(progn
(run-at-time
"1 sec" nil 'delete-windows-on
(get-buffer-create "*compilation*"))
(message "No Compilation Errors!")))))
にこれを追加)、それ以外の場合は直接コンパイルに使用したコマンドが実行され、必要に応じてC-u C-x C-m
を使用してコマンドを変更する必要があります。現在のディレクトリ内にMakefile
がある場合は、使用するかどうかを確認するメッセージが表示されます。
多分この回答はあなたの質問には多すぎますが、試してみてください。
全く動作しません。 – CodyChan