* bug#11156: 24.0.95; require-final-newline and read-only files @ 2012-04-02 21:52 Christopher Schmidt 2012-04-14 13:49 ` Christopher Schmidt 0 siblings, 1 reply; 9+ messages in thread From: Christopher Schmidt @ 2012-04-02 21:52 UTC (permalink / raw) To: 11156 [-- Attachment #1: Type: text/plain, Size: 455 bytes --] 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: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: patch.diff --] [-- Type: text/x-diff, Size: 775 bytes --] === 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@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@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"))) [-- Attachment #3: Type: text/plain, Size: 21 bytes --] Christopher ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11156: 24.0.95; require-final-newline and read-only files 2012-04-02 21:52 bug#11156: 24.0.95; require-final-newline and read-only files Christopher Schmidt @ 2012-04-14 13:49 ` Christopher Schmidt 2012-04-14 18:56 ` martin rudalics 0 siblings, 1 reply; 9+ messages in thread From: Christopher Schmidt @ 2012-04-14 13:49 UTC (permalink / raw) To: 11156 Christopher Schmidt <christopher@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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11156: 24.0.95; require-final-newline and read-only files 2012-04-14 13:49 ` Christopher Schmidt @ 2012-04-14 18:56 ` martin rudalics 2012-04-15 13:48 ` Christopher Schmidt 0 siblings, 1 reply; 9+ messages in thread From: martin rudalics @ 2012-04-14 18:56 UTC (permalink / raw) To: 11156 >> 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11156: 24.0.95; require-final-newline and read-only files 2012-04-14 18:56 ` martin rudalics @ 2012-04-15 13:48 ` Christopher Schmidt 2012-04-18 6:25 ` Chong Yidong 0 siblings, 1 reply; 9+ messages in thread From: Christopher Schmidt @ 2012-04-15 13:48 UTC (permalink / raw) To: 11156 [-- Attachment #1: Type: text/plain, Size: 214 bytes --] martin rudalics <rudalics@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. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: require-final-newline.diff --] [-- Type: text/x-diff, Size: 2542 bytes --] === 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@ch.ristopher.com> + + * files.texi (Saving Buffers): Document the values visit and + visit-save for require-final-newline. + 2012-04-15 Glenn Morris <rgm@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@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@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"))) [-- Attachment #3: Type: text/plain, Size: 21 bytes --] Christopher ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11156: 24.0.95; require-final-newline and read-only files 2012-04-15 13:48 ` Christopher Schmidt @ 2012-04-18 6:25 ` Chong Yidong 2012-05-01 17:02 ` Christopher Schmidt 2012-09-02 18:55 ` 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) Christopher Schmidt 0 siblings, 2 replies; 9+ messages in thread From: Chong Yidong @ 2012-04-18 6:25 UTC (permalink / raw) To: 11156 Christopher Schmidt <christopher@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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11156: 24.0.95; require-final-newline and read-only files 2012-04-18 6:25 ` Chong Yidong @ 2012-05-01 17:02 ` Christopher Schmidt 2012-05-06 5:01 ` Chong Yidong 2012-09-02 18:55 ` 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) Christopher Schmidt 1 sibling, 1 reply; 9+ messages in thread From: Christopher Schmidt @ 2012-05-01 17:02 UTC (permalink / raw) To: 11156 Chong Yidong <cyd@gnu.org> writes: > Thanks, committed to the repository. Thank you. Could the patch also be applied to the emacs-24 branch? Christopher ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11156: 24.0.95; require-final-newline and read-only files 2012-05-01 17:02 ` Christopher Schmidt @ 2012-05-06 5:01 ` Chong Yidong 0 siblings, 0 replies; 9+ messages in thread From: Chong Yidong @ 2012-05-06 5:01 UTC (permalink / raw) To: 11156 Christopher Schmidt <christopher@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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* 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) 2012-04-18 6:25 ` Chong Yidong 2012-05-01 17:02 ` Christopher Schmidt @ 2012-09-02 18:55 ` Christopher Schmidt 2012-09-07 10:53 ` bug#11156: 24.2.50; require-final-newline and read-only files Chong Yidong 1 sibling, 1 reply; 9+ messages in thread From: Christopher Schmidt @ 2012-09-02 18:55 UTC (permalink / raw) To: 11156 reopen 11156 Chong Yidong <cyd@gnu.org> writes: > Christopher Schmidt <christopher@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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11156: 24.2.50; require-final-newline and read-only files 2012-09-02 18:55 ` 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) Christopher Schmidt @ 2012-09-07 10:53 ` Chong Yidong 0 siblings, 0 replies; 9+ messages in thread From: Chong Yidong @ 2012-09-07 10:53 UTC (permalink / raw) To: 11156 Christopher Schmidt <christopher@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. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-09-07 10:53 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-04-02 21:52 bug#11156: 24.0.95; require-final-newline and read-only files Christopher Schmidt 2012-04-14 13:49 ` Christopher Schmidt 2012-04-14 18:56 ` martin rudalics 2012-04-15 13:48 ` Christopher Schmidt 2012-04-18 6:25 ` Chong Yidong 2012-05-01 17:02 ` Christopher Schmidt 2012-05-06 5:01 ` Chong Yidong 2012-09-02 18:55 ` 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) Christopher Schmidt 2012-09-07 10:53 ` bug#11156: 24.2.50; require-final-newline and read-only files Chong Yidong
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git 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).