[PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

David Edmondson dme at dme.org
Tue Jan 24 01:37:53 PST 2012


`notmuch-show-stash-gmane' stashes a URI for the current message at
Gmane, presuming that Gmane has a copy of the message with the same
Message-Id.

`notmuch-show-stash-gmane-and-go' both stashes the message and opens
the relevant page in the configured browser.

Add the relevant test for `notmuch-show-stash-gmane'.
---
 emacs/notmuch-show.el |   20 ++++++++++++++++++++
 test/emacs            |    4 +++-
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..c4d45e7 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1016,6 +1016,8 @@ thread id.  If a prefix is given, crypto processing is toggled."
     (define-key map "s" 'notmuch-show-stash-subject)
     (define-key map "T" 'notmuch-show-stash-tags)
     (define-key map "t" 'notmuch-show-stash-to)
+    (define-key map "g" 'notmuch-show-stash-gmane)
+    (define-key map "G" 'notmuch-show-stash-gmane-and-go)
     map)
   "Submap for stash commands")
 (fset 'notmuch-show-stash-map notmuch-show-stash-map)
@@ -1603,6 +1605,24 @@ buffer."
   (interactive)
   (notmuch-common-do-stash (notmuch-show-get-to)))
 
+(defun notmuch-show-stash-gmane ()
+  "Copy a Gmane URI for the current message to the kill-ring.
+
+This presumes that the message is available at Gmane."
+  (interactive)
+  (notmuch-common-do-stash (concat "http://mid.gmane.org/"
+				   (substring (notmuch-show-get-message-id) 4 -1))))
+
+(defun notmuch-show-stash-gmane-and-go ()
+  "Copy a Gmane URI for the current message to the kill-ring and visit it.
+
+This presumes that the message is available at Gmane."
+  (interactive)
+  (let ((uri (concat "http://mid.gmane.org/"
+		     (substring (notmuch-show-get-message-id) 4 -1))))
+    (notmuch-common-do-stash uri)
+    (browse-url uri)))
+
 ;; Commands typically bound to buttons.
 
 (defun notmuch-show-part-button-default (&optional button)
diff --git a/test/emacs b/test/emacs
index f150d95..5f7467d 100755
--- a/test/emacs
+++ b/test/emacs
@@ -382,9 +382,10 @@ test_emacs '(notmuch-show "id:\"bought\"")
 	(notmuch-show-stash-message-id-stripped)
 	(notmuch-show-stash-tags)
 	(notmuch-show-stash-filename)
+	(notmuch-show-stash-gmane)
 	(switch-to-buffer
 	  (generate-new-buffer "*test-stashing*"))
-	(dotimes (i 9)
+	(dotimes (i 10)
 	  (yank)
 	  (insert "\n")
 	  (rotate-yank-pointer 1))
@@ -400,6 +401,7 @@ id:"bought"
 bought
 inbox,stashtest
 ${gen_msg_filename}
+http://mid.gmane.org/bought
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
-- 
1.7.8.3



More information about the notmuch mailing list