From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: search-invisible and friends Date: Thu, 10 Sep 2020 21:11:07 +0300 Organization: LINKOV.NET Message-ID: <87d02tbits.fsf@mail.linkov.net> References: <87zh5z9l9y.fsf@gnus.org> <838sdjko39.fsf@gnu.org> <871rj9957z.fsf@gnus.org> <83a6xxk8nj.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11022"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: Eli Zaretskii , Lars Ingebrigtsen , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 10 20:19:57 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGRAr-0002la-Nq for ged-emacs-devel@m.gmane-mx.org; Thu, 10 Sep 2020 20:19:57 +0200 Original-Received: from localhost ([::1]:48096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGRAq-0002zX-Qw for ged-emacs-devel@m.gmane-mx.org; Thu, 10 Sep 2020 14:19:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGR8N-0000PP-MD for emacs-devel@gnu.org; Thu, 10 Sep 2020 14:17:26 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:55585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGR8J-0002Ak-0i; Thu, 10 Sep 2020 14:17:23 -0400 X-Originating-IP: 91.129.97.241 Original-Received: from mail.gandi.net (m91-129-97-241.cust.tele2.ee [91.129.97.241]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 320111BF205; Thu, 10 Sep 2020 18:17:12 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Thu, 10 Sep 2020 11:03:06 -0400") Received-SPF: pass client-ip=217.70.183.201; envelope-from=juri@linkov.net; helo=relay8-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 14:17:15 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:255029 Archived-At: >>> Ah, yeah, that sounds quite useful and natural. We could even have a >>> standard property like `no-search' that could be part of the default >>> `search-invisible' value, so that modes can easily mark out regions that >>> shouldn't be searched for. In which case, the whole `display' thing >>> becomes moot -- in my mode, I could just slap the `no-search' property >>> on all the image display bits that I want isearch to avoid? >> Yes, those were my thoughts. > > It'd be good to have such a `no-search` property, Like dired-isearch-filter-filenames adds own filter, this could be implemented like: (defun isearch-filter-no-search (beg end) (not (text-property-not-all (min beg end) (max beg end) 'no-search nil))) (add-function :before-while (local 'isearch-filter-predicate) #'isearch-filter-no-search) (insert (propertize "foo" 'display "bar" 'no-search t)) > but I think it's also important to make the `search-invisible` > automatically handle text that's hidden by a `display` property, > without having to add an explicit `no-search`. Maybe like this: (defun isearch-filter-display (beg end) (not (text-property-not-all (min beg end) (max beg end) 'display nil))) (add-function :before-while (local 'isearch-filter-predicate) #'isearch-filter-display) (insert (propertize "foo" 'display "bar")) > OTOH, maybe there could be unusual circumstances where it would make > sense to consider hidden text as "visible" (e.g. if the `display` > property replaces the text with something that looks very much like the > same text, tho maybe rendered a bit differently). Do you mean to match text in the display replacement, i.e. the string "bar"? This is more complicated but it's possible by using get-text-property and string-match to match the search string in the display property.