emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/icons c829fd9964 06/11: Support icons in compilation mode


From: Stefan Kangas
Subject: scratch/icons c829fd9964 06/11: Support icons in compilation mode
Date: Wed, 24 Aug 2022 02:40:44 -0400 (EDT)

branch: scratch/icons
commit c829fd9964468f3c86d28ef10a4d19200b7643d6
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Support icons in compilation mode
    
    * lisp/progmodes/compile.el (compilation-mode-line-icons): New
    user option.
    (compile--get-compilation-mode-line-errors): New function.
    (compilation-mode-line-errors): Turn into defvar.
---
 lisp/progmodes/compile.el | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 5ce80e0657..d5dbecbfbe 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -165,6 +165,11 @@ and a string describing how the process finished.")
    (t
     (error "No ongoing compilations"))))
 
+(defcustom compilation-mode-line-icons (display-graphic-p)
+  "Non-nil means to use icons in the mode-line."
+  :type 'boolean
+  :version "29.1")
+
 (defvar compilation-error "error"
   "Stem of message to print when no matches are found.")
 
@@ -175,17 +180,29 @@ and a string describing how the process finished.")
 (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")
-    "]"))
+(defun compile--get-compilation-mode-line-errors ()
+  `(,(if compilation-mode-line-icons "  " " [")
+    ;; Errors
+    (:propertize (,@(if compilation-mode-line-icons `(,(icons-get-for-modeline 
"alert/error_outline") " "))
+                  (:eval (int-to-string compilation-num-errors-found)))
+                 face compilation-error
+                 help-echo "Number of errors so far")
+    " "
+    ;; Warnings
+    (:propertize (,@(if compilation-mode-line-icons `(,(icons-get-for-modeline 
"alert/warning_amber") " "))
+                  (:eval (int-to-string compilation-num-warnings-found)))
+                 face compilation-warning
+                 help-echo "Number of warnings so far")
+    " "
+    ;; Infos
+    (:propertize (,@(if compilation-mode-line-icons `(,(icons-get-for-modeline 
"action/info_outline") " "))
+                  (:eval (int-to-string compilation-num-infos-found)))
+                 face compilation-info
+                 help-echo "Number of informational messages so far")
+    ,(if compilation-mode-line-icons "  " " ]")))
+
+(defvar compilation-mode-line-errors
+  (compile--get-compilation-mode-line-errors))
 
 ;; 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]