Following this guide, I have setup an org-mode project "foo" that I want to (frequently) publish using a single keyboard short.

Currently I have defined

(global-set-key (kbd "C-c C-1") 'org-publish)

so after typing C-c C-1, I still have to fill the prompt with the specific project I want to publish, here for example "foo".

How do I setup a shortcut that automatically publishes the project "foo" without additional prompts?


The documentation for org-publish says:

(org-publish PROJECT &optional FORCE ASYNC)

Publish PROJECT.

PROJECT is either a project name, as a string, or a project alist (see `org-publish-project-alist' variable).

(define-key org-mode-map (kbd "C-c C-1") 
   (lambda () 
      (org-publish "foo")))
  • It does not work for me: "eval-region: Wrong number of arguments: ... ". – Felix Hoffmann Mar 25 '15 at 9:25
  • 3
    I would bind a function specific to a mode to that mode map so that it doesn't pollute the global key binding space. (define-key org-mode-map (kbd "C-c C-1") (lambda () (interactive) (org-publish "foo"))) – Kaushal Modi Mar 25 '15 at 10:18
  • 1
    emacswiki.org/emacs/InteractiveKeybinding When passing arguments to a function in a binding, you need to wrap them up first in an interactive wrapper function or a temporary function lambda with interactive. – Kaushal Modi Mar 25 '15 at 10:23
  • @kaushalmodi This works, thank you! Would you mind either editing this answer or posting a new one so that I can accept it? – Felix Hoffmann Mar 25 '15 at 10:48

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.