tumashu / vertico-posframe

GNU General Public License v3.0
106 stars 16 forks source link

Delay in displaying the posframe #6

Closed gcv closed 2 years ago

gcv commented 2 years ago

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?

tumashu commented 2 years ago

If vertico-posframe-mode is enable, posframe just hide, when vertico-posframe-mode is disabled, posframe will be deleted.

gcv commented 2 years ago

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?

tumashu commented 2 years ago

Should be fixed

gcv commented 2 years ago

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.

tumashu commented 2 years ago

maybe vertico-posframe can not work well with vertico-multiform, but i can not find the reason at the moment

tumashu commented 2 years ago

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))))
gcv commented 2 years ago

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.

tumashu commented 2 years ago

yes, one posframe is used to hide minibuffer

tumashu commented 2 years ago

please try master code

gcv commented 2 years ago

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))
tumashu commented 2 years ago

gcv @.***> writes:

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)) Added.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.

--

gcv commented 2 years ago

Thanks! Looks great.