unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs: Elide the display of repeated subjects in thread display mode.
Date: Mon,  8 Nov 2010 10:44:08 +0000	[thread overview]
Message-ID: <1289213048-24332-1-git-send-email-dme@dme.org> (raw)
In-Reply-To: <878w17psjr.fsf@yoom.home.cworth.org>

Collapsed messages do not show a "Subject:" line if the subject is the
same as that of the previous message.
---

Remove the preference setting.

 emacs/notmuch-show.el |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7ec6aa5..13964c2 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -381,17 +381,24 @@ current buffer, if possible."
 (defun notmuch-show-make-symbol (type)
   (make-symbol (concat "notmuch-show-" type)))
 
+(defun notmuch-show-strip-re (string)
+  (replace-regexp-in-string "^\\([Rr]e: *\\)+" "" string))
+
+(defvar notmuch-show-previous-subject "")
+(make-variable-buffer-local 'notmuch-show-previous-subject)
+
 (defun notmuch-show-insert-msg (msg depth)
   "Insert the message MSG at depth DEPTH in the current thread."
-  (let ((headers (plist-get msg :headers))
-	;; Indentation causes the buffer offset of the start/end
-	;; points to move, so we must use markers.
-	message-start message-end
-	content-start content-end
-	headers-start headers-end
-	body-start body-end
-	(headers-invis-spec (notmuch-show-make-symbol "header"))
-	(message-invis-spec (notmuch-show-make-symbol "message")))
+  (let* ((headers (plist-get msg :headers))
+	 ;; Indentation causes the buffer offset of the start/end
+	 ;; points to move, so we must use markers.
+	 message-start message-end
+	 content-start content-end
+	 headers-start headers-end
+	 body-start body-end
+	 (headers-invis-spec (notmuch-show-make-symbol "header"))
+	 (message-invis-spec (notmuch-show-make-symbol "message"))
+	 (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))
 
     ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
     ;; removing items from `buffer-invisibility-spec' (which is what
@@ -428,10 +435,17 @@ current buffer, if possible."
     (insert "\n")
     (save-excursion
       (goto-char content-start)
-      (forward-line 1)
+      ;; If the subject of this message is the same as that of the
+      ;; previous message, don't display it when this message is
+      ;; collapsed.
+      (when (not (string= notmuch-show-previous-subject
+			  bare-subject))
+	(forward-line 1))
       (setq headers-start (point-marker)))
     (setq headers-end (point-marker))
 
+    (setq notmuch-show-previous-subject bare-subject)
+
     (setq body-start (point-marker))
     (notmuch-show-insert-body msg (plist-get msg :body) depth)
     ;; Ensure that the body ends with a newline.
-- 
1.7.2.3

  parent reply	other threads:[~2010-11-08 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-05  9:50 [PATCH] emacs: Add `notmuch-show-elide-same-subject', controlling the appearance of collapsed messages in notmuch-show mode David Edmondson
2010-11-05 17:51 ` Carl Worth
2010-11-07 22:16   ` Sebastian Spaeth
2010-11-08 10:44   ` David Edmondson [this message]
2010-11-08 10:50     ` [PATCH] emacs: Simplify subjects more aggressively David Edmondson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1289213048-24332-1-git-send-email-dme@dme.org \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).