* [PATCH 1/2] emacs: Add a fake Tags: header during display.
2012-01-26 18:16 [PATCH 0/2] Add a fake 'Tags' header David Edmondson
@ 2012-01-26 18:16 ` David Edmondson
2012-01-26 18:16 ` [PATCH 2/2] test: Update tests for new 'Tags' header David Edmondson
2012-01-28 12:16 ` [PATCH 0/2] Add a fake " David Bremner
2 siblings, 0 replies; 5+ messages in thread
From: David Edmondson @ 2012-01-26 18:16 UTC (permalink / raw)
To: notmuch
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] test: Update tests for new 'Tags' header.
2012-01-26 18:16 [PATCH 0/2] Add a fake 'Tags' header David Edmondson
2012-01-26 18:16 ` [PATCH 1/2] emacs: Add a fake Tags: header during display David Edmondson
@ 2012-01-26 18:16 ` David Edmondson
2012-01-28 12:16 ` [PATCH 0/2] Add a fake " David Bremner
2 siblings, 0 replies; 5+ messages in thread
From: David Edmondson @ 2012-01-26 18:16 UTC (permalink / raw)
To: notmuch
---
test/emacs | 3 +++
.../notmuch-show-thread-maildir-storage | 7 +++++++
...hread-maildir-storage-with-fourfold-indentation | 7 +++++++
...show-thread-maildir-storage-without-indentation | 7 +++++++
4 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/test/emacs b/test/emacs
index f150d95..eda5438 100755
--- a/test/emacs
+++ b/test/emacs
@@ -82,6 +82,7 @@ cat <<EOF >EXPECTED
Subject: message-with-invalid-from
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Fri, 05 Jan 2001 15:43:57 +0000
+Tags: inbox
This is just a test message (#1)
EOF
@@ -332,6 +333,7 @@ echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
Subject: The problem with top-posting
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Fri, 05 Jan 2001 15:43:57 +0000
+Tags: inbox
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
@@ -341,6 +343,7 @@ Top Poster <top@poster.com> (2001-01-05) (inbox unread)
Subject: Re: The problem with top-posting
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Fri, 05 Jan 2001 15:43:57 +0000
+Tags: inbox unread
Thanks for the advice! I will be sure to put it to good use.
diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage b/test/emacs.expected-output/notmuch-show-thread-maildir-storage
index cdbfa1d..3e7d3fb 100644
--- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage
+++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage
@@ -2,6 +2,7 @@ Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 14:00:54 -0500
+Tags: inbox signed
[ multipart/mixed ]
[ multipart/signed ]
@@ -42,6 +43,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: Re: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 01:02:38 +0600
+ Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -74,6 +76,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
To: Mikhail Gusarov <dottedmag@dottedmag.net>
Cc: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 15:33:01 -0500
+ Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -105,6 +108,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:50:48 +0600
+ Tags: inbox unread
Twas brillig at 15:33:01 17.11.2009 UTC-05 when lars at seas.harvard.edu
did gyre and gimble:
@@ -133,6 +137,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 13:24:13 -0800
+ Tags: inbox unread
On Tue, 17 Nov 2009 15:33:01 -0500, Lars Kellogg-Stedman <lars at
seas.harvard.edu> wrote:
@@ -156,6 +161,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
To: Keith Packard <keithp@keithp.com>
Cc: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 19:50:40 -0500
+ Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -182,6 +188,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:08:10 -0800
+ Tags: inbox unread
On Tue, 17 Nov 2009 14:00:54 -0500, Lars Kellogg-Stedman <lars at
seas.harvard.edu> wrote:
diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
index b0bf93e..6245c2e 100644
--- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
+++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
@@ -2,6 +2,7 @@ Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 14:00:54 -0500
+Tags: inbox signed
[ multipart/mixed ]
[ multipart/signed ]
@@ -42,6 +43,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: Re: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 01:02:38 +0600
+ Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -74,6 +76,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
To: Mikhail Gusarov <dottedmag@dottedmag.net>
Cc: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 15:33:01 -0500
+ Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -105,6 +108,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:50:48 +0600
+ Tags: inbox unread
Twas brillig at 15:33:01 17.11.2009 UTC-05 when lars at seas.harvard.edu
did gyre and gimble:
@@ -133,6 +137,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 13:24:13 -0800
+ Tags: inbox unread
On Tue, 17 Nov 2009 15:33:01 -0500, Lars Kellogg-Stedman <lars at
seas.harvard.edu> wrote:
@@ -156,6 +161,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
To: Keith Packard <keithp@keithp.com>
Cc: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 19:50:40 -0500
+ Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -182,6 +188,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:08:10 -0800
+ Tags: inbox unread
On Tue, 17 Nov 2009 14:00:54 -0500, Lars Kellogg-Stedman <lars at
seas.harvard.edu> wrote:
diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-without-indentation b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-without-indentation
index 08de8b5..17214f7 100644
--- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-without-indentation
+++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-without-indentation
@@ -2,6 +2,7 @@ Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 14:00:54 -0500
+Tags: inbox signed
[ multipart/mixed ]
[ multipart/signed ]
@@ -42,6 +43,7 @@ Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox signed unread)
Subject: Re: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 01:02:38 +0600
+Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -74,6 +76,7 @@ Subject: Re: [notmuch] Working with Maildir storage?
To: Mikhail Gusarov <dottedmag@dottedmag.net>
Cc: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 15:33:01 -0500
+Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -105,6 +108,7 @@ Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:50:48 +0600
+Tags: inbox unread
Twas brillig at 15:33:01 17.11.2009 UTC-05 when lars at seas.harvard.edu
did gyre and gimble:
@@ -133,6 +137,7 @@ Keith Packard <keithp@keithp.com> (2009-11-17) (inbox unread)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 13:24:13 -0800
+Tags: inbox unread
On Tue, 17 Nov 2009 15:33:01 -0500, Lars Kellogg-Stedman <lars at
seas.harvard.edu> wrote:
@@ -156,6 +161,7 @@ Subject: Re: [notmuch] Working with Maildir storage?
To: Keith Packard <keithp@keithp.com>
Cc: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 19:50:40 -0500
+Tags: inbox signed unread
[ multipart/mixed ]
[ multipart/signed ]
@@ -182,6 +188,7 @@ Carl Worth <cworth@cworth.org> (2009-11-18) (inbox unread)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:08:10 -0800
+Tags: inbox unread
On Tue, 17 Nov 2009 14:00:54 -0500, Lars Kellogg-Stedman <lars at
seas.harvard.edu> wrote:
--
1.7.8.3
^ permalink raw reply related [flat|nested] 5+ messages in thread