GNU bug report logs - #37883
27.0.50; read-file-name: Scrambled INITIAL

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Wed, 23 Oct 2019 09:24:02 UTC

Severity: normal

Found in version 27.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37883 in the body.
You can then email your comments to 37883 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Wed, 23 Oct 2019 09:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 23 Oct 2019 09:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; read-file-name: Scrambled INITIAL
Date: Wed, 23 Oct 2019 11:23:47 +0200
Hello,

in emacs -Q (with default-directory -> ~/)

  (read-file-name-default "File: " nil nil nil "~/.bash_history" nil)

prompts with default minibuffer contents "/:~/~/.bash_history".  No part
of that is shadowed (to indicate which part is meaningful).  Without
fully understanding how the initial contents are calculated, it doesn't
seem very useful with the doubled ~/.  Why can't INITIAL be used
literally?

TIA,

Michael.


In GNU Emacs 27.0.50 (build 27, x86_64-pc-linux-gnu, GTK+ Version 3.24.12)
 of 2019-10-23 built on drachen
Repository revision: 39ba44f18445c7759de5ac91ce25e53123c2abeb
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux bullseye/sid





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Wed, 23 Oct 2019 09:41:02 GMT) Full text and rfc822 format available.

Message #8 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Wed, 23 Oct 2019 11:40:30 +0200
On Okt 23 2019, Michael Heerdegen wrote:

> in emacs -Q (with default-directory -> ~/)
>
>   (read-file-name-default "File: " nil nil nil "~/.bash_history" nil)
>
> prompts with default minibuffer contents "/:~/~/.bash_history".  No part
> of that is shadowed (to indicate which part is meaningful).  Without
> fully understanding how the initial contents are calculated, it doesn't
> seem very useful with the doubled ~/.  Why can't INITIAL be used
> literally?

I think INITIAL is supposed to be a file name component, not a full file
name.  (The manual also discourages the use of INITIAL.)

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Wed, 23 Oct 2019 12:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Andreas Schwab <schwab <at> suse.de>
Cc: 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Wed, 23 Oct 2019 14:40:38 +0200
Andreas Schwab <schwab <at> suse.de> writes:

> > in emacs -Q (with default-directory -> ~/)
> >
> >   (read-file-name-default "File: " nil nil nil "~/.bash_history" nil)
> >
> > prompts with default minibuffer contents "/:~/~/.bash_history".  No part
> > of that is shadowed (to indicate which part is meaningful).  Without
> > fully understanding how the initial contents are calculated, it doesn't
> > seem very useful with the doubled ~/.  Why can't INITIAL be used
> > literally?
>
> I think INITIAL is supposed to be a file name component, not a full file
> name.  (The manual also discourages the use of INITIAL.)

I have no clue.  The manual describes INITIAL as "initial file name".

I think the INITIAL arg can be casually useful.  In my case I'm setting
the value of a (file name valued) widget with the current value as
INITIAL value which feels quite natural (or, would feel, if it worked as
I expect).


Regards,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Wed, 23 Oct 2019 13:22:01 GMT) Full text and rfc822 format available.

Message #14 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Andreas Schwab <schwab <at> suse.de>, 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Wed, 23 Oct 2019 15:20:45 +0200
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Andreas Schwab <schwab <at> suse.de> writes:
>
>> > in emacs -Q (with default-directory -> ~/)
>> >
>> >   (read-file-name-default "File: " nil nil nil "~/.bash_history" nil)
>> >
>> > prompts with default minibuffer contents "/:~/~/.bash_history".  No part
>> > of that is shadowed (to indicate which part is meaningful).  Without
>> > fully understanding how the initial contents are calculated, it doesn't
>> > seem very useful with the doubled ~/.  Why can't INITIAL be used
>> > literally?
>>
>> I think INITIAL is supposed to be a file name component, not a full file
>> name.  (The manual also discourages the use of INITIAL.)
>
> I have no clue.  The manual describes INITIAL as "initial file name".

The docstring of `read-file-name' says

--8<---------------cut here---------------start------------->8---
If DEFAULT-FILENAME is omitted or nil, then if INITIAL is non-nil, the
default is DIR combined with INITIAL
--8<---------------cut here---------------end--------------->8---

> Regards,
>
> Michael.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Wed, 23 Oct 2019 14:54:02 GMT) Full text and rfc822 format available.

Message #17 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Andreas Schwab <schwab <at> suse.de>, 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Wed, 23 Oct 2019 16:53:15 +0200
Michael Albinus <michael.albinus <at> gmx.de> writes:

> The docstring of `read-file-name' says
>
> If DEFAULT-FILENAME is omitted or nil, then if INITIAL is non-nil, the
> default is DIR combined with INITIAL

But I'm talking about the initial minibuffer contents, not the default.
Is it due to historic reasons that the initial contents resemble this
default?

