unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RE: [PATCH] Support "\n" in icomplete-separator
@ 2020-11-06 16:30 Drew Adams
  0 siblings, 0 replies; 115+ messages in thread
From: Drew Adams @ 2020-11-06 16:30 UTC (permalink / raw)
  To: Emacs-Devel List

[Forwarding to the list, as it got dropped from
Reply All.]

> My opinion is that there is no need to show visually that there are more
> candidates, most (all?) other programs I use never do that, they just
> display a list of candidates, and it becomes clear that there are no more
> candidates when the list shrinks after enough input.

"it becomes clear..."

Maybe, maybe not.  If you have N completion matches
and their explicit display shows only N-5 of them,
you might want to know that there are 5 more.

In Icicles, by default, the number of candidates
currently shown, and the total number, are indicated
in the mode-line: e.g. "149/567 shown".

And the mode-line lighter includes "..." when not
all are shown.

(If not all candidates are shown it's because you've
chosen to limit the number to show.)



^ permalink raw reply	[flat|nested] 115+ messages in thread
* [PATCH] Support "\n" in icomplete-separator
@ 2020-11-05 23:10 Andrii Kolomoiets
  2020-11-05 23:29 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 115+ messages in thread
From: Andrii Kolomoiets @ 2020-11-05 23:10 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 704 bytes --]

Hi,

I'm a bit late to the icomplete-vertical party, but please let me show
you my approach at supporting "\n" in 'icomplete-separator'.

The main idea is to treat the 'icomplete-prospects-height' variable
value as the amount of completions we want to see if there is "\n" in the
'icomplete-separator'.

Please see attached patch.

Also see attached screenshot of minibuffer-only frame after:

emacs -Q --eval "(setq default-frame-alist '((minibuffer . nil)))"
M-x icomplete-mode
(setq icomplete-prospects-height 5)
(setq icomplete-hide-common-prefix nil)
(setq icomplete-separator "\n ")
(setq resize-mini-frames t)
M-x icomp

If that approach was already discussed, please let me know.

WDYT?

Thanks!

[-- Attachment #2: icomplete-vertical.diff --]
[-- Type: text/x-patch, Size: 3921 bytes --]

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 4e546807b7..ec11cbffce 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -701,19 +701,23 @@ icomplete-completions
 				((< compare (+ 2 (string-width ellipsis))) most)
 				(t (concat ellipsis (substring most compare))))
 			       close-bracket)))
+             (vertical (string-match "\n" icomplete-separator))
 	     ;;"-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 (unless vertical
