aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-11-07 17:46:04 +0000
committerStefan Monnier2002-11-07 17:46:04 +0000
commitcd59ea72b2cfaa0b0610747e956cb7ff6bcb4b78 (patch)
treea54f86e1cc4be1611f7db217789995a1a22cb9f0
parentc0d27fccebeaf82ec18619d1e0c525de6e3249cf (diff)
downloademacs-cd59ea72b2cfaa0b0610747e956cb7ff6bcb4b78.tar.gz
emacs-cd59ea72b2cfaa0b0610747e956cb7ff6bcb4b78.zip
(isearch-hidden): New var.
(isearch-search-and-update): Test it. (isearch-range-invisible): Set it.
-rw-r--r--lisp/isearch.el137
1 files changed, 71 insertions, 66 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 7b502220c2f..45742b873c4 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -171,7 +171,9 @@ nil means don't match invisible text.
171If the value is `open', if the text matched is made invisible by 171If the value is `open', if the text matched is made invisible by
172an overlay having an `invisible' property and that overlay has a property 172an overlay having an `invisible' property and that overlay has a property
173`isearch-open-invisible', then incremental search will show the contents. 173`isearch-open-invisible', then incremental search will show the contents.
174\(This applies when using `outline.el' and `hideshow.el'.)" 174\(This applies when using `outline.el' and `hideshow.el'.)
175See also `reveal-mode' if you want overlays to automatically be opened
176whenever point is in one of them."
175 :type '(choice (const :tag "Match hidden text" t) 177 :type '(choice (const :tag "Match hidden text" t)
176 (const :tag "Open overlays" open) 178 (const :tag "Open overlays" open)
177 (const :tag "Don't match hidden text" nil)) 179 (const :tag "Don't match hidden text" nil))
@@ -354,6 +356,7 @@ Default value, nil, means edit the string instead."
354(defvar isearch-forward nil) ; Searching in the forward direction. 356(defvar isearch-forward nil) ; Searching in the forward direction.
355(defvar isearch-regexp nil) ; Searching for a regexp. 357(defvar isearch-regexp nil) ; Searching for a regexp.
356(defvar isearch-word nil) ; Searching for words. 358(defvar isearch-word nil) ; Searching for words.
359(defvar isearch-hidden nil) ; Non-nil if the string exists but is invisible.
357 360
358(defvar isearch-cmds nil 361(defvar isearch-cmds nil
359 "Stack of search status sets. 362 "Stack of search status sets.
@@ -1093,7 +1096,7 @@ Otherwise invoke whatever mouse-2 is bound to outside of Isearch."
1093 (if (and (window-minibuffer-p w) 1096 (if (and (window-minibuffer-p w)
1094 (not (minibuffer-window-active-p w))) ; in echo area 1097 (not (minibuffer-window-active-p w))) ; in echo area
1095 (isearch-yank-x-selection) 1098 (isearch-yank-x-selection)
1096 (when binding 1099 (when (functionp binding)
1097 (call-interactively binding))))) 1100 (call-interactively binding)))))
1098 1101
1099 1102
@@ -1132,7 +1135,7 @@ might return the position of the end of the line."
1132(defun isearch-yank-line () 1135(defun isearch-yank-line ()
1133 "Pull rest of line from buffer into search string." 1136 "Pull rest of line from buffer into search string."
1134 (interactive) 1137 (interactive)
1135 (isearch-yank-internal (lambda () (line-end-position)))) 1138 (isearch-yank-internal 'line-end-position)))
1136 1139
1137 1140
1138(defun isearch-search-and-update () 1141(defun isearch-search-and-update ()
@@ -1141,7 +1144,10 @@ might return the position of the end of the line."
1141 ;; unsuccessful regexp search may become 1144 ;; unsuccessful regexp search may become
1142 ;; successful by addition of characters which 1145 ;; successful by addition of characters which
1143 ;; make isearch-string valid 1146 ;; make isearch-string valid
1144 isearch-regexp) 1147 isearch-regexp
1148 ;; If the string was found but was completely invisible,
1149 ;; it might now be partly visible, so try again.
1150 (prog1 isearch-hidden (setq isearch-hidden nil)))
1145 ;; In reverse search, adding stuff at 1151 ;; In reverse search, adding stuff at
1146 ;; the end may cause zero or many more chars to be 1152 ;; the end may cause zero or many more chars to be
1147 ;; matched, in the string following point. 1153 ;; matched, in the string following point.
@@ -1767,68 +1773,67 @@ Can be changed via `isearch-search-fun-function' for special needs."
1767 1773
1768(defun isearch-range-invisible (beg end) 1774(defun isearch-range-invisible (beg end)
1769 "Return t if all the text from BEG to END is invisible." 1775 "Return t if all the text from BEG to END is invisible."
1770 (and (/= beg end) 1776 (when (/= beg end)
1771 ;; Check that invisibility runs up to END. 1777 ;; Check that invisibility runs up to END.
1772 (save-excursion 1778 (save-excursion
1773 (goto-char beg) 1779 (goto-char beg)
1774 (let ( 1780 (let (;; can-be-opened keeps track if we can open some overlays.
1775 ;; can-be-opened keeps track if we can open some overlays. 1781 (can-be-opened (eq search-invisible 'open))
1776 (can-be-opened (eq search-invisible 'open)) 1782 ;; the list of overlays that could be opened
1777 ;; the list of overlays that could be opened 1783 (crt-overlays nil))
1778 (crt-overlays nil)) 1784 (when (and can-be-opened isearch-hide-immediately)
1779 (when (and can-be-opened isearch-hide-immediately) 1785 (isearch-close-unnecessary-overlays beg end))
1780 (isearch-close-unnecessary-overlays beg end)) 1786 ;; If the following character is currently invisible,
1781 ;; If the following character is currently invisible, 1787 ;; skip all characters with that same `invisible' property value.
1782 ;; skip all characters with that same `invisible' property value. 1788 ;; Do that over and over.
1783 ;; Do that over and over. 1789 (while (and (< (point) end)
1784 (while (and (< (point) end) 1790 (let ((prop
1785 (let ((prop 1791 (get-char-property (point) 'invisible)))
1786 (get-char-property (point) 'invisible))) 1792 (if (eq buffer-invisibility-spec t)
1787 (if (eq buffer-invisibility-spec t) 1793 prop
1788 prop 1794 (or (memq prop buffer-invisibility-spec)
1789 (or (memq prop buffer-invisibility-spec) 1795 (assq prop buffer-invisibility-spec)))))
1790 (assq prop buffer-invisibility-spec))))) 1796 (if (get-text-property (point) 'invisible)
1791 (if (get-text-property (point) 'invisible) 1797 (progn
1792 (progn 1798 (goto-char (next-single-property-change (point) 'invisible
1793 (goto-char (next-single-property-change (point) 'invisible 1799 nil end))
1794 nil end)) 1800 ;; if text is hidden by an `invisible' text property
1795 ;; if text is hidden by an `invisible' text property 1801 ;; we cannot open it at all.
1796 ;; we cannot open it at all. 1802 (setq can-be-opened nil))
1797 (setq can-be-opened nil)) 1803 (when can-be-opened
1798 (unless (null can-be-opened) 1804 (let ((overlays (overlays-at (point)))
1799 (let ((overlays (overlays-at (point))) 1805 ov-list
1800 ov-list 1806 o
1801 o 1807 invis-prop)
1802 invis-prop) 1808 (while overlays
1803 (while overlays 1809 (setq o (car overlays)
1804 (setq o (car overlays) 1810 invis-prop (overlay-get o 'invisible))
1805 invis-prop (overlay-get o 'invisible)) 1811 (if (if (eq buffer-invisibility-spec t)
1806 (if (if (eq buffer-invisibility-spec t) 1812 invis-prop
1807 invis-prop 1813 (or (memq invis-prop buffer-invisibility-spec)
1808 (or (memq invis-prop buffer-invisibility-spec) 1814 (assq invis-prop buffer-invisibility-spec)))
1809 (assq invis-prop buffer-invisibility-spec))) 1815 (if (overlay-get o 'isearch-open-invisible)
1810 (if (overlay-get o 'isearch-open-invisible) 1816 (setq ov-list (cons o ov-list))
1811 (setq ov-list (cons o ov-list)) 1817 ;; We found one overlay that cannot be
1812 ;; We found one overlay that cannot be 1818 ;; opened, that means the whole chunk
1813 ;; opened, that means the whole chunk 1819 ;; cannot be opened.
1814 ;; cannot be opened. 1820 (setq can-be-opened nil)))
1815 (setq can-be-opened nil))) 1821 (setq overlays (cdr overlays)))
1816 (setq overlays (cdr overlays))) 1822 (if can-be-opened
1817 (if can-be-opened 1823 ;; It makes sense to append to the open
1818 ;; It makes sense to append to the open 1824 ;; overlays list only if we know that this is
1819 ;; overlays list only if we know that this is 1825 ;; t.
1820 ;; t. 1826 (setq crt-overlays (append ov-list crt-overlays)))))
1821 (setq crt-overlays (append ov-list crt-overlays))))) 1827 (goto-char (next-overlay-change (point)))))
1822 (goto-char (next-overlay-change (point))))) 1828 ;; See if invisibility reaches up thru END.
1823 ;; See if invisibility reaches up thru END. 1829 (if (>= (point) end)
1824 (if (>= (point) end) 1830 (if (and can-be-opened (consp crt-overlays))
1825 (if (and (not (null can-be-opened)) (consp crt-overlays)) 1831 (progn
1826 (progn 1832 (setq isearch-opened-overlays
1827 (setq isearch-opened-overlays 1833 (append isearch-opened-overlays crt-overlays))
1828 (append isearch-opened-overlays crt-overlays)) 1834 (mapc 'isearch-open-overlay-temporary crt-overlays)
1829 (mapc 'isearch-open-overlay-temporary crt-overlays) 1835 nil)
1830 nil) 1836 (setq isearch-hidden t)))))))
1831 t))))))
1832 1837
1833 1838
1834;; Highlighting 1839;; Highlighting