From b5e34c34bcd81a0f261a5ee6dedaf51261ae5025 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 25 Nov 2020 22:24:11 +0200 Subject: [PATCH] * lisp/minibuffer.el (completions-format): Add new value 'one-column'. * lisp/minibuffer.el (completion--insert-strings): Support 'one-column'. * lisp/simple.el (read-from-kill-ring): Truncate strings at frame-width. --- etc/NEWS | 3 +++ lisp/minibuffer.el | 13 ++++++++++--- lisp/simple.el | 7 ++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index d1e896ef70e..5f8f408c6f2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1345,6 +1345,9 @@ This new command (bound to 'C-c C-l') regenerates the current hunk. When non-nil, some commands like 'describe-symbol' show more detailed completions with more information in completion prefix and suffix. +--- +*** User option 'completions-format' supports a new value 'one-column'. + --- *** New user option 'bibtex-unify-case-convert'. This new option allows the user to customize how case is converted diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 48bd39587bc..87bf3d36fa4 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1679,9 +1679,11 @@ Return nil if there is no valid completion, else t." "Define the appearance and sorting of completions. If the value is `vertical', display completions sorted vertically in columns in the *Completions* buffer. -If the value is `horizontal', display completions sorted -horizontally in alphabetical order, rather than down the screen." - :type '(choice (const horizontal) (const vertical)) +If the value is `horizontal', display completions sorted in columns +horizontally in alphabetical order, rather than down the screen. +If the value is `one-column', display completions down the screen +in one column." + :type '(choice (const horizontal) (const vertical) (const one-column)) :version "23.2") (defcustom completions-detailed nil @@ -1727,6 +1729,9 @@ It also eliminates runs of equal strings." (apply #'+ (mapcar #'string-width str)) (string-width str)))) (cond + ((eq completions-format 'one-column) + ;; Nothing special + ) ((eq completions-format 'vertical) ;; Vertical format (when (> row rows) @@ -1790,6 +1795,8 @@ It also eliminates runs of equal strings." (font-lock-prepend-text-property beg end 'face 'completions-annotations))))) (cond + ((eq completions-format 'one-column) + (insert "\n")) ((eq completions-format 'vertical) ;; Vertical format (if (> column 0) diff --git a/lisp/simple.el b/lisp/simple.el index 69b4639292a..c9f4f2bb445 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5477,15 +5477,16 @@ With ARG, rotate that many kills forward (or backward, if negative)." (completions (mapcar (lambda (s) (let* ((s (query-replace-descr s)) - (b 0)) + (b 0) + (limit (frame-width))) ;; Add ellipsis on leading whitespace (when (string-match "\\`[[:space:]]+" s) (setq b (match-end 0)) (add-text-properties 0 b `(display ,ellipsis) s)) ;; Add ellipsis at the end of a long string - (when (> (length s) (+ 40 b)) + (when (> (length s) (+ limit b)) (add-text-properties - (min (+ 40 b) (length s)) (length s) + (min (+ limit b) (length s)) (length s) `(display ,ellipsis) s)) s)) read-from-kill-ring-history))) -- 2.39.2