Add gist for paredit in the minibuffer

This commit is contained in:
Bram Schoenmakers 2023-01-05 14:07:10 +01:00
parent 84d40cdb8a
commit e4c92482b8
2 changed files with 57 additions and 0 deletions

View File

@ -329,6 +329,39 @@ Found [[https://www.reddit.com/r/emacs/comments/e2u5n9/comment/f918t22/][a Reddi
(eshell-mode . outline-minor-mode))
#+end_src
* Paredit inside minibuffer commands
Used [[https://github.com/purcell/emacs.d/blob/master/lisp/init-paredit.el][Purcell's configation]] as a starting point.
#+name: minibuffer-paredit
#+begin_src elisp :tangle gists/minibuffer-paredit.el
(use-package paredit
:hook
(minibuffer-setup . my/conditionally-enable-paredit-mode)
(minibuffer-exit . my/restore-paredit-key)
:config
(defvar my/paredit-minibuffer-commands '(eval-expression
pp-eval-expression
eval-expression-with-eldoc
ibuffer-do-eval
ibuffer-do-view-and-eval
org-ql-sparse-tree
org-ql-search)
"Interactive commands for which paredit should be enabled in the minibuffer.")
(defun my/conditionally-enable-paredit-mode ()
"Enable paredit during lisp-related minibuffer commands."
(when (memq this-command my/paredit-minibuffer-commands)
(enable-paredit-mode)
(unbind-key (kbd "RET") paredit-mode-map)))
(defun my/restore-paredit-key ()
"Restore the RET binding that was disabled by
my/conditionally-enable-paredit-mode."
(bind-key (kbd "RET") #'paredit-newline paredit-mode-map)))
#+end_src
* Meta
** License

View File

@ -0,0 +1,24 @@
(use-package paredit
:hook
(minibuffer-setup . my/conditionally-enable-paredit-mode)
(minibuffer-exit . my/restore-paredit-key)
:config
(defvar my/paredit-minibuffer-commands '(eval-expression
pp-eval-expression
eval-expression-with-eldoc
ibuffer-do-eval
ibuffer-do-view-and-eval
org-ql-sparse-tree
org-ql-search)
"Interactive commands for which paredit should be enabled in the minibuffer.")
(defun my/conditionally-enable-paredit-mode ()
"Enable paredit during lisp-related minibuffer commands."
(when (memq this-command my/paredit-minibuffer-commands)
(enable-paredit-mode)
(unbind-key (kbd "RET") paredit-mode-map)))
(defun my/restore-paredit-key ()
"Restore the RET binding that was disabled by
my/conditionally-enable-paredit-mode."
(bind-key (kbd "RET") #'paredit-newline paredit-mode-map)))