emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select completions from the minibuffer


From: Ergus
Subject: Re: Select completions from the minibuffer
Date: Fri, 18 Mar 2022 00:10:27 +0100

Hi Juri:

Yes I just confirmed, actually the pre-redisplay-function is not called
for simple commands like self-insert or moving the point and in your
case neither.

Looking at the last line in `deactivate-mark` it seems like it is a
known issue and changing such optimization in the display engine may be
probably undesirable (Eli will confirm soon hopefully), so in your case
maybe is better to force the update on demand like in deactivate-mark:

```
(defmacro with-minibuffer-completions-window (&rest body)
  "Execute the forms in BODY from the minibuffer in its completions window.
When used in a minibuffer window, select the window with completions,
and execute the forms."
  (declare (indent 0) (debug t))
  `(let ((window (or (get-buffer-window "*Completions*" 0)
                     ;; Make sure we have a completions window.
                     (progn (minibuffer-completion-help)
                            (get-buffer-window "*Completions*" 0)))))
     (when window
       (with-selected-window window
         ,@body
         (redisplay--update-cursor-face-highlight window)))))
```

This seems to work.

Is it enough?


On Thu, Mar 17, 2022 at 10:56:01PM +0200, Juri Linkov wrote:
But cursor-face is not highlighted in *Completions* when the current buffer
is the minibuffer.  Such highlighting is necessary when completions
are navigated from the minibuffer.

Please check the change and try to set
cursor-face-highlight-nonselected-window unconditionally in
*Completions* to t when using your mode.

Now it keeps highlighting in *Completions* after switching to the minibuffer,
but still doesn't move the highlighting in *Completions* when
completions are navigated from the minibuffer with

 (defmacro with-minibuffer-completions-window (&rest body)
   "Execute the forms in BODY from the minibuffer in its completions window.
 When used in a minibuffer window, select the window with completions,
 and execute the forms."
   (declare (indent 0) (debug t))
   `(let ((window (or (get-buffer-window "*Completions*" 0)
                      ;; Make sure we have a completions window.
                      (progn (minibuffer-completion-help)
                             (get-buffer-window "*Completions*" 0)))))
      (when window
        (with-selected-window window
          ,@body))))

 (defun minibuffer-next-completion (&optional n)
   "Run `next-completion' from the minibuffer in its completions window."
   (interactive "p")
   (with-minibuffer-completions-window
     (next-completion n)))

If you could improve the initialization in order to use
cursor-in-non-selected-windows unless the user sets another value
manually it may be nicer (because in the general scenario the user could
set cursor-in-non-selected-windows latter so this variable may have an
outdated value) otherwise consider if this may be simply t or nil by
default. But at the moment it works fine for the current use cases.

I think it's unrelated to cursor-in-non-selected-windows
because the cursor in non-selected windows is displayed as
a hollow box, but cursor-face stays the same.
So you can set cursor-face-highlight-nonselected-window
to nil by default.  Then commands could let-bind it like

 (defun minibuffer-next-completion (&optional n)
   "Run `next-completion' from the minibuffer in its completions window."
   (interactive "p")
   (let ((cursor-face-highlight-nonselected-window t))
     (with-minibuffer-completions-window
       (next-completion n))))

(but this currently doesn't work for the same reason as above)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]