Org-mode mailing list
 help / color / mirror / Atom feed
From: Tim Visher <>
To: Alexander Adolf <>
Cc: Emacs Org Mode mailing list <>
Subject: Re: How to use `open` to handle `message:*` links on macOS
Date: Thu, 29 Apr 2021 12:21:47 -0400
Message-ID: <> (raw)
In-Reply-To: <>

[-- Attachment #1: Type: text/plain, Size: 2964 bytes --]

Hi Diego and Alexander,

Thanks for the tips here. I finally got around to trying them out. Here's
what I ended up with and it's working perfectly.

(defun timvisher-org-link-mac-mail-open-link
    (mid _)
  (start-process "open-link" nil "open" (format "message://%%3C%s%%3E"

(defun timvisher-org-link-mac-mail-add-message-links
   "message" :follow #'timvisher-org-link-mac-mail-open-link))

(eval-after-load 'org

Pairing that with my org-capture TODO Current Mail Template is a dream come
true. :)

(defun timvisher-org-current-mail-get-selected-message-subject
     "osascript" nil t nil
     "-e" "tell application \"Mail\" to get subject of item 1 of
(selection as list)")
    (buffer-substring-no-properties (point-min) (- (point-max) 1))))

(defun timvisher-org-current-mail-get-selected-message-id
     "osascript" nil t nil
     "-e" "tell application \"Mail\" to get message id of item 1 of
(selection as list)")
     (buffer-substring-no-properties (point-min) (- (point-max) 1))

(defun timvisher-org-current-mail-get-link-string
  (let ((subject (timvisher-org-current-mail-get-selected-message-subject))
        (message-id (timvisher-org-current-mail-get-selected-message-id)))
    (org-link-make-string (format "message:%s" message-id)

(defun timvisher-org-current-mail-get-body-quote-template-element
  (let ((body (setq body (with-temp-buffer
                  "osascript" nil t nil
                  "-e" "tell application \"Mail\" to get content of
item 1 of (selection as list)")
                 (buffer-substring-no-properties (point-min) (-
(point-max) 1))))))
    (format "
  #+begin_quote%s  #+end_quote"
              (lambda (acc next)
                (if (string= next (or (car (last acc)) ""))
                  (append acc (list next))))
              (mapcar (lambda (string)
                        (let ((string (string-trim string)))
                          (if (string= "" string)
                            (format "  %s" string))))
                      (split-string body "\n"))

(setq org-capture-templates
        ("twcm" "TODO Work Current Mail" entry
         (file+headline "~/Dropbox/todo/" "Inbox")
         "* TODO %(timvisher-org-current-mail-get-link-string)
:prepend t :immediate-finish t)

Thanks so much! :)

[-- Attachment #2: Type: text/html, Size: 6720 bytes --]

  reply	other threads:[~2021-04-29 16:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 19:44 Tim Visher
2021-01-11 21:57 ` Diego Zamboni
2021-01-15 14:12 ` Alexander Adolf
2021-04-29 16:21   ` Tim Visher [this message]
2021-04-29 16:28     ` Diego Zamboni
2021-04-29 19:37     ` Tim Cross
2021-04-29 21:01       ` Tim Visher
2021-04-29 23:38     ` Alexander Adolf
2021-05-02 20:58       ` Tim Visher
2021-05-06 17:04         ` Alexander Adolf
2021-05-06 17:38           ` Tim Visher

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:

  List information:

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

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ \
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:

AGPL code for this site: git clone