* icomplete-vertical above prompt
@ 2021-04-11 14:58 Gregory Heytings
2021-04-11 15:11 ` Gregory Heytings
2021-04-11 21:59 ` Juri Linkov
0 siblings, 2 replies; 9+ messages in thread
From: Gregory Heytings @ 2021-04-11 14:58 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]
>
> I wonder how easy would be to improve Icomplete to display completions
> in the standard buffer *Completions* instead of the minibuffer? Then
> both use cases will be covered:
>
> 1. icomplete-vertical-mode for users who prefer vertical completions in
> the minibuffer;
>
> 2. vertical completions in *Completions* for users who don't like when
> the mode-line jumps up and down when completing.
>
Note that this doesn't happen with the default resize-mini-windows value,
which is grow-only. It jumps up once, and will not jump down until the
end of the completion.
>
> In this case the same icomplete keys could be used to navigate
> completions in the *Completions* buffer from the minibuffer with
> icomplete-forward-completions and icomplete-backward-completions, and
> icomplete-force-complete-and-exit to accept the selected completion.
>
By popular demand (Stefan M asked for something similar some time ago
IIRC), here is a patch that does what you want, but not exactly how you
described it. It displays completion candidates above the prompt instead
of below the prompt, and you can navigate them from the minibuffer.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=Add-option-to-display-candidates-above-prompt-with-i.patch, Size: 6217 bytes --]
From c5bb62903c4985171f9ef3f654de8946fafa97e8 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Sun, 11 Apr 2021 14:22:17 +0000
Subject: [PATCH] Add option to display candidates above prompt with
icomplete-vertical-mode
* lisp/icomplete.el (icomplete-vertical-mode-above-prompt,
icomplete-vertical-mode-above-prompt-height): New user variables.
(icomplete-exhibit): Consider the new user variables.
* doc/emacs/buffers.texi (Icomplete): Mention the new variables.
* etc/NEWS: Mention the new variables.
---
doc/emacs/buffers.texi | 11 +++++++---
etc/NEWS | 4 ++++
lisp/icomplete.el | 46 ++++++++++++++++++++++++++++++++++++------
3 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi
index bec7f37547..b3e4316dd6 100644
--- a/doc/emacs/buffers.texi
+++ b/doc/emacs/buffers.texi
@@ -766,13 +766,18 @@ the variable @code{fido-mode} to @code{t} (@pxref{Easy
Customization}).
@findex icomplete-vertical-mode
+@vindex icomplete-vertical-mode-above-prompt
+@vindex icomplete-vertical-mode-above-prompt-height
@cindex Icomplete vertical mode
Icomplete mode and Fido mode display the possible completions on the
same line as the prompt by default. To display the completion candidates
-vertically under the prompt, type @kbd{M-x icomplete-vertical-mode}, or
-customize the variable @code{icomplete-vertical-mode} to @code{t}
-(@pxref{Easy Customization}).
+vertically, type @kbd{M-x icomplete-vertical-mode}, or customize the
+variable @code{icomplete-vertical-mode} to @code{t} (@pxref{Easy
+Customization}). By default, this displays completion candidates under
+the prompt. To display them above the prompt, customize the variables
+@code{icomplete-vertical-mode-above-prompt} to @code{t}, and the
+variable @code{icomplete-vertical-mode-above-prompt-height} to .
@node Buffer Menus
@subsection Customizing Buffer Menus
diff --git a/etc/NEWS b/etc/NEWS
index aaf38022c5..3d22f95d7d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -500,6 +500,10 @@ indentation is done using SMIE or with the old ad-hoc code.
*** New minor mode Icomplete-Vertical mode.
This mode is intended to be used with Icomplete or Fido, to display the
list of completions candidates vertically instead of horizontally.
+Additionally, the user options 'icomplete-vertical-mode-above-prompt'
+and 'icomplete-vertical-mode-above-prompt-height' control whether and
+how the completion candidates are displayed above the prompt instead of,
+by default, under the prompt.
---
** Specific warnings can now be disabled from the warning buffer.
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index d5b6f76d7b..794c6d776d 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -569,6 +569,22 @@ Usually run by inclusion in `minibuffer-setup-hook'."
map)
"Keymap used by `icomplete-vertical-mode' in the minibuffer.")
+(defcustom icomplete-vertical-mode-above-prompt nil
+ "Whether to display candidates above prompt with `icomplete-vertical-mode'.
+When nil, display the candidates under the prompt.
+When non-nil, display the candidates above the prompt."
+ :type '(choice (const :tag "Off" nil)
+ (const :tag "On" t))
+ :version "28.1")
+
+(defcustom icomplete-vertical-mode-above-prompt-height 10
+ "How many candidates to display above prompt with `icomplete-vertical-mode'.
+In small frames, less candidates may be displayed."
+ :type 'integer
+ :version "28.1")
+
+(defvar icomplete--above-minibuffer-window nil)
+
(defun icomplete--vertical-minibuffer-setup ()
"Setup the minibuffer for vertical display of completion candidates."
(use-local-map (make-composed-keymap icomplete-vertical-mode-minibuffer-map
@@ -659,12 +675,30 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
deactivate-mark)
;; Do nothing if while-no-input was aborted.
(when (stringp text)
- (move-overlay icomplete-overlay (point) (point) (current-buffer))
- ;; The current C cursor code doesn't know to use the overlay's
- ;; marker's stickiness to figure out whether to place the cursor
- ;; before or after the string, so let's spoon-feed it the pos.
- (put-text-property 0 1 'cursor t text)
- (overlay-put icomplete-overlay 'after-string text))))))))
+ (when (and icomplete-vertical-mode icomplete-vertical-mode-above-prompt)
+ (let ((buffer (get-buffer-create " *Icomplete Completions*"))
+ (limit (string-search "\n" text)))
+ (when limit
+ (let ((candidates (substring text (1+ limit))))
+ (setq text (substring text 0 limit))
+ (unless (window-live-p icomplete--above-minibuffer-window)
+ (setq icomplete--above-minibuffer-window
+ (display-buffer
+ buffer
+ `(display-buffer-in-side-window
+ (side . bottom)
+ (window-height
+ . ,icomplete-vertical-mode-above-prompt-height)))))
+ (with-current-buffer buffer
+ (setq-local mode-line-format nil cursor-type nil)
+ (erase-buffer)
+ (insert candidates))))))
+ (move-overlay icomplete-overlay (point) (point) (current-buffer))
+ ;; The current C cursor code doesn't know to use the overlay's
+ ;; marker's stickiness to figure out whether to place the cursor
+ ;; before or after the string, so let's spoon-feed it the pos.
+ (put-text-property 0 1 'cursor t text)
+ (overlay-put icomplete-overlay 'after-string text))))))))
;;;_ > icomplete-completions (name candidates predicate require-match)
(defun icomplete-completions (name candidates predicate require-match)
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 14:58 icomplete-vertical above prompt Gregory Heytings
@ 2021-04-11 15:11 ` Gregory Heytings
2021-04-11 21:59 ` Juri Linkov
1 sibling, 0 replies; 9+ messages in thread
From: Gregory Heytings @ 2021-04-11 15:11 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
>
> By popular demand (Stefan M asked for something similar some time ago
> IIRC), here is a patch that does what you want, but not exactly how you
> described it. It displays completion candidates above the prompt
> instead of below the prompt, and you can navigate them from the
> minibuffer.
>
[This patch should not be installed until my paperwork is completed.]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 14:58 icomplete-vertical above prompt Gregory Heytings
2021-04-11 15:11 ` Gregory Heytings
@ 2021-04-11 21:59 ` Juri Linkov
2021-04-11 23:02 ` Gregory Heytings
1 sibling, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-04-11 21:59 UTC (permalink / raw)
To: Gregory Heytings; +Cc: emacs-devel
>> I wonder how easy would be to improve Icomplete to display completions in
>> the standard buffer *Completions* instead of the minibuffer? Then both
>> use cases will be covered:
>>
>> 1. icomplete-vertical-mode for users who prefer vertical completions in
>> the minibuffer;
>>
>> 2. vertical completions in *Completions* for users who don't like when
>> the mode-line jumps up and down when completing.
>
> Note that this doesn't happen with the default resize-mini-windows value,
> which is grow-only. It jumps up once, and will not jump down until the end
> of the completion.
Regardless of the value of icomplete-vertical-mode-above-prompt,
in both cases it jumps once, and that's the problem for users
who don't like such jumps, even once.
Also if the number of completions is less than the default 10,
then a lot of empty lines separate completions from the minibuffer.
>> In this case the same icomplete keys could be used to navigate
>> completions in the *Completions* buffer from the minibuffer with
>> icomplete-forward-completions and icomplete-backward-completions, and
>> icomplete-force-complete-and-exit to accept the selected completion.
>
> By popular demand (Stefan M asked for something similar some time ago
> IIRC), here is a patch that does what you want, but not exactly how you
> described it. It displays completion candidates above the prompt instead
> of below the prompt, and you can navigate them from the minibuffer.
I don't remember a request for such feature, but I remember complaints
about the jumping mode-line. icomplete-vertical-mode-above-prompt
doesn't solve this problem.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 21:59 ` Juri Linkov
@ 2021-04-11 23:02 ` Gregory Heytings
2021-04-11 23:19 ` Juri Linkov
2021-04-12 9:37 ` Jean Louis
0 siblings, 2 replies; 9+ messages in thread
From: Gregory Heytings @ 2021-04-11 23:02 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
>
> Regardless of the value of icomplete-vertical-mode-above-prompt, in both
> cases it jumps once, and that's the problem for users who don't like
> such jumps, even once.
>
I'm not sure I understand what you mean. How could you display completion
candidates without moving the modeline? I suppose what you have in mind
is posframes? But posframes are a completely different beast, and don't
work in terminals AFAIK.
For that matter, I also don't understand why users "don't like such jumps
even once". The point is to make some room to display some information,
the same happens in many cases, like when *Completions* is opened, or with
popular packages such as Magit or which-key.
>
> Also if the number of completions is less than the default 10, then a
> lot of empty lines separate completions from the minibuffer.
>
That could be tweaked, perhaps. But I'm not sure it's worth the price.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 23:02 ` Gregory Heytings
@ 2021-04-11 23:19 ` Juri Linkov
2021-04-11 23:25 ` Gregory Heytings
2021-04-12 9:37 ` Jean Louis
1 sibling, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-04-11 23:19 UTC (permalink / raw)
To: Gregory Heytings; +Cc: emacs-devel
>> Regardless of the value of icomplete-vertical-mode-above-prompt, in both
>> cases it jumps once, and that's the problem for users who don't like such
>> jumps, even once.
>
> I'm not sure I understand what you mean. How could you display completion
> candidates without moving the modeline?
When typing 'TAB TAB' or 'M-v' to open the *Completions* buffer,
it doesn't cause the feeling that the mode-line jumps because
it looks like the mode-line stays at the same screen position,
only its contents changes from the mode-line of the original buffer
to the mode-line of the *Completions* buffer.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 23:19 ` Juri Linkov
@ 2021-04-11 23:25 ` Gregory Heytings
2021-04-11 23:34 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: Gregory Heytings @ 2021-04-11 23:25 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
>>> Regardless of the value of icomplete-vertical-mode-above-prompt, in
>>> both cases it jumps once, and that's the problem for users who don't
>>> like such jumps, even once.
>>
>> I'm not sure I understand what you mean. How could you display
>> completion candidates without moving the modeline?
>
> When typing 'TAB TAB' or 'M-v' to open the *Completions* buffer, it
> doesn't cause the feeling that the mode-line jumps because it looks like
> the mode-line stays at the same screen position, only its contents
> changes from the mode-line of the original buffer to the mode-line of
> the *Completions* buffer.
>
Okay, that's easy to do with my patch: remove the setq-local
mode-line-format nil, and you'll see a modeline between the minibuffer and
the completion list. I'll add another defcustom for this.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 23:25 ` Gregory Heytings
@ 2021-04-11 23:34 ` Juri Linkov
2021-04-11 23:41 ` Ergus
0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-04-11 23:34 UTC (permalink / raw)
To: Gregory Heytings; +Cc: emacs-devel
>> When typing 'TAB TAB' or 'M-v' to open the *Completions* buffer, it
>> doesn't cause the feeling that the mode-line jumps because it looks like
>> the mode-line stays at the same screen position, only its contents
>> changes from the mode-line of the original buffer to the mode-line of the
>> *Completions* buffer.
>
> Okay, that's easy to do with my patch: remove the setq-local
> mode-line-format nil, and you'll see a modeline between the minibuffer and
> the completion list. I'll add another defcustom for this.
Maybe also it would be possible to add an option to display icomplete
completions in the standard *Completions* buffer with its keybindings?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 23:34 ` Juri Linkov
@ 2021-04-11 23:41 ` Ergus
0 siblings, 0 replies; 9+ messages in thread
From: Ergus @ 2021-04-11 23:41 UTC (permalink / raw)
To: Juri Linkov; +Cc: Gregory Heytings, emacs-devel
On Mon, Apr 12, 2021 at 02:34:10AM +0300, Juri Linkov wrote:
>>> When typing 'TAB TAB' or 'M-v' to open the *Completions* buffer, it
>>> doesn't cause the feeling that the mode-line jumps because it looks like
>>> the mode-line stays at the same screen position, only its contents
>>> changes from the mode-line of the original buffer to the mode-line of the
>>> *Completions* buffer.
>>
>> Okay, that's easy to do with my patch: remove the setq-local
>> mode-line-format nil, and you'll see a modeline between the minibuffer and
>> the completion list. I'll add another defcustom for this.
>
>Maybe also it would be possible to add an option to display icomplete
>completions in the standard *Completions* buffer with its keybindings?
>
This sounds very similar to helm ;)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: icomplete-vertical above prompt
2021-04-11 23:02 ` Gregory Heytings
2021-04-11 23:19 ` Juri Linkov
@ 2021-04-12 9:37 ` Jean Louis
1 sibling, 0 replies; 9+ messages in thread
From: Jean Louis @ 2021-04-12 9:37 UTC (permalink / raw)
To: Gregory Heytings; +Cc: emacs-devel, Juri Linkov
* Gregory Heytings <gregory@heytings.org> [2021-04-12 02:03]:
>
> >
> > Regardless of the value of icomplete-vertical-mode-above-prompt, in both
> > cases it jumps once, and that's the problem for users who don't like
> > such jumps, even once.
> >
>
> I'm not sure I understand what you mean. How could you display completion
> candidates without moving the modeline? I suppose what you have in mind is
> posframes? But posframes are a completely different beast, and don't work
> in terminals AFAIK.
>
> For that matter, I also don't understand why users "don't like such jumps
> even once". The point is to make some room to display some information, the
> same happens in many cases, like when *Completions* is opened, or with
> popular packages such as Magit or which-key.
For me mode line is always static as by impression, standard
completion does not jerk it up and only completion packages do
that. First completion I was using was helm and it did not fiddle with
the mode line. Great. Until I found ivy and others who do that. IMHO
best representation is when a small window appears with candidates
above the mode line, or even full screen in some cases.
Jerking mode line up down is not in harmony with the description of
mode line in the manual.
File: emacs.info, Node: Mode Line, Next: Menu Bar, Prev: Echo Area, Up: Screen
1.3 The Mode Line
=================
At the bottom of each window is a “mode line”, which describes what is
going on in the current buffer. When there is only one window, the mode
line appears right above the echo area; it is the next-to-last line in
the frame.
Non-jerked mode line offers better accessibility.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
Sign an open letter in support of Richard M. Stallman
https://rms-support-letter.github.io/
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-04-12 9:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-11 14:58 icomplete-vertical above prompt Gregory Heytings
2021-04-11 15:11 ` Gregory Heytings
2021-04-11 21:59 ` Juri Linkov
2021-04-11 23:02 ` Gregory Heytings
2021-04-11 23:19 ` Juri Linkov
2021-04-11 23:25 ` Gregory Heytings
2021-04-11 23:34 ` Juri Linkov
2021-04-11 23:41 ` Ergus
2021-04-12 9:37 ` Jean Louis
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).