diff options
| author | Juri Linkov | 2021-01-19 20:12:47 +0200 |
|---|---|---|
| committer | Juri Linkov | 2021-01-19 20:13:48 +0200 |
| commit | e718d3a84920f545b6a3540a3ba9c2ccd7eefdf7 (patch) | |
| tree | 64db641db63630f7a9528d14e6127da3531e9a4e /lisp/replace.el | |
| parent | 1248c67484d599b36e094f0e641c82482fd269ce (diff) | |
| download | emacs-e718d3a84920f545b6a3540a3ba9c2ccd7eefdf7.tar.gz emacs-e718d3a84920f545b6a3540a3ba9c2ccd7eefdf7.zip | |
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.
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 8f8cbfac542..db5b340631a 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -2425,23 +2425,27 @@ It is called with three arguments, as if it were | |||
| 2425 | (overlay-put replace-overlay 'priority 1001) ;higher than lazy overlays | 2425 | (overlay-put replace-overlay 'priority 1001) ;higher than lazy overlays |
| 2426 | (overlay-put replace-overlay 'face 'query-replace))) | 2426 | (overlay-put replace-overlay 'face 'query-replace))) |
| 2427 | 2427 | ||
| 2428 | (when (and query-replace-highlight-submatches | 2428 | (when (and query-replace-highlight-submatches regexp-flag) |
| 2429 | regexp-flag) | ||
| 2430 | (mapc 'delete-overlay replace-submatches-overlays) | 2429 | (mapc 'delete-overlay replace-submatches-overlays) |
| 2431 | (setq replace-submatches-overlays nil) | 2430 | (setq replace-submatches-overlays nil) |
| 2432 | (let ((submatch-data (cddr (butlast (match-data t)))) | 2431 | ;; 'cddr' removes whole expression match from match-data |
| 2432 | (let ((submatch-data (cddr (match-data t))) | ||
| 2433 | (group 0) | 2433 | (group 0) |
| 2434 | ov face) | 2434 | b e ov face) |
| 2435 | (while submatch-data | 2435 | (while submatch-data |
| 2436 | (setq group (1+ group)) | 2436 | (setq b (pop submatch-data) |
| 2437 | (setq ov (make-overlay (pop submatch-data) (pop submatch-data)) | 2437 | e (pop submatch-data)) |
| 2438 | face (intern-soft (format "isearch-group-%d" group))) | 2438 | (when (and (integer-or-marker-p b) |
| 2439 | ;; Recycle faces from beginning. | 2439 | (integer-or-marker-p e)) |
| 2440 | (unless (facep face) | 2440 | (setq ov (make-overlay b e) |
| 2441 | (setq group 1 face 'isearch-group-1)) | 2441 | group (1+ group) |
| 2442 | (overlay-put ov 'face face) | 2442 | face (intern-soft (format "isearch-group-%d" group))) |
| 2443 | (overlay-put ov 'priority 1002) | 2443 | ;; Recycle faces from beginning |
| 2444 | (push ov replace-submatches-overlays)))) | 2444 | (unless (facep face) |
| 2445 | (setq group 1 face 'isearch-group-1)) | ||
| 2446 | (overlay-put ov 'face face) | ||
| 2447 | (overlay-put ov 'priority 1002) | ||
| 2448 | (push ov replace-submatches-overlays))))) | ||
| 2445 | 2449 | ||
| 2446 | (if query-replace-lazy-highlight | 2450 | (if query-replace-lazy-highlight |
| 2447 | (let ((isearch-string search-string) | 2451 | (let ((isearch-string search-string) |