comparison lisp/international/mule.el @ 59208:34a8622540ad

(explicit-buffer-file-coding-system): New buffer local variable. (after-insert-file-set-coding): Set it to coding-system-for-read.
author Kenichi Handa <handa@m17n.org>
date Thu, 30 Dec 2004 12:39:58 +0000
parents b38b4451693d
children 1d3fcf11a9ad
comparison
equal deleted inserted replaced
59207:3912575fcded 59208:34a8622540ad
1725 (error nil)))) 1725 (error nil))))
1726 coding-system))) 1726 coding-system)))
1727 1727
1728 (setq set-auto-coding-function 'set-auto-coding) 1728 (setq set-auto-coding-function 'set-auto-coding)
1729 1729
1730 (defun after-insert-file-set-coding (inserted) 1730 ;; This variable is set in these two cases:
1731 ;; (1) A file is read by a coding system specified explicitly.
1732 ;; after-insert-file-set-coding sets this value to
1733 ;; coding-system-for-read.
1734 ;; (2) A buffer is saved.
1735 ;; After writing, basic-save-buffer-1 sets this value to
1736 ;; last-coding-system-used.
1737 ;; This variable is used for decoding in revert-buffer.
1738 (defvar explicit-buffer-file-coding-system nil
1739 "The file coding system explicitly specified for the current buffer.
1740 Internal use only.")
1741 (make-variable-buffer-local 'explicit-buffer-file-coding-system)
1742 (put 'explicit-buffer-file-coding-system 'permanent-local t)
1743
1744 (defun after-insert-file-set-coding (inserted &optional visit)
1731 "Set `buffer-file-coding-system' of current buffer after text is inserted. 1745 "Set `buffer-file-coding-system' of current buffer after text is inserted.
1732 INSERTED is the number of characters that were inserted, as figured 1746 INSERTED is the number of characters that were inserted, as figured
1733 in the situation before this function. Return the number of characters 1747 in the situation before this function. Return the number of characters
1734 inserted, as figured in the situation after. The two numbers can be 1748 inserted, as figured in the situation after. The two numbers can be
1735 different if the buffer has become unibyte." 1749 different if the buffer has become unibyte.
1750 The optional second arg VISIT non-nil means that we are visiting a file."
1751 (if (and visit
1752 coding-system-for-read
1753 (not (eq coding-system-for-read 'auto-save-coding)))
1754 (setq explicit-buffer-file-coding-system coding-system-for-read))
1736 (if last-coding-system-used 1755 (if last-coding-system-used
1737 (let ((coding-system 1756 (let ((coding-system
1738 (find-new-buffer-file-coding-system last-coding-system-used)) 1757 (find-new-buffer-file-coding-system last-coding-system-used))
1739 (modified-p (buffer-modified-p))) 1758 (modified-p (buffer-modified-p)))
1740 (when coding-system 1759 (when coding-system