Fork me on GitHub
Illia Danko13:02:56

Good day dear Clojurians. 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 ()
(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...


I can’t easily test it here, but I would guess you need to call my/vim-paredit-init with a quoted arg --

(my/vim-paredit-init 'clojure-mode-map)

Illia Danko20:02:23

I’ve tried, doesn’t work