unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
@ 2019-10-23  9:23 Michael Heerdegen
  2019-10-23  9:40 ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2019-10-23  9:23 UTC (permalink / raw)
  To: 37883


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






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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-23  9:23 bug#37883: 27.0.50; read-file-name: Scrambled INITIAL Michael Heerdegen
@ 2019-10-23  9:40 ` Andreas Schwab
  2019-10-23 12:40   ` Michael Heerdegen
  2019-10-23 15:16   ` Michael Heerdegen
  0 siblings, 2 replies; 9+ messages in thread
From: Andreas Schwab @ 2019-10-23  9:40 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 37883

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@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."





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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-23  9:40 ` Andreas Schwab
@ 2019-10-23 12:40   ` Michael Heerdegen
  2019-10-23 13:20     ` Michael Albinus
  2019-10-23 15:16   ` Michael Heerdegen
  1 sibling, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2019-10-23 12:40 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 37883

Andreas Schwab <schwab@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.





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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-23 12:40   ` Michael Heerdegen
@ 2019-10-23 13:20     ` Michael Albinus
  2019-10-23 14:53       ` Michael Heerdegen
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2019-10-23 13:20 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Andreas Schwab, 37883

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Andreas Schwab <schwab@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.





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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-23 13:20     ` Michael Albinus
@ 2019-10-23 14:53       ` Michael Heerdegen
  2019-10-23 16:24         ` Michael Albinus
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2019-10-23 14:53 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Andreas Schwab, 37883

Michael Albinus <michael.albinus@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.





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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-23  9:40 ` Andreas Schwab
  2019-10-23 12:40   ` Michael Heerdegen
@ 2019-10-23 15:16   ` Michael Heerdegen
  1 sibling, 0 replies; 9+ messages in thread
From: Michael Heerdegen @ 2019-10-23 15:16 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 37883

Andreas Schwab <schwab@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.





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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-23 14:53       ` Michael Heerdegen
@ 2019-10-23 16:24         ` Michael Albinus
  2019-10-25  8:45           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2019-10-23 16:24 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Andreas Schwab, 37883

Michael Heerdegen <michael_heerdegen@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.





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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-23 16:24         ` Michael Albinus
@ 2019-10-25  8:45           ` Eli Zaretskii
  2022-01-28 16:04             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2019-10-25  8:45 UTC (permalink / raw)
  To: Michael Albinus; +Cc: michael_heerdegen, schwab, 37883

> From: Michael Albinus <michael.albinus@gmx.de>
> Date: Wed, 23 Oct 2019 18:24:55 +0200
> Cc: Andreas Schwab <schwab@suse.de>, 37883@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?





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

* bug#37883: 27.0.50; read-file-name: Scrambled INITIAL
  2019-10-25  8:45           ` Eli Zaretskii
@ 2022-01-28 16:04             ` Lars Ingebrigtsen
  0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-28 16:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: michael_heerdegen, schwab, Michael Albinus, 37883

Eli Zaretskii <eliz@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





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

end of thread, other threads:[~2022-01-28 16:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23  9:23 bug#37883: 27.0.50; read-file-name: Scrambled INITIAL Michael Heerdegen
2019-10-23  9:40 ` Andreas Schwab
2019-10-23 12:40   ` Michael Heerdegen
2019-10-23 13:20     ` Michael Albinus
2019-10-23 14:53       ` Michael Heerdegen
2019-10-23 16:24         ` Michael Albinus
2019-10-25  8:45           ` Eli Zaretskii
2022-01-28 16:04             ` Lars Ingebrigtsen
2019-10-23 15:16   ` Michael Heerdegen

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).