From 19618231c31ba49a1a64214d49ed672c679e485a Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 5 Mar 1998 04:00:53 +0000 Subject: [PATCH] (basic-save-buffer): Use save-current-buffer not save-excursion. --- lisp/files.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 606c49e6a14..3a9ab31f308 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2160,7 +2160,7 @@ the last real save, but optional arg FORCE non-nil means delete anyway." "Save the current buffer in its visited file, if it has been modified. After saving the buffer, run `after-save-hook'." (interactive) - (save-excursion + (save-current-buffer ;; In an indirect buffer, save its base buffer instead. (if (buffer-base-buffer) (set-buffer (buffer-base-buffer))) @@ -2198,18 +2198,19 @@ After saving the buffer, run `after-save-hook'." (error "Save not confirmed")) (save-restriction (widen) - (and (> (point-max) 1) - (/= (char-after (1- (point-max))) ?\n) - (not (and (eq selective-display t) - (= (char-after (1- (point-max))) ?\r))) - (or (eq require-final-newline t) - (and require-final-newline - (y-or-n-p - (format "Buffer %s does not end in newline. Add one? " - (buffer-name))))) - (save-excursion - (goto-char (point-max)) - (insert ?\n))) + (save-excursion + (and (> (point-max) 1) + (/= (char-after (1- (point-max))) ?\n) + (not (and (eq selective-display t) + (= (char-after (1- (point-max))) ?\r))) + (or (eq require-final-newline t) + (and require-final-newline + (y-or-n-p + (format "Buffer %s does not end in newline. Add one? " + (buffer-name))))) + (save-excursion + (goto-char (point-max)) + (insert ?\n)))) (or (run-hook-with-args-until-success 'write-contents-hooks) (run-hook-with-args-until-success 'local-write-file-hooks) (run-hook-with-args-until-success 'write-file-hooks) -- 2.39.2