Help request: disabling puni-mode in minibuffer except after `eval-expression`
apc opened this issue · 2 comments
First, thanks for this awesome package.
Now, my request: as a user of Vertico and its extensions, especially Verico-directory, I want Puni to leave DEL alone while in the minibuffer. At the moment, I'm making this work by adding puni-disable-puni-mode
to minibuffer-setup-hook
, with something like the following use-package declaration:
(use-package puni
:defer 3
:init
;; The autoloads of Puni are set up so you can enable `puni-mode` or
;; `puni-global-mode` before `puni` is actually loaded. Only after you press
;; any key that calls Puni commands, it's loaded.
(puni-global-mode)
:bind (:map puni-mode-map
("C-k" . my/puni-kill-line))
:hook
(minibuffer-setup . puni-disable-puni-mode))
This has the unfortunate side effect of also disabling Puni mode after calling eval-expression
. I tried simply adding puni-mode
to eval-expression-minibuffer-setup-hook
but, perhaps unsurprisingly, that does not work. Do you or anyone reading here know of a way to disable puni-mode in the minibuffer except when running eval-expression
?
Just an update: I found this answer to a different question and adapted it to solve my problem.
(defun my/disable-puni-in-minibuffer ()
"Disable `puni-mode' in minibuffer unless when eval-expression"
(unless (eq this-command 'eval-expression)
(puni-disable-puni-mode)))
Adding this function to minibuffer-setup-hook
seems to do the trick. I'd still be interested to know if you have any thoughts on this issue, since it seems like it might affect others using the package. But feel free to close, of course.
perhaps unsurprisingly, that does not work.
I think the reason is eval-expression-minibuffer-setup-hook
is prepended to minibuffer-setup-hook
. See the implementation of read--expression
and the docstring of minibuffer-with-setup-hook
.
I don't think I have a cleaner solution. One way is to merge puni-mode-map
into read-expression-map
(I think make-composed-keymap
could do the job), so you can still use Puni's keybindings without enabling puni-mode
.