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 4692440D154 for ; Fri, 5 Nov 2010 02:51:01 -0700 (PDT) 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 Ma0rrVAmfG3Y for ; Fri, 5 Nov 2010 02:50:50 -0700 (PDT) Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com [74.125.82.41]) by olra.theworths.org (Postfix) with ESMTP id 89EC94196F0 for ; Fri, 5 Nov 2010 02:50:50 -0700 (PDT) Received: by wwi18 with SMTP id 18so1440957wwi.2 for ; Fri, 05 Nov 2010 02:50:49 -0700 (PDT) Received: by 10.216.35.78 with SMTP id t56mr1892644wea.34.1288950647751; Fri, 05 Nov 2010 02:50:47 -0700 (PDT) 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 p4sm667614wej.4.2010.11.05.02.50.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Nov 2010 02:50:46 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 46E7459405B; Fri, 5 Nov 2010 09:50:16 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Add `notmuch-show-elide-same-subject', controlling the appearance of collapsed messages in notmuch-show mode. Date: Fri, 5 Nov 2010 09:50:15 +0000 Message-Id: <1288950615-32406-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.2.3 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: Fri, 05 Nov 2010 09:51:01 -0000 If `notmuch-show-elide-same-subject' is set to `t' then collapsed messages do not show a "Subject:" line if the subject is the same as that of the previous message. --- emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++---------- 1 files changed, 28 insertions(+), 10 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7ec6aa5..07cf846 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -58,6 +58,12 @@ any given message." :group 'notmuch :type 'boolean) +(defcustom notmuch-show-elide-same-subject nil + "Do not show the subject of a collapsed message if it is the +same as that of the previous message." + :group 'notmuch + :type 'boolean) + (defcustom notmuch-show-relative-dates t "Display relative dates in the message summary line." :group 'notmuch @@ -381,17 +387,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 +441,15 @@ current buffer, if possible." (insert "\n") (save-excursion (goto-char content-start) - (forward-line 1) + (when (and notmuch-show-elide-same-subject + (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