How can I create a keybinding for specific org-export commands?

E.g. I'd like to bind to F9 exporting to an html file. Currently I need to hit C-c C-e h h.



You can figure out what commands are bound to the keys in the org-export-dispatch menu (C-c C-e in org-mode) by looking at the :menu-entry section of that backend's (org-export-define-backend ..) form.

As for ox-html.el, from the source (org-mode git master branch), we get this:

;; -- snip --
'(?h "Export to HTML"
     ((?H "As HTML buffer" org-html-export-as-html)
      (?h "As HTML file" org-html-export-to-html)
      (?o "As HTML file and open"
          (lambda (a s v b)
            (if a (org-html-export-to-html t s v b)
              (org-open-file (org-html-export-to-html nil s v b)))))))
;; -- snip --

So you can bind F9 to org-html-export-to-html. That is what is called when you do C-c C-e h h.

| improve this answer | |
  • 2
    Or, to solve all such problems in the future, use a tool like Helm so you can do incremental completion on all commands with helm-M-x; search for "org export html" is sufficient for narrowing down choices to the obvious one. – Tianxiang Xiong May 10 '16 at 21:05
  • @TianxiangXiong Correct. The same applies to any list completion package like ido or ivy too. – Kaushal Modi May 10 '16 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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