summaryrefslogtreecommitdiff
path: root/lisp/minibuffer.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2020-09-14 14:22:06 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-09-14 14:22:06 +0200
commit14486c44885ffe4532118676aaa6e3783a0417bb (patch)
treeb6aa8fc242f2ba3061d79c380629657c9c5e3f12 /lisp/minibuffer.el
parentcbfa41154467c6a6e3016a5689bc3f165f4e0032 (diff)
downloademacs-14486c44885ffe4532118676aaa6e3783a0417bb.tar.gz
Allow preserving (some) text properties from completion tables
* doc/lispref/minibuf.texi (Text from Minibuffer): Document it. * lisp/minibuffer.el (completion--replace): Preserve text properties on completed items (bug#43218).
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r--lisp/minibuffer.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 62a33f3e2dd..3e23c05bb0c 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1065,10 +1065,16 @@ in the last `cdr'."
(defun completion--replace (beg end newtext)
"Replace the buffer text between BEG and END with NEWTEXT.
Moves point to the end of the new text."
- ;; The properties on `newtext' include things like
- ;; completions-first-difference, which we don't want to include
- ;; upon insertion.
- (set-text-properties 0 (length newtext) nil newtext)
+ ;; The properties on `newtext' include things like the
+ ;; `completions-first-difference' face, which we don't want to
+ ;; include upon insertion.
+ (if minibuffer-allow-text-properties
+ ;; If we're preserving properties, then just remove the faces
+ ;; and other properties added by the completion machinery.
+ (remove-text-properties 0 (length newtext) '(face completion-score)
+ newtext)
+ ;; Remove all text properties.
+ (set-text-properties 0 (length newtext) nil newtext))
;; Maybe this should be in subr.el.
;; You'd think this is trivial to do, but details matter if you want
;; to keep markers "at the right place" and be robust in the face of