Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id D3F4F40DAC7 for ; Mon, 8 Nov 2010 02:45:24 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mdHNGTRPjUHe for ; Mon, 8 Nov 2010 02:45:14 -0800 (PST) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) by olra.theworths.org (Postfix) with ESMTP id 51AF840DAC2 for ; Mon, 8 Nov 2010 02:45:14 -0800 (PST) Received: by wyb40 with SMTP id 40so5745544wyb.26 for ; Mon, 08 Nov 2010 02:45:13 -0800 (PST) Received: by 10.216.179.81 with SMTP id g59mr4084696wem.35.1289213113406; Mon, 08 Nov 2010 02:45:13 -0800 (PST) Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com [81.149.164.25]) by mx.google.com with ESMTPS id e12sm2991684wer.36.2010.11.08.02.45.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 08 Nov 2010 02:45:12 -0800 (PST) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 9854259405B; Mon, 8 Nov 2010 10:44:09 +0000 (GMT) From: David Edmondson 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 Message-Id: <1289213048-24332-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <878w17psjr.fsf@yoom.home.cworth.org> References: <878w17psjr.fsf@yoom.home.cworth.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2010 10:45:25 -0000 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