0

I use vanilla Emacs with evil. I did not install smartparens but it is present and enabled on my system as a dependency of something.

I need to rebind the M-s keys to something other than the default sp-splice-sexp.

The output of describe-key for M-s is currently:

M-s runs the command sp-splice-sexp, which is an interactive compiled
Lisp function in ‘smartparens.el’.

It is bound to M-s, <normal-state> M-s.

Going into smartparens.el, I am able to see that a smartparens-mode-map is defined and M-s belongs to it.

I have tried in vain to do:

(define-key smartparens-mode-map (kbd "M-s") nil)

or

(evil-define-key 'normal smartparens-mode-map (kbd "M-s") nil)

or

(define-key evil-normal-state-map (kbd "M-s") nil)

The list of the MELPA packages I use is:

auto-package-update atom-one-dark-theme slime
company evil column-enforce-mode paredit evil-cleverparens
highlight-parentheses key-chord

One of these packages must be loading smartparens and defining the keymap but I can't find which one. Is there a way perhaps to see which keymap or evil keymap to change?

  • Have you tried to disable smartparens-mode? – Stefan May 12 '19 at 20:10
  • I have tried (smartparens-mode -1) in my init.el and also (add-hook 'prog-mode-hook (lambda () (smartparens-mode -1)) t). No changes whatsoever, the shortcut still exists in prog-mode or wherever else. – Thomas Houllier May 12 '19 at 20:18
0

Smartparens doesn't add any key bindings by default as sp-base-key-bindings is set to nil.

Evil-cleverparens has Smartparens as dependency. And evil-cleverparens adds some additional keybindings by default. This includes setting M-s to sp-splice-sexp.

So you have to unbind M-s in evil-cleverparens-mode-map:

(with-eval-after-load 'evil-cleverparens
  (evil-define-key 'normal evil-cleverparens-mode-map (kbd "M-s") nil))

Or change evil-cleverparens-use-additional-bindings to not use those bindings before loading evil-cleverparens:

(setq evil-cleverparens-use-additional-bindings nil)
|improve this answer|||||
  • I see. Disabling the additional bindings works for me. But changing the evil-cleverparens-mode-map does not. My configuration might be too messy. Anyhow, I consider my problem solved! Thank you! – Thomas Houllier Feb 3 at 18:17
  • @ThomasHoullier changed from define-key to evil-define-key, should work now. – Hubisan Feb 3 at 21:33
  • Indeed, it works now. Thx. – Thomas Houllier Feb 4 at 18:41
0

Similar to How do I turn-off smartparens when using prelude?, the following might do it:

(defun rebind-keys ()
  (define-key smartparens-mode-map (kbd "M-s") nil)
)

(add-hook 'smartparens-enabled-hook 'rebind-keys t)
|improve this answer|||||
  • Alright, just tried this to no avail. Nothing seems changed. I tried adding to the hook 'smartparens-enabled-hook either a key rebinding function or (smartparens-mode -1). Nothing seems to change anything, very puzzling. – Thomas Houllier Jan 3 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.