emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: AW <alexander.willand@t-online.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Link from orgmode file to E-Mail (using kmail or notmuch)
Date: Sun, 22 Jan 2023 10:29:45 +0300	[thread overview]
Message-ID: <Y8zl6Zuaizjhp+Xi@protected.localdomain> (raw)
In-Reply-To: <3218434.44csPzL39Z@linux.fritz.box>

* AW <alexander.willand@t-online.de> [2023-01-22 00:33]:
> Workflow: E-Mails with a question comes in, I open a TODO heading in
> an orgmode file regarding the question.
> 
> Now, I'd like to add a link to the E-Mail under this TODO heading in the 
> orgmode file. I've seen the manual page about external links, https://
> orgmode.org/manual/External-Links.html 

I am using Mutt: https://mutt.org which must be in your
distribution. 

There is way how to automatically capture Message-ID and put it
outside of the Mutt, though I did not yet implement it.

However, if I wish to open specific e-mail I point to the Maildir, or
maybe Mbox or other type,

Maildir: /home/data1/protected/Maildir/tomas@tuxteam.de
Message-ID: Y0mt4/G+DlKlURuC@tuxteam.de

Then I use this function:

(defun hyperscope-mutt-view-by-message-id (link argument)
  "Opens email by message ID by using mutt"
  (let* ((folder link)
	 (message-id (replace-regexp-in-string "=" "\\\\=" argument))
	 (push (format "push '<search>=i %s<enter><enter>'" message-id)))
    (call-process "xterm" nil nil nil "-e" "mutt" "-f" folder "-e" push)))

Where by function must receive LINK and ARGUMENT, whereby ARGUMENT
means Message-ID string.

xterm is called, mutt launched for FOLDER which is same as LINK, and
"-e" specify a command to be executed after initialization, which is
in this case "push "'<search>=i Y0mt4/G+DlKlURuC@tuxteam.de<enter><enter>'"

And I get to see that specific e-mail that was hyperlinked.

You may implement this in org by creating elisp: type of links easy. You could call this function different:

(defalias 'my-message-id 'hyperscope-mutt-view-by-message-id)

(my-message-id LINK ARGUMENT)

Opens email by message ID by using mutt

[[elisp:(my-message-id "/home/data1/protected/Maildir/tomas@tuxteam.de" "Y0mt4/G+DlKlURuC@tuxteam.de")][Link to my message]]

And after clicking on the above Org hyperlink I can see it works well. 

KMail does not work on my side, so you can see which command line
options are available to find message by Message-ID.

In Thunderbird you may use this plugin:

Copy Message ID :: Add-ons for Thunderbird:
https://addons.thunderbird.net/en-us/thunderbird/addon/copy-message-id/

as to get quickly Message-ID.

The way to open up in Thunderbird is:

./thunderbird mid:PUT-HERE-YOUR-MESSAGE-ID

Here is easier way to insert Message-ID hyperlinks:

