diff options
| author | Richard M. Stallman | 1998-05-11 01:33:54 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-11 01:33:54 +0000 |
| commit | 0516edee5f13a1589df2aa2e316e6f4e9ab5f36c (patch) | |
| tree | e2eada90ee49dd3eb2bec9081b02412bc8330b6d | |
| parent | c83c4f60988647a387eddd85c8698112cc3c4e04 (diff) | |
| download | emacs-0516edee5f13a1589df2aa2e316e6f4e9ab5f36c.tar.gz emacs-0516edee5f13a1589df2aa2e316e6f4e9ab5f36c.zip | |
(save-buffer-coding-system): New variable.
(basic-save-buffer-1): Obey it.
(basic-save-buffer): Set save-buffer-coding-system instead of
buffer-file-coding-system, if save-buffer-coding-system is already non-nil.
| -rw-r--r-- | lisp/files.el | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el index 60a45aac4b5..53496020e88 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -2147,6 +2147,14 @@ the last real save, but optional arg FORCE non-nil means delete anyway." | |||
| 2147 | (defvar after-save-hook nil | 2147 | (defvar after-save-hook nil |
| 2148 | "Normal hook that is run after a buffer is saved to its file.") | 2148 | "Normal hook that is run after a buffer is saved to its file.") |
| 2149 | 2149 | ||
| 2150 | (defvar save-buffer-coding-system nil | ||
| 2151 | "If non-nil, use this coding system for saving the buffer. | ||
| 2152 | More precisely, use this coding system in place of the | ||
| 2153 | value of `buffer-file-coding-system', when saving the buffer. | ||
| 2154 | Calling `write-region' for any purpose other than saving the buffer | ||
| 2155 | will still use `buffer-file-coding-system'; this variable has no effect | ||
| 2156 | in such cases.") | ||
| 2157 | |||
| 2150 | (defun basic-save-buffer () | 2158 | (defun basic-save-buffer () |
| 2151 | "Save the current buffer in its visited file, if it has been modified. | 2159 | "Save the current buffer in its visited file, if it has been modified. |
| 2152 | After saving the buffer, run `after-save-hook'." | 2160 | After saving the buffer, run `after-save-hook'." |
| @@ -2211,7 +2219,9 @@ After saving the buffer, run `after-save-hook'." | |||
| 2211 | ;; Now we have saved the current buffer. Let's make sure | 2219 | ;; Now we have saved the current buffer. Let's make sure |
| 2212 | ;; that buffer-file-coding-system is fixed to what | 2220 | ;; that buffer-file-coding-system is fixed to what |
| 2213 | ;; actually used for saving by binding it locally. | 2221 | ;; actually used for saving by binding it locally. |
| 2214 | (setq buffer-file-coding-system last-coding-system-used) | 2222 | (if save-buffer-coding-system |
| 2223 | (setq save-buffer-coding-system last-coding-system-used) | ||
| 2224 | (setq buffer-file-coding-system last-coding-system-used)) | ||
| 2215 | (setq buffer-file-number | 2225 | (setq buffer-file-number |
| 2216 | (nthcdr 10 (file-attributes buffer-file-name))) | 2226 | (nthcdr 10 (file-attributes buffer-file-name))) |
| 2217 | (if setmodes | 2227 | (if setmodes |
| @@ -2231,7 +2241,10 @@ After saving the buffer, run `after-save-hook'." | |||
| 2231 | ;; but inhibited if one of write-file-hooks returns non-nil. | 2241 | ;; but inhibited if one of write-file-hooks returns non-nil. |
| 2232 | ;; It returns a value to store in setmodes. | 2242 | ;; It returns a value to store in setmodes. |
| 2233 | (defun basic-save-buffer-1 () | 2243 | (defun basic-save-buffer-1 () |
| 2234 | (let (tempsetmodes setmodes) | 2244 | (let ((buffer-file-coding-system |
| 2245 | (or save-buffer-coding-system | ||
| 2246 | buffer-file-coding-system)) | ||
| 2247 | tempsetmodes setmodes) | ||
| 2235 | (if (not (file-writable-p buffer-file-name)) | 2248 | (if (not (file-writable-p buffer-file-name)) |
| 2236 | (let ((dir (file-name-directory buffer-file-name))) | 2249 | (let ((dir (file-name-directory buffer-file-name))) |
| 2237 | (if (not (file-directory-p dir)) | 2250 | (if (not (file-directory-p dir)) |