Mercurial > emacs
comparison lisp/files.el @ 100639:752b6a20d191
(buffer-swapped-with): New variable.
(basic-save-buffer-0): Most of basic-save-buffer moved here.
(basic-save-buffer): Unswap the buffer temporarily if nec.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 22 Dec 2008 19:48:08 +0000 |
parents | 62b6bd1722a5 |
children | a4a09df46d2f |
comparison
equal
deleted
inserted
replaced
100638:fcedbc3826f9 | 100639:752b6a20d191 |
---|---|
4063 in such cases.") | 4063 in such cases.") |
4064 | 4064 |
4065 (make-variable-buffer-local 'save-buffer-coding-system) | 4065 (make-variable-buffer-local 'save-buffer-coding-system) |
4066 (put 'save-buffer-coding-system 'permanent-local t) | 4066 (put 'save-buffer-coding-system 'permanent-local t) |
4067 | 4067 |
4068 (defvar buffer-swapped-with nil | |
4069 "Buffer that this buffer's contents are temporarily swapped with. | |
4070 You should only set this variable in file-visiting buffers, | |
4071 because it only affects how to save the buffer in its file.") | |
4072 | |
4073 (make-variable-buffer-local 'buffer-swapped-with) | |
4074 | |
4068 (defun basic-save-buffer () | 4075 (defun basic-save-buffer () |
4069 "Save the current buffer in its visited file, if it has been modified. | 4076 "Save the current buffer in its visited file, if it has been modified. |
4070 The hooks `write-contents-functions' and `write-file-functions' get a chance | 4077 The hooks `write-contents-functions' and `write-file-functions' get a chance |
4071 to do the job of saving; if they do not, then the buffer is saved in | 4078 to do the job of saving; if they do not, then the buffer is saved in |
4072 the visited file in the usual way. | 4079 the visited file in the usual way. |
4073 Before and after saving the buffer, this function runs | 4080 Before and after saving the buffer, this function runs |
4074 `before-save-hook' and `after-save-hook', respectively." | 4081 `before-save-hook' and `after-save-hook', respectively." |
4075 (interactive) | 4082 (interactive) |
4083 (if (not buffer-swapped-with) | |
4084 (basic-save-buffer-0) | |
4085 ;; If this buffer's real contents are "swapped" with some other buffer, | |
4086 ;; temporarily unswap in order to save the real contents. | |
4087 (unwind-protect | |
4088 (progn | |
4089 (buffer-swap-text buffer-swapped-with) | |
4090 (basic-save-buffer-0)) | |
4091 (buffer-swap-text buffer-swapped-with)))) | |
4092 | |
4093 (defun basic-save-buffer-0 () | |
4076 (save-current-buffer | 4094 (save-current-buffer |
4077 ;; In an indirect buffer, save its base buffer instead. | 4095 ;; In an indirect buffer, save its base buffer instead. |
4078 (if (buffer-base-buffer) | 4096 (if (buffer-base-buffer) |
4079 (set-buffer (buffer-base-buffer))) | 4097 (set-buffer (buffer-base-buffer))) |
4080 (if (buffer-modified-p) | 4098 (if (buffer-modified-p) |