Subject: Re: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers

From: Ihor Radchenko <[email-masked]>
Date: Tue, 12 Dec 2023 23:43:47 +0000

Stefan Monnier <[email-masked]> writes:

>> E.g. company-dabbrev-code creates a dynamic binding for case-fold-search in
>> one place and then calls a function (company-dabbrev--search) that iterates
>> across all buffers with re-search-forward.
>
> BTW, that `company-dabbrev-code` function may not do what you expect
> in those buffers that have set `case-fold-search` buffer-locally.

Yup.

Steps to reproduce:

1. emacs -Q
2. M-: (setq-local case-fold-search nil)
3. C-x b <RET> (to *Messages*)
4. M-: (let ((case-fold-search t)) (with-current-buffer (get-buffer "*scratch*") (search-forward "CREATE")))
5. Observe search failing

If step (2) is omitted, search succeeds.

Although, I am not sure if I like that let-binding is not reliable for
buffer-locals. It is simply confusing from the point of view of let
usage; even if documented. I'd rather go for `let' becoming more consistent.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>