* lisp/progmodes/compile.el (compilation-start): Use compilation-always-kill
authorMartin Blais <blais@furius.ca>
Tue, 18 Sep 2012 04:18:36 +0000 (00:18 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 18 Sep 2012 04:18:36 +0000 (00:18 -0400)
to initialize query-on-exit; then test that instead.

Fixes: debbugs:12288

lisp/ChangeLog
lisp/progmodes/compile.el

index 7ceacc5..c1c9e5e 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-18  Martin Blais  <blais@furius.ca>  (tiny change)
+
+       * progmodes/compile.el (compilation-start): Use compilation-always-kill
+       to initialize query-on-exit; then test that instead (bug#12288).
+
 2012-09-17  Stefan Merten  <smerten@oekonux.de>
 
        * rst.el: Add support for `testcover'.
        :local as the address.
        (list-processes): Doc fix.
 
-2012-08-04  Michal Nazarewicz  <mina86@mina86.com>  (tiny change)
+2012-08-04  Michal Nazarewicz  <mina86@mina86.com>
 
        * lisp/mpc.el: Support password in host argument.
        (mpc--proc-connect): Parse and use new password element.
index f5dedf0..95b8758 100644 (file)
@@ -1556,20 +1556,20 @@ Returns the compilation buffer created."
              (get-buffer-create
                (compilation-buffer-name name-of-mode mode name-function)))
       (let ((comp-proc (get-buffer-process (current-buffer))))
-       (if comp-proc
-           (if (or (not (eq (process-status comp-proc) 'run))
-                    compilation-always-kill
-                   (yes-or-no-p
-                    (format "A %s process is running; kill it? "
-                            name-of-mode)))
-               (condition-case ()
-                   (progn
-                     (interrupt-process comp-proc)
-                     (sit-for 1)
-                     (delete-process comp-proc))
-                 (error nil))
-             (error "Cannot have two processes in `%s' at once"
-                    (buffer-name)))))
+      (if comp-proc
+          (if (or (not (eq (process-status comp-proc) 'run))
+                  (eq (process-query-on-exit-flag comp-proc) nil)
+                  (yes-or-no-p
+                   (format "A %s process is running; kill it? "
+                           name-of-mode)))
+              (condition-case ()
+                  (progn
+                    (interrupt-process comp-proc)
+                    (sit-for 1)
+                    (delete-process comp-proc))
+                (error nil))
+            (error "Cannot have two processes in `%s' at once"
+                   (buffer-name)))))
       ;; first transfer directory from where M-x compile was called
       (setq default-directory thisdir)
       ;; Make compilation buffer read-only.  The filter can still write it.
@@ -1624,7 +1624,7 @@ Returns the compilation buffer created."
       (let ((process-environment
             (append
              compilation-environment
-             (if (if (boundp 'system-uses-terminfo) ; `if' for compiler warning
+             (if (if (boundp 'system-uses-terminfo);`If' for compiler warning.
                      system-uses-terminfo)
                  (list "TERM=dumb" "TERMCAP="
                        (format "COLUMNS=%d" (window-width)))
@@ -1674,13 +1674,20 @@ Returns the compilation buffer created."
                           nil `("-c" ,command))))
                     (start-file-process-shell-command (downcase mode-name)
                                                       outbuf command))))
-             ;; Make the buffer's mode line show process state.
-             (setq mode-line-process
-                   '(:propertize ":%s" face compilation-mode-line-run))
-             (set-process-sentinel proc 'compilation-sentinel)
-             (unless (eq mode t)
-               ;; Keep the comint filter, since it's needed for proper handling
-               ;; of the prompts.
+              ;; Make the buffer's mode line show process state.
+              (setq mode-line-process
+                    '(:propertize ":%s" face compilation-mode-line-run))
+
+              ;; Set the process as killable without query by default.
+              ;; This allows us to start a new compilation without
+              ;; getting prompted.
+              (when compilation-always-kill
+                (set-process-query-on-exit-flag proc nil))
+
+              (set-process-sentinel proc 'compilation-sentinel)
+              (unless (eq mode t)
+                ;; Keep the comint filter, since it's needed for proper
+               ;; handling of the prompts.
                (set-process-filter proc 'compilation-filter))
              ;; Use (point-max) here so that output comes in
              ;; after the initial text,