summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2004-12-30 12:39:58 +0000
committerKenichi Handa <handa@m17n.org>2004-12-30 12:39:58 +0000
commit0436cc1b60b6120208af957416cc92e8ba1665eb (patch)
tree5324cbd72c1efcd38d9875e569c00602b451aabd /lisp
parent37a3c7744cd360d7eb967fae90b562431bc021a5 (diff)
downloademacs-0436cc1b60b6120208af957416cc92e8ba1665eb.tar.gz
(explicit-buffer-file-coding-system): New
buffer local variable. (after-insert-file-set-coding): Set it to coding-system-for-read.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/international/mule.el23
1 files changed, 21 insertions, 2 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 3a8560f29fb..b493747bc61 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1727,12 +1727,31 @@ function by default."
(setq set-auto-coding-function 'set-auto-coding)
-(defun after-insert-file-set-coding (inserted)
+;; This variable is set in these two cases:
+;; (1) A file is read by a coding system specified explicitly.
+;; after-insert-file-set-coding sets this value to
+;; coding-system-for-read.
+;; (2) A buffer is saved.
+;; After writing, basic-save-buffer-1 sets this value to
+;; last-coding-system-used.
+;; This variable is used for decoding in revert-buffer.
+(defvar explicit-buffer-file-coding-system nil
+ "The file coding system explicitly specified for the current buffer.
+Internal use only.")
+(make-variable-buffer-local 'explicit-buffer-file-coding-system)
+(put 'explicit-buffer-file-coding-system 'permanent-local t)
+
+(defun after-insert-file-set-coding (inserted &optional visit)
"Set `buffer-file-coding-system' of current buffer after text is inserted.
INSERTED is the number of characters that were inserted, as figured
in the situation before this function. Return the number of characters
inserted, as figured in the situation after. The two numbers can be
-different if the buffer has become unibyte."
+different if the buffer has become unibyte.
+The optional second arg VISIT non-nil means that we are visiting a file."
+ (if (and visit
+ coding-system-for-read
+ (not (eq coding-system-for-read 'auto-save-coding)))
+ (setq explicit-buffer-file-coding-system coding-system-for-read))
(if last-coding-system-used
(let ((coding-system
(find-new-buffer-file-coding-system last-coding-system-used))