Prevent unsaved prompts when formatting #1498

The fix for #1489 (in 13f5a762) gives the temp buffer (where formatting
is performed) a real buffer-file-name, which causes it to prompt to save
it when it is killed.
This commit is contained in:
Henrik Lissner 2019-06-16 12:42:17 +02:00
parent 0b1ecb8105
commit 9bba39bd3a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -134,6 +134,7 @@ See `+format/buffer' for the interactive version of this function, and
(origin-buffer-file-name (buffer-file-name (buffer-base-buffer))) (origin-buffer-file-name (buffer-file-name (buffer-base-buffer)))
(origin-default-directory default-directory)) (origin-default-directory default-directory))
(with-temp-buffer (with-temp-buffer
(with-silent-modifications
(insert output) (insert output)
;; Ensure this temp buffer _seems_ as much like the origin ;; Ensure this temp buffer _seems_ as much like the origin
;; buffer as possible. ;; buffer as possible.
@ -145,7 +146,7 @@ See `+format/buffer' for the interactive version of this function, and
(setq indent (+format--current-indentation)) (setq indent (+format--current-indentation))
(when (> indent 0) (when (> indent 0)
(indent-rigidly (point-min) (point-max) (- indent)))) (indent-rigidly (point-min) (point-max) (- indent))))
(funcall f-function executable mode-result))))) (funcall f-function executable mode-result))))))
(unwind-protect (unwind-protect
(cond ((null output) 'error) (cond ((null output) 'error)
((eq output t) 'noop) ((eq output t) 'noop)