unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Alerts for saves to non-existent files
@ 2012-08-29 12:21 kj
  2012-08-29 14:54 ` Peter Dyballa
  2012-08-29 17:04 ` Joost Kremers
  0 siblings, 2 replies; 6+ messages in thread
From: kj @ 2012-08-29 12:21 UTC (permalink / raw)
  To: help-gnu-emacs




It often happens that I move or rename the file "underlying" some
buffer in an ongoing Emacs session and (for various reasons) fail
to make the appropriate change in Emacs, with the result that I
end up inadvertently saving changes to the old location.  This
often leads to unnecessary puzzlement (e.g. changes to an input
file fail to have the expected effects, etc.).

Therefore, I'm looking for a way to have Emacs notice when an
attempt is made to save to a file that no longer exists.  (Of
course, this scenario has to be distinguished somehow from the one
in which the intent is to *create* a file by saving a buffer for
the first time, but maybe it is enough to somehow associate a "first
save" flag with the buffer.)

Is there a way to tell Emacs that, from now on, it should save all
changes to this buffer to the new path (and preferably without
asking for any additional confirmation)?

(As itches go, this one is mild indeed, but it also has a very long
standing, and for this reason alone it has caused, cumulatively
over 3+ decades, a huge amount of vexation.)

Thanks!


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

* Re: Alerts for saves to non-existent files
  2012-08-29 12:21 Alerts for saves to non-existent files kj
@ 2012-08-29 14:54 ` Peter Dyballa
  2012-08-29 17:04 ` Joost Kremers
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2012-08-29 14:54 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org List


Am 29.08.2012 um 14:21 schrieb kj:

> Is there a way to tell Emacs that, from now on, it should save all
> changes to this buffer to the new path (and preferably without
> asking for any additional confirmation)?

Write the buffer contents at once to the new location!

--
Greetings

 Pete

Some day we may discover how to make magnets that can point in any direction.




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

* Re: Alerts for saves to non-existent files
  2012-08-29 12:21 Alerts for saves to non-existent files kj
  2012-08-29 14:54 ` Peter Dyballa
@ 2012-08-29 17:04 ` Joost Kremers
  2012-08-31 12:35   ` kj
  1 sibling, 1 reply; 6+ messages in thread
From: Joost Kremers @ 2012-08-29 17:04 UTC (permalink / raw)
  To: help-gnu-emacs

kj wrote:
> Is there a way to tell Emacs that, from now on, it should save all
> changes to this buffer to the new path (and preferably without
> asking for any additional confirmation)?

you can use C-x C-w to save a buffer to another file. that doesn't delete
the original file, but using C-x C-w and then deleting the original file
should cause less vexation than your current scenario. ;-)


-- 
Joost Kremers                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

* Re: Alerts for saves to non-existent files
  2012-08-29 17:04 ` Joost Kremers
@ 2012-08-31 12:35   ` kj
  2012-08-31 14:19     ` Raffaele Ricciardi
  2012-09-04 13:59     ` Joost Kremers
  0 siblings, 2 replies; 6+ messages in thread
From: kj @ 2012-08-31 12:35 UTC (permalink / raw)
  To: help-gnu-emacs

In <slrnk3sit9.dkp.joostkremers@j.kremers4.news.arnhem.chello.nl> Joost Kremers <joostkremers@yahoo.com> writes:

>kj wrote:
>> Is there a way to tell Emacs that, from now on, it should save all
>> changes to this buffer to the new path (and preferably without
>> asking for any additional confirmation)?

>you can use C-x C-w to save a buffer to another file. that doesn't delete
>the original file, but using C-x C-w and then deleting the original file
>should cause less vexation than your current scenario. ;-)


No, that doesn't address the problem I tried (but clearly failed)
to describe.  I want to prevent cases in which I *inadvertently*
do C-x C-s, forgetting/not realizing that the current value of
buffer-file-name is a non-existent path.

In fact, I'd be completely satisfied if in such situations Emacs
handled C-x C-s in basically the same way it does for buffers (e.g.
*scratch* or *shell*) whose buffer-file-name is nil, namely by
prompting the user for a "File to save in: ...".  The only difference
between these two cases would be that in the former one, the proposed
path following the prompt would be the (non-existent) path currently
in buffer-file-name, while in the latter it is only directory
prefix, to which the user must add a basename.


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

* Re: Alerts for saves to non-existent files
  2012-08-31 12:35   ` kj
@ 2012-08-31 14:19     ` Raffaele Ricciardi
  2012-09-04 13:59     ` Joost Kremers
  1 sibling, 0 replies; 6+ messages in thread
From: Raffaele Ricciardi @ 2012-08-31 14:19 UTC (permalink / raw)
  To: help-gnu-emacs

On 31/08/12 13:35, kj wrote:
> In <slrnk3sit9.dkp.joostkremers@j.kremers4.news.arnhem.chello.nl> Joost Kremers <joostkremers@yahoo.com> writes:
>
>> kj wrote:
>>> Is there a way to tell Emacs that, from now on, it should save all
>>> changes to this buffer to the new path (and preferably without
>>> asking for any additional confirmation)?
>
>> you can use C-x C-w to save a buffer to another file. that doesn't delete
>> the original file, but using C-x C-w and then deleting the original file
>> should cause less vexation than your current scenario. ;-)
>
>
> No, that doesn't address the problem I tried (but clearly failed)
> to describe.  I want to prevent cases in which I *inadvertently*
> do C-x C-s, forgetting/not realizing that the current value of
> buffer-file-name is a non-existent path.
>
> In fact, I'd be completely satisfied if in such situations Emacs
> handled C-x C-s in basically the same way it does for buffers (e.g.
> *scratch* or *shell*) whose buffer-file-name is nil, namely by
> prompting the user for a "File to save in: ...".  The only difference
> between these two cases would be that in the former one, the proposed
> path following the prompt would be the (non-existent) path currently
> in buffer-file-name, while in the latter it is only directory
> prefix, to which the user must add a basename.
>

