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)
This commit is contained in:
Eli Zaretskii 2024-07-20 08:58:39 +03:00
parent 55110d1fda
commit 96f1db89ee

View file

@ -4051,24 +4051,26 @@ details."
(defun completion--hilit-from-re (string regexp &optional point-idx) (defun completion--hilit-from-re (string regexp &optional point-idx)
"Fontify STRING using REGEXP POINT-IDX. "Fontify STRING using REGEXP POINT-IDX.
`completions-common-part' and `completions-first-difference' are Uses `completions-common-part' and `completions-first-difference'
used. POINT-IDX is the position of point in the presumed \"PCM\" faces to fontify STRING.
pattern that was used to generate derive REGEXP from." POINT-IDX is the position of point in the presumed \"PCM\" pattern
(let* ((md (and regexp (string-match regexp string) (cddr (match-data t)))) from which REGEXP was generated."
(pos (if point-idx (match-beginning point-idx) (match-end 0))) (let* ((md (and regexp (string-match regexp string) (cddr (match-data t))))
(me (and md (match-end 0))) (pos (if point-idx (match-beginning point-idx) (match-end 0)))
(from 0)) (me (and md (match-end 0)))
(while md (from 0))
(add-face-text-property from (pop md) 'completions-common-part nil string) (while md
(setq from (pop md))) (add-face-text-property from (pop md)
(if (> (length string) pos) 'completions-common-part nil string)
(add-face-text-property (setq from (pop md)))
pos (1+ pos) (if (and (numberp pos) (> (length string) pos))
'completions-first-difference (add-face-text-property
nil string)) pos (1+ pos)
(unless (or (not me) (= from me)) 'completions-first-difference
(add-face-text-property from me 'completions-common-part nil string)) nil string))
string)) (unless (or (not me) (= from me))
(add-face-text-property from me 'completions-common-part nil string))
string))
(defun completion--flex-score-1 (md-groups match-end len) (defun completion--flex-score-1 (md-groups match-end len)
"Compute matching score of completion. "Compute matching score of completion.