[notmuch] [PATCH] notmuch.el: hide original message in top posted replies.
authordavid <david@tethera.net>
Wed, 24 Feb 2010 18:30:06 +0000 (14:30 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:16 +0000 (09:36 -0800)
ea/ba5a533ad64a9dbbf9bb609193db35cee4b6c2 [new file with mode: 0644]

diff --git a/ea/ba5a533ad64a9dbbf9bb609193db35cee4b6c2 b/ea/ba5a533ad64a9dbbf9bb609193db35cee4b6c2
new file mode 100644 (file)
index 0000000..d230237
--- /dev/null
@@ -0,0 +1,154 @@
+Return-Path: <bremner@pivot.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id CEBA3431FBC\r
+       for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 10:30:51 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.256\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.256 tagged_above=-999 required=5\r
+       tests=[AWL=-0.257, BAYES_50=0.001] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id c0j5CWQ+W7g0 for <notmuch@notmuchmail.org>;\r
+       Wed, 24 Feb 2010 10:30:51 -0800 (PST)\r
+Received: from convex-new.cs.unb.ca (convex-new.cs.unb.ca [131.202.245.35])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0652B431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 10:30:50 -0800 (PST)\r
+Received: from bremner by convex-new.cs.unb.ca with local (Exim 4.69)\r
+       (envelope-from <bremner@pivot.cs.unb.ca>)\r
+       id 1NkLzz-000633-O4; Wed, 24 Feb 2010 14:30:15 -0400\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Date: Wed, 24 Feb 2010 14:30:06 -0400\r
+Message-Id: <1267036206-23218-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.6.6\r
+In-Reply-To: <87y6iiwlth.fsf@yoom.home.cworth.org>\r
+References: <87y6iiwlth.fsf@yoom.home.cworth.org>\r
+Cc: David Bremner <bremner@unb.ca>\r
+Subject: [notmuch] [PATCH] notmuch.el: hide original message in top posted\r
+       replies.\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 24 Feb 2010 18:30:52 -0000\r
+\r
+From: David Bremner <bremner@unb.ca>\r
+\r
+This code treats top posted copies essentially like signatures, except\r
+that it doesn't sanity check their length, since neither do their\r
+senders.\r
+\r
+In an unrelated cleanup, remove the let definition of sig-end, since\r
+it was unused.\r
+\r
+New user-visible variable:\r
+\r
+  notmuch-show-original-button-format:   Allow customization of button text.\r
+---\r
+\r
+This is the unsquashed version of what was new in the v3 of the\r
+citation patch, rebased against current master.\r
+\r
+ notmuch.el |   40 ++++++++++++++++++++++++++++++++++++----\r
+ 1 files changed, 36 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 6482170..b1a590f 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -107,9 +107,15 @@\r
+ The regexp can (and should) include $ to match the end of the\r
+ line, but should not include ^ to match the beginning of the\r
+ line. This is because notmuch may have inserted additional space\r
+-for indentation at the beginning of the line. But notmuch will\r
+-move past the indentation when testing this pattern, (so that the\r
+-pattern can still test against the entire line).")\r
++for indentation at the beginning of the line.")\r
++\r
++(defvar notmuch-show-original-regexp "\\(--+\s?[oO]riginal [mM]essage\s?--+\\)$"\r
++  "Pattern to match a line that separates original message from reply in top-posted message.\r
++\r
++The regexp can (and should) include $ to match the end of the\r
++line, but should not include ^ to match the beginning of the\r
++line. This is because notmuch may have inserted additional space\r
++for indentation at the beginning of the line.")\r
\r
+ (defvar notmuch-show-signature-button-format\r
+   "[ %d-line signature. Click/Enter to toggle visibility. ]"\r
+@@ -123,6 +129,13 @@ Can use up to one integer format parameter, i.e. %d")\r
\r
+ Can use up to one integer format parameter, i.e. %d")\r
\r
++(defvar notmuch-show-original-button-format \r
++  "[ %d-line hidden original message. Click/Enter to show ]"\r
++  "String used to construct button text for hidden copies of messages\r
++\r
++Can use up to one integer format parameter, i.e. %d")\r
++\r
++\r
+ (defvar notmuch-show-signature-lines-max 12\r
+   "Maximum length of signature that will be hidden by default.")\r
\r
+@@ -717,6 +730,9 @@ which this thread was originally shown."\r
+   :supertype 'notmuch-button-invisibility-toggle-type)\r
+ (define-button-type 'notmuch-button-signature-toggle-type 'help-echo "mouse-1, RET: Show signature"\r
+   :supertype 'notmuch-button-invisibility-toggle-type)\r
++(define-button-type 'notmuch-button-original-toggle-type 'help-echo "mouse-1, RET: Show original message"\r
++  :supertype 'notmuch-button-invisibility-toggle-type)\r
++\r
+ (define-button-type 'notmuch-button-headers-toggle-type 'help-echo "mouse-1, RET: Show headers"\r
+   :supertype 'notmuch-button-invisibility-toggle-type)\r
+ (define-button-type 'notmuch-button-body-toggle-type\r
+@@ -768,9 +784,25 @@ is what to put on the button."\r
+   (let ((citation-regexp (notmuch-show-citation-regexp depth))\r
+       (signature-regexp (concat (format "^[[:space:]]\\{%d\\}" depth)\r
+                                 notmuch-show-signature-regexp))\r
++      (original-regexp (concat (format "^[[:space:]]\\{%d\\}" depth) \r
++                                notmuch-show-original-regexp))\r
++\r
+       (indent (concat "\n" (make-string depth ? ))))\r
+     (goto-char beg)\r
+     (beginning-of-line)\r
++\r
++    (if (and (< (point) end) \r
++           (re-search-forward original-regexp end t))\r
++      (let* ((msg-start (match-beginning 0))\r
++             (msg-lines (1- (count-lines msg-start end))))\r
++        (notmuch-show-region-to-button \r
++         msg-start\r
++         end\r
++         "original"\r
++         indent\r
++         (format notmuch-show-original-button-format msg-lines)\r
++         )))\r
++\r
+     (while (and (< (point) end)\r
+               (re-search-forward citation-regexp end t))\r
+       (let* ((cite-start (match-beginning 0))\r
+@@ -786,10 +818,10 @@ is what to put on the button."\r
+          (format notmuch-show-citation-button-format\r
+                  (- cite-lines notmuch-show-citation-lines-prefix))\r
+          ))))\r
++\r
+     (if (and (< (point) end)\r
+            (re-search-forward signature-regexp end t))\r
+       (let* ((sig-start (match-beginning 0))\r
+-             (sig-end (match-end 0))\r
+              (sig-lines (1- (count-lines sig-start end))))\r
+         (if (<= sig-lines notmuch-show-signature-lines-max)\r
+             (notmuch-show-region-to-button\r
+-- \r
+1.6.6\r
+\r