From: David Edmondson <dme@dme.org>
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 [thread overview]
Message-ID: <1327601789-6040-2-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1327601789-6040-1-git-send-email-dme@dme.org>
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
next prev parent reply other threads:[~2012-01-26 18:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 18:16 [PATCH 0/2] Add a fake 'Tags' header David Edmondson
2012-01-26 18:16 ` David Edmondson [this message]
2012-01-26 18:16 ` [PATCH 2/2] test: Update tests for new " David Edmondson
2012-01-28 12:16 ` [PATCH 0/2] Add a fake " David Bremner
2012-01-30 9:21 ` 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=1327601789-6040-2-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).