[Top][All Lists]

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

master f45710e: Fontify the signature separator in Message mode

From: Lars Ingebrigtsen
Subject: master f45710e: Fontify the signature separator in Message mode
Date: Wed, 14 Jul 2021 12:08:51 -0400 (EDT)

branch: master
commit f45710e1ddf0f3a1470f6bc3a1116afd841de41a
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fontify the signature separator in Message mode
    * lisp/gnus/message.el (message-signature-separator): New face
    (message-font-lock-keywords): Add it to the signature, and ensure
    that the trailing space isn't removed when hitting RET.
    (message--match-signature): New helper function.
 lisp/gnus/message.el | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index a9be2d6..2c06639 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -1658,6 +1658,10 @@ starting with `not' and followed by regexps."
   "Face used for displaying MML."
   :group 'message-faces)
+(defface message-signature-separator '((t :bold t))
+  "Face used for displaying the signature separator."
+  :group 'message-faces)
 (defun message-match-to-eoh (_limit)
   (let ((start (point)))
@@ -1751,9 +1755,22 @@ number of levels specified in the faces 
                 (0 ',cited-text-face))
        (setq level (1+ level)))
-     keywords))
+     keywords)
+   ;; Match signature.  This `field' stuff ensures that hitting `RET'
+   ;; after the signature separator doesn't remove the trailing space.
+   (list
+    '(message--match-signature (0 '( face message-signature-separator
+                                     rear-nonsticky t
+                                     field signature)))))
   "Additional expressions to highlight in Message mode.")
+(defun message--match-signature (limit)
+  (save-excursion
+    (and (re-search-forward message-signature-separator limit t)
+         ;; It's the last one in the buffer.
+         (not (save-excursion
+                (re-search-forward message-signature-separator nil t))))))
 (defvar message-face-alist
   '((bold . message-bold-region)
     (underline . underline-region)

reply via email to

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