Mercurial > emacs
comparison lisp/simple.el @ 21459:b787b88cc575
(newline): Mark as hard the newline that was just
typed, not the previous one. Suppress optimization if there's a
marker either before or after the newline.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 09 Apr 1998 20:05:58 +0000 |
parents | 4824e5e6d88a |
children | 8f34099fb8b4 |
comparison
equal
deleted
inserted
replaced
21458:96dd58f4f3bb | 21459:b787b88cc575 |
---|---|
60 (not before-change-function) | 60 (not before-change-function) |
61 (not after-change-functions) | 61 (not after-change-functions) |
62 (not before-change-functions) | 62 (not before-change-functions) |
63 ;; Make sure there are no markers here. | 63 ;; Make sure there are no markers here. |
64 (not (buffer-has-markers-at (1- (point)))) | 64 (not (buffer-has-markers-at (1- (point)))) |
65 (not (buffer-has-markers-at (point))) | |
65 ;; Make sure no text properties want to know | 66 ;; Make sure no text properties want to know |
66 ;; where the change was. | 67 ;; where the change was. |
67 (not (get-char-property (1- (point)) 'modification-hooks)) | 68 (not (get-char-property (1- (point)) 'modification-hooks)) |
68 (not (get-char-property (1- (point)) 'insert-behind-hooks)) | 69 (not (get-char-property (1- (point)) 'insert-behind-hooks)) |
69 (or (eobp) | 70 (or (eobp) |
91 (auto-fill-function (if (or arg flag) nil auto-fill-function))) | 92 (auto-fill-function (if (or arg flag) nil auto-fill-function))) |
92 (unwind-protect | 93 (unwind-protect |
93 (self-insert-command (prefix-numeric-value arg)) | 94 (self-insert-command (prefix-numeric-value arg)) |
94 ;; If we get an error in self-insert-command, put point at right place. | 95 ;; If we get an error in self-insert-command, put point at right place. |
95 (if flag (forward-char 1)))) | 96 (if flag (forward-char 1)))) |
96 ;; If we did *not* get an error, cancel that forward-char. | 97 ;; Even if we did *not* get an error, keep that forward-char; |
97 (if flag (backward-char 1)) | 98 ;; all further processing should apply to the newline that the user |
99 ;; thinks he inserted. | |
100 | |
98 ;; Mark the newline(s) `hard'. | 101 ;; Mark the newline(s) `hard'. |
99 (if use-hard-newlines | 102 (if use-hard-newlines |
100 (set-hard-newline-properties | 103 (set-hard-newline-properties |
101 (- (point) (if arg (prefix-numeric-value arg) 1)) (point))) | 104 (- (point) (if arg (prefix-numeric-value arg) 1)) (point))) |
102 ;; If the newline leaves the previous line blank, | 105 ;; If the newline leaves the previous line blank, |
103 ;; and we have a left margin, delete that from the blank line. | 106 ;; and we have a left margin, delete that from the blank line. |
104 (or flag | 107 (or flag |
105 (save-excursion | 108 (save-excursion |
106 (goto-char beforepos) | 109 (goto-char beforepos) |
107 (beginning-of-line) | 110 (beginning-of-line) |
108 (and (looking-at "[ \t]$") | 111 (and (looking-at "[ \t]$") |
109 (> (current-left-margin) 0) | 112 (> (current-left-margin) 0) |
110 (delete-region (point) (progn (end-of-line) (point)))))) | 113 (delete-region (point) (progn (end-of-line) (point)))))) |
111 (if flag (forward-char 1)) | |
112 ;; Indent the line after the newline, except in one case: | 114 ;; Indent the line after the newline, except in one case: |
113 ;; when we added the newline at the beginning of a line | 115 ;; when we added the newline at the beginning of a line |
114 ;; which starts a page. | 116 ;; which starts a page. |
115 (or was-page-start | 117 (or was-page-start |
116 (move-to-left-margin nil t))) | 118 (move-to-left-margin nil t))) |