273 |
:group 'backup) |
:group 'backup) |
274 |
|
|
275 |
(defcustom require-final-newline nil |
(defcustom require-final-newline nil |
276 |
"*Value of t says silently ensure a file ends in a newline when it is saved. |
"*Whether to add a newline automatically at the end of the file. |
277 |
Non-nil but not t says ask user whether to add a newline when there isn't one. |
|
278 |
nil means don't add newlines." |
A value of t means do this only when the file is about to be saved. |
279 |
:type '(choice (const :tag "Off" nil) |
A value of `visit' means do this right after the file is visited. |
280 |
(const :tag "Add" t) |
A value of `visit-save' means do it at both of those times. |
281 |
|
Any other non-nil value means ask user whether to add a newline, when saving. |
282 |
|
nil means don't add newlines. |
283 |
|
|
284 |
|
Certain major modes set this locally to the value obtained |
285 |
|
from `mode-require-final-newline'." |
286 |
|
:type '(choice (const :tag "When visiting" visit) |
287 |
|
(const :tag "When saving" t) |
288 |
|
(const :tag "When visiting or saving" visit-save) |
289 |
|
(const :tag "Never" nil) |
290 |
(other :tag "Ask" ask)) |
(other :tag "Ask" ask)) |
291 |
:group 'editing-basics) |
:group 'editing-basics) |
292 |
|
|
293 |
|
(defcustom mode-require-final-newline t |
294 |
|
"*Whether to add a newline at the end of the file, in certain major modes. |
295 |
|
Those modes set `require-final-newline' to this value when you enable them. |
296 |
|
They do so because they are used for files that are supposed |
297 |
|
to end in newlines, and the question is how to arrange that. |
298 |
|
|
299 |
|
A value of t means do this only when the file is about to be saved. |
300 |
|
A value of `visit' means do this right after the file is visited. |
301 |
|
A value of `visit-save' means do it at both of those times. |
302 |
|
Any other non-nil value means ask user whether to add a newline, when saving." |
303 |
|
:type '(choice (const :tag "When visiting" visit) |
304 |
|
(const :tag "When saving" t) |
305 |
|
(const :tag "When visiting or saving" visit-save) |
306 |
|
(other :tag "Ask" ask)) |
307 |
|
:group 'editing-basics |
308 |
|
:version "21.4") |
309 |
|
|
310 |
(defcustom auto-save-default t |
(defcustom auto-save-default t |
311 |
"*Non-nil says by default do auto-saving of every file-visiting buffer." |
"*Non-nil says by default do auto-saving of every file-visiting buffer." |
312 |
:type 'boolean |
:type 'boolean |
1653 |
(when (and view-read-only view-mode) |
(when (and view-read-only view-mode) |
1654 |
(view-mode-disable)) |
(view-mode-disable)) |
1655 |
(normal-mode t) |
(normal-mode t) |
1656 |
|
;; If requested, add a newline at the end of the file. |
1657 |
|
(and (memq require-final-newline '(visit visit-save)) |
1658 |
|
(> (point-max) (point-min)) |
1659 |
|
(/= (char-after (1- (point-max))) ?\n) |
1660 |
|
(not (and (eq selective-display t) |
1661 |
|
(= (char-after (1- (point-max))) ?\r))) |
1662 |
|
(save-excursion |
1663 |
|
(goto-char (point-max)) |
1664 |
|
(insert "\n"))) |
1665 |
(when (and buffer-read-only |
(when (and buffer-read-only |
1666 |
view-read-only |
view-read-only |
1667 |
(not (eq (get major-mode 'mode-class) 'special))) |
(not (eq (get major-mode 'mode-class) 'special))) |
3229 |
(not (and (eq selective-display t) |
(not (and (eq selective-display t) |
3230 |
(= (char-after (1- (point-max))) ?\r))) |
(= (char-after (1- (point-max))) ?\r))) |
3231 |
(or (eq require-final-newline t) |
(or (eq require-final-newline t) |
3232 |
|
(eq require-final-newline 'visit-save) |
3233 |
(and require-final-newline |
(and require-final-newline |
3234 |
(y-or-n-p |
(y-or-n-p |
3235 |
(format "Buffer %s does not end in newline. Add one? " |
(format "Buffer %s does not end in newline. Add one? " |