(defun rcd-org-link-message-id-by-elisp ()
  (interactive)
  (let* ((my-selection (gui-selection-value))
	 (functions '("(my-message-id \"%s\" \"%s\")" "(message-id-by-thunderbird \"%s\")"))
	 (function (completing-read "Choose function for Message-ID: " functions nil t))
	 (name (read-string "Name of link: "))
	 (folder (read-string "Enter mail folder if any or RET for nothing: "))
	 (message-id (read-string "Enter Message-ID: " my-selection)))
    (insert "[[elisp:" (format function folder message-id) "][" name "]]")))

1. Copy Message ID in memory, but you also need to know Mail folder, depending of function

2. M-x rcd-org-link-message-id-by-elisp and answer questions

3. [[elisp:(my-message-id "my mail folder" "my message ID")][my name]]

> I'm on Linux, KDE as GUI, distro Tumbleweed by openSUSE. The E-mail
> software is kmail. Unfortunately, there is no way to get the path to
> an individual E- mail out of kmail, which I could simply use to put
> it into my orgmode file as a link.  So I installed notmuchmail and
> the emacs package notmuch.el.

It requires indexing and wastes time. If you use Mutt, it will open up
Message-ID e-mails in breeze. You may invoke external HTML viewers or
external program to see e-mails in different way. I know it is double
work.

Peculiar ways to make Evolution work are explained by Karl Voit:

Moving from Thunderbird to Evolution for Emails and Calendar:
https://karl-voit.at/2021/06/01/Thunderbird-to-Evolution/

Feature request: getting a message-id link from email + CLI option to open email via message-id (#1508) · Issues · GNOME / evolution · GitLab:
https://gitlab.gnome.org/GNOME/evolution/-/issues/1508

> By notmuch-search I can find an individual E-mail. In the E-Mail
> buffer I type c I , which copies the message-ID of that E-Mail into
> the keyring.  Instead of a link I paste the message-ID into my
> orgmode file. If I'd like to read the E-Mail again, I can use
> notmuch-search: id: <abc123> to find the E- Mail again.  I know,
> this is not a really efficient way. Probably you are not surprised
> to read my question: How can I have a link in an orgmode file to an
> E-Mail using either a feature of kmail oder notmuch ?  Regards,

We tried to solve this problem for Mutt here, since 3 years already:

Feature proposal: provide possibility to link directly to a message (#172) · Issues · Mutt Project / mutt · GitLab:
https://gitlab.com/muttmua/mutt/-/issues/172

Of course, one can see that both in Gnome and Mutt society, people
hardly understand use cases of capturing hyperlinks to messages.

Capturing of e-mails attributes is more of a problem that creating
hyperlinks in Org.

Good that Mutt supports Muttlisp language. But I do not use it. I did
not figure out yet how to make IMAP hyperlinks, but that is definitely
possible. 

Here is how to capture Hyperlinks by using Mutt:
------------------------------------------------

.muttrc settings
----------------

##############
# Folder hooks
##############

folder-hook . 'set my_folder=$folder;set folder="XXX";set visual=^'
folder-hook . 'setenv MUTTCURRENTFOLDER $visual'
folder-hook . 'set folder=$my_folder'

macro index,pager \em ":set wait_key=no<enter><pipe-entry>grep -i -o -P '(?<=Message-Id: <).*(?=>)' | sed 's%\(.*\)%'\"$MUTTCURRENTFOLDER\"'###\1%' | capture-mutt-message-id.sh $folder<enter>"

File: capture-mutt-message-id.sh
--------------------------------

#!/usr/bin/bash
read -r message_id
folder="$@"
echo "Got folder: $folder with Message-ID: $message_id"
emacsclient -e "(rcd-mutt-capture-message-id \"$folder\" \"$message_id\")"
sleep 3


Emacs Lisp function:
--------------------

This function shall be adapted to be used in Org. There is name,
folder and message-id to be used.

(defun rcd-mutt-capture-message-id (folder message-id)
  "Create new Hyperdocument by using FOLDER and MESSAGE-ID."
  (raise-frame)
  (x-focus-frame nil)
  (let* ((name (rcd-ask-get "Name for the Message-ID Hyperdocument: "))
	 (parent (hyperscope-select-set "Parent set for Message-ID: "))
	 (id (hyperscope-add-generic name folder nil 22 nil parent message-id)))
    (rcd-message "Captured Hyperdocument ID: %s Message-ID with folder: %s, and Message-ID: %s" id folder message-id)
    (hyperscope-isolate id)))

Mutt workflow:
--------------

0. It uses Emacs in background, program `emacsclient' should be
   capable of connecting to Emacs server

1. Open up any e-mail, never mind where it is:

2. press `ESC m' to capture Message ID as hyperlink

3. Emacs will raise it's frame, describe the hyperlink to that Message-ID

4. Continue reading e-mails


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/


  parent reply	other threads:[~2023-01-22  7:36 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <draft-87r0vhxg15.fsf@tosh-laptop.mail-host-address-is-not-set>
2023-01-21 21:32 ` Link from orgmode file to E-Mail (using kmail or notmuch) AW
2023-01-21 22:43   ` Gautier Ponsinet
2023-01-22  4:44   ` Max Nikulin
2023-01-22  8:32     ` Ihor Radchenko
2023-01-22  9:38       ` Jean Louis
2023-01-22 10:36       ` Max Nikulin
2023-01-22 18:47       ` AW
2023-01-23  6:19         ` Jean Louis
2023-01-23 10:40         ` Ihor Radchenko
2023-01-23 13:55           ` AW
2023-01-23 18:28             ` Jean Louis
2023-01-24  9:40             ` Ihor Radchenko
2023-01-24 10:42               ` Dirk-Jan C. Binnema
2023-01-24 11:17                 ` Ihor Radchenko
2023-01-24 17:08                   ` Dirk-Jan C. Binnema
2023-01-24 19:12                   ` Jean Louis
2023-01-26 10:01                 ` AW
2023-01-24 19:01               ` Jean Louis
2023-01-28 14:08                 ` [OT] email opens (was: Link from orgmode file to E-Mail (using kmail or notmuch)) Gregor Zattler
2023-01-28 18:26                   ` tomas
2023-01-29  4:37                   ` Jean Louis
2023-01-26  9:58               ` Link from orgmode file to E-Mail (using kmail or notmuch) AW
2023-01-26 10:16                 ` Ihor Radchenko
2023-01-26 11:43                 ` Max Nikulin
2023-01-26 12:18                 ` Jean Louis
2023-01-26 18:41                   ` AW
2023-01-23 11:46         ` Max Nikulin
2023-01-23 13:59           ` AW
2023-01-23 14:20             ` AW
2023-01-24  9:44             ` Ihor Radchenko
2023-01-24 16:11             ` Max Nikulin
2023-01-24 17:32               ` Bruno Barbier
2023-01-25 12:48                 ` Max Nikulin
2023-01-28  2:36                 ` Max Nikulin
2023-01-28  8:30                   ` Bruno Barbier
2023-01-28  8:30                     ` Max Nikulin
2023-01-31 19:56                       ` PATCH for worg about cb_thunderlink (Re: Link from orgmode file to E-Mail (using kmail or notmuch)) Bruno Barbier
2023-02-01 16:18                         ` Max Nikulin
2023-02-01 18:16                           ` Bruno Barbier
2023-02-02 14:47                             ` Max Nikulin
2023-02-02  6:04                               ` Bruno Barbier
2023-02-03 14:50                                 ` Max Nikulin
2023-02-03 15:42                                   ` Bruno Barbier
2023-02-04  4:59                                     ` Max Nikulin
2023-02-06 11:46                                       ` Bruno Barbier
2023-02-07 15:08                                         ` [PATCH] worg/org-faq.org: Recommend cb_thunderlink Thunderbird add-on Max Nikulin
2023-02-07 18:26                                           ` Bruno Barbier
2023-02-08 15:45                                             ` Max Nikulin
2023-01-23 18:37           ` Link from orgmode file to E-Mail (using kmail or notmuch) Jean Louis
2023-01-24 17:22             ` Max Nikulin
2023-01-24 17:49               ` Jean Louis
2023-01-25 15:31                 ` Max Nikulin
2023-01-25 16:48                   ` This is out of thread subject Jean Louis
2023-01-25 18:01                     ` Ihor Radchenko
2023-01-26  6:28                       ` Jean Louis
2023-01-27 11:23                         ` Ihor Radchenko
2023-01-27 11:51                       ` Firefox permission dialog and org-protocol Max Nikulin
2023-01-29 13:50                         ` Ihor Radchenko
2023-01-30  5:48                           ` Max Nikulin
2023-01-30 14:59                             ` [BUG] org-manual: Using bookmarklet for org-capture is no longer reliable (was: Firefox permission dialog and org-protocol) Ihor Radchenko
2023-01-31  8:11                               ` [BUG] org-manual: Using bookmarklet for org-capture is no longer reliable Charles Philip Chan
2023-01-31 12:20                                 ` Max Nikulin
2023-02-01 13:38                                   ` Ihor Radchenko
2023-02-02 14:09                                     ` Max Nikulin
2023-02-02 14:17                                       ` Ihor Radchenko
2023-02-02 15:02                                         ` Max Nikulin
2023-02-05  7:43                                 ` Max Nikulin
2023-02-05 10:26                                   ` Ihor Radchenko
2023-01-31  1:59                             ` Firefox permission dialog and org-protocol Samuel Wales
2023-01-26 16:19                 ` Link from orgmode file to E-Mail (using kmail or notmuch) Max Nikulin
2023-01-27  6:41                   ` Jean Louis
2023-01-27 15:19                     ` Max Nikulin
2023-01-29  4:18                       ` Jean Louis
2023-01-29  8:41                         ` Ihor Radchenko
2023-01-24 17:39             ` Bruno Barbier
2023-01-24 17:52               ` Jean Louis
2023-01-25 12:56                 ` [FR] Should Org provide commonly used link types? (was: Link from orgmode file to E-Mail (using kmail or notmuch)) Ihor Radchenko
2023-01-25 16:40                   ` Should Org provide commonly used link types? Jean Louis
2023-01-25 18:15                     ` Ihor Radchenko
2023-01-26  5:09                       ` Jean Louis
2023-01-26  6:11                       ` Jean Louis
2023-04-26 18:18                     ` jawatech
2023-01-24  9:42           ` Link from orgmode file to E-Mail (using kmail or notmuch) Ihor Radchenko
2023-01-24 15:49             ` Max Nikulin
2023-01-24 18:14               ` Jean Louis
2023-01-24 18:03             ` Jean Louis
2023-01-22  7:29   ` Jean Louis [this message]
2023-01-27 18:15 ` Bruno Barbier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y8zl6Zuaizjhp+Xi@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=alexander.willand@t-online.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).