changeset 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 aea857f85930
children 1e9e1fa3548b
files lisp/international/mule.el
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/mule.el	Mon Apr 14 10:00:00 2003 +0000
+++ b/lisp/international/mule.el	Mon Apr 14 10:06:55 2003 +0000
@@ -1695,7 +1695,11 @@
 (setq set-auto-coding-function 'set-auto-coding)
 
 (defun after-insert-file-set-coding (inserted)
-  "Set `buffer-file-coding-system' of current buffer after text is inserted."
+  "Set `buffer-file-coding-system' of current buffer after text is inserted.
+INSERTED is the number of characters that were inserted, as figured
+in the situation before this function.  Return the number of characters
+inserted, as figured in the situation after.  The two numbers can be
+different if the buffer has become unibyte."
   (if last-coding-system-used
       (let ((coding-system
 	     (find-new-buffer-file-coding-system last-coding-system-used))
@@ -1711,9 +1715,9 @@
 		   (= (buffer-size) inserted))
 	      ;; For coding systems no-conversion and raw-text...,
 	      ;; edit the buffer as unibyte.
-	      (let ((pos-byte (position-bytes (+ (point) inserted))))
+	      (let ((pos-marker (copy-marker (+ (point) inserted))))
 		(set-buffer-multibyte nil)
-		(setq inserted (- pos-byte (position-bytes (point))))))
+		(setq inserted (- pos-marker (point)))))
 	  (set-buffer-modified-p modified-p))))
   inserted)