* 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.
This commit is contained in:
Juri Linkov 2020-11-25 22:24:11 +02:00
parent 1eb168fa97
commit b5e34c34bc
3 changed files with 17 additions and 6 deletions

View file

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

View file

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

View file

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