From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.bugs Subject: bug#25354: patch for this bug Date: Sun, 05 Mar 2017 10:50:18 -0700 Message-ID: <87tw771ulh.fsf@tromey.com> References: <8760lvt5at.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1488736282 24194 195.159.176.226 (5 Mar 2017 17:51:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Mar 2017 17:51:22 +0000 (UTC) To: 25354@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 05 18:51:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckaJK-00059D-Oi for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Mar 2017 18:51:12 +0100 Original-Received: from localhost ([::1]:39865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckaJQ-0000jC-Ij for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Mar 2017 12:51:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckaJG-0000hI-9a for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 12:51:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ckaJD-0000qz-7d for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 12:51:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43020) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ckaJC-0000qu-V3 for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 12:51:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ckaJC-00011a-OC for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 12:51:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <8760lvt5at.fsf@tromey.com> Resent-From: Tom Tromey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Mar 2017 17:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25354 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25354-submit@debbugs.gnu.org id=B25354.14887362563908 (code B ref 25354); Sun, 05 Mar 2017 17:51:02 +0000 Original-Received: (at 25354) by debbugs.gnu.org; 5 Mar 2017 17:50:56 +0000 Original-Received: from localhost ([127.0.0.1]:41217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckaJ6-00010y-81 for submit@debbugs.gnu.org; Sun, 05 Mar 2017 12:50:56 -0500 Original-Received: from gproxy6-pub.mail.unifiedlayer.com ([67.222.39.168]:60149) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ckaJ3-00010U-L6 for 25354@debbugs.gnu.org; Sun, 05 Mar 2017 12:50:54 -0500 Original-Received: (qmail 1323 invoked by uid 0); 5 Mar 2017 17:50:35 -0000 Original-Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy6.mail.unifiedlayer.com with SMTP; 5 Mar 2017 17:50:35 -0000 Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id sHqX1u00A2f2jeq01HqaXj; Sun, 05 Mar 2017 10:50:34 -0700 X-Authority-Analysis: v=2.1 cv=H5NInYoi c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=6Iz7jQTuP9IA:10 a=_mHTggNDVMVOyZjgcHEA:9 a=zstS-IiYAAAA:8 a=QXN5vvrPPmLy6p3aH-gA:9 a=ebsCqfcDe2X1UNAV:21 a=SH4vnbeS2IA8dPqg:21 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NkngaFYXP+3UZpsfoNBAT4cOFOBf18lHJo3FvRFRPxk=; b=DBERcyDgaKOEsTz4c3k7H3byrd Rj52KnwMMQuNEzcsSURfiJbIJKhozSNgo1h/66ffCMFqCPI+80sKguyAZHRZhdMlyw724/iBClDHY EgM1ZYhOnW1evt/YlXjd1SxzL; Original-Received: from 71-218-43-111.hlrn.qwest.net ([71.218.43.111]:57438 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1ckaIh-0008TL-5f for 25354@debbugs.gnu.org; Sun, 05 Mar 2017 10:50:31 -0700 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.218.43.111 X-Exim-ID: 1ckaIh-0008TL-5f X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-43-111.hlrn.qwest.net (bapiya) [71.218.43.111]:57438 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130217 Archived-At: --=-=-= Content-Type: text/plain This implements the feature requested here: it counts errors, warnings, and informational messages as they are parsed, and then updates the mode line with this information. Let me know what you think. Tom --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=P Content-Description: patch commit 0b9197ba7d79fef88781b097086e188c356e22a0 Author: Tom Tromey Date: Sun Mar 5 10:48:41 2017 -0700 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. diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index d35388e..6520ea4 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -127,7 +127,21 @@ compilation-error (defvar compilation-arguments nil "Arguments that were given to `compilation-start'.") -(defvar compilation-num-errors-found) +(defvar compilation-num-errors-found 0) +(defvar compilation-num-warnings-found 0) +(defvar compilation-num-infos-found 0) + +(defconst compilation-mode-line-errors + '(" [" (:propertize (:eval (int-to-string compilation-num-errors-found)) + face compilation-error + help-echo "Number of errors so far") + " " (:propertize (:eval (int-to-string compilation-num-warnings-found)) + face compilation-warning + help-echo "Number of warnings so far") + " " (:propertize (:eval (int-to-string compilation-num-infos-found)) + face compilation-info + help-echo "Number of informational messages so far") + "]")) ;; If you make any changes to `compilation-error-regexp-alist-alist', ;; be sure to run the ERT test in test/lisp/progmodes/compile-tests.el. @@ -884,10 +898,10 @@ compilation-skip-visited :group 'compilation :version "22.1") -(defun compilation-face (type) - (or (and (car type) (match-end (car type)) compilation-warning-face) - (and (cdr type) (match-end (cdr type)) compilation-info-face) - compilation-error-face)) +(defun compilation-type (type) + (or (and (car type) (match-end (car type)) 1) + (and (cdr type) (match-end (cdr type)) 0) + 2)) ;; LOC (or location) is a list of (COLUMN LINE FILE-STRUCTURE nil nil) @@ -1332,6 +1346,14 @@ compilation--parse-region (compilation-parse-errors start end))) +(defun compilation--note-type (type) + "Note that a new message with severity TYPE was seen. +This updates the appropriate variable used by the mode-line." + (cl-case type + (0 (cl-incf compilation-num-infos-found)) + (1 (cl-incf compilation-num-warnings-found)) + (2 (cl-incf compilation-num-errors-found)))) + (defun compilation-parse-errors (start end &rest rules) "Parse errors between START and END. The errors recognized are the ones specified in RULES which default @@ -1395,14 +1417,17 @@ compilation-parse-errors file line end-line col end-col (or type 2) fmt)) (when (integerp file) + (setq type (if (consp type) + (compilation-type type) + (or type 2))) + (compilation--note-type type) + (compilation--put-prop file 'font-lock-face - (if (consp type) - (compilation-face type) - (symbol-value (aref [compilation-info-face - compilation-warning-face - compilation-error-face] - (or type 2)))))) + (symbol-value (aref [compilation-info-face + compilation-warning-face + compilation-error-face] + type)))) (compilation--put-prop line 'font-lock-face compilation-line-face) @@ -1766,7 +1791,8 @@ compilation-start outbuf command)))) ;; Make the buffer's mode line show process state. (setq mode-line-process - '(:propertize ":%s" face compilation-mode-line-run)) + '((:propertize ":%s" face compilation-mode-line-run) + compilation-mode-line-errors)) ;; Set the process as killable without query by default. ;; This allows us to start a new compilation without @@ -1795,7 +1821,8 @@ compilation-start (message "Executing `%s'..." command) ;; Fake mode line display as if `start-process' were run. (setq mode-line-process - '(:propertize ":run" face compilation-mode-line-run)) + '((:propertize ":run" face compilation-mode-line-run) + compilation-mode-line-errors)) (force-mode-line-update) (sit-for 0) ; Force redisplay (save-excursion @@ -2104,6 +2131,9 @@ compilation-setup (make-local-variable 'compilation-messages-start) (make-local-variable 'compilation-error-screen-columns) (make-local-variable 'overlay-arrow-position) + (setq-local compilation-num-errors-found 0) + (setq-local compilation-num-warnings-found 0) + (setq-local compilation-num-infos-found 0) (set (make-local-variable 'overlay-arrow-string) "") (setq next-error-overlay-arrow-position nil) (add-hook 'kill-buffer-hook @@ -2193,16 +2223,18 @@ compilation-handle-exit (add-text-properties omax (point) (append '(compilation-handle-exit t) nil)) (setq mode-line-process - (let ((out-string (format ":%s [%s]" process-status (cdr status))) - (msg (format "%s %s" mode-name - (replace-regexp-in-string "\n?$" "" - (car status))))) - (message "%s" msg) - (propertize out-string - 'help-echo msg - 'face (if (> exit-status 0) - 'compilation-mode-line-fail - 'compilation-mode-line-exit)))) + (list + (let ((out-string (format ":%s [%s]" process-status (cdr status))) + (msg (format "%s %s" mode-name + (replace-regexp-in-string "\n?$" "" + (car status))))) + (message "%s" msg) + (propertize out-string + 'help-echo msg + 'face (if (> exit-status 0) + 'compilation-mode-line-fail + 'compilation-mode-line-exit))) + compilation-mode-line-errors)) ;; Force mode line redisplay soon. (force-mode-line-update) (if (and opoint (< opoint omax)) --=-=-=--