unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
@ 2011-07-05 20:12 Daniel Schoepe
  2011-07-06 14:18 ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
  2011-10-28 14:48 ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
  0 siblings, 2 replies; 16+ messages in thread
From: Daniel Schoepe @ 2011-07-05 20:12 UTC (permalink / raw)
  To: notmuch

This fixes the minor annoyance that message ids were parsed as mail
addresses by goto-address-mode in notmuch-show buffers.
---
 emacs/notmuch-show.el |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f96743b..0f7fcfe 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -778,6 +778,24 @@ current buffer, if possible."
 (defvar notmuch-show-parent-buffer nil)
 (make-variable-buffer-local 'notmuch-show-parent-buffer)
 
+(defun notmuch-show-buttonise-links (start end)
+  "Buttonise URLs and mail addresses between START and END.
+
+This also turns id:\"<message id>\"-parts into buttons for
+a corresponding notmuch search."
+  (goto-address-fontify-region start end)
+  (save-excursion
+    (goto-char start)
+    (while (re-search-forward "id:\"[^ ]+\"" end t)
+      ;; remove the overlay created by goto-address-mode
+      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
+      (make-text-button (match-beginning 0) (match-end 0)
+			'action `(lambda (arg)
+				   (notmuch-search ,(match-string-no-properties 0)))
+			'follow-link t
+			'help-echo "Mouse-1, RET: search for this message"
+			'face goto-address-mail-face))))
+
 ;;;###autoload
 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
   "Run \"notmuch show\" with the given thread ID and display results.
@@ -822,9 +840,8 @@ function is used. "
 	  (notmuch-show-insert-forest
 	   (notmuch-query-get-threads basic-args))))
 
-      ;; Enable buttonisation of URLs and email addresses in the
-      ;; buffer.
-      (goto-address-mode t)
+      (jit-lock-register #'notmuch-show-buttonise-links)
+
       ;; Act on visual lines rather than logical lines.
       (visual-line-mode t)
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-10-28 17:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-05 20:12 [PATCH] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
2011-07-06 14:18 ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
2011-07-06 14:18   ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
2011-07-07  7:04     ` Pieter Praet
2011-07-07  7:16     ` Dmitry Kurochkin
2011-07-07  8:07       ` Pieter Praet
2011-07-07  8:15       ` Daniel Schoepe
2011-07-07  8:22         ` Dmitry Kurochkin
2011-10-11 14:27     ` Daniel Schoepe
2011-10-17  9:16     ` Thomas Schwinge
2011-10-17 12:13       ` Daniel Schoepe
2011-10-17 13:11         ` Thomas Schwinge
2011-10-17 13:43           ` Daniel Schoepe
2011-10-28 14:48 ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
2011-10-28 14:48   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
2011-10-28 17:21   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for David Bremner

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).