C-h v before-save-hook RET


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

* Re: Alerts for saves to non-existent files
  2012-08-31 12:35   ` kj
  2012-08-31 14:19     ` Raffaele Ricciardi
@ 2012-09-04 13:59     ` Joost Kremers
  1 sibling, 0 replies; 6+ messages in thread
From: Joost Kremers @ 2012-09-04 13:59 UTC (permalink / raw)
  To: help-gnu-emacs

kj wrote:
> In <slrnk3sit9.dkp.joostkremers@j.kremers4.news.arnhem.chello.nl> Joost Kremers <joostkremers@yahoo.com> writes:
>
>>kj wrote:
>>> Is there a way to tell Emacs that, from now on, it should save all
>>> changes to this buffer to the new path (and preferably without
>>> asking for any additional confirmation)?
>
>>you can use C-x C-w to save a buffer to another file. that doesn't delete
>>the original file, but using C-x C-w and then deleting the original file
>>should cause less vexation than your current scenario. ;-)
>
>
> No, that doesn't address the problem I tried (but clearly failed)
> to describe.  I want to prevent cases in which I *inadvertently*
> do C-x C-s, forgetting/not realizing that the current value of
> buffer-file-name is a non-existent path.

Sorry, you did describe it well, I didn't explain very well what I
meant. What I suggested was to change your habit of renaming files from
within the shell to renaming them with C-x C-w in Emacs.

But the before-save-hook that Raffaele mentioned is definitely better... 


-- 
Joost Kremers                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

end of thread, other threads:[~2012-09-04 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-29 12:21 Alerts for saves to non-existent files kj
2012-08-29 14:54 ` Peter Dyballa
2012-08-29 17:04 ` Joost Kremers
2012-08-31 12:35   ` kj
2012-08-31 14:19     ` Raffaele Ricciardi
2012-09-04 13:59     ` Joost Kremers

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