EDIT: ANSWER
The cause for the problem in this question was pointed out in the Emacs mailing list. It is due to the (kbd ...)
forms not getting evaluated because the keymap in the define-minor-mode
is passed as a quoted list.
The (kbd ...)
forms can be used by using a backquoted list and then placing a ,
before each (kbd ...)
form so that they get evaluated.
END EDIT
I know there are similar questions like mine, but I could not find an answer to my question.
This question was edited (below) because it appears to be a bug (please confirm).
I want my minor-mode bindings to get precedence over the pdf-view major mode bindings.
I define my minor mode with the following code:
(define-minor-mode pdf-continuous-scroll-mode
"Emulate continuous scroll with two synchronized buffers"
nil
" Continuous"
'(((kbd "j") . (lambda () (interactive) (print "pushed j")))
((kbd "k") . (lambda () (interactive) (print "pushed k")))
((kbd "C-n") . (lambda () (interactive) (print "pushed C-n")))
((kbd "C-p") . (lambda () (interactive)(print "pushed C-p"))))
(print "loaded minor mode"))
Now when I evaluate this while I am viewing a document with PDF-tools and enable the minor mode, then the j
/k
bindings work but the C-n/C-p
bindings do not because Emacs still uses the pdf-view major mode keybindings (i.e. it scrolls the document).
I find here that minor-mode keymaps should have highest precedence behind overlay keymaps. I checked if maybe there is some overlay keymap used in PDF-tools but I could not find one.
Can anybody explain why my minor mode bindings do not get precedence over de pdf-view major mode bindings?
EDITS
- I find the
C-n
andC-p
do not even get precedence over the global-keymap. I can just start emacs usingemacs -Q
, evaluate the code and activate the minor mode. Then stillC-n
andC-p
do not work. Please someone confirm this is a bug, then I will report the bug.
END EDIT