我通常会设置一个非平凡的编译命令,然后频繁调用'recompile
。有没有办法抑制保存文件的提示,类似于在 auctex 中调用的方法(setq TeX-save-query nil)
?我发现总是必须手动保存或y
在提示符下按,这非常烦人。当我点击重新编译时,我希望在必要时保存所有文件。
答案1
compilation-ask-about-save is a variable defined in `compile.el'.
Its value is t
Documentation:
Non-nil means M-x compile asks which buffers to save before compiling.
Otherwise, it saves all modified buffers without asking.
You can customize this variable.
下面是函数recompile
,它演示了还使用变量compilation-ask-about-save
:
(defun recompile (&optional edit-command)
"Re-compile the program including the current buffer.
If this is run in a Compilation mode buffer, re-use the arguments from the
original use. Otherwise, recompile using `compile-command'.
If the optional argument `edit-command' is non-nil, the command can be edited."
(interactive "P")
(save-some-buffers (not compilation-ask-about-save)
compilation-save-buffers-predicate)
(let ((default-directory (or compilation-directory default-directory))
(command (eval compile-command)))
(when edit-command
(setq command (compilation-read-command (or (car compilation-arguments)
command)))
(if compilation-arguments (setcar compilation-arguments command)))
(apply 'compilation-start (or compilation-arguments (list command)))))
另请参阅 —— 的文档字符串save-some-buffers
”可选参数(前缀)非零表示毫无疑问地保存所有内容。“
save-some-buffers is an interactive compiled Lisp function in
`files.el'.
It is bound to C-x s.
(save-some-buffers &optional ARG PRED)
Save some modified file-visiting buffers. Asks user about each one.
You can answer `y' to save, `n' not to save, `C-r' to look at the
buffer in question with `view-buffer' before deciding or `d' to
view the differences using `diff-buffer-with-file'.
This command first saves any buffers where `buffer-save-without-query' is
non-nil, without asking.
Optional argument (the prefix) non-nil means save all with no questions.
Optional second argument PRED determines which buffers are considered:
If PRED is nil, all the file-visiting buffers are considered.
If PRED is t, then certain non-file buffers will also be considered.
If PRED is a zero-argument function, it indicates for each buffer whether
to consider it or not when called with that buffer current.
See `save-some-buffers-action-alist' if you want to
change the additional actions you can take on files.