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