mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
project-compile: Don't let-bind compile-command
* lisp/progmodes/project.el (project-compile): Handle ignoring compile-command from a vc-compilation-mode buffer in a way that does not involve let-binding compile-command.
This commit is contained in:
parent
27f0a3fd86
commit
16b19ceb28
1 changed files with 20 additions and 12 deletions
|
|
@ -1639,18 +1639,26 @@ If non-nil, it overrides `compilation-buffer-name-function' for
|
||||||
"Run `compile' in the project root."
|
"Run `compile' in the project root."
|
||||||
(declare (interactive-only compile))
|
(declare (interactive-only compile))
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((default-directory (project-root (project-current t)))
|
(let* ((default-directory (project-root (project-current t)))
|
||||||
(compilation-buffer-name-function
|
(compilation-buffer-name-function
|
||||||
(or project-compilation-buffer-name-function
|
(or project-compilation-buffer-name-function
|
||||||
compilation-buffer-name-function))
|
compilation-buffer-name-function))
|
||||||
;; Specifically ignore the value of `compile-command' if we were
|
(orig-current-buffer (and (derived-mode-p 'vc-compilation-mode)
|
||||||
;; invoked from a `vc-compilation-mode' buffer because for
|
(local-variable-p 'compile-command)
|
||||||
;; `project-compile' we know the user wants to build the
|
(current-buffer)))
|
||||||
;; project, not re-run a VC pull or push operation (bug#79658).
|
(orig-compile-command (and orig-current-buffer compile-command)))
|
||||||
(compile-command (if (derived-mode-p 'vc-compilation-mode)
|
;; If invoked from a `vc-compilation-mode' buffer, we want to ignore
|
||||||
(with-temp-buffer compile-command)
|
;; `compile-command' because for this command we know the user wants
|
||||||
compile-command)))
|
;; to build the project, not re-run a VC pull or push (bug#79658).
|
||||||
(call-interactively #'compile)))
|
;; Do this without let-binding `compile-command', however, in order
|
||||||
|
;; that the user's command to build the project is not immediately
|
||||||
|
;; thrown away. Essentially we want to turn the `setq' of
|
||||||
|
;; `compile-command' done by `compile' into a `setq-default'.
|
||||||
|
(when orig-current-buffer
|
||||||
|
(kill-local-variable 'compile-command))
|
||||||
|
(unwind-protect (call-interactively #'compile)
|
||||||
|
(with-current-buffer orig-current-buffer
|
||||||
|
(setq-local compile-command orig-compile-command)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun project-recompile (&optional edit-command)
|
(defun project-recompile (&optional edit-command)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue