--- 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