1695 |
(setq set-auto-coding-function 'set-auto-coding) |
(setq set-auto-coding-function 'set-auto-coding) |
1696 |
|
|
1697 |
(defun after-insert-file-set-coding (inserted) |
(defun after-insert-file-set-coding (inserted) |
1698 |
"Set `buffer-file-coding-system' of current buffer after text is inserted." |
"Set `buffer-file-coding-system' of current buffer after text is inserted. |
1699 |
|
INSERTED is the number of characters that were inserted, as figured |
1700 |
|
in the situation before this function. Return the number of characters |
1701 |
|
inserted, as figured in the situation after. The two numbers can be |
1702 |
|
different if the buffer has become unibyte." |
1703 |
(if last-coding-system-used |
(if last-coding-system-used |
1704 |
(let ((coding-system |
(let ((coding-system |
1705 |
(find-new-buffer-file-coding-system last-coding-system-used)) |
(find-new-buffer-file-coding-system last-coding-system-used)) |
1715 |
(= (buffer-size) inserted)) |
(= (buffer-size) inserted)) |
1716 |
;; For coding systems no-conversion and raw-text..., |
;; For coding systems no-conversion and raw-text..., |
1717 |
;; edit the buffer as unibyte. |
;; edit the buffer as unibyte. |
1718 |
(let ((pos-byte (position-bytes (+ (point) inserted)))) |
(let ((pos-marker (copy-marker (+ (point) inserted)))) |
1719 |
(set-buffer-multibyte nil) |
(set-buffer-multibyte nil) |
1720 |
(setq inserted (- pos-byte (position-bytes (point)))))) |
(setq inserted (- pos-marker (point))))) |
1721 |
(set-buffer-modified-p modified-p)))) |
(set-buffer-modified-p modified-p)))) |
1722 |
inserted) |
inserted) |
1723 |
|
|