unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Buffer local variables, let bindings, and read-file-name
@ 2013-05-01 18:12 Harald Hanche-Olsen
  2013-05-03  1:14 ` Michael Heerdegen
  0 siblings, 1 reply; 3+ messages in thread
From: Harald Hanche-Olsen @ 2013-05-01 18:12 UTC (permalink / raw)
  To: emacs-devel

Is there a good explanation for the following behaviour?

Background: This is on OS X, which has a case insensitive filesystem,
so read-file-name-completion-ignore-case is accordingly set to t.
Possibly, the problem can be reproduced on other OSs by setting the
variable first; but I haven't checked.

----------------
Now if I create a new buffer and evaluate (read-file-name "file: ")
in the buffer, I get case insensitive completion, and all is well.

But if I evaluate (setq-local completion-ignore-case t) in the buffer
and try (read-file-name "file: ") again, completion is case sensitive.
----------------

How can this be? I see that the code for read-file-name-default does
(let ((completion-ignore-case read-file-name-completion-ignore-case)) …)
i.e., it let binds a buffer local variable to the same value it has
already, namely t. And yet, it behaves as if it were now nil.

I know that there can be difficulties with let bindings and
buffer-local variables, but not this kind of difficulties?

Starting emacs with -Q produces the same result.
This is emacs from trunk as of April 11.

- Harald



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Buffer local variables, let bindings, and read-file-name
  2013-05-01 18:12 Buffer local variables, let bindings, and read-file-name Harald Hanche-Olsen
@ 2013-05-03  1:14 ` Michael Heerdegen
  2013-05-03  7:53   ` Harald Hanche-Olsen
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Heerdegen @ 2013-05-03  1:14 UTC (permalink / raw)
  To: Harald Hanche-Olsen; +Cc: emacs-devel

Hello Harald,

> Is there a good explanation for the following behaviour?
>
> Background: This is on OS X, which has a case insensitive filesystem,
> so read-file-name-completion-ignore-case is accordingly set to t.
> Possibly, the problem can be reproduced on other OSs by setting the
> variable first; but I haven't checked.
>
> ----------------
> Now if I create a new buffer and evaluate (read-file-name "file: ")
> in the buffer, I get case insensitive completion, and all is well.
>
> But if I evaluate (setq-local completion-ignore-case t) in the buffer
> and try (read-file-name "file: ") again, completion is case sensitive.
> ----------------
>
> How can this be? I see that the code for read-file-name-default does
> (let ((completion-ignore-case read-file-name-completion-ignore-case)) …)
> i.e., it let binds a buffer local variable to the same value it has
> already, namely t. And yet, it behaves as if it were now nil.
>
> I know that there can be difficulties with let bindings and
> buffer-local variables, but not this kind of difficulties?
>
> Starting emacs with -Q produces the same result.
> This is emacs from trunk as of April 11.

I can reproduce this here with Debian Linux.  I started emacs -Q,
evaluated

  (setq read-file-name-completion-ignore-case t)

(it defaults to nil in my case), and followed your recipe step by step.
And I get exactly the same behavior.  Simply looks like a bug, probably
in the (newly written) completion code.

Please make a bug report (M-x report-emacs-bug), include your recipe and
please also mention that it's the same with Linux.

Sorry for the late reply (where is Stefan?), and thanks for letting us
know.


Regards,

Michael.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Buffer local variables, let bindings, and read-file-name
  2013-05-03  1:14 ` Michael Heerdegen
@ 2013-05-03  7:53   ` Harald Hanche-Olsen
  0 siblings, 0 replies; 3+ messages in thread
From: Harald Hanche-Olsen @ 2013-05-03  7:53 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: emacs-devel

[Michael Heerdegen <michael_heerdegen@web.de> (2013-05-03 01:14:30 UTC)]

> > ----------------
> > Now if I create a new buffer and evaluate (read-file-name "file: ")
> > in the buffer, I get case insensitive completion, and all is well.
> >
> > But if I evaluate (setq-local completion-ignore-case t) in the buffer
> > and try (read-file-name "file: ") again, completion is case sensitive.
> > ----------------
> 
> I can reproduce this here with Debian Linux.  I started emacs -Q,
> evaluated
> 
>   (setq read-file-name-completion-ignore-case t)
> 
> (it defaults to nil in my case), and followed your recipe step by step.
> And I get exactly the same behavior.  Simply looks like a bug, probably
> in the (newly written) completion code.

Thanks for confirming this.

> Please make a bug report (M-x report-emacs-bug), include your recipe and
> please also mention that it's the same with Linux.

Done. 14340: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14340

I also added a bit of analysis. It's short enough to repeat here:

read-file-name-default let binds completion-ignore-case to the value of
read-file-name-completion-ignore-case before doing a pile of setup
work and calling completing-read.

When completion-ignore-case is buffer local, let overrides the buffer
local binding and not the global binding. But because completing-read
evaluates the variable in the minibuffer, it gets the global value
instead, i.e., nil.

(I may be wrong about some details in this, but I but this is the gist
of the problem.)

- Harald



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-03  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-01 18:12 Buffer local variables, let bindings, and read-file-name Harald Hanche-Olsen
2013-05-03  1:14 ` Michael Heerdegen
2013-05-03  7:53   ` Harald Hanche-Olsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).