From: Sam Steingold Date: Wed, 7 Apr 2010 16:20:35 +0000 (-0400) Subject: (compilation-save-buffers-predicate): New custom variable. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~566 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9e86ab0bc776f59ca97bd1487af0b38364d5ec5b;p=emacs.git (compilation-save-buffers-predicate): New custom variable. (compile, recompile): Pass it to `save-some-buffers'. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ad2f6cf56ee..6cdaaf2255b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2010-04-07 Sam Steingold + + * progmodes/compile.el (compilation-save-buffers-predicate): New + custom variable. + (compile, recompile): Pass it to `save-some-buffers'. + 2010-04-07 Jan Djärv * wid-edit.el (widget-choose): Move cursor to the second line of diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 51e42809153..5fc4a5f99df 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -583,6 +583,21 @@ Otherwise, it saves all modified buffers without asking." :type 'boolean :group 'compilation) +;;;###autoload +(defcustom compilation-save-buffers-predicate nil + "The second argument (PRED) passed to `save-some-buffers' before compiling. +E.g., one can set this to + (lambda () + (string-prefix-p my-compilation-root (file-truename (buffer-file-name)))) +to limit saving to files located under `my-compilation-root'. +Note, that, in general, `compilation-directory' cannot be used instead +of `my-compilation-root' here." + :type '(choice + (const :tag "Default (save all file-visiting buffers)" nil) + (const :tag "Save all buffers" t) + function) + :group 'compilation) + ;;;###autoload (defcustom compilation-search-path '(nil) "List of directories to search for source files named in error messages. @@ -1097,7 +1112,8 @@ to a function that generates a unique name." (consp current-prefix-arg))) (unless (equal command (eval compile-command)) (setq compile-command command)) - (save-some-buffers (not compilation-ask-about-save) nil) + (save-some-buffers (not compilation-ask-about-save) + compilation-save-buffers-predicate) (setq-default compilation-directory default-directory) (compilation-start command comint)) @@ -1108,7 +1124,8 @@ 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) nil) + (save-some-buffers (not compilation-ask-about-save) + compilation-save-buffers-predicate) (let ((default-directory (or compilation-directory default-directory))) (when edit-command (setcar compilation-arguments