1727 |
|
|
1728 |
(setq set-auto-coding-function 'set-auto-coding) |
(setq set-auto-coding-function 'set-auto-coding) |
1729 |
|
|
1730 |
(defun after-insert-file-set-coding (inserted) |
;; 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) |
1745 |
"Set `buffer-file-coding-system' of current buffer after text is inserted. |
"Set `buffer-file-coding-system' of current buffer after text is inserted. |
1746 |
INSERTED is the number of characters that were inserted, as figured |
INSERTED is the number of characters that were inserted, as figured |
1747 |
in the situation before this function. Return the number of characters |
in the situation before this function. Return the number of characters |
1748 |
inserted, as figured in the situation after. The two numbers can be |
inserted, as figured in the situation after. The two numbers can be |
1749 |
different if the buffer has become unibyte." |
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)) |
1755 |
(if last-coding-system-used |
(if last-coding-system-used |
1756 |
(let ((coding-system |
(let ((coding-system |
1757 |
(find-new-buffer-file-coding-system last-coding-system-used)) |
(find-new-buffer-file-coding-system last-coding-system-used)) |