From c829fd9964468f3c86d28ef10a4d19200b7643d6 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 9 Oct 2021 05:30:43 +0200 Subject: [PATCH] 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 5ce80e06577..d5dbecbfbe6 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. -- 2.39.5