3

When I add a mailto link with C-c C-l, the closing > is missing.

If I enter:

mailto:Apa <[email protected]>

Leaving the description blank, I get a link like

mailto:Apa <[email protected]

If I end with >>, the link is correct. If I enter it with markup like below, it works.

[[mailto:Apa <[email protected]>]]

This comes from the following snippet of org-insert-link (Emacs 24.4.1)

(if (and (string-match org-plain-link-re link)
         (not (string-match org-ts-regexp link)))
    ;; URL-like link, normalize the use of angular brackets.
    (setq link (org-remove-angle-brackets link)))

So modifying org-plain-link-re or org-ts-regexp is one way to achieve this. These are pretty impressive expressions, which looks a bit intimidating to touch.

I understand that <> tags are used by org, and this is the likely reason for these types of mail links not getting treated like one would naively think, but I also can't believe I'm the only one that uses addresses of this type.

So has anyone tweaked emacs org to accept this, or is it a bug, or is this address format considered evil?

1
  • I think this sounds like a bug. This should work out of the box.
    – erikstokes
    May 27, 2015 at 23:04

2 Answers 2

2

Since org-remove-angle-brackets is responsable for actually striping the "<>" from the link, we can fix this by adding some advice saying that if the link starts with "mailto:", just return the link, otherwise do whatever the original function does.

(advice-add #'org-remove-angle-brackets :before-until
            (lambda (s) (if (string-prefix-p "mailto:" s) s)))
1
  • Works like a charm! Maybe I'll gather some courage and report it as a bug... May 28, 2015 at 8:38
1

It's expecting a URL, and ' ' (space), <> (angle brackets), " (double quotes) are not valid characters in a URL, and so must be encoded.

  • ' ' becomes %20
  • " becomes %22
  • < becomes %3c
  • > becomes %3e

So, the email address:

Apa <[email protected]>

is expressed as a URL like this:

mailto:%22Apa%22%20%[email protected]%3e

which is a chore to write.

Ideally, Emacs would check whether the entered link uses the mailto: URL scheme and encode the special characters for you. In the meantime, perhaps some advice?

1
  • Tried to find some info about what format it does expect, but didn't find much. The info page shows an example with a simple address. Cheers for the info, the advice from @erikstokes does the trick. May 28, 2015 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.