Reputation:
I'm trying ParEdit mode and this is something that it does not the way I'd want: it shadows the original binding for C-M-F and replaces it with C-M-f. I.e. it forwards sexp instead of selecting it :| I couldn't find the place where the bindings are defined at the first glance.
Any way to cancel this behaviour? Or what would be the analogue command in ParEdit for selecting an sexp?
EDIT:
To give you a better idea of what happens, if I do C-h k while ParEdit is active, and then C-M-S-f this is what I get:
C-M-f (translated from C-M-S-f) runs the command paredit-forward,
which is an interactive compiled Lisp function in `paredit.el'.
It is bound to C-M-f.
(paredit-forward)
Move forward an S-expression, or up an S-expression forward.
If there are no more S-expressions in this one before the closing
delimiter, move past that closing delimiter; otherwise, move forward
past the S-expression following the point.
C-M-f
(foo |(bar baz) quux)
->
(foo (bar baz)| quux)
(foo (bar)|)
->
(foo (bar))|
[back]
I don't want it to translate anything, this is absolutely undesired behaviour.
Upvotes: 2
Views: 926
Reputation: 5875
Resurrecting a very old question, but I think I know a more general solution to this.
paredit
is a very old package that predates modern packaging hygiene. i.e. aggressive setting of default keybindings.
To undo that, run this after loading the paredit package:
(paredit-do-commands (spec keys _fn _examples) nil
(dolist (key keys)
(define-key paredit-mode-map (read-kbd-macro key) nil)))
now you're back to no keybindings, and you can use the regular mechanisms. Read the value (not the documentation) on paredit-commands
to see which commands are available and what their default bindings are, some of which you might want to retain.
Upvotes: 0
Reputation: 61
Paredit isn't translating the keys. Emacs is. It's the same in every mode. If there's no binding for C-M-F, Emacs will try C-M-f instead.
If you want to select the S-expression after the point, the standard Emacs key for this is C-M-SPC.
Upvotes: 2
Reputation: 8192
You can use:
(eval-after-load "paredit"
'(progn
(define-key paredit-mode-map (kbd "C-M-f") nil)))
Strictly speaking the progn is unnecessary, but you might want to redefine/remove more keys afterwards
EDIT
Unlike forward-sexp, paredit-forward doesn't check whether shift is pressed. You could try using this
(eval-after-load "paredit"
'(progn
(define-key paredit-mode-map (kbd "C-M-S-f")
(lambda ()
(interactive)
(unless (region-active-p)
(set-mark (point)))
(paredit-forward)))))
EDIT
An alternative way to do the same thing (select the following sexp), would be C-M-space. Then, should you want to do so, you can swap point and mark with C-x C-x (or C-x (no delay here) C-x C-x if you use CUA)
EDIT (last?)
The proper way to make a function also mark when shift is pressed is this:
(put 'paredit-forward 'CUA 'move)
Upvotes: 2