1

I am trying to change the default prefix key C-c @ to C-c for outline-minor-mode:

      (define-key outline-minor-mode-map (kbd "C-c")
        (lookup-key outline-minor-mode-map (kbd "C-c @")))

This works fine if outline-minor-mode is already loaded. But I cannot find a way to put this into .emacs so that it is run whenever outline-minor-mode is activated.

I have tried:

(add-hook 'outline-minor-mode-hook
      (define-key outline-minor-mode-map (kbd "C-c")
        (lookup-key outline-minor-mode-map (kbd "C-c @"))))

Which gives:

Symbol's value as variable is void: outline-minor-mode-map
2

You must pass a function to add-hook. As it is you are evaluating the define-key call immediately, which is why you get the error.

with-eval-after-load is exactly what you are looking for.

(with-eval-after-load "outline"
  (define-key outline-minor-mode-map (kbd "C-c")
              (lookup-key outline-minor-mode-map (kbd "C-c @"))))

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.