summaryrefslogtreecommitdiff
path: root/lisp/isearch.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r--lisp/isearch.el48
1 files changed, 38 insertions, 10 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index d9a48cfcf2d..4c4b9474245 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2478,8 +2478,8 @@ The arguments passed to `highlight-regexp' are the regexp from
the last search and the face from `hi-lock-read-face-name'."
(interactive)
(isearch--highlight-regexp-or-lines
- #'(lambda (regexp face lighter)
- (highlight-regexp regexp face nil lighter))))
+ (lambda (regexp face lighter)
+ (highlight-regexp regexp face nil lighter))))
(defun isearch-highlight-lines-matching-regexp ()
"Exit Isearch mode and call `highlight-lines-matching-regexp'.
@@ -2487,8 +2487,8 @@ The arguments passed to `highlight-lines-matching-regexp' are the
regexp from the last search and the face from `hi-lock-read-face-name'."
(interactive)
(isearch--highlight-regexp-or-lines
- #'(lambda (regexp face _lighter)
- (highlight-lines-matching-regexp regexp face))))
+ (lambda (regexp face _lighter)
+ (highlight-lines-matching-regexp regexp face))))
(defun isearch-delete-char ()
@@ -3536,6 +3536,20 @@ Can be changed via `isearch-search-fun-function' for special needs."
(if isearch-forward #'re-search-forward #'re-search-backward)
regexp bound noerror count))))
+(defun isearch--search-skip-inhibited (func string bound noerror)
+ "Search for STRING with FUNC, but skip areas where isearch is inhibited.
+Returns the value of the (final) call to the search function."
+ (let (pos)
+ (while (and (setq pos (funcall func string bound noerror))
+ ;; If we're inhibited here, skip to the end of that
+ ;; area and try again.
+ (get-text-property (match-beginning 0) 'inhibit-isearch)
+ (goto-char (next-single-property-change
+ (match-beginning 0)
+ 'inhibit-isearch
+ nil (point-max)))))
+ pos))
+
(defun isearch-search-string (string bound noerror)
"Search for the first occurrence of STRING or its translation.
STRING's characters are translated using `translation-table-for-input'
@@ -3547,7 +3561,8 @@ The match found must not extend after that position.
Optional third argument, if t, means if fail just return nil (no error).
If not nil and not t, move to limit of search and return nil."
(let* ((func (isearch-search-fun))
- (pos1 (save-excursion (funcall func string bound noerror)))
+ (pos1 (save-excursion
+ (isearch--search-skip-inhibited func string bound noerror)))
pos2)
(when (and
;; Avoid "obsolete" warnings for translation-table-for-input.
@@ -3570,7 +3585,8 @@ Optional third argument, if t, means if fail just return nil (no error).
(when translated
(save-match-data
(save-excursion
- (if (setq pos2 (funcall func translated bound noerror))
+ (if (setq pos2 (isearch--search-skip-inhibited
+ func string bound noerror))
(setq match-data (match-data t)))))
(when (and pos2
(or (not pos1)
@@ -3724,6 +3740,15 @@ Optional third argument, if t, means if fail just return nil (no error).
(overlay-put ov 'isearch-invisible nil)))))))
+(defun isearch--invisible-p (val)
+ "Like `invisible-p', but also takes into account `inhibit-isearch' properties.
+If search is inhibited due to the latter, return `inhibit-isearch', and
+if it's due to the former, return `invisible'."
+ (or (and (invisible-p val)
+ 'invisible)
+ (and (get-text-property (point) 'inhibit-isearch)
+ 'inhibit-isearch)))
+
(defun isearch-range-invisible (beg end)
"Return t if all the text from BEG to END is invisible."
(when (/= beg end)
@@ -3733,16 +3758,19 @@ Optional third argument, if t, means if fail just return nil (no error).
(let (;; can-be-opened keeps track if we can open some overlays.
(can-be-opened (eq search-invisible 'open))
;; the list of overlays that could be opened
- (crt-overlays nil))
+ (crt-overlays nil)
+ ii-prop)
(when (and can-be-opened isearch-hide-immediately)
(isearch-close-unnecessary-overlays beg end))
;; If the following character is currently invisible,
;; skip all characters with that same `invisible' property value.
;; Do that over and over.
- (while (and (< (point) end) (invisible-p (point)))
- (if (invisible-p (get-text-property (point) 'invisible))
+ (while (and (< (point) end)
+ (isearch--invisible-p (point)))
+ (if (setq ii-prop (isearch--invisible-p
+ (get-text-property (point) 'invisible)))
(progn
- (goto-char (next-single-property-change (point) 'invisible
+ (goto-char (next-single-property-change (point) ii-prop
nil end))
;; if text is hidden by an `invisible' text property
;; we cannot open it at all.