aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2009-03-03 01:56:14 +0000
committerKenichi Handa2009-03-03 01:56:14 +0000
commit4c549102e5c1329da17f338f445bfc001e5a51b2 (patch)
tree5d071f788443f6bc307085ee772891d139f04255
parent71a0c011da89f12b6d921cf8c28eae80ee9f26b7 (diff)
downloademacs-4c549102e5c1329da17f338f445bfc001e5a51b2.tar.gz
emacs-4c549102e5c1329da17f338f445bfc001e5a51b2.zip
(set-buffer-file-coding-system): Set cdr
part of buffer-file-coding-system-explicit. (after-insert-file-set-coding): Set buffer-file-coding-system-explicit to a cons.
-rw-r--r--lisp/international/mule.el39
1 files changed, 24 insertions, 15 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 508b20692f1..c281db7d95d 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1146,6 +1146,25 @@ FORM is a form to evaluate to define the coding-system."
1146 (put (intern name) 'coding-system-define-form form) 1146 (put (intern name) 'coding-system-define-form form)
1147 (setq coding-system-alist (cons (list name) coding-system-alist))))) 1147 (setq coding-system-alist (cons (list name) coding-system-alist)))))
1148 1148
1149;; This variable is set in these three cases:
1150;; (1) A file is read by a coding system specified explicitly.
1151;; after-insert-file-set-coding sets the car of this value to
1152;; coding-system-for-read, and sets the cdr to nil.
1153;; (2) A buffer is saved.
1154;; After writing, basic-save-buffer-1 sets the car of this value
1155;; to last-coding-system-used.
1156;; (3) set-buffer-file-coding-system is called.
1157;; The cdr of this value is set to the specified coding system.
1158;; This variable is used for decoding in revert-buffer and encoding in
1159;; select-safe-coding-system.
1160(defvar buffer-file-coding-system-explicit nil
1161 "The file coding system explicitly specified for the current buffer.
1162The value is a cons of coding systems for reading (decoding) and
1163writing (encoding).
1164Internal use only.")
1165(make-variable-buffer-local 'buffer-file-coding-system-explicit)
1166(put 'buffer-file-coding-system-explicit 'permanent-local t)
1167
1149(defun set-buffer-file-coding-system (coding-system &optional force nomodify) 1168(defun set-buffer-file-coding-system (coding-system &optional force nomodify)
1150 "Set the file coding-system of the current buffer to CODING-SYSTEM. 1169 "Set the file coding-system of the current buffer to CODING-SYSTEM.
1151This means that when you save the buffer, it will be converted 1170This means that when you save the buffer, it will be converted
@@ -1169,6 +1188,9 @@ just set the variable `buffer-file-coding-system' directly."
1169 (setq coding-system 1188 (setq coding-system
1170 (merge-coding-systems coding-system buffer-file-coding-system))) 1189 (merge-coding-systems coding-system buffer-file-coding-system)))
1171 (setq buffer-file-coding-system coding-system) 1190 (setq buffer-file-coding-system coding-system)
1191 (if buffer-file-coding-system-explicit
1192 (setcdr buffer-file-coding-system-explicit coding-system)
1193 (setq buffer-file-coding-system-explicit (cons nil coding-system)))
1172 ;; This is in case of an explicit call. Normally, `normal-mode' and 1194 ;; This is in case of an explicit call. Normally, `normal-mode' and
1173 ;; `set-buffer-major-mode-hook' take care of setting the table. 1195 ;; `set-buffer-major-mode-hook' take care of setting the table.
1174 (if (fboundp 'ucs-set-table-for-input) ; don't lose when building 1196 (if (fboundp 'ucs-set-table-for-input) ; don't lose when building
@@ -1831,20 +1853,6 @@ function by default."
1831 1853
1832(setq set-auto-coding-function 'set-auto-coding) 1854(setq set-auto-coding-function 'set-auto-coding)
1833 1855
1834;; This variable is set in these two cases:
1835;; (1) A file is read by a coding system specified explicitly.
1836;; after-insert-file-set-coding sets this value to
1837;; coding-system-for-read.
1838;; (2) A buffer is saved.
1839;; After writing, basic-save-buffer-1 sets this value to
1840;; last-coding-system-used.
1841;; This variable is used for decoding in revert-buffer.
1842(defvar buffer-file-coding-system-explicit nil
1843 "The file coding system explicitly specified for the current buffer.
1844Internal use only.")
1845(make-variable-buffer-local 'buffer-file-coding-system-explicit)
1846(put 'buffer-file-coding-system-explicit 'permanent-local t)
1847
1848(defun after-insert-file-set-coding (inserted &optional visit) 1856(defun after-insert-file-set-coding (inserted &optional visit)
1849 "Set `buffer-file-coding-system' of current buffer after text is inserted. 1857 "Set `buffer-file-coding-system' of current buffer after text is inserted.
1850INSERTED is the number of characters that were inserted, as figured 1858INSERTED is the number of characters that were inserted, as figured
@@ -1855,7 +1863,8 @@ The optional second arg VISIT non-nil means that we are visiting a file."
1855 (if (and visit 1863 (if (and visit
1856 coding-system-for-read 1864 coding-system-for-read
1857 (not (eq coding-system-for-read 'auto-save-coding))) 1865 (not (eq coding-system-for-read 'auto-save-coding)))
1858 (setq buffer-file-coding-system-explicit coding-system-for-read)) 1866 (setq buffer-file-coding-system-explicit
1867 (cons coding-system-for-read nil)))
1859 (if last-coding-system-used 1868 (if last-coding-system-used
1860 (let ((coding-system 1869 (let ((coding-system
1861 (find-new-buffer-file-coding-system last-coding-system-used))) 1870 (find-new-buffer-file-coding-system last-coding-system-used)))