aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1995-08-21 22:15:58 +0000
committerRoland McGrath1995-08-21 22:15:58 +0000
commit01f89d118362180114153cc39b88cdf3495deae2 (patch)
tree60aa74792d1dbc72518795a4506b6bb0f24e4216
parent59aadc813c30893d688c0722d53a9f6cd2430508 (diff)
downloademacs-01f89d118362180114153cc39b88cdf3495deae2.tar.gz
emacs-01f89d118362180114153cc39b88cdf3495deae2.zip
(compilation-exit-message-function): New variable.
(compilation-sentinel): If compilation-exit-message-function is non-nil, call it to produce messages for buffer and mode line. (grep): Use that variable to produce snazzier messages.
-rw-r--r--lisp/progmodes/compile.el41
1 files changed, 32 insertions, 9 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 29de92e8cc1..508283ca740 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -257,6 +257,12 @@ The default value matches lines printed by the `-w' option of GNU Make.")
257 "Stack of previous directories for `compilation-leave-directory-regexp'. 257 "Stack of previous directories for `compilation-leave-directory-regexp'.
258The head element is the directory the compilation was started in.") 258The head element is the directory the compilation was started in.")
259 259
260(defvar compilation-exit-message-function nil "\
261If non-nil, called when a compilation process dies to return a status message.
262This should be a function a two arguments as passed to a process sentinel
263\(see `set-process-sentinel\); it returns a cons (MESSAGE . MODELINE) of the
264strings to write into the compilation buffer, and to put in its mode line.")
265
260;; History of compile commands. 266;; History of compile commands.
261(defvar compile-history nil) 267(defvar compile-history nil)
262;; History of grep commands. 268;; History of grep commands.
@@ -266,7 +272,7 @@ The head element is the directory the compilation was started in.")
266 '(("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 1 font-lock-function-name-face)) 272 '(("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 1 font-lock-function-name-face))
267;;; ("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 0 font-lock-keyword-face keep) 273;;; ("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 0 font-lock-keyword-face keep)
268 "Additional expressions to highlight in Compilation mode.") 274 "Additional expressions to highlight in Compilation mode.")
269 275
270;;;###autoload 276;;;###autoload
271(defun compile (command) 277(defun compile (command)
272 "Compile the program including the current buffer. Default: run `make'. 278 "Compile the program including the current buffer. Default: run `make'.
@@ -317,10 +323,23 @@ easily repeat a grep command."
317 (interactive 323 (interactive
318 (list (read-from-minibuffer "Run grep (like this): " 324 (list (read-from-minibuffer "Run grep (like this): "
319 grep-command nil nil 'grep-history))) 325 grep-command nil nil 'grep-history)))
320 (compile-internal (concat command-args " " grep-null-device) 326 (let ((buf (compile-internal (concat command-args " " grep-null-device)
321 "No more grep hits" "grep" 327 "No more grep hits" "grep"
322 ;; Give it a simpler regexp to match. 328 ;; Give it a simpler regexp to match.
323 nil grep-regexp-alist)) 329 nil grep-regexp-alist)))
330 (save-excursion
331 (set-buffer buf)
332 (set (make-local-variable 'compilation-exit-message-function)
333 (lambda (proc msg)
334 (let ((code (process-exit-status proc)))
335 (if (eq (process-status proc) 'exit)
336 (cond ((zerop code)
337 '("finished (matches found)\n" . "matched"))
338 ((= code 1)
339 '("finished with no matches found\n" . "no match"))
340 (t
341 (cons msg code)))
342 (cons msg code))))))))
324 343
325(defun compile-internal (command error-message 344(defun compile-internal (command error-message
326 &optional name-of-mode parser regexp-alist 345 &optional name-of-mode parser regexp-alist
@@ -546,7 +565,11 @@ See `compilation-mode'."
546 ;; buffer killed 565 ;; buffer killed
547 (set-process-buffer proc nil) 566 (set-process-buffer proc nil)
548 (let ((obuf (current-buffer)) 567 (let ((obuf (current-buffer))
549 omax opoint) 568 omax opoint
569 (status (if compilation-exit-message-function
570 (funcall compilation-exit-message-function
571 proc msg)
572 (cons msg (process-exit-status proc)))))
550 ;; save-excursion isn't the right thing if 573 ;; save-excursion isn't the right thing if
551 ;; process-buffer is current-buffer 574 ;; process-buffer is current-buffer
552 (unwind-protect 575 (unwind-protect
@@ -560,13 +583,13 @@ See `compilation-mode'."
560 (goto-char omax) 583 (goto-char omax)
561 ;; Record where we put the message, so we can ignore it 584 ;; Record where we put the message, so we can ignore it
562 ;; later on. 585 ;; later on.
563 (insert ?\n mode-name " " msg) 586 (insert ?\n mode-name " " (car status))
564 (forward-char -1) 587 (forward-char -1)
565 (insert " at " (substring (current-time-string) 0 19)) 588 (insert " at " (substring (current-time-string) 0 19))
566 (forward-char 1) 589 (forward-char 1)
567 (setq mode-line-process 590 (setq mode-line-process
568 (format ":%s [%d]" (process-status proc) 591 (format ":%s [%s]"
569 (process-exit-status proc))) 592 (process-status proc) (cdr status)))
570 ;; Since the buffer and mode line will show that the 593 ;; Since the buffer and mode line will show that the
571 ;; process is dead, we can delete it now. Otherwise it 594 ;; process is dead, we can delete it now. Otherwise it
572 ;; will stay around until M-x list-processes. 595 ;; will stay around until M-x list-processes.