1

I was wondering if we can know whether a given package has a local map of keybindings. For example, I'd like to bind the function pdf-occur of the pdf-tools package by using the use-package macro. This would entail doing something like:

(use-package pdf-tools
  :map pdf-tools-mode-map  ## ??? this is what I need to know: is there a local map? What's its name?
   ("s-o"  . pdf-occur)) 

1 Answer 1

1

A couple of alternative ways to find out:

  • Use C-h m to see a description of the major mode. It may mention the keymap variable (e.g. pdf-tools-mode-map) or key bindings in it. If it mentions only bindings (not the keymap variable), use C-h k followed by one of those bindings. The *Help* buffer will tell you the name of the keymap (the variable name) where that key is bound for the mode.

  • Use C-h v followed by the name of your major mode (e.g. pdf-tools-mode) and -map, then TAB, to see if there's a variable with that name (e.g. pdf-tools-mode-map).

2
  • Awesome! Your tips have helped me find a pdf-isearch-minor-mode where the pdf-occur function is defined. I haven't found a pdf-isearch-minor-mode-map explicitly, but defining my keybinding there makes it work whenever I am in a PDF document so I guess it exists? Thank you!
    – Daniel
    Commented Dec 28, 2021 at 16:46
  • Thank Emacs and its C-h m and C-h v. ;-)
    – Drew
    Commented Dec 28, 2021 at 21:22

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.