org-mode links meet hydra

| categories: hydra, orgmode, emacs | tags: | View Comments

I have played with a lot of options to give org-mode links extra functionality. Here are a few of the ideas I have looked at so far.

  1. Enabling right clicks on links
  2. A home made minibuffer menu in org-ref
  3. A helm buffer in org-ref

Here, I want to explore a hydra menu for a link. The idea is pretty simple, we need functions that do something with the link at point, and a hydra interface to call them. This turned out to be a little tricky. I could not get the path from the link in the link lambda function, and we need a way to pass the path to the function. I use a global variable for that. I wish there was another way to do that, but this does actually work. We illustrate it here with a more functional doi link.

(defun doi-crossref ()
  "Search DOI in CrossRef."
    "" *doi-hydra-path*)))

(defun doi-google-scholar ()
  "Google scholar the doi."
    "" *doi-hydra-path*)))

(defun doi-pubmed ()
  "Pubmed the doi."
    (url-hexify-string *doi-hydra-path*))))

 (defhydra doi-hydra ()
   ("c" doi-crossref "Crossref")
   ("g" doi-google-scholar "Google Scholar")
   ("p" doi-pubmed "Pubmed"))

(org-add-link-type "doi"
  (lambda (path) (setq *doi-hydra-path* path) (doi-hydra/body)))
lambda (path) (setq doi-hydra-path path) (doi-hydra/body)

Now for a test, 10.1021/jp047349j.

It works fine, when you click on a link, you get a minibuffer menu with context hints, and pressing any other key than is defined simply cancels the command.

Copyright (C) 2015 by John Kitchin. See the License for information about copying.

org-mode source

Org-mode version = 8.2.10

blog comments powered by Disqus