unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [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; 123+ 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] 123+ messages in thread

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

Thread overview: 123+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-05 23:10 [PATCH] Support "\n" in icomplete-separator 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  9:13                                           ` on helm substantial differences - " Jean Louis
2020-11-12  9:20                                             ` Gregory Heytings via Emacs development discussions.
2020-11-12 10:25                                               ` Jean Louis
2020-11-12 10:54                                                 ` Gregory Heytings via Emacs development discussions.
2020-11-12 11:33                                                   ` Jean Louis
2020-11-12 14:40                                                     ` Gregory Heytings via Emacs development discussions.
2020-11-12 17:46                                                       ` Jean Louis
2020-11-12 14:41                                             ` Eli Zaretskii
2020-11-12 17:49                                               ` Jean Louis
2020-11-12 17:58                                                 ` Eli Zaretskii
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-12 20:02                                           ` ivy-posframe review - " Jean Louis
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).