Re: Is there an hyperlink type for Mutt's e-mails?

Jean Louis <[email protected]> Sun, 05 Apr 2026 23:27:33 +0300
Newsgroups gmane.emacs.orgmode,gmane.mail.mutt.user
Organization GNU Support
Message-ID <[email protected]>
--=_62176fe74814025ae947e8dca9eb7845
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8;
 format=flowed

On 2026-04-05 22:37, Sébastien Hinderer wrote:
> Dear Org and Mutt friends,
> 
> Before diving into trying to implement a new Org hyperlink type for 
> mutt
> mailboxes and mails, I am wondering whether this maybe already exists?
> 
> I did check org-contrib but the only mutt-related thing I found
> there is support for accessing Mairix through Mutt. Which is great
> but not exactly what I am looking for.

I am using following since years:

(defun hyperscope-mutt-view-by-message-id (link argument)
   "Open mutt at folder LINK, searching for MESSAGE-ID ARGUMENT.
Escapes '=' chars in ARGUMENT for mutt's search syntax."
   (let* ((folder link)
	 (message-id (replace-regexp-in-string "=" "\\\\=" argument))
	 (push (format "push '<search>=i %s<enter><enter>'" message-id)))
     (let ((default-directory folder))
       (setenv "muttdir" folder)
       (start-process "mutt" "mutt" "xterm" "-e" "mutt" "-f" folder "-e" 
push))))

So the above one would be your Org link function.

LINK is folder, like: "~/Maildir/[email protected]"
MESSAGE-ID is like this: "[email protected]"

For Org, here are helper functions:

(defun hyperscope-mutt-insert-org-link ()
   "Interactively insert an Org link to an email in mutt."
   (interactive)
   (let ((folder (read-directory-name "Mail folder: " "~/Maildir/" nil 
t))
         (message-id (read-string "Message-ID: ")))
     ;; Store as "folder||message-id"
     (org-insert-link nil (format "mutt:%s||%s" folder message-id) 
message-id)))

You could rework the function to ask you for different link display 
name.

(defun hyperscope-mutt-open-link (link _description)
   "Open mutt from Org link with format FOLDER||MESSAGE-ID."
   (let* ((parts (split-string link "||"))
          (folder (car parts))
          (message-id (cadr parts)))
     (if (and folder message-id)
         (hyperscope-mutt-view-by-message-id folder message-id)
       (error "Invalid mutt link format. Use FOLDER||MESSAGE-ID"))))

(org-link-set-parameters "mutt" :follow #'hyperscope-mutt-open-link)

Now what you do in Org file:

M-x hyperscope-mutt-insert-org-link RET

enter:

~/Maildir/[email protected]/

and Message-ID: [email protected]

Then you get the link like this:

[[mutt:~/Maildir/[email protected]/||[email protected]][[email protected]]]

you click on it, and mutt opens with that message.

So that works on Maildirs, and you may need to fiddle with it.

There is attached file mutt-org-link.sh, you use it as Mutt helper to 
quickly capture Message-ID as Org link:

macro pager \e1 
"<pipe-entry>/home/data1/protected/bin/rcd/mutt-org-link.sh<enter>" 
"Extract Message-ID and copy Org link for Emacs Org mode"

You can configure Mutt macro as you wish to set up the right path of 
different key.

Once link is in clipboard, you can go to Org mode and insert it.

-- 
Jean Louis
--=_62176fe74814025ae947e8dca9eb7845
Content-Transfer-Encoding: base64
Content-Type: text/x-shellscript;
 name=mutt-org-link.sh
Content-Disposition: attachment;
 filename=mutt-org-link.sh;
 size=868

IyEvYmluL2Jhc2gKIyBtdXR0LW9yZy1saW5rIC0gRXh0cmFjdCBNZXNzYWdlLUlEIGZyb20gZW1h
aWwgYW5kIGNvcHkgT3JnIGxpbmsgdG8gY2xpcGJvYXJkCgojIFJlYWQgdGhlIGVtYWlsIGZyb20g
c3RkaW4KZW1haWw9JChjYXQpCgojIEV4dHJhY3QgTWVzc2FnZS1JRAptZXNzYWdlX2lkPSQoZWNo
byAiJGVtYWlsIiB8IGdyZXAgLWkgIl5NZXNzYWdlLUlEOiIgfCBoZWFkIC0xIHwgc2VkICdzL15N
ZXNzYWdlLUlEOiAvL2knIHwgdHIgLWQgJyBccicpCgojIFJlbW92ZSBhbmdsZSBicmFja2V0cyBp
ZiBwcmVzZW50Cm1lc3NhZ2VfaWRfY2xlYW49JChlY2hvICIkbWVzc2FnZV9pZCIgfCBzZWQgJ3Mv
XjwvLztzLz4kLy8nKQoKIyBBc2sgZm9yIGZvbGRlciAoZGVmYXVsdCB0byB+L01haWxkaXIpCnJl
YWQgLXAgIk1haWwgZm9sZGVyIChkZWZhdWx0OiB+L01haWxkaXIpOiAi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