Delay in displaying the posframe
gcv opened this issue · 12 comments
There's a slight but noticeable delay before the posframe appears. In my past experiments with posframe, this results from the child frame being allocated each tie rather than just redisplayed. Is this happening with vertico-posframe? If so, is there a way to keep the frame around and just hide it?
If vertico-posframe-mode is enable, posframe just hide, when vertico-posframe-mode is disabled, posframe will be deleted.
I see. It would be great to keep the posframe around when vertico-posframe is selectively enabled for certain commands using the new vertico-multiform configuration system. Is this possible?
Should be fixed
Thanks for looking into it so quickly! The new code does not work for me, though.
Configuration:
(setq vertico-multiform-command-modes
'((execute-extended-command indexed posframe)))
Then, when I use M-x, I can run one command. When I try to run another command, the posframe flashes into existence but then disappears. If I type a key, it reappears.
Eventually, I get into a state which also get me this error:
posframe-show: Wrong type argument: frame-live-p, #<dead frame 0x7ffa6061c060>
After this happens, I have to call posframe-delete-all
to be able to use M-x again.
maybe vertico-posframe can not work well with vertico-multiform, but i can not find the reason at the moment
please try the below code
(define-minor-mode vertico-posframe-mode
"Display Vertico in posframe instead of the minibuffer."
:global t
(cond
(vertico-posframe-mode
(advice-add #'minibuffer-message :before #'vertico-posframe--minibuffer-message)
(advice-add #'vertico--display-candidates :override #'vertico-posframe--display)
(advice-add #'vertico--setup :after #'vertico-posframe--setup)
;; Create posframe in advance to limit flicker.
;; (vertico-posframe--show-init)
;; (vertico-posframe--create-minibuffer-cover "")
)
(t
(advice-remove #'minibuffer-message #'vertico-posframe--minibuffer-message)
(advice-remove #'vertico--display-candidates #'vertico-posframe--display)
(advice-remove #'vertico--setup #'vertico-posframe--setup))))
That works! Posframe displays noticeably faster. I don't see any problems at the moment.
One odd thing, though: (frame-list)
seems to contain two 'posframe-buffer
entries when I thought there should be just one.
yes, one posframe is used to hide minibuffer
please try master code
That works! Thanks.
Would you consider adding a vertico-posframe-cleanup
public interface function that deletes the two posframes and kills their associated buffers? Sometimes it's important to remove child frames and I'd prefer a public interface to do that.
(defun vertico-posframe-cleanup ()
"Remove frames and buffers used for vertico-posframe internal state."
(interactive)
(posframe-delete vertico-posframe--buffer)
(posframe-delete vertico-posframe--minibuffer-cover))
Thanks! Looks great.