Skip to content

Commit 96f1db8

Browse files
committed
Avoid errors in 'icomplete-vertical-mode'
* lisp/minibuffer.el (completion--hilit-from-re): Avoid signaling an error if STRING does not match REGEXP. Fix doc string and indentation. (Bug#72176)
1 parent 55110d1 commit 96f1db8

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

lisp/minibuffer.el

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4051,24 +4051,26 @@ details."
40514051

40524052
(defun completion--hilit-from-re (string regexp &optional point-idx)
40534053
"Fontify STRING using REGEXP POINT-IDX.
4054-
`completions-common-part' and `completions-first-difference' are
4055-
used. POINT-IDX is the position of point in the presumed \"PCM\"
4056-
pattern that was used to generate derive REGEXP from."
4057-
(let* ((md (and regexp (string-match regexp string) (cddr (match-data t))))
4058-
(pos (if point-idx (match-beginning point-idx) (match-end 0)))
4059-
(me (and md (match-end 0)))
4060-
(from 0))
4061-
(while md
4062-
(add-face-text-property from (pop md) 'completions-common-part nil string)
4063-
(setq from (pop md)))
4064-
(if (> (length string) pos)
4065-
(add-face-text-property
4066-
pos (1+ pos)
4067-
'completions-first-difference
4068-
nil string))
4069-
(unless (or (not me) (= from me))
4070-
(add-face-text-property from me 'completions-common-part nil string))
4071-
string))
4054+
Uses `completions-common-part' and `completions-first-difference'
4055+
faces to fontify STRING.
4056+
POINT-IDX is the position of point in the presumed \"PCM\" pattern
4057+
from which REGEXP was generated."
4058+
(let* ((md (and regexp (string-match regexp string) (cddr (match-data t))))
4059+
(pos (if point-idx (match-beginning point-idx) (match-end 0)))
4060+
(me (and md (match-end 0)))
4061+
(from 0))
4062+
(while md
4063+
(add-face-text-property from (pop md)
4064+
'completions-common-part nil string)
4065+
(setq from (pop md)))
4066+
(if (and (numberp pos) (> (length string) pos))
4067+
(add-face-text-property
4068+
pos (1+ pos)
4069+
'completions-first-difference
4070+
nil string))
4071+
(unless (or (not me) (= from me))
4072+
(add-face-text-property from me 'completions-common-part nil string))
4073+
string))
40724074

40734075
(defun completion--flex-score-1 (md-groups match-end len)
40744076
"Compute matching score of completion.

0 commit comments

Comments
 (0)