1

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

2 Answers2

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)
  • 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 03 '20 at 22:39
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)
Hubisan
  • 1,623
  • 7
  • 10