Hi Tassilo, I adapted your code for my use and found it was failing due to some stray double-quotes. I'm using notmuch from git so maybe these quotes were added in the year since you first posted your idea.
See below for the simple fix: On Tue, Nov 24, 2009 at 3:02 AM, Tassilo Horn <tassilo at member.fsf.org> wrote: > --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)))) I needed to define the message-id like: (message-id (replace-regexp-in-string "\"" "" (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--- Regards and thanks for this handy code! -Brett.