I love Emacs' paredit-mode, but I miss it very sorely when doing eval-expression
(M-:
). How can I have paredit in the minibuffer when doing eval-expression
? Thanks!
Asked
Active
Viewed 667 times
2 Answers
13
Add a function to minibuffer-setup-hook
, like so:
(add-hook 'minibuffer-setup-hook 'conditionally-enable-paredit-mode)
(defun conditionally-enable-paredit-mode ()
"enable paredit-mode during eval-expression"
(if (eq this-command 'eval-expression)
(paredit-mode 1)))

Trey Jackson
- 73,529
- 11
- 197
- 229
-
Not bad, but as you allude to that applies paredit to everything (ex. `shell-command`/`M-!`) and not just Emacs Lisp entry in the minibuffer. I'd prefer that not be the case. I wonder if I'll end up having to replace `eval-expression` with something that calls a more special read function. – draebek Apr 19 '10 at 05:58
-
1It enables it only for eval-expression, but maybe you wrote your comment before Trey edited his answer... – Bozhidar Batsov Apr 19 '10 at 08:35
-
Yup, I did write it before it was a hook looking at `this-command`. I didn't think of doing that. Thanks! – draebek Apr 19 '10 at 13:52
-
This causes return key to become rebound to `paredit-newline` which is very frustrating. I tried `(local-set-key [return] 'minibuffer-complete-and-exit)` in vain after `(paredit-mode 1)`. What to do? – Nordlöw Jan 26 '13 at 13:08
-
1@Nordlöw Ahhh... the latest version (I had the beta) does set up a binding for `C-j` - which you might have bound to `return`. In vanilla Emacs 24.2 the `C-j` and `
` are different bindings, so `C-j` is bound to `paredit-newline` and ` – Trey Jackson Jan 26 '13 at 18:59` is bound to `'exit-minibuffer`. I'd check your `.emacs` for bindings to those keys, and/or try running Emacs w/out your settings and just load `paredit.el` to see how it behaves.
2
Add function paredit-mode
to eval-expression-minibuffer-setup-hook
, like so
(add-hook 'eval-expression-minibuffer-setup-hook #'paredit-mode)

Marco Wahl
- 694
- 7
- 14