From: Damien Cassou <damien.cassou@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/4] emacs: Make all tags in `notmuch-show' clickable
Date: Tue, 11 Dec 2012 10:00:36 +0100 [thread overview]
Message-ID: <1355216437-21109-4-git-send-email-damien.cassou@gmail.com> (raw)
In-Reply-To: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com>
Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
---
emacs/notmuch-show.el | 15 +++++++--------
emacs/notmuch-tagger.el | 33 +++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index a71497a..93bce07 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -362,10 +362,8 @@ operation on the contents of the current buffer."
(goto-char (notmuch-show-message-top))
(if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
(let ((inhibit-read-only t))
- (replace-match (concat "("
- (propertize (mapconcat 'identity tags " ")
- 'face 'notmuch-tag-face)
- ")")))))
+ (replace-match (propertize (notmuch-tagger-format-tags tags)
+ 'face 'notmuch-tag-face)))))
(notmuch-show-update-header-line))
(defun notmuch-clean-address (address)
@@ -442,10 +440,11 @@ message at DEPTH in the current thread."
(notmuch-show-clean-address (plist-get headers :From))
" ("
date
- ") ("
- (propertize (mapconcat 'identity tags " ")
- 'face 'notmuch-tag-face)
- ")\n")
+ ") "
+ (propertize
+ (notmuch-tagger-format-tags tags)
+ 'face 'notmuch-tag-face)
+ "\n")
(overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
(defun notmuch-show-insert-header (header header-value)
diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el
index 38b858a..35b81ca 100644
--- a/emacs/notmuch-tagger.el
+++ b/emacs/notmuch-tagger.el
@@ -44,12 +44,21 @@ test if the library is present before calling this function."
(let ((tag (header-button-get button 'notmuch-tagger-tag)))
(notmuch-tagger-goto-target tag)))
+(defun notmuch-tagger-body-button-action (button)
+ "Open `notmuch-search' for the tag referenced by BUTTON."
+ (let ((tag (button-get button 'notmuch-tagger-tag)))
+ (notmuch-tagger-goto-target tag)))
+
(eval-after-load "header-button"
'(define-button-type 'notmuch-tagger-header-button-type
'supertype 'header
'action #'notmuch-tagger-header-button-action
'follow-link t))
+(define-button-type 'notmuch-tagger-body-button-type
+ 'action #'notmuch-tagger-body-button-action
+ 'follow-link t)
+
(defun notmuch-tagger-really-make-header-link (tag)
"Return a property list that presents a link to TAG.
@@ -73,6 +82,20 @@ if not."
(notmuch-tagger-really-make-header-link tag)
tag))
+(defun notmuch-tagger-make-body-link (tag)
+ "Return a property list that presents a link to TAG.
+The returned property list will not work in the header-line. For
+a link that works on the header-line, prefer
+`notmuch-tagger-make-header-link'."
+ (let ((button (copy-sequence tag)))
+ (make-text-button
+ button nil
+ 'type 'notmuch-tagger-body-button-type
+ 'notmuch-tagger-tag tag
+ 'skip t ;; don't stop when using TAB
+ 'help-echo (format "%s: Search other messages like this" tag))
+ button))
+
(defun notmuch-tagger-format-tags-header-line (tags)
"Format TAGS as a `mode-line-format' template.
The result is suitable for inclusion in `header-line-format'."
@@ -83,5 +106,15 @@ The result is suitable for inclusion in `header-line-format'."
" ")
")"))
+(defun notmuch-tagger-format-tags (tags)
+ "Format TAGS as a string suitable for insertion in a buffer.
+If the result of this function is to be used within the
+header-line, prefer `notmuch-tagger-format-tags-header-line'
+instead of this function."
+ (concat
+ "("
+ (mapconcat #'notmuch-tagger-make-body-link tags " ")
+ ")"))
+
(provide 'notmuch-tagger)
;;; notmuch-tagger.el ends here
--
1.7.10.4
next prev parent reply other threads:[~2012-12-11 9:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-11 9:00 Damien Cassou
2012-12-11 9:00 ` [PATCH 1/4] emacs: Add a thread's tags to notmuch-show header-line Damien Cassou
2012-12-11 9:00 ` [PATCH 2/4] emacs: Make tags in notmuch-show header-line clickable Damien Cassou
2012-12-11 9:00 ` Damien Cassou [this message]
2012-12-11 9:00 ` [PATCH 4/4] emacs: Add unit-tests for clickable tags Damien Cassou
2012-12-13 11:45 ` Mark Walters
-- strict thread matches above, loose matches on Subject: below --
2012-12-13 13:09 [PATCH v5] emacs: display tags in notmuch-show with links Damien Cassou
2012-12-13 13:09 ` [PATCH 3/4] emacs: Make all tags in `notmuch-show' clickable Damien Cassou
2012-12-10 14:32 [PATCH v3] emacs: display tags in notmuch-show with links Damien Cassou
2012-12-10 14:32 ` [PATCH 3/4] emacs: Make all tags in `notmuch-show' clickable Damien Cassou
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=1355216437-21109-4-git-send-email-damien.cassou@gmail.com \
--to=damien.cassou@gmail.com \
--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).