Reload file from disk

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Reload file from disk

Florian Weimer
Some time ago, it was possible to reload the current buffer from disk
using C-x C-f RET.  This was changed to run dired instead.  The
argument at the time was you could use C-x C-f M-n RET to reload the
current buffer, and that dired was more important.  The behavior of
M-n is documented for find-file at al.:

| but the visited file name is available through the minibuffer
| history: type M-n to pull it into the minibuffer.

But over the years, C-x C-f M-n RET started doing more and more
bizarre things.  It now inserts the file name at point in the buffer,
which is particularly annoying if you try to reload a ChangeLog file.
And I just noticed that when on a domain name such as example.com, it
will apparently attempt to ping that host.

Can we please make M-n behave as documented in this context, or even
better, revert to the old C-x C-f RET behavior?  One could always
browse the current directory using C-x C-f . RET, which is why never
understood the motivation behind that change.

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Eli Zaretskii
> From: Florian Weimer <[hidden email]>
> Date: Sat, 11 Nov 2017 10:17:18 +0100
>
> | but the visited file name is available through the minibuffer
> | history: type M-n to pull it into the minibuffer.
>
> But over the years, C-x C-f M-n RET started doing more and more
> bizarre things.  It now inserts the file name at point in the buffer,
> which is particularly annoying if you try to reload a ChangeLog file.

It does?  I cannot reproduce this in "emacs -Q".  Could it be that you
have some optional package activated which does that?  If not, can you
show a recipe starting from "emacs -Q" that reproduces the behavior
you describe?

> And I just noticed that when on a domain name such as example.com, it
> will apparently attempt to ping that host.

This I can reproduce, and you can disable it by customizing
file-name-at-point-functions to a nil value.

> Can we please make M-n behave as documented in this context, or even
> better, revert to the old C-x C-f RET behavior?  One could always
> browse the current directory using C-x C-f . RET, which is why never
> understood the motivation behind that change.

The previous behavior of "C-x C-f RET" was considered confusing and
not very useful by many users, so I don't think we want to go back
there.

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Eli Zaretskii
> Date: Sat, 11 Nov 2017 12:29:24 +0200
> From: Eli Zaretskii <[hidden email]>
> Cc: [hidden email]
>
> > But over the years, C-x C-f M-n RET started doing more and more
> > bizarre things.  It now inserts the file name at point in the buffer,
> > which is particularly annoying if you try to reload a ChangeLog file.
>
> It does?  I cannot reproduce this in "emacs -Q".

Sorry, I see that I misunderstood your somewhat ambiguous wording.  I
see what you meant now, and the answer is the same: customize
file-name-at-point-functions to nil, and both the behaviors that
annoyed you will be gone.

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Florian Weimer
* Eli Zaretskii:

>> Date: Sat, 11 Nov 2017 12:29:24 +0200
>> From: Eli Zaretskii <[hidden email]>
>> Cc: [hidden email]
>>
>> > But over the years, C-x C-f M-n RET started doing more and more
>> > bizarre things.  It now inserts the file name at point in the buffer,
>> > which is particularly annoying if you try to reload a ChangeLog file.
>>
>> It does?  I cannot reproduce this in "emacs -Q".
>
> Sorry, I see that I misunderstood your somewhat ambiguous wording.  I
> see what you meant now, and the answer is the same: customize
> file-name-at-point-functions to nil, and both the behaviors that
> annoyed you will be gone.

The documentation for find-file et al. still could use some updating
and a reference to file-name-at-point-functions.  For some reason, I
was unable to find the latter.

(I still find the default behavior thoroughly bizarre, but that's
probably a matter of taste.)

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Eli Zaretskii
> From: Florian Weimer <[hidden email]>
> Cc: [hidden email]
> Date: Sat, 11 Nov 2017 11:54:57 +0100
>
> > Sorry, I see that I misunderstood your somewhat ambiguous wording.  I
> > see what you meant now, and the answer is the same: customize
> > file-name-at-point-functions to nil, and both the behaviors that
> > annoyed you will be gone.
>
> The documentation for find-file et al. still could use some updating
> and a reference to file-name-at-point-functions.  For some reason, I
> was unable to find the latter.

You are absolutely right, which is why I just updated the
documentation, both the doc strings and the manual, to mention this.
I was astonished to find out that this feature was first introduced in
Emacs 23.2(!), but never mentioned even in NEWS.

> (I still find the default behavior thoroughly bizarre, but that's
> probably a matter of taste.)

I'm with you, but it looks like we are the minority nowadays.

Thanks for bringing up this awful gap in documentation.

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Andreas Schwab-2
In reply to this post by Eli Zaretskii
On Nov 11 2017, Eli Zaretskii <[hidden email]> wrote:

