So I'm writing some custom functions to help me editing some guitar chords using LaTeX's songs
package. I find convenient to rebind isearch-exit
, so that when I press RET
, the cursor is left at the beginning of the matched text (this speeds up in inserting chords in the right position). Since I do this only in some specific files, I thought to create a custom minor mode, and active that in those files using an eval
in .dir-locals
. The point is, I need to bind RET
in isearch-mode-map
(like with define-key
), but only in a buffer local way (like with local-set-key
). Can this be done?
Ideally, given this function:
(defun isearch-exit-other-end ()
"Exit isearch, at the opposite end of the string."
(interactive)
(goto-char isearch-other-end)
(isearch-exit))
;; (define-key isearch-mode-map (kbd "M-<return>") #'isearch-exit-other-end)
(define-minor-mode chord-insertion-mode
"Mode to help inserting chords with the LaTeX \"songs\" package, at the right spot."
:lighter " chord"
:keymap `((,(kbd "C-c C-c") . #'my--insert-chord)
(,(kbd "C-c c") . #'my--insert-chord)
)
:after-hook (???)) ;; <----- WHAT TO PLACE HERE?
I would like to do something similar to
(define-local-key isearch-mode-map (kbd "RET") #'isearch-exit-other-end)
How can I set a key buffer-locally, but in a keymap different from the active one? Thanks!