From f56b86dffa5e6deb57e99bd16507920d75cf81a4 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Wed, 24 Feb 2010 14:30:06 -0400 Subject: [PATCH] notmuch.el: hide original message in top posted replies. This code treats top posted copies essentially like signatures, except that it doesn't sanity check their length, since neither do their senders. New user-visible variables: notmuch-wash-button-original-hidden-format notmuch-wash-button-original-visible-format Rebased-by: Carl Worth --- emacs/notmuch-wash.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index 115c3bb9..6760f3e7 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -35,6 +35,9 @@ "\\(^[[:space:]]*>.*\n\\)+" "Pattern to match citation lines.") +(defvar notmuch-wash-original-regexp "^\\(--+\s?[oO]riginal [mM]essage\s?--+\\)$" + "Pattern to match a line that separates original message from reply in top-posted message.") + (defvar notmuch-wash-button-signature-hidden-format "[ %d-line signature. Click/Enter to show. ]" "String used to construct button text for hidden signatures. @@ -55,6 +58,16 @@ Can use up to one integer format parameter, i.e. %d") "String used to construct button text for visible citations. Can use up to one integer format parameter, i.e. %d") +(defvar notmuch-wash-button-original-hidden-format + "[ %d-line hidden original message. Click/Enter to show. ]" + "String used to construct button text for hidden citations. +Can use up to one integer format parameter, i.e. %d") + +(defvar notmuch-wash-button-original-visible-format + "[ %d-line original message. Click/Enter to hide. ]" + "String used to construct button text for visible citations. +Can use up to one integer format parameter, i.e. %d") + (defvar notmuch-wash-signature-lines-max 12 "Maximum length of signature that will be hidden by default.") @@ -106,6 +119,10 @@ collapse the remaining lines into a button.") 'help-echo "mouse-1, RET: Show signature" :supertype 'notmuch-wash-button-invisibility-toggle-type) +(define-button-type 'notmuch-wash-button-original-toggle-type + 'help-echo "mouse-1, RET: Show original message" + :supertype 'notmuch-wash-button-invisibility-toggle-type) + (defun notmuch-wash-region-isearch-show (overlay) (remove-from-invisibility-spec (overlay-get overlay 'invisible))) @@ -151,6 +168,13 @@ insert before the button, probably for indentation." "Excerpt citations and up to one signature." (goto-char (point-min)) (beginning-of-line) + (if (and (< (point) (point-max)) + (re-search-forward notmuch-wash-original-regexp nil t)) + (let* ((msg-start (match-beginning 0)) + (msg-end (point-max)) + (msg-lines (count-lines msg-start msg-end))) + (notmuch-wash-region-to-button + msg-start msg-end "original" "\n"))) (while (and (< (point) (point-max)) (re-search-forward notmuch-wash-citation-regexp nil t)) (let* ((cite-start (match-beginning 0)) -- 2.26.2