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.

Full log


View this message in rfc822 format

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: 11156 <at> debbugs.gnu.org
Subject: bug#11156: 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

This bug report was last modified 12 years and 319 days ago.

Previous Next


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