changeset 20532:7ffd3d9afeb4

(Fminibuffer_complete_word): Handle bytes vs characters when comparing buffer against string. (temp_echo_area_glyphs): Save, update, delete text using byte and char positions. (read_minibuf): BACKUP_N counts bytes.
author Richard M. Stallman <rms@gnu.org>
date Wed, 31 Dec 1997 21:56:00 +0000
parents f019e056ad9a
children 60b9e88f8743
files src/minibuf.c
diffstat 1 files changed, 20 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/minibuf.c	Wed Dec 31 21:49:31 1997 +0000
+++ b/src/minibuf.c	Wed Dec 31 21:56:00 1997 +0000
@@ -188,7 +188,7 @@
 static Lisp_Object read_minibuf ();
 
 /* Read from the minibuffer using keymap MAP, initial contents INITIAL
-   (a string), putting point minus BACKUP_N chars from the end of INITIAL,
+   (a string), putting point minus BACKUP_N bytes from the end of INITIAL,
    prompting with PROMPT (a string), using history list HISTVAR
    with initial position HISTPOS.  (BACKUP_N should be <= 0.)
 
@@ -369,8 +369,8 @@
   if (!NILP (initial))
     {
       Finsert (1, &initial);
-      if (!NILP (backup_n) && INTEGERP (backup_n))
-	Fgoto_char (make_number (PT + XFASTINT (backup_n)));
+      if (INTEGERP (backup_n))
+	Fforward_char (backup_n);
     }
 
   echo_area_glyphs = 0;
@@ -1607,7 +1607,7 @@
 #else /* Rewritten code */
   {
     register unsigned char *buffer_string;
-    int buffer_length, completion_length;
+    int buffer_nbytes, completion_nbytes;
 
     CHECK_STRING (completion, 0);
     tem = Fbuffer_string ();
@@ -1627,26 +1627,25 @@
       }
     buffer_string = XSTRING (tem)->data;
     completion_string = XSTRING (completion)->data;
-    buffer_length = XSTRING (tem)->size; /* ie ZV - BEGV */
-    completion_length = XSTRING (completion)->size;
-    i = buffer_length - completion_length;
-    /* Mly: I don't understand what this is supposed to do AT ALL */
+    buffer_nbytes = XSTRING (tem)->size; /* ie ZV_BYTE - BEGV_BYTE */
+    completion_nbytes = XSTRING (completion)->size;
+    i = buffer_nbytes - completion_nbytes;
     if (i > 0 ||
-	0 <= scmp (buffer_string, completion_string, buffer_length))
+	0 <= scmp (buffer_string, completion_string, buffer_nbytes))
       {
 	/* Set buffer to longest match of buffer tail and completion head. */
 	if (i <= 0) i = 1;
 	buffer_string += i;
-	buffer_length -= i;
-	while (0 <= scmp (buffer_string++, completion_string, buffer_length--))
+	buffer_nbytes -= i;
+	while (0 <= scmp (buffer_string++, completion_string, buffer_nbytes--))
 	  i++;
-	del_range (1, i + 1);
-	SET_PT (ZV);
+	del_range_byte (1, i + 1, 1);
+	SET_PT_BOTH (ZV, ZV_BYTE);
       }
     UNGCPRO;
   }
 #endif /* Rewritten code */
-  i = ZV - BEGV;
+  i = ZV_BYTE - BEGV_BYTE;
 
   /* If completion finds next char not unique,
      consider adding a space or a hyphen. */
@@ -1695,7 +1694,7 @@
 
   /* If got no characters, print help for user.  */
 
-  if (i == ZV - BEGV)
+  if (i == ZV_BYTE - BEGV_BYTE)
     {
       if (auto_help)
 	Fminibuffer_completion_help ();
@@ -1926,20 +1925,22 @@
      char *m;
 {
   int osize = ZV;
+  int osize_byte = ZV_BYTE;
   int opoint = PT;
+  int opoint_byte = PT_BYTE;
   Lisp_Object oinhibit;
   oinhibit = Vinhibit_quit;
 
   /* Clear out any old echo-area message to make way for our new thing.  */
   message (0);
 
-  SET_PT (osize);
+  SET_PT_BOTH (osize, osize_byte);
   insert_string (m);
-  SET_PT (opoint);
+  SET_PT_BOTH (opoint, opoint_byte);
   Vinhibit_quit = Qt;
   Fsit_for (make_number (2), Qnil, Qnil);
-  del_range (osize, ZV);
-  SET_PT (opoint);
+  del_range_both (osize, ZV, osize_byte, ZV_BYTE, 1);
+  SET_PT_BOTH (opoint, opoint_byte);
   if (!NILP (Vquit_flag))
     {
       Vquit_flag = Qnil;