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)

From: Christopher Schmidt <[email-masked]>
Date: Sun, 2 Sep 2012 19:55:34 +0100 (BST)

reopen 11156

Chong Yidong <[email-masked]> writes:
> Christopher Schmidt <[email-masked]> 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