2

When I am using Emacs Org Mode to publish projects, Emacs will convert external links according to the link type.

For example, when I am trying to link Evernote note link in Org Mode, the Evernote link url is:

evernote:///view/52572/s1/6e53e0ed-272a-4ec9-89c7-f636b16d6a3c/6e53e0ed-272a-4ec9-89c7-f636b16d6a3c/

I input the link like following in Org Mode file:

[[evernote:///view/52572/s1/6e53e0ed-272a-4ec9-89c7-f636b16d6a3c/6e53e0ed-272a-4ec9-89c7-f636b16d6a3c/][Som Evernote note title]]

Then I publish the project, the above link will convert to something like:

index.html#evernote-view/52572/s1/6e53e0ed-272a-4ec9-89c7-f636b16d6a3c/6e53e0ed-272a-4ec9-89c7-f636b16d6a3c

The prefix evernote:///view is converted to evernote-view.

So, any idea about don't let Emacs to convert this evernote:///view prefix?

1 Answer 1

5

Use the org-add-link-type function. Put the following in your .emacs

(require 'org)
(org-add-link-type "evernote" nil '(lambda (path desc frmt)
      (format "<a href=\"evernote:%s\">%s</a>" path desc)))

org-add-link-type takes three parameters, which is the name of a link identifier tag (in this case "evernote"), a link-follow function and a link-export function. In this case we only worry about the export, so we only provide the latter function as a lambda. It takes the properties of the link defined and exports an html string.

Improvements that could be made include

  • Provide the link-follow function, which would allow you to "click" the links in emacs.
  • Create export types for other than html. The frmt parameter holds the value of the type of export being performed, but in the above it is ignored since it only exports for HTML.

You can read some more about it here and in the source code of org-mode

Your Answer

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

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