diff options
| author | Kenichi Handa | 2004-12-30 12:39:58 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-12-30 12:39:58 +0000 |
| commit | 0436cc1b60b6120208af957416cc92e8ba1665eb (patch) | |
| tree | 5324cbd72c1efcd38d9875e569c00602b451aabd | |
| parent | 37a3c7744cd360d7eb967fae90b562431bc021a5 (diff) | |
| download | emacs-0436cc1b60b6120208af957416cc92e8ba1665eb.tar.gz emacs-0436cc1b60b6120208af957416cc92e8ba1665eb.zip | |
(explicit-buffer-file-coding-system): New
buffer local variable.
(after-insert-file-set-coding): Set it to coding-system-for-read.
| -rw-r--r-- | lisp/international/mule.el | 23 |
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." | |||
| 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)) |