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 9EA3B431FC2 for ; Thu, 26 Jan 2012 10:16:36 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled 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 A8DChII1W+kA for ; Thu, 26 Jan 2012 10:16:35 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 9006A431FBF for ; Thu, 26 Jan 2012 10:16:35 -0800 (PST) Received: by wibhi8 with SMTP id hi8so676099wib.26 for ; Thu, 26 Jan 2012 10:16:33 -0800 (PST) Received: by 10.181.13.113 with SMTP id ex17mr5563053wid.15.1327601793296; Thu, 26 Jan 2012 10:16:33 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id fr8sm14981734wib.10.2012.01.26.10.16.31 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jan 2012 10:16:32 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 85F68A02BA; Thu, 26 Jan 2012 18:16:30 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 1/2] emacs: Add a fake Tags: header during display. Date: Thu, 26 Jan 2012 18:16:28 +0000 Message-Id: <1327601789-6040-2-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327601789-6040-1-git-send-email-dme@dme.org> References: <1327601789-6040-1-git-send-email-dme@dme.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: Thu, 26 Jan 2012 18:16:36 -0000 If `truncate-lines' is `nil' in `notmuch-show-mode' the tags can be lost from the right edge of the window. Create a fake 'Tags' header to display them with the other headers. Enable it by default by adding it to `notmuch-message-headers' and keep it up to date during tagging operations. --- emacs/notmuch-show.el | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index c37479a..a975a29 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -41,7 +41,7 @@ (declare-function notmuch-select-tag-with-completion "notmuch" (prompt &rest search-terms)) (declare-function notmuch-search-show-thread "notmuch" nil) -(defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date") +(defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date" "Tags") "Headers that should be shown in a message, in this order. For an open message, all of these headers will be made visible @@ -255,6 +255,8 @@ operation on the contents of the current buffer." 'message-header-subject) ((looking-at "[Ff]rom:") 'message-header-from) + ((looking-at "Tags:") + 'notmuch-tag-face) (t 'message-header-other)))) @@ -277,13 +279,21 @@ operation on the contents of the current buffer." (defun notmuch-show-update-tags (tags) "Update the displayed tags of the current message." (save-excursion - (goto-char (notmuch-show-message-top)) - (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) - (let ((inhibit-read-only t)) + ;; Update the header line. + (let ((inhibit-read-only t)) + (goto-char (notmuch-show-message-top)) + (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) (replace-match (concat "(" (propertize (mapconcat 'identity tags " ") 'face 'notmuch-tag-face) - ")")))))) + ")"))) + ;; Update the header, if present. + (when (member "Tags" notmuch-message-headers) + (goto-char (notmuch-show-message-top)) + (if (re-search-forward"^ *Tags: \\(.*\\)$" (notmuch-show-message-bottom) t) + (replace-match (propertize (mapconcat 'identity tags " ") + 'face 'notmuch-tag-face) + nil t nil 1)))))) (defun notmuch-show-clean-address (address) "Try to clean a single email ADDRESS for display. Return @@ -789,6 +799,10 @@ current buffer, if possible." (message-invis-spec (notmuch-show-make-symbol "message")) (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))) + ;; Add a fake 'Tags' header which can be used in + ;; `notmuch-show-insert-headers'. + (plist-put headers :Tags (mapconcat #'identity (plist-get msg :tags) " ")) + ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise ;; removing items from `buffer-invisibility-spec' (which is what ;; `notmuch-show-headers-visible' and -- 1.7.8.3