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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 17 Dec 2023 14:14:55 +0200

> From: Ihor Radchenko <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked],
>  [email-masked]
> Date: Sun, 17 Dec 2023 11:26:28 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> > Maybe I'm confused, but won't this change have at least _some_ effect
> >> > on Lisp programs?  For example, what about this fragment from the
> >> > ELisp manual, which describes the effect of
> >> > make-variable-buffer-local:
> >> >
> >> >      A peculiar wrinkle of this feature is that binding the variable
> >> >      (with ‘let’ or other binding constructs) does not create a
> >> >      buffer-local binding for it.  Only setting the variable (with ‘set’
> >> >      or ‘setq’), while the variable does not have a ‘let’-style binding
> >> >      that was made in the current buffer, does so.
> >> >
> >> > Will this case work the same after the change as it did before?
> >> 
> >> I read this differently
> >
> > Differently from what?
> 
> AFAIU, you are concerned that my call to Fmake_variable_buffer_local may
> have unexpected side effects because make-variable-buffer-local can be
> tricky, as stated in the quoted paragraph.
> But it is not how I read this.
> 
> Or did you mean something else?

I meant to ask whether the behavior with case-fold-search before your
changes in the context of the above situation differs from its
behavior after the changes.

> 
> >> - when you have
> >> 
> >>    (let ((var 'val))
> >>     (make-variable-buffer-local 'var))
> >> 
> >> it will not set buffer-local value to 'val.
> >
> > And before the patch what would have happened?
> 
> I did not make changes to `make-variable-buffer-local' in the patch.
> Nothing changed there. I just wanted to make sure that we understand
> that paragraph the same way - that `make-variable-buffer-local' has
> "wrinkle" when called inside let context.
> 
> >> And the patch makes `case-fold-search' buffer-local internally. Nothing
> >> needs to call (make-variable-buffer-local 'case-fold-search).
> >
> > The patch itself calls make-variable-buffer-local.
> 
> On top level, when Emacs defines all other variables. So, my call to
> make-variable-buffer-local is not inside let and thus should not have
> any problem with the paragraph you quoted.

I think this is a misunderstanding: the quote from the ELisp manual
doesn't describe the situation where make-variable-buffer-local is
called inside a let-binding.  It is describing the behavior of 'let'
when the variable was made buffer-local via make-variable-buffer-local.