GNU bug report logs -
#67313
[PATCH] New command write-file-no-switch
Previous Next
Reported by: Jeremy Bryant <jb <at> jeremybryant.net>
Date: Mon, 20 Nov 2023 23:38:01 UTC
Severity: normal
Tags: patch
Done: Jeremy Bryant <jb <at> jeremybryant.net>
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 67313 in the body.
You can then email your comments to 67313 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67313
; Package
emacs
.
(Mon, 20 Nov 2023 23:38:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jeremy Bryant <jb <at> jeremybryant.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 20 Nov 2023 23:38:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tags: patch
By default write-file changes the buffer to point to the new filename,
but a user may wish to simply do the equivalent of write-file without
switching, as a sort of backup file.
The attached is a patch concept to introduce the idea. Please let me
know if this makes sense to introduce a new command rather than
modifying the existing one (which may be less convenient). I understand
there would be additional things to do for new commands, but would like
to propose the idea first. Any suggestions welcome.
[0001-New-command-write-file-no-switch.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67313
; Package
emacs
.
(Tue, 21 Nov 2023 11:28:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 67313 <at> debbugs.gnu.org (full text, mbox):
> Date: Mon, 20 Nov 2023 23:33:27 +0000
> From: Jeremy Bryant via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> By default write-file changes the buffer to point to the new filename,
> but a user may wish to simply do the equivalent of write-file without
> switching, as a sort of backup file.
>
> The attached is a patch concept to introduce the idea. Please let me
> know if this makes sense to introduce a new command rather than
> modifying the existing one (which may be less convenient). I understand
> there would be additional things to do for new commands, but would like
> to propose the idea first. Any suggestions welcome.
Why is it not enough to be able to use "M-x write-region"?
In any case, a new command is definitely overkill, IMO.
> + (copy-file buffer-file-name filename)
This doesn't write the buffer to the file, it copies the file visited
by the buffer to the new file. So if the buffer has unsaved edits,
they will not be written, unlike what write-file does.
Also, what if this command is invoked from a buffer that doesn't visit
any file, and thus buffer-file-name is nil?
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67313
; Package
emacs
.
(Tue, 21 Nov 2023 23:00:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 67313 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Date: Mon, 20 Nov 2023 23:33:27 +0000
>> From: Jeremy Bryant via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> By default write-file changes the buffer to point to the new filename,
>> but a user may wish to simply do the equivalent of write-file without
>> switching, as a sort of backup file.
>>
>> The attached is a patch concept to introduce the idea. Please let me
>> know if this makes sense to introduce a new command rather than
>> modifying the existing one (which may be less convenient). I understand
>> there would be additional things to do for new commands, but would like
>> to propose the idea first. Any suggestions welcome.
>
> Why is it not enough to be able to use "M-x write-region"?
>
> In any case, a new command is definitely overkill, IMO.
>
>> + (copy-file buffer-file-name filename)
>
> This doesn't write the buffer to the file, it copies the file visited
> by the buffer to the new file. So if the buffer has unsaved edits,
> they will not be written, unlike what write-file does.
>
> Also, what if this command is invoked from a buffer that doesn't visit
> any file, and thus buffer-file-name is nil?
>
> Thanks.
Thank you for pointing out write-region, it is indeed more appropriate,
replacing the line above by
(write-region nil nil filename)
The attached patch is the prototype of how this may be used.
[0001-write-file-no-visit-Like-write-file-but-without-visi.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67313
; Package
emacs
.
(Fri, 24 Nov 2023 08:06:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 67313 <at> debbugs.gnu.org (full text, mbox):
> From: Jeremy Bryant <jb <at> jeremybryant.net>
> Cc: 67313 <at> debbugs.gnu.org
> Date: Tue, 21 Nov 2023 22:52:13 +0000
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > Why is it not enough to be able to use "M-x write-region"?
> >
> > In any case, a new command is definitely overkill, IMO.
>
> Thank you for pointing out write-region, it is indeed more appropriate,
> replacing the line above by
>
> (write-region nil nil filename)
>
>
> The attached patch is the prototype of how this may be used.
Thanks. As stated above, I'm not sure I agree we need a new command.
write-region already exists, as a command, and I personally use it
quite a lot in these cases.
Does anyone else think we need an additional command for saving a
buffer to a different file?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67313
; Package
emacs
.
(Thu, 30 Nov 2023 23:21:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 67313 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> > Why is it not enough to be able to use "M-x write-region"?
>> >
>> > In any case, a new command is definitely overkill, IMO.
>>
>> Thank you for pointing out write-region, it is indeed more appropriate,
>> replacing the line above by
>>
>> (write-region nil nil filename)
>>
>>
>> The attached patch is the prototype of how this may be used.
>
> Thanks. As stated above, I'm not sure I agree we need a new command.
> write-region already exists, as a command, and I personally use it
> quite a lot in these cases.
>
> Does anyone else think we need an additional command for saving a
> buffer to a different file?
Eli, another way is also to clarify the manual to explain write-region.
Second patch attached for consideration. This may help users.
[0001-Elisp-manual-Mention-write-region-for-whole-buffer.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67313
; Package
emacs
.
(Fri, 01 Dec 2023 08:40:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 67313 <at> debbugs.gnu.org (full text, mbox):
> From: Jeremy Bryant <jb <at> jeremybryant.net>
> Cc: 67313 <at> debbugs.gnu.org
> Date: Thu, 30 Nov 2023 23:18:59 +0000
>
> > Thanks. As stated above, I'm not sure I agree we need a new command.
> > write-region already exists, as a command, and I personally use it
> > quite a lot in these cases.
> >
> > Does anyone else think we need an additional command for saving a
> > buffer to a different file?
>
>
> Eli, another way is also to clarify the manual to explain write-region.
> Second patch attached for consideration. This may help users.
Thanks, that's a no-brainer. Installed on the emacs-29 branch (after
fixing some markup and punctuation issues).
Should we close this bug now?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67313
; Package
emacs
.
(Fri, 01 Dec 2023 23:14:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 67313 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Jeremy Bryant <jb <at> jeremybryant.net>
>> Cc: 67313 <at> debbugs.gnu.org
>> Date: Thu, 30 Nov 2023 23:18:59 +0000
>>
>> > Thanks. As stated above, I'm not sure I agree we need a new command.
>> > write-region already exists, as a command, and I personally use it
>> > quite a lot in these cases.
>> >
>> > Does anyone else think we need an additional command for saving a
>> > buffer to a different file?
>>
>>
>> Eli, another way is also to clarify the manual to explain write-region.
>> Second patch attached for consideration. This may help users.
>
> Thanks, that's a no-brainer. Installed on the emacs-29 branch (after
> fixing some markup and punctuation issues).
>
> Should we close this bug now?
Yes, closing bug as fixed by this addition to the manual.
(noted usage of @w)
Reply sent
to
Jeremy Bryant <jb <at> jeremybryant.net>
:
You have taken responsibility.
(Fri, 01 Dec 2023 23:14:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Jeremy Bryant <jb <at> jeremybryant.net>
:
bug acknowledged by developer.
(Fri, 01 Dec 2023 23:14:03 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, 30 Dec 2023 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 132 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.