From: Gregory Heytings via "Emacs development discussions." <emacs-devel@gnu.org>
To: Ergus <spacibba@aol.com>
Cc: Eli Zaretskii <eliz@gnu.org>, casouri@gmail.com, emacs-devel@gnu.org
Subject: Re: feature/icomplete-vertical
Date: Sat, 19 Sep 2020 04:03:36 +0000 [thread overview]
Message-ID: <alpine.NEB.2.22.394.2009190430590453.10337@sdf.lonestar.org> (raw)
In-Reply-To: <20200919015957.prffuac2jke3hp6a@Ergus>
[-- Attachment #1: Type: text/plain, Size: 2631 bytes --]
Hi Ergus,
Thanks for your comments.
>
> 1) Icomplete shouldn't call shrink-window because the minibuffer resize
> must respect the max-mini-window-height and resize-mini-windows policy.
>
Okay, these lines in my patch can just be dropped indeed. This makes the
whole thing even simpler.
>
> 2) When using different fonts (as a user jixiuf did) the prompt
> disappears because there is a mismatch between the visible lines and the
> ones the minibuffer shows. So we need to fix that in a general way and
> calculate sizes in pixels to avoid this problem.
>
I see. I did not think about that potential problem before sending the
patch. I attach an updated patch (still very short) in which this problem
is (I think) fixed.
>
> 3) In vertical the [] and () are annoying; more than in horizontal so we
> should give some control for them. Now there is a mechanism a bit
> complex, but just because it is under development. I am actually trying
> to simplify that.
>
That could be an additional feature indeed. I do not understand why they
are annoying, it's common in completion mechanisms to have such
indications, but why not. But I think it is better to separate concerns.
>
> 4) Even in vertical the icomplete-separator must be respected somehow
> because some users reported to use it (with the external package) to
> separate the candidates from the left of the window, add prompts and so
> on. (for example adding a > before the first candidate (changing the {)
> and a space before the others (changing the separator)) So our changes
> need to support all that in a simpler way. Also some users requested to
> have two \n as a separator (don't ask me why).
>
That could also be an additional feature, again I don't really see why it
would be useful, but why not. OTOH, it is not possible to do this with
the current version of icomplete in horizontal mode, and again I think it
is better to separate concerns.
>
> 5) I opted for a more modular approach because filling the code with
> several 'if' it harder to read and very error prone to maintain latter.
> So I just separated the setups when vertical and horizontal so if we
> want to add more policies and features we have to deal with less race
> conditions.
>
The patch I propose has only five "if icomplete-vertical", that's not much
I think. And in fact it's easy to remove three of them, and to have only
two "if icomplete-vertical" (see the other attached patch). If horizontal
icomplete remains the default behavior (as I think it will), these if's
make it clear where the code differs between the two cases.
Gregory
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=icomplete.patch; charset=us-ascii, Size: 4592 bytes --]
--- icomplete.el.orig 2020-09-01 10:14:22.000000000 +0000
+++ icomplete.el 2020-09-19 03:20:09.000000000 +0000
@@ -62,6 +62,8 @@
:type 'string
:version "24.4")
+(defcustom icomplete-vertical nil "...")
+
(defcustom icomplete-hide-common-prefix t
"When non-nil, hide common prefix from completion candidates.
When nil, show candidates in full."
@@ -107,6 +109,8 @@
:type 'integer
:version "26.1")
+(defvar icomplete--prospects-actual-height 0 "...")
+
(defcustom icomplete-compute-delay .3
"Completions-computation stall, used only with large-number completions.
See `icomplete-delay-completions-threshold'."
@@ -431,6 +435,13 @@
"Run in minibuffer on activation to establish incremental completion.
Usually run by inclusion in `minibuffer-setup-hook'."
(when (and icomplete-mode (icomplete-simple-completing-p))
+ (setq icomplete--prospects-actual-height
+ (min icomplete-prospects-height
+ (1- (floor (/ (* (if (floatp max-mini-window-height)
+ (frame-native-height)
+ (frame-char-height))
+ max-mini-window-height)
+ (line-pixel-height))))))
(set (make-local-variable 'completion-show-inline-help) nil)
(use-local-map (make-composed-keymap icomplete-minibuffer-map
(current-local-map)))
@@ -650,18 +661,22 @@
(t (concat ellipsis (substring most compare))))
close-bracket)))
;;"-prospects" - more than one candidate
- (prospects-len (+ (string-width
- (or determ (concat open-bracket close-bracket)))
- (string-width icomplete-separator)
- (+ 2 (string-width ellipsis)) ;; take {…} into account
- (string-width (buffer-string))))
+ (prospects-len (if icomplete-vertical
+ 0
+ (+ (string-width
+ (or determ (concat open-bracket close-bracket)))
+ (string-width icomplete-separator)
+ (+ 2 (string-width ellipsis)) ;; take {…} into account
+ (string-width (buffer-string)))))
(prospects-max
- ;; Max total length to use, including the minibuffer content.
- (* (+ icomplete-prospects-height
- ;; If the minibuffer content already uses up more than
- ;; one line, increase the allowable space accordingly.
- (/ prospects-len (window-width)))
- (window-width)))
+ (if icomplete-vertical
+ (- icomplete--prospects-actual-height (/ (point) (window-width)))
+ ;; Max total length to use, including the minibuffer content.
+ (* (+ icomplete-prospects-height
+ ;; If the minibuffer content already uses up more than
+ ;; one line, increase the allowable space accordingly.
+ (/ prospects-len (window-width)))
+ (window-width))))
;; Find the common prefix among `comps'.
;; We can't use the optimization below because its assumptions
;; aren't always true, e.g. when completion-cycling (bug#10850):
@@ -705,12 +720,18 @@
(setq comp
(if prefix-len (substring (car comps) prefix-len) (car comps))
comps (cdr comps))
- (setq prospects-len
- (+ (string-width comp)
- (string-width icomplete-separator)
- prospects-len))
+ (if icomplete-vertical
+ (if (> (length comp) 0)
+ (setq prospects-len (1+ prospects-len)))
+ (setq prospects-len
+ (+ (string-width comp)
+ (string-width icomplete-separator)
+ prospects-len)))
(if (< prospects-len prospects-max)
- (push comp prospects)
+ (if icomplete-vertical
+ (if (> (length comp) 0)
+ (push comp prospects))
+ (push comp prospects))
(setq limit t))))
(setq prospects (nreverse prospects))
;; Return the first match if the user hits enter.
@@ -726,11 +747,16 @@
;; is cached.
(if last (setcdr last base-size))
(if prospects
- (concat determ
- "{"
- (mapconcat 'identity prospects icomplete-separator)
- (and limit (concat icomplete-separator ellipsis))
- "}")
+ (if icomplete-vertical
+ (concat determ
+ " \n"
+ (mapconcat 'identity prospects "\n")
+ (and limit (concat "\n" ellipsis)))
+ (concat determ
+ "{"
+ (mapconcat 'identity prospects icomplete-separator)
+ (and limit (concat icomplete-separator ellipsis))
+ "}"))
(concat determ " [Matched]"))))))
;;; Iswitchb compatibility
[-- Attachment #3: Type: text/x-diff, Size: 3567 bytes --]
--- a/icomplete.el 2020-09-01 10:14:22.000000000 +0000
+++ b/icomplete.el 2020-09-19 03:54:43.000000000 +0000
@@ -62,6 +62,8 @@
:type 'string
:version "24.4")
+(defcustom icomplete-vertical nil "...")
+
(defcustom icomplete-hide-common-prefix t
"When non-nil, hide common prefix from completion candidates.
When nil, show candidates in full."
@@ -107,6 +109,8 @@
:type 'integer
:version "26.1")
+(defvar icomplete--prospects-actual-height 0 "...")
+
(defcustom icomplete-compute-delay .3
"Completions-computation stall, used only with large-number completions.
See `icomplete-delay-completions-threshold'."
@@ -431,6 +435,13 @@
"Run in minibuffer on activation to establish incremental completion.
Usually run by inclusion in `minibuffer-setup-hook'."
(when (and icomplete-mode (icomplete-simple-completing-p))
+ (setq icomplete--prospects-actual-height
+ (min icomplete-prospects-height
+ (1- (floor (/ (* (if (floatp max-mini-window-height)
+ (frame-native-height)
+ (frame-char-height))
+ max-mini-window-height)
+ (line-pixel-height))))))
(set (make-local-variable 'completion-show-inline-help) nil)
(use-local-map (make-composed-keymap icomplete-minibuffer-map
(current-local-map)))
@@ -701,17 +712,30 @@
;; completion field.
(setq determ (concat open-bracket "" close-bracket)))
;; Compute prospects for display.
- (while (and comps (not limit))
- (setq comp
- (if prefix-len (substring (car comps) prefix-len) (car comps))
- comps (cdr comps))
- (setq prospects-len
- (+ (string-width comp)
- (string-width icomplete-separator)
- prospects-len))
- (if (< prospects-len prospects-max)
- (push comp prospects)
- (setq limit t))))
+ (if icomplete-vertical
+ (let ((prospects-len 0)
+ (prospects-max (- icomplete--prospects-actual-height (/ (point) (window-width)))))
+ (while (and comps (not limit))
+ (setq comp
+ (if prefix-len (substring (car comps) prefix-len) (car comps))
+ comps (cdr comps))
+ (if (> (length comp) 0)
+ (setq prospects-len (1+ prospects-len)))
+ (if (< prospects-len prospects-max)
+ (if (> (length comp) 0)
+ (push comp prospects))
+ (setq limit t))))
+ (while (and comps (not limit))
+ (setq comp
+ (if prefix-len (substring (car comps) prefix-len) (car comps))
+ comps (cdr comps))
+ (setq prospects-len
+ (+ (string-width comp)
+ (string-width icomplete-separator)
+ prospects-len))
+ (if (< prospects-len prospects-max)
+ (push comp prospects)
+ (setq limit t)))))
(setq prospects (nreverse prospects))
;; Return the first match if the user hits enter.
(when icomplete-show-matches-on-no-input
@@ -726,11 +750,16 @@
;; is cached.
(if last (setcdr last base-size))
(if prospects
- (concat determ
- "{"
- (mapconcat 'identity prospects icomplete-separator)
- (and limit (concat icomplete-separator ellipsis))
- "}")
+ (if icomplete-vertical
+ (concat determ
+ " \n"
+ (mapconcat 'identity prospects "\n")
+ (and limit (concat "\n" ellipsis)))
+ (concat determ
+ "{"
+ (mapconcat 'identity prospects icomplete-separator)
+ (and limit (concat icomplete-separator ellipsis))
+ "}"))
(concat determ " [Matched]"))))))
;;; Iswitchb compatibility
next prev parent reply other threads:[~2020-09-19 4:03 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-12 13:10 feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-12 13:33 ` feature/icomplete-vertical Ergus
2020-09-12 14:30 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-14 6:44 ` feature/icomplete-vertical jixiuf
2020-09-14 7:08 ` feature/icomplete-vertical Ergus
2020-09-14 15:02 ` feature/icomplete-vertical Ergus
2020-09-14 17:13 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-14 17:31 ` feature/icomplete-vertical Ergus
2020-09-16 15:22 ` feature/icomplete-vertical jixiuf
[not found] ` <20200918005354.muskx2b7tssyqzzk@Ergus>
2020-09-18 3:08 ` feature/icomplete-vertical jixiuf
2020-09-18 11:58 ` feature/icomplete-vertical Ergus
2020-09-18 17:05 ` feature/icomplete-vertical Ergus
2020-09-18 19:52 ` feature/icomplete-vertical Eli Zaretskii
2020-09-20 10:55 ` feature/icomplete-vertical João Távora
2020-09-20 13:04 ` feature/icomplete-vertical Ergus
2020-09-20 13:15 ` feature/icomplete-vertical Eli Zaretskii
2020-09-20 13:37 ` feature/icomplete-vertical Ergus
2020-09-20 14:07 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-20 14:28 ` feature/icomplete-vertical Eli Zaretskii
2020-09-20 15:04 ` feature/icomplete-vertical Ergus
2020-09-20 15:54 ` feature/icomplete-vertical Eli Zaretskii
2020-09-20 16:13 ` feature/icomplete-vertical Ergus
2020-09-20 17:09 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-20 17:43 ` feature/icomplete-vertical Eli Zaretskii
2020-10-01 16:48 ` feature/icomplete-vertical Ergus
2020-10-02 4:45 ` feature/icomplete-vertical jixiuf
2020-10-03 2:13 ` feature/icomplete-vertical Ergus
2020-10-04 23:47 ` feature/icomplete-vertical João Távora
2020-10-05 4:48 ` feature/icomplete-vertical Ergus
2020-10-05 9:06 ` feature/icomplete-vertical João Távora
2020-10-05 12:23 ` feature/icomplete-vertical Ergus
2020-10-05 12:28 ` feature/icomplete-vertical João Távora
2020-10-05 12:52 ` feature/icomplete-vertical Ergus
2020-10-05 5:45 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 9:13 ` feature/icomplete-vertical João Távora
2020-10-05 9:46 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 9:57 ` feature/icomplete-vertical João Távora
2020-10-05 10:11 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 10:52 ` feature/icomplete-vertical João Távora
2020-10-05 11:00 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 11:11 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 11:33 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 11:48 ` feature/icomplete-vertical João Távora
2020-10-05 17:59 ` feature/icomplete-vertical martin rudalics
2020-10-05 18:24 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 11:24 ` feature/icomplete-vertical João Távora
2020-10-05 11:45 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 11:54 ` feature/icomplete-vertical João Távora
2020-10-05 12:05 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 13:07 ` feature/icomplete-vertical João Távora
2020-10-05 13:25 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 19:03 ` feature/icomplete-vertical João Távora
2020-10-05 19:12 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 19:19 ` feature/icomplete-vertical João Távora
2020-10-05 19:30 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 19:36 ` feature/icomplete-vertical João Távora
2020-10-05 11:02 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 11:32 ` feature/icomplete-vertical João Távora
2020-10-05 11:54 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 11:58 ` feature/icomplete-vertical João Távora
2020-10-05 12:02 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 12:07 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 12:25 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 12:33 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 13:19 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 13:44 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 19:14 ` feature/icomplete-vertical João Távora
2020-10-05 19:24 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 19:32 ` feature/icomplete-vertical João Távora
2020-10-06 6:16 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 19:44 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 19:49 ` feature/icomplete-vertical João Távora
2020-10-06 6:20 ` feature/icomplete-vertical Eli Zaretskii
2020-10-05 13:13 ` feature/icomplete-vertical Stefan Monnier
2020-10-05 7:52 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-10-05 8:22 ` feature/icomplete-vertical Manuel Uberti
2020-10-05 9:40 ` feature/icomplete-vertical João Távora
2020-10-05 10:53 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-20 14:49 ` feature/icomplete-vertical Ergus
2020-09-20 15:46 ` feature/icomplete-vertical Eli Zaretskii
2020-09-18 21:39 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-18 23:27 ` feature/icomplete-vertical Stefan Monnier
2020-09-19 1:59 ` feature/icomplete-vertical Ergus
2020-09-19 4:03 ` Gregory Heytings via Emacs development discussions. [this message]
2020-09-19 6:15 ` feature/icomplete-vertical Ergus
2020-09-19 8:35 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-19 10:30 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-19 11:19 ` feature/icomplete-vertical Ergus
2020-09-19 11:56 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-19 12:57 ` feature/icomplete-vertical Ergus
2020-09-19 11:43 ` feature/icomplete-vertical Ergus
2020-09-19 13:00 ` feature/icomplete-vertical Stefan Monnier
2020-09-19 13:42 ` feature/icomplete-vertical Ergus
2020-09-19 15:35 ` feature/icomplete-vertical Stefan Monnier
2020-09-19 13:59 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-19 14:43 ` feature/icomplete-vertical Ergus
2020-09-19 15:37 ` feature/icomplete-vertical Stefan Monnier
2020-09-19 15:49 ` feature/icomplete-vertical Ergus
2020-09-19 16:01 ` feature/icomplete-vertical Stefan Monnier
2020-09-19 16:05 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-19 16:15 ` feature/icomplete-vertical Stefan Monnier
2020-09-19 16:19 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-19 16:58 ` feature/icomplete-vertical Eli Zaretskii
2020-09-19 17:06 ` feature/icomplete-vertical Ergus
2020-09-19 17:21 ` feature/icomplete-vertical Eli Zaretskii
2020-09-19 20:47 ` feature/icomplete-vertical Ergus
2020-09-19 22:07 ` feature/icomplete-vertical Stefan Monnier
2020-09-20 5:31 ` feature/icomplete-vertical Eli Zaretskii
2020-09-20 10:47 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-20 13:04 ` feature/icomplete-vertical Ergus
2020-09-19 21:40 ` feature/icomplete-vertical Dmitry Gutov
2020-09-20 5:45 ` feature/icomplete-vertical Eli Zaretskii
2020-09-19 15:55 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-19 10:47 ` feature/icomplete-vertical Ergus
2020-09-19 17:08 ` feature/icomplete-vertical Drew Adams
2020-09-20 0:28 ` feature/icomplete-vertical Gregory Heytings via Emacs development discussions.
2020-09-20 1:18 ` feature/icomplete-vertical Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2020-10-02 6:37 feature/icomplete-vertical Manuel Uberti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.NEB.2.22.394.2009190430590453.10337@sdf.lonestar.org \
--to=emacs-devel@gnu.org \
--cc=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=ghe@sdf.org \
--cc=spacibba@aol.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).