unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Snippet to jump to message in Gnus from notmuch-show buffer
@ 2009-11-24  8:02 Tassilo Horn
  2009-11-27 12:54 ` Carl Worth
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Tassilo Horn @ 2009-11-24  8:02 UTC (permalink / raw)
  To: notmuch

Hi all,

I'm a Gnus user and use notmuch mostly for searching.  When I want to
reply to a message, I need to get back to Gnus, so that my Gnus posting
styles (gcc into that group, right email address, correct signature,...)
are applied.

Therefore, I created this small snippet.  Now C-c C-c inside some
message in the *notmuch-show* buffer opens this article in a Gnus
*Summary* buffer, where I can reply to it, forward it, ...

Of course, the translation from file name to Gnus group name is
something that is different for any user.  The essence of this code is
the call to the org-gnus.el function `org-gnus-follow-link', which takes
the group name and the message-id.  It's included in Emacsen >= 23.

--8<---------------cut here---------------start------------->8---
(require 'notmuch)

(defun th-notmuch-file-to-group (file)
  "Calculate the Gnus group name from the given file name.

Example:

  IN: /home/horn/Mail/Dovecot/uni/INBOX/dbox-Mails/u.4075
  OUT: nnimap+Uni:INBOX"
  (concat "nnimap+"
          (replace-regexp-in-string 
           "^\\([^/]+\\)/" "\\1:"
           (replace-regexp-in-string 
            "/dbox-Mails/.*" ""
            (replace-regexp-in-string
             "/home/horn/Mail/Dovecot/" "" file)))))

(defun th-notmuch-goto-message-in-gnus ()
  "Open a summary buffer containing the current notmuch
article."
  (interactive)
  (let ((group (th-notmuch-file-to-group (notmuch-show-get-filename)))
        (message-id (replace-regexp-in-string
                     "^id:" "" (notmuch-show-get-message-id))))
    (message "G: %s, mid: %s" group message-id)
    (if (and group message-id)
        (org-gnus-follow-link group message-id)
      (message "Couldn't get relevant infos for switching to Gnus."))))

(define-key notmuch-show-mode-map (kbd "C-c C-c") 'th-notmuch-goto-message-in-gnus)
--8<---------------cut here---------------end--------------->8---

BTW, why does `notmuch-show-get-message-id' prefix the message-id with
"id:"?

Bye,
Tassilo

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

end of thread, other threads:[~2010-11-21  1:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-24  8:02 Snippet to jump to message in Gnus from notmuch-show buffer Tassilo Horn
2009-11-27 12:54 ` Carl Worth
2009-11-27 17:29   ` Kan-Ru Chen
2009-11-27 13:31 ` Carl Worth
2009-11-27 22:10   ` Tassilo Horn
2009-11-28 14:55     ` Adam Sjøgren
2009-12-02 20:51     ` Carl Worth
2009-12-02 21:12       ` Adam Sjøgren
2010-11-21  1:12 ` Brett Viren

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