[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature/icomplete-vertical
From: |
Manuel Uberti |
Subject: |
Re: feature/icomplete-vertical |
Date: |
Mon, 5 Oct 2020 10:22:10 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 05/10/20 09:52, Gregory Heytings via Emacs development discussions. wrote:
>
> Hi Ergus and João,
>
> As I explained in a separate thread, at the moment the best way to implement
> icomplete-vertical (and in general to display completion candidates in the
> minibuffer) is to convince Emacs to start displaying the minibuffer at its
> beginning. This avoids all known problems.
>
> With this solution, displaying completion candidates after point in a
> minibuffer
> is a trivial task: it suffices to insert the completion candidates in the
> minibuffer, and Emacs will display as many of these candidates as possible,
> given the user preferences (max-mini-window-height, resize-mini-windows, ...),
> the size of the Emacs frame, the phase of the moon, ... This works on Emacs
> 24,
> 25, 26, 27 and 28, with fixed and variable width fonts.
>
> Part 1 of the solution (which solves the "root" problem, and is not specific
> to
> icomplete-vertical):
>
> (defvar-local start-display-at-beginning-of-minibuffer nil)
> (defun start-display-at-beginning-of-minibuffer (&rest args)
> (when (and start-display-at-beginning-of-minibuffer (minibufferp))
> (set-window-start-at-begin (point-min) (point))))
> (defun set-window-start-at-begin (beg end)
> (when (< (+ beg 2) end)
> (set-window-start nil beg)
> (unless (pos-visible-in-window-p end nil t)
> (set-window-start-at-begin (+ beg (/ (- end beg) 2)) end))))
> (add-hook 'window-scroll-functions #'start-display-at-beginning-of-minibuffer)
> (add-hook 'post-command-hook #'start-display-at-beginning-of-minibuffer)
>
> Part 2 of the solution (which implements icomplete-vertical):
>
> (setq icomplete-separator "\n")
> (add-hook 'icomplete-minibuffer-setup-hook (lambda () (setq
> start-display-at-beginning-of-minibuffer t)))
> (defun icomplete-vertical-reformat-completions (completions)
> (save-match-data
> (if (string-match "^\\((.*)\\|\\[.+\\]\\)?{\\(\\(?:.\\|\n\\)+\\)}"
> completions)
> (format "%s \n%s" (or (match-string 1 completions) "") (match-string 2
> completions))
> completions)))
> (advice-add 'icomplete-completions :filter-return
> #'icomplete-vertical-reformat-completions)
>
> The only limit of this solution is that is is not possible to display an
> ellipsis ("...") at the end of the completion candidates list, to indicate
> that
> some completion candidates are not displayed. This is a minor limitation, and
> IMO using one screen line just to display "..." is a waste of resources.
>
> Gregory
Hi Gregory,
FWIW, your code works absolutely fine for me and I was able to replace the
external icomplete-vertical package with your solution.
Thanks for working on this.
--
Manuel Uberti
www.manueluberti.eu
- Re: feature/icomplete-vertical, (continued)
- Re: feature/icomplete-vertical, Eli Zaretskii, 2020/10/05
- Re: feature/icomplete-vertical, João Távora, 2020/10/05
- Re: feature/icomplete-vertical, Eli Zaretskii, 2020/10/05
- Re: feature/icomplete-vertical, João Távora, 2020/10/05
- Re: feature/icomplete-vertical, Eli Zaretskii, 2020/10/06
- Re: feature/icomplete-vertical, Gregory Heytings, 2020/10/05
- Re: feature/icomplete-vertical, João Távora, 2020/10/05
- Re: feature/icomplete-vertical, Eli Zaretskii, 2020/10/06
- Re: feature/icomplete-vertical, Stefan Monnier, 2020/10/05
Re: feature/icomplete-vertical, Gregory Heytings, 2020/10/05
Re: feature/icomplete-vertical, Manuel Uberti, 2020/10/02