From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Kurochkin Newsgroups: gmane.emacs.bugs Subject: bug#8721: isearch does not handle list values for `invisible' property Date: Tue, 24 May 2011 03:46:56 +0400 Message-ID: <87mxidq8sv.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1306194811 11622 80.91.229.12 (23 May 2011 23:53:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 May 2011 23:53:31 +0000 (UTC) To: 8721@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 24 01:53:27 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QOew6-0001Bk-U9 for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 May 2011 01:53:23 +0200 Original-Received: from localhost ([::1]:43907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOew6-0006bY-Jw for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 19:53:22 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOevo-0006az-2y for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 19:53:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOevm-0007yG-Sc for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 19:53:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOevm-0007yC-Nc for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 19:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QOevm-0008OR-4S; Mon, 23 May 2011 19:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Kurochkin Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 May 2011 23:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8721 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: submit@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.130619477232237 (code B ref -1); Mon, 23 May 2011 23:53:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 May 2011 23:52:52 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOevb-0008Nu-Vo for submit@debbugs.gnu.org; Mon, 23 May 2011 19:52:52 -0400 Original-Received: from mail-fx0-f44.google.com ([209.85.161.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOepb-0008Dr-MK for submit@debbugs.gnu.org; Mon, 23 May 2011 19:46:40 -0400 Original-Received: by fxm15 with SMTP id 15so4274999fxm.3 for ; Mon, 23 May 2011 16:46:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:user-agent:date:message-id :mime-version:content-type; bh=T44CXumZmgNgT97PgkhXF+WBm2Teum1DByH9wLN1UbM=; b=bFQNkSWrfNXIc7otIQ2nLtAV4/+KQ+Dyf6xVPxTmXDtMf4eyqFi+wzSiI7i+7ZcV09 TfiQtdqVAqGLRLkRpuUsjLRFWR9jeGYrGapNPJEKN9MZZm5hEF9FMTMcT92H0sug5Tfe RiHJp3bdYOxg0nYO+kNQ9sV/K8H67ONUXGlQs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:user-agent:date:message-id:mime-version :content-type; b=cdvnBlGodkBLn8gFRWQNTrj5VioH/+fQlKhEjnRQeYbPnpTZasTu5XX/OJUMsW1jsR ewNMcCs8mqGfqtDjRnww9N9c+FDWE4PV6l3uLBCGjpucEjNUuErpHNsC6Rfq61eqoKwl 4L+JEUNoUXRkgu3hQyZppNyPWGjZ6LYU0r4uo= Original-Received: by 10.223.156.67 with SMTP id v3mr3047273faw.34.1306194393925; Mon, 23 May 2011 16:46:33 -0700 (PDT) Original-Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id j18sm2507154faa.42.2011.05.23.16.46.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 May 2011 16:46:33 -0700 (PDT) User-Agent: Notmuch/0.5-216-g0104e23 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) X-Mailman-Approved-At: Mon, 23 May 2011 19:52:51 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 23 May 2011 19:53:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-Mailman-Approved-At: Mon, 23 May 2011 19:53:20 -0400 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:46670 Archived-At: --=-=-= 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=1-use-invisible-p-in-isearch-range-invisible.patch 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) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename*0*=us-ascii''2-improve-invisible-text-propery-check-in-isearch-r; filename*1*=ange-invisible.patch 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. --=-=-=--