>> Date: Sat, 11 Nov 2017 12:29:24 +0200
>> From: Eli Zaretskii <[hidden email]>
>> Cc: [hidden email]
>>
>> > But over the years, C-x C-f M-n RET started doing more and more
>> > bizarre things.  It now inserts the file name at point in the buffer,
>> > which is particularly annoying if you try to reload a ChangeLog file.
>>
>> It does?  I cannot reproduce this in "emacs -Q".
>
> Sorry, I see that I misunderstood your somewhat ambiguous wording.  I
> see what you meant now, and the answer is the same: customize
> file-name-at-point-functions to nil, and both the behaviors that
> annoyed you will be gone.

Even better, bind revert-buffer to a key.

Andreas.

--
Andreas Schwab, [hidden email]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Noam Postavsky-2
In reply to this post by Florian Weimer
On Sat, Nov 11, 2017 at 4:17 AM, Florian Weimer <[hidden email]> wrote:
> Some time ago, it was possible to reload the current buffer from disk
> using C-x C-f RET.  This was changed to run dired instead.  The
> argument at the time was you could use C-x C-f M-n RET to reload the
> current buffer, and that dired was more important.

I usually use C-x C-v RET for this.
Or if I want to reload because the file changed externally, SPC r
(though the buffer must be in unmodified state for that).

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Ken Olum
In reply to this post by Eli Zaretskii
   From: Eli Zaretskii <[hidden email]>
   Date: Sat, 11 Nov 2017 13:55:26 +0200

   > From: Florian Weimer <[hidden email]>

   > (I still find the default behavior thoroughly bizarre, but that's
   > probably a matter of taste.)

   I'm with you, but it looks like we are the minority nowadays.

I redefined find-file-read-args in my init file to reinstate the old
behavior when the new came out.  How about a variable to control this
for the possibly large minority that prefer the old behavior?

                                          Ken

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Eli Zaretskii
> From: Ken Olum <[hidden email]>
> Date: Sat, 11 Nov 2017 08:45:04 -0500
>
>    > (I still find the default behavior thoroughly bizarre, but that's
>    > probably a matter of taste.)
>
>    I'm with you, but it looks like we are the minority nowadays.
>
> I redefined find-file-read-args in my init file to reinstate the old
> behavior when the new came out.  How about a variable to control this
> for the possibly large minority that prefer the old behavior?

There's already a variable: file-name-at-point-functions.  It just was
undocumented until now.  Given that it's documented, do we still need
a separate knob?

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Ken Olum
   From: Eli Zaretskii <[hidden email]>
   Date: Sat, 11 Nov 2017 16:11:34 +0200

   There's already a variable: file-name-at-point-functions.  It just was
   undocumented until now.  Given that it's documented, do we still need
   a separate knob?

Sorry for the confusion.  I think we're discussing different things
here.  My goal was to have the default for find-file (without typing
M-n) be the current file, so that C-x C-f RET would reload the buffer.
I think file-name-at-point-functions affects only the question of what
you get when you type M-n.

If there are enough people who would like C-x C-f RET to reload the
buffer, perhaps there should be a variable for that.  But perhaps
there are not.  (This has little consequence for me personally, since
I already worked around it a different way.)

                                        Ken

Reply | Threaded
Open this post in threaded view
|

RE: Reload file from disk

Drew Adams
>  My goal was to have the default for find-file (without typing
> M-n) be the current file, so that C-x C-f RET would reload the buffer.

FWIW, y'all should be talking about "finding" a Lisp file
(in the sense of `find-file'), not "loading" a Lisp file
(in the sense of `load-file' and `load-library').

I was confused for a while, because I thought you actually
meant loading (evaluating) the file.  And for loading,
`M-x load-file' _does_ use the current buffer's file as
the default.

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Joost Kremers-2
In reply to this post by Florian Weimer

On Sat, Nov 11 2017, Florian Weimer wrote:
> Some time ago, it was possible to reload the current buffer from
> disk
> using C-x C-f RET.  This was changed to run dired instead.

Try C-x C-v (`find-alternate-file') instead: it defaults to the
file currently being visited by the buffer, so you just need to
type RET to reload it.


--
Joost Kremers
Life has its moments

Reply | Threaded
Open this post in threaded view
|

Re: Reload file from disk

Tom Tromey-4
>>>>> "Joost" == Joost Kremers <[hidden email]> writes:

Joost> On Sat, Nov 11 2017, Florian Weimer wrote:
>> Some time ago, it was possible to reload the current buffer from
>> disk
>> using C-x C-f RET.  This was changed to run dired instead.

Joost> Try C-x C-v (`find-alternate-file') instead: it defaults to the file
Joost> currently being visited by the buffer, so you just need to type RET to
Joost> reload it.

This isn't always as nice as the old behavior of C-x C-f RET because it
moves point to the start of the buffer.

Tom