unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* (no subject)
@ 2005-03-02  2:26 Chong Yidong
  2005-03-02  3:02 ` Luc Teirlinck
  0 siblings, 1 reply; 60+ messages in thread
From: Chong Yidong @ 2005-03-02  2:26 UTC (permalink / raw)


Could this patch be checked in? When require-final-newlines is t, the
newline is inserted by (insert "\n"), which does not take
use-hard-newlines into account, so the newline is not marked as 'hard.


*** emacs/lisp/files.el~	Tue Mar  1 22:13:16 2005
--- emacs/lisp/files.el	Wed Mar  2 10:16:52 2005
***************
*** 1661,1667 ****
  		   (= (char-after (1- (point-max))) ?\r)))
  	 (save-excursion
  	   (goto-char (point-max))
! 	   (insert "\n")))
      (when (and buffer-read-only
  	       view-read-only
  	       (not (eq (get major-mode 'mode-class) 'special)))
--- 1661,1667 ----
  		   (= (char-after (1- (point-max))) ?\r)))
  	 (save-excursion
  	   (goto-char (point-max))
! 	   (newline)))
      (when (and buffer-read-only
  	       view-read-only
  	       (not (eq (get major-mode 'mode-class) 'special)))
***************
*** 3244,3250 ****
  				     (buffer-name)))))
  		   (save-excursion
  		     (goto-char (point-max))
! 		     (insert ?\n))))
  	    ;; Support VC version backups.
  	    (vc-before-save)
  	    (run-hooks 'before-save-hook)
--- 3244,3250 ----
  				     (buffer-name)))))
  		   (save-excursion
  		     (goto-char (point-max))
! 		     (newline))))
  	    ;; Support VC version backups.
  	    (vc-before-save)
  	    (run-hooks 'before-save-hook)

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: require-hard-newlines to use newline
@ 2005-03-06  2:18 Chong Yidong
  2005-03-07  5:02 ` Richard Stallman
  0 siblings, 1 reply; 60+ messages in thread
From: Chong Yidong @ 2005-03-06  2:18 UTC (permalink / raw)
  Cc: emacs-devel

>     I don't think there's a problem in this situation; he just has to make
>     sure that point is before the final (hard) newline before he continues
>     editing.
>
> If the user has to do that, then why does it matter whether this
> newline is hard or soft?

Because, everywhere else in the buffer, the newline at the end of a
paragraph is hard.

To forestall this discussion going round in a circle again: one might
object that the newline at the end of the last paragraph need not be hard,
because the user may not have decided to end that paragraph yet. But
that's okay, because eventually he *has* to end that paragraph (that's
what require-final-newline says). Because the final newline is inserted in
a save-excursion, after point, there is never any inconvenience to the
user.

I will have one last try at illustrating why using a soft newline can lead
to strange behavior. If this does not work, then I will simply drop the
issue.

Consider this, scenario A:

emacs -Q
M-x use-hard-newline
M-: (setq require-final-newline t)
C-x C-f foo.txt
some text
C-x C-s

And consider another scenario, scenario B, which is the same except the
user explicitly types in a newline before C-x C-s ("some text RET").

Now suppose the user goes to another buffer to do his editing, and comes
back to this buffer a long time later. He does not remember the exact
sequence of edits he performed on that buffer -- in particular, whether he
typed RET or not. From moving point around, he observes that the buffer
contains "some text" followed by a final newline.

Now suppose he does this:

M->
some more text
M-q

There is a big difference! In scenario A, M-q causes moves "some more
text" onto the same line as "some text". In scenario B, nothing happens
(which is correct, because the purpose of use-hard-newlines is to allow a
hard break in the middle of a sentence.) This leads to an appearance of
unpredictability.

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2005-03-15 18:39 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-02  2:26 (no subject) Chong Yidong
2005-03-02  3:02 ` Luc Teirlinck
2005-03-02  3:26   ` require-hard-newlines to use newline Chong Yidong
2005-03-02  3:55     ` Luc Teirlinck
2005-03-03  2:29     ` Richard Stallman
2005-03-03  2:49       ` Chong Yidong
2005-03-03 20:57         ` Richard Stallman
2005-03-03 22:32           ` Chong Yidong
2005-03-04  0:33             ` Luc Teirlinck
2005-03-04  0:56               ` Chong Yidong
2005-03-04  1:40                 ` Miles Bader
2005-03-04  6:02                   ` Chong Yidong
2005-03-04  9:55                     ` David Kastrup
2005-03-04 23:46                   ` Richard Stallman
2005-03-08  0:05                     ` Luc Teirlinck
2005-03-08  2:10                       ` Chong Yidong
2005-03-08  3:09                         ` Luc Teirlinck
2005-03-08  4:28                         ` Luc Teirlinck
2005-03-08 15:45                           ` Luc Teirlinck
2005-03-08 16:42                             ` Chong Yidong
2005-03-08 18:04                               ` Stefan Monnier
2005-03-08 18:12                                 ` Luc Teirlinck
2005-03-08 19:02                                   ` Stefan Monnier
2005-03-08 18:26                                 ` Luc Teirlinck
2005-03-08 16:03                       ` Richard Stallman
2005-03-08 16:39                         ` Chong Yidong
2005-03-09  9:45                           ` Chong Yidong
2005-03-11  1:46                           ` Richard Stallman
2005-03-11  9:10                             ` Chong Yidong
2005-03-11 10:25                               ` Kim F. Storm
2005-03-11 13:03                                 ` Chong Yidong
2005-03-11 14:32                                   ` Stefan Monnier
2005-03-11 14:57                                     ` Kim F. Storm
2005-03-11 15:08                                       ` Chong Yidong
2005-03-11 15:28                                         ` Stefan Monnier
2005-03-11 15:13                                       ` Chong Yidong
2005-03-11 15:30                                       ` Stefan Monnier
2005-03-11 16:11                                         ` Chong Yidong
2005-03-11 17:32                                           ` Stefan Monnier
2005-03-12  2:40                                             ` Chong Yidong
2005-03-11 22:29                                           ` Kim F. Storm
2005-03-12  2:23                                             ` Chong Yidong
2005-03-12 22:16                                   ` Richard Stallman
2005-03-12 23:53                                     ` Stefan Monnier
2005-03-14  3:00                                       ` Richard Stallman
2005-03-13  6:14                                     ` Chong Yidong
2005-03-14  3:00                                       ` Richard Stallman
2005-03-14  3:42                                         ` Chong Yidong
2005-03-15 18:39                                           ` Richard Stallman
2005-03-12 22:16                               ` Richard Stallman
2005-03-04 23:45             ` Richard Stallman
2005-03-05  2:03               ` Chong Yidong
2005-03-06  0:41                 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-03-06  2:18 Chong Yidong
2005-03-07  5:02 ` Richard Stallman
2005-03-07 10:45   ` Oliver Scholz
2005-03-08  0:50     ` Luc Teirlinck
2005-03-08  1:43       ` Luc Teirlinck
2005-03-08  2:52     ` Richard Stallman
2005-03-08  1:31   ` Luc Teirlinck

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).