+                              (+ (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 vertical
+                  icomplete-prospects-height
+                ;; 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):
@@ -730,7 +734,9 @@ icomplete-completions
                    ;; is already displayed via `most'.
                    (string-prefix-p prefix most t)
                    (length prefix))) ;;)
-	     prospects comp limit)
+             (limit (when vertical
+                      (> (length comps) prospects-max)))
+	     prospects comp)
 	(if (or (eq most-try t) (not (consp (cdr comps))))
 	    (setq prospects nil)
 	  (when (member name comps)
@@ -753,17 +759,24 @@ icomplete-completions
 	    ;; 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 vertical
+              (while (and comps (> prospects-max 0))
+                (setq prospects-max (1- prospects-max))
+                (push (if prefix-len
+                          (substring (pop comps) prefix-len)
+                        (pop comps))
+                      prospects))
+            (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))
 	;; Decorate first of the prospects.
 	(when prospects

[-- Attachment #3: icomplete-vertical.png --]
[-- Type: image/png, Size: 43149 bytes --]

^ permalink raw reply related	[flat|nested] 115+ messages in thread

end of thread, other threads:[~2020-11-17 14:05 UTC | newest]

Thread overview: 115+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <<m2a6vv8ko3.fsf@gmail.com>
     [not found] ` <<20201105235735.oxouuek66ehu5o45@Ergus>
     [not found]   ` <<m2y2je7jcx.fsf@gmail.com>
     [not found]     ` <<20201106151541.dpgep7borlja25su@Ergus>
     [not found]       ` <<m2d00n7gj4.fsf@gmail.com>
     [not found]         ` <<837dqv5huk.fsf@gnu.org>
     [not found]           ` <<m24klys0n2.fsf@gmail.com>
     [not found]             ` <<83mtzp2qj0.fsf@gnu.org>
     [not found]               ` <<m2imad6sh1.fsf@gmail.com>
     [not found]                 ` <<83r1p11369.fsf@gnu.org>
     [not found]                   ` <<m2a6vo7wcw.fsf@gmail.com>
     [not found]                     ` <<ca240036-8493-968d-2204-620f430334b9@gmx.at>
     [not found]                       ` <<m2sg9g5j2p.fsf@gmail.com>
     [not found]                         ` <<fe70158f-d55a-010a-74ba-2f81d1bb7663@gmx.at>
     [not found]                           ` <<837dqr27zs.fsf@gnu.org>
2020-11-11 19:03                             ` [PATCH] Support "\n" in icomplete-separator Drew Adams
     [not found]                             ` <<alpine.NEB.2.22.394.2011111803220453.17489@sdf.lonestar.org>
     [not found]                               ` <<83361f22ah.fsf@gnu.org>
     [not found]                                 ` <<alpine.NEB.2.22.394.2011111926450453.27530@sdf.lonestar.org>
     [not found]                                   ` <<83sg9fzlto.fsf@gnu.org>
     [not found]                                     ` <<alpine.NEB.2.22.394.2011112128400453.4149@sdf.lonestar.org>
     [not found]                                       ` <<83r1ozz22j.fsf@gnu.org>
     [not found]                                         ` <<alpine.NEB.2.22.394.2011120932160453.28737@sdf.lonestar.org>
     [not found]                                           ` <<83d00izloj.fsf@gnu.org>
     [not found]                                             ` <<alpine.NEB.2.22.394.2011121544550453.26984@sdf.lonestar.org>
     [not found]                                               ` <<83361ezix2.fsf@gnu.org>
2020-11-12 17:42                                                 ` Drew Adams
2020-11-06 16:30 Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2020-11-05 23:10 Andrii Kolomoiets
2020-11-05 23:29 ` Stefan Monnier
2020-11-06  0:04   ` Ergus
2020-11-06  2:44     ` Stefan Monnier
2020-11-06  8:42     ` Gregory Heytings via Emacs development discussions.
2020-11-06 10:26   ` Andrii Kolomoiets
2020-11-05 23:57 ` Ergus
2020-11-06  8:43   ` Gregory Heytings via Emacs development discussions.
2020-11-06 12:36   ` Andrii Kolomoiets
2020-11-06 15:15     ` Ergus
2020-11-08 20:14       ` Andrii Kolomoiets
2020-11-08 20:30         ` Gregory Heytings via Emacs development discussions.
2020-11-08 20:36           ` Andrii Kolomoiets
2020-11-09  3:28         ` Eli Zaretskii
2020-11-09 21:04           ` Andrii Kolomoiets
2020-11-10 15:13             ` Eli Zaretskii
2020-11-10 17:18               ` Andrii Kolomoiets
2020-11-10 18:18                 ` Gregory Heytings via Emacs development discussions.
2020-11-11  9:41                   ` Andrii Kolomoiets
2020-11-10 18:23                 ` Eli Zaretskii
2020-11-10 19:17                   ` Gregory Heytings via Emacs development discussions.
2020-11-10 19:27                     ` Eli Zaretskii
2020-11-10 20:00                       ` Gregory Heytings via Emacs development discussions.
2020-11-10 21:09                   ` Andrii Kolomoiets
2020-11-11  8:27                     ` martin rudalics
2020-11-11  9:07                       ` Gregory Heytings via Emacs development discussions.
2020-11-11 15:57                         ` Jean Louis
2020-11-11  9:38                       ` Andrii Kolomoiets
2020-11-11 10:01                         ` martin rudalics
2020-11-11 10:21                           ` Gregory Heytings via Emacs development discussions.
2020-11-11 10:53                             ` martin rudalics
2020-11-11 11:22                               ` Gregory Heytings via Emacs development discussions.
2020-11-11 15:49                                 ` martin rudalics
2020-11-11 15:57                                   ` Eli Zaretskii
2020-11-11 16:16                                     ` Jean Louis
2020-11-11 17:06                                     ` martin rudalics
2020-11-11 17:28                                       ` Gregory Heytings via Emacs development discussions.
2020-11-11 16:05                                   ` Gregory Heytings via Emacs development discussions.
2020-11-11 17:06                                     ` martin rudalics
2020-11-11 17:26                                     ` Stefan Monnier
2020-11-11 17:37                                       ` Gregory Heytings via Emacs development discussions.
2020-11-11 15:32                             ` Jean Louis
2020-11-11 15:26                           ` Jean Louis
2020-11-11 16:06                           ` Eli Zaretskii
2020-11-11 17:12                             ` Gregory Heytings via Emacs development discussions.
2020-11-11 17:19                               ` Alfred M. Szmidt
2020-11-11 17:44                                 ` Gregory Heytings via Emacs development discussions.
2020-11-11 17:50                                   ` Alfred M. Szmidt
2020-11-11 18:14                                     ` Eli Zaretskii
2020-11-11 18:09                               ` Eli Zaretskii
2020-11-11 18:39                                 ` Gregory Heytings via Emacs development discussions.
2020-11-11 20:21                                   ` Eli Zaretskii
2020-11-11 20:37                                     ` Gregory Heytings via Emacs development discussions.
2020-11-11 21:55                                       ` Ergus
2020-11-11 22:26                                         ` Jean Louis
2020-11-11 22:59                                         ` Stefan Monnier
2020-11-12  3:28                                       ` Eli Zaretskii
2020-11-12  8:50                                         ` Gregory Heytings via Emacs development discussions.
2020-11-12 14:36                                           ` Eli Zaretskii
2020-11-12 15:05                                             ` Gregory Heytings via Emacs development discussions.
2020-11-12 15:36                                               ` Eli Zaretskii
2020-11-12 16:10                                                 ` Gregory Heytings via Emacs development discussions.
2020-11-12 17:50                                                   ` Eli Zaretskii
2020-11-13 12:40                                                     ` Gregory Heytings via Emacs development discussions.
2020-11-13 12:59                                                       ` Eli Zaretskii
2020-11-13 13:36                                                         ` Gregory Heytings via Emacs development discussions.
2020-11-13 13:52                                                           ` Eli Zaretskii
2020-11-13 15:09                                                             ` Stephen Berman
2020-11-13 16:05                                                               ` Eli Zaretskii
2020-11-13 17:31                                                                 ` Stephen Berman
2020-11-16 10:24                                                             ` Gregory Heytings via Emacs development discussions.
2020-11-16 17:44                                                               ` Eli Zaretskii
2020-11-17 11:51                                                                 ` Gregory Heytings via Emacs development discussions.
2020-11-12  7:58                                     ` martin rudalics
2020-11-12  8:52                                       ` Gregory Heytings via Emacs development discussions.
2020-11-12 14:37                                         ` Eli Zaretskii
2020-11-12 12:39                                       ` Dmitry Gutov
2020-11-12 19:31                                         ` Howard Melman
2020-11-11 14:09                         ` Jean Louis
2020-11-11 15:51                           ` Eli Zaretskii
2020-11-11 16:05                             ` Jean Louis
2020-11-11 18:52                       ` Drew Adams
2020-11-11 19:10                         ` martin rudalics
2020-11-11 19:49                           ` Drew Adams
2020-11-12  7:58                             ` martin rudalics
2020-11-11 19:51                           ` Drew Adams
2020-11-11 16:30                     ` Eli Zaretskii
2020-11-12 22:51                       ` Andrii Kolomoiets
2020-11-13  8:39                         ` Eli Zaretskii
2020-11-13 12:56                           ` Gregory Heytings via Emacs development discussions.
2020-11-13 13:02                             ` Eli Zaretskii
2020-11-13 13:44                               ` Gregory Heytings via Emacs development discussions.
2020-11-13 13:55                                 ` Eli Zaretskii
2020-11-16 10:25                                   ` Gregory Heytings via Emacs development discussions.
2020-11-16 17:40                                     ` Eli Zaretskii
2020-11-16 17:41                                     ` Stefan Monnier
2020-11-16 18:24                                       ` Eli Zaretskii
2020-11-17 11:51                                       ` Gregory Heytings via Emacs development discussions.
2020-11-17 14:05                                         ` Stefan Monnier
2020-11-13 19:27                             ` Andrii Kolomoiets
2020-11-17  8:59                               ` Gregory Heytings via Emacs development discussions.
2020-11-13 20:18                           ` Andrii Kolomoiets
2020-11-14  6:17                             ` Ergus
2020-11-14 20:36                               ` Andrii Kolomoiets
2020-11-15  2:39                                 ` Ergus
2020-11-15 19:32                                   ` Andrii Kolomoiets
2020-11-10 20:01                 ` Stefan Monnier
2020-11-06  5:52 ` Jean Louis
2020-11-06 12:40   ` Andrii Kolomoiets
2020-11-06 12:59     ` Jean Louis
2020-11-08 20:28       ` Andrii Kolomoiets
2020-11-08 20:50         ` 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).