What you cite also doesn't explain why this combination happens in the
way it does.  The doubled ~/ seems not useful, and the /: is...some
Tramp thing?

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Wed, 23 Oct 2019 15:17:02 GMT) Full text and rfc822 format available.

Message #20 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Andreas Schwab <schwab <at> suse.de>
Cc: 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Wed, 23 Oct 2019 17:16:36 +0200
Andreas Schwab <schwab <at> suse.de> writes:

> (The manual also discourages the use of INITIAL.)

BTW, what the manual says: "*Please note:* we recommend using DEFAULT
rather than INITIAL in most cases." - maybe that could be a bit more
precise?  Which cases - what's problematic with using INITIAL in these
cases?  Why doesn't the docstring say that INITIAL is not recommended?
Should developers better use alternatives (I guess one could use
`minibuffer-setup-hook' to insert a default), or is any initial
minibuffer content considered "bad"?

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Wed, 23 Oct 2019 16:26:01 GMT) Full text and rfc822 format available.

Message #23 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Andreas Schwab <schwab <at> suse.de>, 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Wed, 23 Oct 2019 18:24:55 +0200
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

Hi Michael,

>> The docstring of `read-file-name' says
>>
>> If DEFAULT-FILENAME is omitted or nil, then if INITIAL is non-nil, the
>> default is DIR combined with INITIAL
>
> But I'm talking about the initial minibuffer contents, not the default.
> Is it due to historic reasons that the initial contents resemble this
> default?

It is not said explicitly, but INITIAL is expected to be a trailing
string of DEFAULT-FILENAME, where the cursor stays in the minibuffer.

And yes, in your case (with a nil DIR and a nil DEFAUL-FILENAME), DIR is
set to "~/", and DEFAUL-FILENAME is set to "~/.bash_history". Finally,
(minibuffer-maybe-quote-filename (concat dir initial)) is called.
(concat dir initial) expands to "~/~/.bash_history", and
(minibuffer-maybe-quote-filename ...) adds the leading "/:".

You better call (read-file-name-default "File: " "~/" nil nil ".bash_history" nil)

If read-file-name-default does not satisfy your needs, you might write
your own read-file-name-function, and bind it to
read-file-name-function.

> What you cite also doesn't explain why this combination happens in the
> way it does.  The doubled ~/ seems not useful, and the /: is...some
> Tramp thing?

It isn't Tramp, rather the contrary. "/:" marks quoted file names,
i.e. file names which shouldn't be given to a file name handler.

> Michael.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Fri, 25 Oct 2019 08:46:02 GMT) Full text and rfc822 format available.

Message #26 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: michael_heerdegen <at> web.de, schwab <at> suse.de, 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Fri, 25 Oct 2019 11:45:18 +0300
> From: Michael Albinus <michael.albinus <at> gmx.de>
> Date: Wed, 23 Oct 2019 18:24:55 +0200
> Cc: Andreas Schwab <schwab <at> suse.de>, 37883 <at> debbugs.gnu.org
> 
> >> The docstring of `read-file-name' says
> >>
> >> If DEFAULT-FILENAME is omitted or nil, then if INITIAL is non-nil, the
> >> default is DIR combined with INITIAL
> >
> > But I'm talking about the initial minibuffer contents, not the default.
> > Is it due to historic reasons that the initial contents resemble this
> > default?
> 
> It is not said explicitly, but INITIAL is expected to be a trailing
> string of DEFAULT-FILENAME, where the cursor stays in the minibuffer.
> 
> And yes, in your case (with a nil DIR and a nil DEFAUL-FILENAME), DIR is
> set to "~/", and DEFAUL-FILENAME is set to "~/.bash_history". Finally,
> (minibuffer-maybe-quote-filename (concat dir initial)) is called.
> (concat dir initial) expands to "~/~/.bash_history", and
> (minibuffer-maybe-quote-filename ...) adds the leading "/:".
> 
> You better call (read-file-name-default "File: " "~/" nil nil ".bash_history" nil)
> 
> If read-file-name-default does not satisfy your needs, you might write
> your own read-file-name-function, and bind it to
> read-file-name-function.

Would someone like to suggest a documentation change to clarify these
issues?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37883; Package emacs. (Fri, 28 Jan 2022 16:06:02 GMT) Full text and rfc822 format available.

Message #29 received at 37883 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: michael_heerdegen <at> web.de, schwab <at> suse.de,
 Michael Albinus <michael.albinus <at> gmx.de>, 37883 <at> debbugs.gnu.org
Subject: Re: bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
Date: Fri, 28 Jan 2022 17:04:52 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> Would someone like to suggest a documentation change to clarify these
> issues?

The semantics of INITIAL are very odd, and I'm not sure they can be
explained.  So I've now added some hand-waving to the doc read-file-name
doc string, which should at least allow the users to know that it's a
bit odd.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 37883 <at> debbugs.gnu.org and Michael Heerdegen <michael_heerdegen <at> web.de> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 28 Jan 2022 16:06:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 26 Feb 2022 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 53 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.