GNU bug report logs - #11156
24.0.95; require-final-newline and read-only files

Previous Next

Package: emacs;

Reported by: Christopher Schmidt <christopher <at> ch.ristopher.com>

Date: Mon, 2 Apr 2012 21:53:01 UTC

Severity: minor

Found in version 24.0.95

Done: Chong Yidong <cyd <at> gnu.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 11156 in the body.
You can then email your comments to 11156 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#11156; Package emacs. (Mon, 02 Apr 2012 21:53:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Schmidt <christopher <at> ch.ristopher.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 02 Apr 2012 21:53:01 GMT) Full text and rfc822 format available.

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

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.95; require-final-newline and read-only files
Date: Mon, 02 Apr 2012 23:52:11 +0200
[Message part 1 (text/plain, inline)]
Hi,

I think I hit on a bug in GNU Emacs 24.0.95.1 (x86_64-unknown-linux-gnu,
GTK+ Version 2.24.10) of 2012-04-02.

Recipe:
cd /tmp
echo -n rms > rms
chmod u=r rms
emacs -q
eval: (setq require-final-newline 'visit)
C-x C-f /tmp/rms RET

There is a new buffer but no window displays it.  The *Messages*-buffer
contains `find-file-noselect-1: Buffer is read-only: #<buffer rms>'

Emacs tries to add a newline to the (read-only) buffer.  Here's a quick
fix:
[patch.diff (text/x-diff, inline)]
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-04-02 16:32:06 +0000
+++ lisp/ChangeLog	2012-04-02 21:28:06 +0000
@@ -1,3 +1,8 @@
+2012-04-02  Christopher Schmidt  <christopher <at> ch.ristopher.com>
+
+	* files.el (after-find-file): Do not add a newline at the end when
+	buffer is read-only.
+
 2012-04-02  Glenn Morris  <rgm <at> gnu.org>
 
 	* emacs-lisp/authors.el (authors-aliases): Another addition.

=== modified file 'lisp/files.el'
--- lisp/files.el	2012-04-01 02:44:24 +0000
+++ lisp/files.el	2012-04-02 21:45:36 +0000
@@ -2152,6 +2152,7 @@
 	 (/= (char-after (1- (point-max))) ?\n)
 	 (not (and (eq selective-display t)
 		   (= (char-after (1- (point-max))) ?\r)))
+	 (not buffer-read-only)
 	 (save-excursion
 	   (goto-char (point-max))
 	   (insert "\n")))

[Message part 3 (text/plain, inline)]
        Christopher

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Sat, 14 Apr 2012 13:52:01 GMT) Full text and rfc822 format available.

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

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#11156: 24.0.95; require-final-newline and read-only files
Date: Sat, 14 Apr 2012 15:49:28 +0200
Christopher Schmidt <christopher <at> ch.ristopher.com> writes:

> I think I hit on a bug in GNU Emacs 24.0.95.1
> (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10) of 2012-04-02.
>
> Recipe:
> cd /tmp
> echo -n rms > rms
> chmod u=r rms
> emacs -q
> eval: (setq require-final-newline 'visit)
> C-x C-f /tmp/rms RET
>
> There is a new buffer but no window displays it.  The
> *Messages*-buffer contains `find-file-noselect-1: Buffer is read-only:
> #<buffer rms>'

It is annoying that one needs to manually switch to the buffer after
finding a read-only file.  But, more important, find-file-hook is not
run.  This breaks lots of packages and makes this issue a severe one for
me.

        Christopher




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Sat, 14 Apr 2012 18:59:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#11156: 24.0.95; require-final-newline and read-only files
Date: Sat, 14 Apr 2012 20:56:57 +0200
>> cd /tmp
>> echo -n rms > rms
>> chmod u=r rms
>> emacs -q
>> eval: (setq require-final-newline 'visit)
>> C-x C-f /tmp/rms RET
>>
>> There is a new buffer but no window displays it.  The
>> *Messages*-buffer contains `find-file-noselect-1: Buffer is read-only:
>> #<buffer rms>'
>
> It is annoying that one needs to manually switch to the buffer after
> finding a read-only file.  But, more important, find-file-hook is not
> run.  This breaks lots of packages and makes this issue a severe one for
> me.

`after-find-file' shouldn't try adding a newline if `buffer-read-only'
is non-nil.  And the values 'visit and 'visit-save should be documented
in the Elisp manual.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Sun, 15 Apr 2012 15:44:01 GMT) Full text and rfc822 format available.

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

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#11156: 24.0.95; require-final-newline and read-only files
Date: Sun, 15 Apr 2012 15:48:24 +0200
[Message part 1 (text/plain, inline)]
martin rudalics <rudalics <at> gmx.at> writes:

> `after-find-file' shouldn't try adding a newline if `buffer-read-only'
> is non-nil.  And the values 'visit and 'visit-save should be
> documented in the Elisp manual.

[require-final-newline.diff (text/x-diff, inline)]
=== modified file 'doc/lispref/ChangeLog'
--- doc/lispref/ChangeLog	2012-04-15 07:28:01 +0000
+++ doc/lispref/ChangeLog	2012-04-15 13:37:35 +0000
@@ -1,3 +1,8 @@
+2012-04-15  Christopher Schmidt  <christopher <at> ch.ristopher.com>
+
+	* files.texi (Saving Buffers): Document the values visit and
+	visit-save for require-final-newline.
+
 2012-04-15  Glenn Morris  <rgm <at> gnu.org>
 
 	* processes.texi (Processes, Subprocess Creation, Shell Arguments):

=== modified file 'doc/lispref/files.texi'
--- doc/lispref/files.texi	2012-04-14 01:59:01 +0000
+++ doc/lispref/files.texi	2012-04-15 13:47:26 +0000
@@ -489,11 +489,13 @@
 @defopt require-final-newline
 This variable determines whether files may be written out that do
 @emph{not} end with a newline.  If the value of the variable is
-@code{t}, then @code{save-buffer} silently adds a newline at the end of
-the file whenever the buffer being saved does not already end in one.
-If the value of the variable is non-@code{nil}, but not @code{t}, then
-@code{save-buffer} asks the user whether to add a newline each time the
-case arises.
+@code{t}, then @code{save-buffer} silently adds a newline at the end
+of the buffer whenever it does not already end in one.  If the value
+is @code{visit}, a newline is added at the end of buffer that doesn't
+have one, just after the file is visited.  If the value is
+@code{visit-save}, a newline is added both on visiting and on saving.
+For every other non-@code{nil} value, @code{save-buffer} asks the user
+whether to add a newline each time the case arises.
 
 If the value of the variable is @code{nil}, then @code{save-buffer}
 doesn't add newlines at all.  @code{nil} is the default value, but a few

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-04-15 09:16:50 +0000
+++ lisp/ChangeLog	2012-04-15 13:17:00 +0000
@@ -445,6 +445,11 @@
 
 	* notifications.el (notifications-notify): Fix docstring.
 
+2012-04-02  Christopher Schmidt  <christopher <at> ch.ristopher.com>
+
+	* files.el (after-find-file): Do not add a newline at the end when
+	buffer is read-only.
+
 2012-04-02  Glenn Morris  <rgm <at> gnu.org>
 
 	* emacs-lisp/authors.el (authors-aliases): Another addition.

=== modified file 'lisp/files.el'
--- lisp/files.el	2012-04-14 01:46:06 +0000
+++ lisp/files.el	2012-04-15 13:15:13 +0000
@@ -2152,6 +2152,7 @@
 	 (/= (char-after (1- (point-max))) ?\n)
 	 (not (and (eq selective-display t)
 		   (= (char-after (1- (point-max))) ?\r)))
+	 (not buffer-read-only)
 	 (save-excursion
 	   (goto-char (point-max))
 	   (insert "\n")))

[Message part 3 (text/plain, inline)]
        Christopher

bug closed, send any further explanations to 11156 <at> debbugs.gnu.org and Christopher Schmidt <christopher <at> ch.ristopher.com> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 18 Apr 2012 06:26:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Wed, 18 Apr 2012 06:27:01 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#11156: 24.0.95; require-final-newline and read-only files
Date: Wed, 18 Apr 2012 14:25:20 +0800
Christopher Schmidt <christopher <at> ch.ristopher.com> writes:

>> `after-find-file' shouldn't try adding a newline if `buffer-read-only'
>> is non-nil.  And the values 'visit and 'visit-save should be
>> documented in the Elisp manual.
>
> === modified file 'doc/lispref/ChangeLog'
> ...

Thanks, committed to the repository.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Tue, 01 May 2012 17:05:02 GMT) Full text and rfc822 format available.

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

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#11156: 24.0.95; require-final-newline and read-only files
Date: Tue, 01 May 2012 19:02:46 +0200
Chong Yidong <cyd <at> gnu.org> writes:

> Thanks, committed to the repository.

Thank you.  Could the patch also be applied to the emacs-24 branch?

        Christopher




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Sun, 06 May 2012 05:04:02 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> gnu.org>
To: 11156 <at> debbugs.gnu.org
Subject: Re: bug#11156: 24.0.95; require-final-newline and read-only files
Date: Sun, 06 May 2012 13:01:04 +0800
Christopher Schmidt <christopher <at> ch.ristopher.com> writes:

>> Thanks, committed to the repository.
>
> Thank you.  Could the patch also be applied to the emacs-24 branch?

Doesn't seem important enough for that.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Jun 2012 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Christopher Schmidt <christopher <at> ch.ristopher.com> to control <at> debbugs.gnu.org. (Sun, 02 Sep 2012 18:49:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Sun, 02 Sep 2012 18:58:02 GMT) Full text and rfc822 format available.

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

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: bug#11156: 24.2.50;
	require-final-newline and read-only files (was: bug#11156: 24.0.95;
	require-final-newline and read-only files)
Date: Sun,  2 Sep 2012 19:55:34 +0100 (BST)
reopen 11156

Chong Yidong <cyd <at> gnu.org> writes:
> Christopher Schmidt <christopher <at> ch.ristopher.com> writes:
>
>>> `after-find-file' shouldn't try adding a newline if
>>> `buffer-read-only' is non-nil.  And the values 'visit and
>>> 'visit-save should be documented in the Elisp manual.
>>
>> === modified file 'doc/lispref/ChangeLog'
>> ...
>
> Thanks, committed to the repository.

There is still a minor bug in regard to require-final-newline.

Recipe:
emacs -q
M-: (setq require-final-newline 'visit)
Open an image file via C-x C-f

There is a new buffer but no window displays it.  The *Messages*-buffer
contains "find-file-noselect-1: Text is read-only".

This is because image-mode sets the read-only property of the whole
buffer string to t.  buffer-read-only is nil in this case, though.

I think all code fragments that try to add new lines due to
require-final-newline should ignore text-read-only errors.

        Christopher




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11156; Package emacs. (Fri, 07 Sep 2012 10:55:01 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> gnu.org>
To: 11156 <at> debbugs.gnu.org
Subject: Re: bug#11156: 24.2.50; require-final-newline and read-only files
Date: Fri, 07 Sep 2012 18:53:37 +0800
Christopher Schmidt <christopher <at> ch.ristopher.com> writes:

> There is still a minor bug in regard to require-final-newline.
>
> Recipe:
> emacs -q
> M-: (setq require-final-newline 'visit)
> Open an image file via C-x C-f
>
> There is a new buffer but no window displays it.  The *Messages*-buffer
> contains "find-file-noselect-1: Text is read-only".
>
> I think all code fragments that try to add new lines due to
> require-final-newline should ignore text-read-only errors.

Fixed, thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 05 Oct 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 228 days ago.

Previous Next


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