branch: externals/tmr
commit 1e4945d59b1643a9aa02b096da6880791adff97c
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Define tmr faces instead of hardcoding error, success, etc.
---
 tmr.el | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 53 insertions(+), 11 deletions(-)

diff --git a/tmr.el b/tmr.el
index be7358dc81..454a699b81 100644
--- a/tmr.el
+++ b/tmr.el
@@ -130,6 +130,48 @@ Each function must accept a timer as argument."
   :package-version '(tmr . "1.0.0")
   :type 'string)
 
+(defgroup tmr-faces ()
+  "Faces for `tmr'."
+  :link '(info-link :tag "Info Manual" "(tmr)")
+  :link '(url-link :tag "Homepage" "https://protesilaos.com/emacs/tmr";)
+  :link '(emacs-library-link :tag "Library Source" "tmr.el")
+  :group 'tmr)
+
+(defface tmr-duration nil
+  "Face for styling the duration of a timer."
+  :package-version '(tmr . "1.0.0")
+  :group 'tmr-faces)
+
+(defface tmr-description '((t :inherit bold))
+  "Face for styling the description of a timer."
+  :package-version '(tmr . "1.0.0")
+  :group 'tmr-faces)
+
+(defface tmr-start-time '((t :inherit success))
+  "Face for styling the start time of a timer."
+  :package-version '(tmr . "1.0.0")
+  :group 'tmr-faces)
+
+(defface tmr-end-time '((t :inherit error))
+  "Face for styling the start time of a timer."
+  :package-version '(tmr . "1.0.0")
+  :group 'tmr-faces)
+
+(defface tmr-is-acknowledged '((t :inherit success))
+  "Face for styling the acknowledgment confirmation."
+  :package-version '(tmr . "1.0.0")
+  :group 'tmr-faces)
+
+(defface tmr-must-be-acknowledged '((t :inherit warning))
+  "Face for styling the acknowledgment confirmation."
+  :package-version '(tmr . "1.0.0")
+  :group 'tmr-faces)
+
+(defface tmr-finished '((t :inherit error))
+  "Face for styling the confirmation of a finished timer."
+  :package-version '(tmr . "1.0.0")
+  :group 'tmr-faces)
+
 (cl-defstruct (tmr--timer
                (:constructor tmr--timer-create)
                (:copier tmr--timer-copy))
@@ -173,23 +215,23 @@ Each function must accept a timer as argument."
     ;; one: check `tmr-print-message-for-created-timer' and
     ;; `tmr-print-message-for-cancelled-timer'.
     (format "TMR start %s; end %s; %s %s%s%s"
-            (propertize start 'face 'success)
-            (propertize end 'face 'error)
+            (propertize start 'face 'tmr-start-time)
+            (propertize end 'face 'tmr-end-time)
             (if (string-search ":" (tmr--timer-input timer))
                 "until"
               "duration")
-            (tmr--timer-input timer)
+            (propertize (tmr--timer-input timer) 'face 'tmr-duration)
             (cond
              ((and (tmr--timer-acknowledgep timer)
                    (tmr--timer-finishedp timer))
-              (concat "; " (propertize "acknowledged" 'face 'success)))
+              (concat "; " (propertize "acknowledged" 'face 
'tmr-is-acknowledged)))
              ((tmr--timer-acknowledgep timer)
-              (concat "; " (propertize "acknowledge" 'face 'warning)))
+              (concat "; " (propertize "acknowledge" 'face 
'tmr-must-be-acknowledged)))
              ((tmr--timer-finishedp timer)
-              (concat "; " (propertize "finished" 'face 'success)))
+              (concat "; " (propertize "finished" 'face 'tmr-finished)))
              (t ""))
             (if description
-                (concat "; " (propertize description 'face 'bold))
+                (concat "; " (propertize description 'face 'tmr-description))
               ""))))
 
 (defun tmr--long-description-for-finished-timer (timer)
@@ -201,10 +243,10 @@ optional `tmr--timer-description'."
         (description (tmr--timer-description timer)))
     ;; For the TMR prefix, see comment in `tmr--long-description'.
     (format "TMR Time is up!\n%s%s %s\n%s %s"
-            (if description (concat (propertize description 'face 'bold) "\n") 
"")
-            (propertize "Started" 'face 'success)
+            (if description (concat (propertize description 'face 
'tmr-description) "\n") "")
+            (propertize "Started" 'face 'tmr-start-time)
             start
-            (propertize "Ended" 'face 'error)
+            (propertize "Ended" 'face 'tmr-end-time)
             end)))
 
 (defun tmr--format-creation-date (timer)
@@ -229,7 +271,7 @@ optional `tmr--timer-description'."
       (if (< secs 0)
           ;; Negative remaining time occurs for non-acknowledged timers with
           ;; additional duration.
-          (propertize str 'face 'error)
+          (propertize str 'face 'tmr-must-be-acknowledged)
         str))))
 
 (defun tmr--format-time (time)

Reply via email to