mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-27 07:37:33 +00:00
Better check for nil in search-/query-replace-highlight-submatches (bug#45973)
* lisp/isearch.el (isearch-highlight): * lisp/replace.el (replace-highlight): Use integer-or-marker-p to check matches.
This commit is contained in:
parent
1248c67484
commit
e718d3a849
@ -3757,23 +3757,27 @@ since they have special meaning in a regexp."
|
||||
(overlay-put isearch-overlay 'priority 1001)
|
||||
(overlay-put isearch-overlay 'face isearch-face)))
|
||||
|
||||
(when (and search-highlight-submatches
|
||||
isearch-regexp)
|
||||
(when (and search-highlight-submatches isearch-regexp)
|
||||
(mapc 'delete-overlay isearch-submatches-overlays)
|
||||
(setq isearch-submatches-overlays nil)
|
||||
(let ((submatch-data (cddr (butlast match-data)))
|
||||
;; 'cddr' removes whole expression match from match-data
|
||||
(let ((submatch-data (cddr match-data))
|
||||
(group 0)
|
||||
ov face)
|
||||
b e ov face)
|
||||
(while submatch-data
|
||||
(setq group (1+ group))
|
||||
(setq ov (make-overlay (pop submatch-data) (pop submatch-data))
|
||||
face (intern-soft (format "isearch-group-%d" group)))
|
||||
;; Recycle faces from beginning.
|
||||
(unless (facep face)
|
||||
(setq group 1 face 'isearch-group-1))
|
||||
(overlay-put ov 'face face)
|
||||
(overlay-put ov 'priority 1002)
|
||||
(push ov isearch-submatches-overlays)))))
|
||||
(setq b (pop submatch-data)
|
||||
e (pop submatch-data))
|
||||
(when (and (integer-or-marker-p b)
|
||||
(integer-or-marker-p e))
|
||||
(setq ov (make-overlay b e)
|
||||
group (1+ group)
|
||||
face (intern-soft (format "isearch-group-%d" group)))
|
||||
;; Recycle faces from beginning
|
||||
(unless (facep face)
|
||||
(setq group 1 face 'isearch-group-1))
|
||||
(overlay-put ov 'face face)
|
||||
(overlay-put ov 'priority 1002)
|
||||
(push ov isearch-submatches-overlays))))))
|
||||
|
||||
(defun isearch-dehighlight ()
|
||||
(when isearch-overlay
|
||||
|
@ -2425,23 +2425,27 @@ It is called with three arguments, as if it were
|
||||
(overlay-put replace-overlay 'priority 1001) ;higher than lazy overlays
|
||||
(overlay-put replace-overlay 'face 'query-replace)))
|
||||
|
||||
(when (and query-replace-highlight-submatches
|
||||
regexp-flag)
|
||||
(when (and query-replace-highlight-submatches regexp-flag)
|
||||
(mapc 'delete-overlay replace-submatches-overlays)
|
||||
(setq replace-submatches-overlays nil)
|
||||
(let ((submatch-data (cddr (butlast (match-data t))))
|
||||
;; 'cddr' removes whole expression match from match-data
|
||||
(let ((submatch-data (cddr (match-data t)))
|
||||
(group 0)
|
||||
ov face)
|
||||
b e ov face)
|
||||
(while submatch-data
|
||||
(setq group (1+ group))
|
||||
(setq ov (make-overlay (pop submatch-data) (pop submatch-data))
|
||||
face (intern-soft (format "isearch-group-%d" group)))
|
||||
;; Recycle faces from beginning.
|
||||
(unless (facep face)
|
||||
(setq group 1 face 'isearch-group-1))
|
||||
(overlay-put ov 'face face)
|
||||
(overlay-put ov 'priority 1002)
|
||||
(push ov replace-submatches-overlays))))
|
||||
(setq b (pop submatch-data)
|
||||
e (pop submatch-data))
|
||||
(when (and (integer-or-marker-p b)
|
||||
(integer-or-marker-p e))
|
||||
(setq ov (make-overlay b e)
|
||||
group (1+ group)
|
||||
face (intern-soft (format "isearch-group-%d" group)))
|
||||
;; Recycle faces from beginning
|
||||
(unless (facep face)
|
||||
(setq group 1 face 'isearch-group-1))
|
||||
(overlay-put ov 'face face)
|
||||
(overlay-put ov 'priority 1002)
|
||||
(push ov replace-submatches-overlays)))))
|
||||
|
||||
(if query-replace-lazy-highlight
|
||||
(let ((isearch-string search-string)
|
||||
|
Loading…
Reference in New Issue
Block a user