comparison lisp/international/mule.el @ 50584:e36ce541f439

(after-insert-file-set-coding): Properly treat INSERTED as number of characters, for both the argument and the value.
author Richard M. Stallman <rms@gnu.org>
date Mon, 14 Apr 2003 10:06:55 +0000
parents 589dbff3b754
children e5124f8f4dc9
comparison
equal deleted inserted replaced
50583:aea857f85930 50584:e36ce541f439
1693 coding-system))) 1693 coding-system)))
1694 1694
1695 (setq set-auto-coding-function 'set-auto-coding) 1695 (setq set-auto-coding-function 'set-auto-coding)
1696 1696
1697 (defun after-insert-file-set-coding (inserted) 1697 (defun after-insert-file-set-coding (inserted)
1698 "Set `buffer-file-coding-system' of current buffer after text is inserted." 1698 "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."
1699 (if last-coding-system-used 1703 (if last-coding-system-used
1700 (let ((coding-system 1704 (let ((coding-system
1701 (find-new-buffer-file-coding-system last-coding-system-used)) 1705 (find-new-buffer-file-coding-system last-coding-system-used))
1702 (modified-p (buffer-modified-p))) 1706 (modified-p (buffer-modified-p)))
1703 (when coding-system 1707 (when coding-system
1709 ;; same as INSERTED, we must be visiting it. 1713 ;; same as INSERTED, we must be visiting it.
1710 (not modified-p) 1714 (not modified-p)
1711 (= (buffer-size) inserted)) 1715 (= (buffer-size) inserted))
1712 ;; For coding systems no-conversion and raw-text..., 1716 ;; For coding systems no-conversion and raw-text...,
1713 ;; edit the buffer as unibyte. 1717 ;; edit the buffer as unibyte.
1714 (let ((pos-byte (position-bytes (+ (point) inserted)))) 1718 (let ((pos-marker (copy-marker (+ (point) inserted))))
1715 (set-buffer-multibyte nil) 1719 (set-buffer-multibyte nil)
1716 (setq inserted (- pos-byte (position-bytes (point)))))) 1720 (setq inserted (- pos-marker (point)))))
1717 (set-buffer-modified-p modified-p)))) 1721 (set-buffer-modified-p modified-p))))
1718 inserted) 1722 inserted)
1719 1723
1720 ;; The coding-spec and eol-type of coding-system returned is decided 1724 ;; The coding-spec and eol-type of coding-system returned is decided
1721 ;; independently in the following order. 1725 ;; independently in the following order.