From f45710e1ddf0f3a1470f6bc3a1116afd841de41a Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 14 Jul 2021 18:08:33 +0200 Subject: [PATCH] Fontify the signature separator in Message mode * lisp/gnus/message.el (message-signature-separator): New face (bug#17757). (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 a9be2d6b347..2c0663915f8 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))) (rfc822-goto-eoh) @@ -1751,9 +1755,22 @@ number of levels specified in the faces `message-cited-text-*'." (0 ',cited-text-face)) keywords)) (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) -- 2.39.2