From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers Date: Wed, 13 Dec 2023 14:32:21 +0000 Message-ID: <87fs06w4ui.fsf@localhost> References: <878r919qfh.fsf@localhost> <87cyxqzmhh.fsf@localhost> <83zg0uzlgw.fsf@gnu.org> <87v8bhxzcu.fsf@localhost> <83y1gdxws8.fsf@gnu.org> <87jzrwm7ul.fsf@localhost> <87h6n0m781.fsf@localhost> <87v8935wik.fsf@localhost> <83msuftr0i.fsf@gnu.org> <87plzbxtxa.fsf@localhost> <87y1dzvvf0.fsf@localhost> <83plzas3pg.fsf@gnu.org> <87r0jqw8u9.fsf@localhost> <83jzpis08a.fsf@gnu.org> <87il52w744.fsf@localhost> <83fs06rz10.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24273"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, 66117@debbugs.gnu.org, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 13 15:30:16 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rDQFc-00066G-73 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Dec 2023 15:30:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDQFF-0007iX-Jl; Wed, 13 Dec 2023 09:29:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDQFA-0007h7-IR for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 09:29:48 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rDQF8-0007pd-St for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 09:29:48 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rDQFO-0007yZ-77 for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 09:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Dec 2023 14:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66117 X-GNU-PR-Package: emacs Original-Received: via spool by 66117-submit@debbugs.gnu.org id=B66117.170247778330616 (code B ref 66117); Wed, 13 Dec 2023 14:30:02 +0000 Original-Received: (at 66117) by debbugs.gnu.org; 13 Dec 2023 14:29:43 +0000 Original-Received: from localhost ([127.0.0.1]:58477 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDQF4-0007xj-Up for submit@debbugs.gnu.org; Wed, 13 Dec 2023 09:29:43 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:58589) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDQF0-0007xO-EW for 66117@debbugs.gnu.org; Wed, 13 Dec 2023 09:29:41 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id E8D9C240027 for <66117@debbugs.gnu.org>; Wed, 13 Dec 2023 15:29:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1702477755; bh=Sk1A/Tcpxz/5vkpeImrWe25OT6v2F4Ev5veDGg4jbdo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=VWN4Q2nO15CDDEQ5gpHCZDjQ0BAh6kURuQTMUis5DSMobjinLn2q+o+P06FOCd6uE wi5CYWTJw3c82fdgRqDfx2nRU6awn9EmHuXx8C4nvxtg8xzjqTDRVmoJABC7m2EoD4 FQNYnxdGRxogEj2TiM3Ox98Nh3lR325KlYDlyWdefp7EWTG5PXvXHajjZuDMm0lHAU 9yFbsduzFPQ4m4cFkwbiX/x3RjG4bbE7SBd1R0gkkhQ30aMQf2W4iMJNomfp35HSLk Dwd0pi07caJdcZSUjtMKjDWzhGSlUrc2qKbnKFwW262CCsA6gy1OaHOeZZA/wPyN19 Rad5JPakHyxVA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SqyXp54JQz6tvs; Wed, 13 Dec 2023 15:29:14 +0100 (CET) In-Reply-To: <83fs06rz10.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276137 Archived-At: Eli Zaretskii writes: >> ;; Each call to ido-ignore-item-p LET-binds case-fold-search. >> ;; That is slow if there's no buffer-local binding available, >> ;; roughly O(number of buffers). This hack avoids it. >> (setq-local case-fold-search nil) >>=20 >> But it will only solve specific problem with `find-buffer-visiting' and >> we can always go for it if we cannot find anything better. > > Which other popular functions need to loop through all the buffers in > Lisp? Org mode... When activating the major mode, Org binds case-fold-search many times - for each Org buffer being opened. The same with happen for other major modes that let-bind case-fold-search during initialization. Also, various multi-buffer search functions, like multi-occur, tag search (etags.el), fileloop.el. >> I thought that trying to solve a more general problem would benefit more >> code - let-binding case-fold-search is extremely common across packages. > > IMO, the general way you are trying to solve this makes this a very > hard problem with potentially Emacs-wide implications. So we might as > well look for easier alternatives. The solution with Emacs-wide implications is not what I proposed, if you are talking about breaking changes in let. What I proposed might slow thing down because of more complex BVAR, but that is yet to be proven. I want to try first before giving up. > We could, for example, document the above trick, for those who need > it. > > Or we could have a separate variable, which would not be a defcustom > nor automatically buffer-local, and will have the same effect as > case-fold-search on low-level searching and matching functions. That's indeed another option. Also, we may introduce something similar to `with-syntax-table' macro - `with-case-fold' and then throw a warning if case-fold-search is let-bound directly. > Btw, are you aware that many case-insensitive operations in Emacs > depend also on the case table in effect, which can also be > buffer-local? So case-insensitive operations in Lisp can be > unexpectedly affected by stuff like the current buffer. One more > reason to use them as little as possible. ... and syntax-table can be set in text properties; so not just affected by current buffer - also by position in buffer. Yet, it is sometimes necessary and there is no simple way around available. In the past, me and Mattias Engdeg=C3=A5rd even discussed a possibility to incorporate case-fold-search flag into regexps directly (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63225#74) That way, things would be less affected by the buffer-locals. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at