0

I have the hard time straggling of passing elisp keymap to a custom function. I expect that after major mode has loaded (in my case it's clojure-mode) my new keybindings become available, but they don't:

;;; Settings.
(straight-use-package 'paredit)

(defun my/shared-lisp-mode-hook ()
  (require 'paredit)
  (my/vim-paredit-init clojure-mode-map))

;;; Clojure.
(straight-use-package 'cider)

;; This doesn't work.
(defun my/vim-paredit-init (map)
  (evil-define-key 'normal map (kbd "<localleader>r") #'paredit-raise-sexp))

;; This works, but not what I want.
;; (defun my/vim-paredit-init (map)
;;   (evil-define-key 'normal clojure-mode-map (kbd "<localleader>r") #'paredit-raise-sexp))


(defun my/clojure-mode-hook ()
  (my/shared-lisp-mode-hook))
  
(add-hook 'clojure-mode-hook #'my/clojure-mode-hook)

I know I miss something conceptual and trivial, but couldn't come up to any, but duplicating paredit key bindings for all major modes: elisp, clojure, which I want to avoid...

4
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Feb 21, 2021 at 0:18
  • There's too much code in your question, and not enough specification of what exactly you want to do. Can you provide a minimal example showing what you've tried, what it does, and what you want/expect instead? Passing a keymap as an arg to a function isn't related to using any packages, modes, or hooks. Please keep it simple.
    – Drew
    Feb 21, 2021 at 0:20
  • 1
    Related: emacs.stackexchange.com/questions/61225
    – ideasman42
    Feb 21, 2021 at 15:45
  • Could the discussion github.com/emacs-evil/evil/issues/301 be relevant? I don't use evil-mode but the discussion suggests to me that you need to run some update function, such as evil-normalize-maps, after evil-define-key. Feb 22, 2021 at 11:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.