aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Tromey2017-03-05 10:48:41 -0700
committerTom Tromey2017-08-07 21:48:33 -0600
commit846870e508021ee8d1099280b3f40fe108a34bf0 (patch)
treed658cfb9421b34d4c7552e2d6f97bb0ddb6128ae
parentc3445aed51944becb3e58f5dace8121c0021f6c7 (diff)
downloademacs-846870e508021ee8d1099280b3f40fe108a34bf0.tar.gz
emacs-846870e508021ee8d1099280b3f40fe108a34bf0.zip
Show number of errors in compilation-mode mode-line
Bug#25354 * lisp/progmodes/compile.el (compilation-num-errors-found): Provide default value. (compilation-num-warnings-found, compilation-num-infos-found): New defvars. (compilation-mode-line-errors): New defconst. (compilation-face): Remove. (compilation-type, compilation--note-type): New functions. (compilation-parse-errors): Call compilation--note-type. (compilation-start): Include compilation-mode-line-errors in mode-line-process. (compilation-setup): Initialize compilation-num-* variables to 0. (compilation-handle-exit): Include compilation-mode-line-errors in mode-line-process. * doc/emacs/building.texi (Compilation): Document new feature.
-rw-r--r--doc/emacs/building.texi4
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/progmodes/compile.el78
3 files changed, 64 insertions, 23 deletions
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index f7eb8fe9eaf..cc79eae7770 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -90,6 +90,10 @@ inserted above point, which remains at the end. Otherwise, point
90remains fixed while compilation output is added at the end of the 90remains fixed while compilation output is added at the end of the
91buffer. 91buffer.
92 92
93 While compilation proceeds, the mode line is updated to show the
94number of errors, warnings, and informational messages that have been
95seen so far.
96
93@cindex compilation buffer, keeping point at end 97@cindex compilation buffer, keeping point at end
94@vindex compilation-scroll-output 98@vindex compilation-scroll-output
95 If you change the variable @code{compilation-scroll-output} to a 99 If you change the variable @code{compilation-scroll-output} to a
diff --git a/etc/NEWS b/etc/NEWS
index 58b08348b10..2b789be3c85 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -741,6 +741,11 @@ where to place point after C-c M-r and C-c M-s.
741*** Messages from CMake are now recognized. 741*** Messages from CMake are now recognized.
742 742
743+++ 743+++
744*** The number of errors, warnings, and informational messages is now
745displayed in the mode line. These are updated as compilation
746proceeds.
747
748+++
744*** A new option 'dired-always-read-filesystem' default to nil. 749*** A new option 'dired-always-read-filesystem' default to nil.
745If non-nil, buffers visiting files are reverted before search them; 750If non-nil, buffers visiting files are reverted before search them;
746for instance, in 'dired-mark-files-containing-regexp' a non-nil value 751for instance, in 'dired-mark-files-containing-regexp' a non-nil value
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 31ec5a67d03..f0935cd2add 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -127,7 +127,21 @@ and a string describing how the process finished.")
127(defvar compilation-arguments nil 127(defvar compilation-arguments nil
128 "Arguments that were given to `compilation-start'.") 128 "Arguments that were given to `compilation-start'.")
129 129
130(defvar compilation-num-errors-found) 130(defvar compilation-num-errors-found 0)
131(defvar compilation-num-warnings-found 0)
132(defvar compilation-num-infos-found 0)
133
134(defconst compilation-mode-line-errors
135 '(" [" (:propertize (:eval (int-to-string compilation-num-errors-found))
136 face compilation-error
137 help-echo "Number of errors so far")
138 " " (:propertize (:eval (int-to-string compilation-num-warnings-found))
139 face compilation-warning
140 help-echo "Number of warnings so far")
141 " " (:propertize (:eval (int-to-string compilation-num-infos-found))
142 face compilation-info
143 help-echo "Number of informational messages so far")
144 "]"))
131 145
132;; If you make any changes to `compilation-error-regexp-alist-alist', 146;; If you make any changes to `compilation-error-regexp-alist-alist',
133;; be sure to run the ERT test in test/lisp/progmodes/compile-tests.el. 147;; be sure to run the ERT test in test/lisp/progmodes/compile-tests.el.
@@ -886,10 +900,10 @@ from a different message."
886 :group 'compilation 900 :group 'compilation
887 :version "22.1") 901 :version "22.1")
888 902
889(defun compilation-face (type) 903(defun compilation-type (type)
890 (or (and (car type) (match-end (car type)) compilation-warning-face) 904 (or (and (car type) (match-end (car type)) 1)
891 (and (cdr type) (match-end (cdr type)) compilation-info-face) 905 (and (cdr type) (match-end (cdr type)) 0)
892 compilation-error-face)) 906 2))
893 907
894;; LOC (or location) is a list of (COLUMN LINE FILE-STRUCTURE nil nil) 908;; LOC (or location) is a list of (COLUMN LINE FILE-STRUCTURE nil nil)
895 909
@@ -1334,6 +1348,14 @@ FMTS is a list of format specs for transforming the file name.
1334 1348
1335 (compilation-parse-errors start end))) 1349 (compilation-parse-errors start end)))
1336 1350
1351(defun compilation--note-type (type)
1352 "Note that a new message with severity TYPE was seen.
1353This updates the appropriate variable used by the mode-line."
1354 (cl-case type
1355 (0 (cl-incf compilation-num-infos-found))
1356 (1 (cl-incf compilation-num-warnings-found))
1357 (2 (cl-incf compilation-num-errors-found))))
1358
1337(defun compilation-parse-errors (start end &rest rules) 1359(defun compilation-parse-errors (start end &rest rules)
1338 "Parse errors between START and END. 1360 "Parse errors between START and END.
1339The errors recognized are the ones specified in RULES which default 1361The errors recognized are the ones specified in RULES which default
@@ -1397,14 +1419,17 @@ to `compilation-error-regexp-alist' if RULES is nil."
1397 file line end-line col end-col (or type 2) fmt)) 1419 file line end-line col end-col (or type 2) fmt))
1398 1420
1399 (when (integerp file) 1421 (when (integerp file)
1422 (setq type (if (consp type)
1423 (compilation-type type)
1424 (or type 2)))
1425 (compilation--note-type type)
1426
1400 (compilation--put-prop 1427 (compilation--put-prop
1401 file 'font-lock-face 1428 file 'font-lock-face
1402 (if (consp type) 1429 (symbol-value (aref [compilation-info-face
1403 (compilation-face type) 1430 compilation-warning-face
1404 (symbol-value (aref [compilation-info-face 1431 compilation-error-face]
1405 compilation-warning-face 1432 type))))
1406 compilation-error-face]
1407 (or type 2))))))
1408 1433
1409 (compilation--put-prop 1434 (compilation--put-prop
1410 line 'font-lock-face compilation-line-face) 1435 line 'font-lock-face compilation-line-face)
@@ -1768,7 +1793,8 @@ Returns the compilation buffer created."
1768 outbuf command)))) 1793 outbuf command))))
1769 ;; Make the buffer's mode line show process state. 1794 ;; Make the buffer's mode line show process state.
1770 (setq mode-line-process 1795 (setq mode-line-process
1771 '(:propertize ":%s" face compilation-mode-line-run)) 1796 '((:propertize ":%s" face compilation-mode-line-run)
1797 compilation-mode-line-errors))
1772 1798
1773 ;; Set the process as killable without query by default. 1799 ;; Set the process as killable without query by default.
1774 ;; This allows us to start a new compilation without 1800 ;; This allows us to start a new compilation without
@@ -1797,7 +1823,8 @@ Returns the compilation buffer created."
1797 (message "Executing `%s'..." command) 1823 (message "Executing `%s'..." command)
1798 ;; Fake mode line display as if `start-process' were run. 1824 ;; Fake mode line display as if `start-process' were run.
1799 (setq mode-line-process 1825 (setq mode-line-process
1800 '(:propertize ":run" face compilation-mode-line-run)) 1826 '((:propertize ":run" face compilation-mode-line-run)
1827 compilation-mode-line-errors))
1801 (force-mode-line-update) 1828 (force-mode-line-update)
1802 (sit-for 0) ; Force redisplay 1829 (sit-for 0) ; Force redisplay
1803 (save-excursion 1830 (save-excursion
@@ -2106,6 +2133,9 @@ Optional argument MINOR indicates this is called from
2106 (make-local-variable 'compilation-messages-start) 2133 (make-local-variable 'compilation-messages-start)
2107 (make-local-variable 'compilation-error-screen-columns) 2134 (make-local-variable 'compilation-error-screen-columns)
2108 (make-local-variable 'overlay-arrow-position) 2135 (make-local-variable 'overlay-arrow-position)
2136 (setq-local compilation-num-errors-found 0)
2137 (setq-local compilation-num-warnings-found 0)
2138 (setq-local compilation-num-infos-found 0)
2109 (set (make-local-variable 'overlay-arrow-string) "") 2139 (set (make-local-variable 'overlay-arrow-string) "")
2110 (setq next-error-overlay-arrow-position nil) 2140 (setq next-error-overlay-arrow-position nil)
2111 (add-hook 'kill-buffer-hook 2141 (add-hook 'kill-buffer-hook
@@ -2195,16 +2225,18 @@ commands of Compilation major mode are available. See
2195 (add-text-properties omax (point) 2225 (add-text-properties omax (point)
2196 (append '(compilation-handle-exit t) nil)) 2226 (append '(compilation-handle-exit t) nil))
2197 (setq mode-line-process 2227 (setq mode-line-process
2198 (let ((out-string (format ":%s [%s]" process-status (cdr status))) 2228 (list
2199 (msg (format "%s %s" mode-name 2229 (let ((out-string (format ":%s [%s]" process-status (cdr status)))
2200 (replace-regexp-in-string "\n?$" "" 2230 (msg (format "%s %s" mode-name
2201 (car status))))) 2231 (replace-regexp-in-string "\n?$" ""
2202 (message "%s" msg) 2232 (car status)))))
2203 (propertize out-string 2233 (message "%s" msg)
2204 'help-echo msg 2234 (propertize out-string
2205 'face (if (> exit-status 0) 2235 'help-echo msg
2206 'compilation-mode-line-fail 2236 'face (if (> exit-status 0)
2207 'compilation-mode-line-exit)))) 2237 'compilation-mode-line-fail
2238 'compilation-mode-line-exit)))
2239 compilation-mode-line-errors))
2208 ;; Force mode line redisplay soon. 2240 ;; Force mode line redisplay soon.
2209 (force-mode-line-update) 2241 (force-mode-line-update)
2210 (if (and opoint (< opoint omax)) 2242 (if (and opoint (< opoint omax))