GNU bug report logs -
#8721
isearch does not handle list values for `invisible' property
Previous Next
Reported by: Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>
Date: Mon, 23 May 2011 23:53:01 UTC
Severity: normal
Tags: patch
Found in version 24.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#8721: isearch does not handle list values for `invisible' property
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 8721 <at> debbugs.gnu.org.
--
8721: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8721
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
> Attached patch fixes the issue by using `invisible-p' function instead of
> custom checks.
Thanks for catching this. I installed your very nice patch on the trunk,
Stefan
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
Package: emacs
Version: 24.0.50
Tags: patch
Isearch allows searching in hidden text by showing invisible overlays.
But it does not work with overlays which have a list value for
`invisible' property.
Attached patch fixes the issue by using `invalid-p' function instead of
custom checks.
The second patch fixes another related issue.
Regards,
Dmitry
[1-use-invisible-p-in-isearch-range-invisible.patch (text/x-diff, inline)]
isearch.el (isearch-range-invisible): use `invisible-p' instead of custom checks
Isearch allows searching in hidden text by showing invisible overlays.
The `isearch-range-invisible' function needs to check if a character
is visible and which overlays make it invisible. Before the change,
this was done using direct checks of properties and
`buffer-invisibility-spec' variable. Besides making code more
complex, the checks were not complete: it did not handle case when
`invisible' property is a list. The patch replaces the custom checks
with `invisible-p' function.
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el 2011-05-03 03:34:26 +0000
+++ lisp/isearch.el 2011-05-23 23:20:05 +0000
@@ -2417,66 +2417,57 @@ update the match data, and return point.
(overlay-put ov 'intangible (overlay-get ov 'isearch-intangible))
(overlay-put ov 'isearch-invisible nil)
(overlay-put ov 'isearch-intangible nil)))))))
(defun isearch-range-invisible (beg end)
"Return t if all the text from BEG to END is invisible."
(when (/= beg end)
;; Check that invisibility runs up to END.
(save-excursion
(goto-char beg)
(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))
(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)
- (let ((prop
- (get-char-property (point) 'invisible)))
- (if (eq buffer-invisibility-spec t)
- prop
- (or (memq prop buffer-invisibility-spec)
- (assq prop buffer-invisibility-spec)))))
+ (while (and (< (point) end) (invisible-p (point)))
(if (get-text-property (point) 'invisible)
(progn
(goto-char (next-single-property-change (point) 'invisible
nil end))
;; if text is hidden by an `invisible' text property
;; we cannot open it at all.
(setq can-be-opened nil))
(when can-be-opened
(let ((overlays (overlays-at (point)))
ov-list
o
invis-prop)
(while overlays
(setq o (car overlays)
invis-prop (overlay-get o 'invisible))
- (if (if (eq buffer-invisibility-spec t)
- invis-prop
- (or (memq invis-prop buffer-invisibility-spec)
- (assq invis-prop buffer-invisibility-spec)))
+ (if (invisible-p invis-prop)
(if (overlay-get o 'isearch-open-invisible)
(setq ov-list (cons o ov-list))
;; We found one overlay that cannot be
;; opened, that means the whole chunk
;; cannot be opened.
(setq can-be-opened nil)))
(setq overlays (cdr overlays)))
(if can-be-opened
;; It makes sense to append to the open
;; overlays list only if we know that this is
;; t.
(setq crt-overlays (append ov-list crt-overlays)))))
(goto-char (next-overlay-change (point)))))
;; See if invisibility reaches up thru END.
(if (>= (point) end)
(if (and can-be-opened (consp crt-overlays))
(progn
(setq isearch-opened-overlays
(append isearch-opened-overlays crt-overlays))
(mapc 'isearch-open-overlay-temporary crt-overlays)
[2-improve-invisible-text-propery-check-in-isearch-range-invisible.patch (text/x-diff, inline)]
isearch.el (isearch-range-invisible): improve `invisible' text property check
Isearch does not search in text hidden with `invisible' text property.
Before the change, `isearch-range-invisible' function checked if
`invisible' text property is set. But it did not check if the text
property really makes the text invisible. This results in isearch not
searching a visible text in some cases. The patch uses `invisible-p'
function to check if the `invisible' text property really makes the
text invisible.
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el 2011-05-23 23:20:05 +0000
+++ lisp/isearch.el 2011-05-23 23:44:16 +0000
@@ -2418,41 +2418,41 @@ update the match data, and return point.
(overlay-put ov 'isearch-invisible nil)
(overlay-put ov 'isearch-intangible nil)))))))
(defun isearch-range-invisible (beg end)
"Return t if all the text from BEG to END is invisible."
(when (/= beg end)
;; Check that invisibility runs up to END.
(save-excursion
(goto-char beg)
(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))
(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 (get-text-property (point) 'invisible)
+ (if (invisible-p (get-text-property (point) 'invisible))
(progn
(goto-char (next-single-property-change (point) 'invisible
nil end))
;; if text is hidden by an `invisible' text property
;; we cannot open it at all.
(setq can-be-opened nil))
(when can-be-opened
(let ((overlays (overlays-at (point)))
ov-list
o
invis-prop)
(while overlays
(setq o (car overlays)
invis-prop (overlay-get o 'invisible))
(if (invisible-p invis-prop)
(if (overlay-get o 'isearch-open-invisible)
(setq ov-list (cons o ov-list))
;; We found one overlay that cannot be
;; opened, that means the whole chunk
;; cannot be opened.
This bug report was last modified 14 years and 57 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.