aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-12-31 21:56:00 +0000
committerRichard M. Stallman1997-12-31 21:56:00 +0000
commita9c26562b3d0790b1dadf242d8ad3b10bbafe381 (patch)
tree27c6aba2a90e66ac9e6355cc64cb21a38c9deaea /src
parentc399b46133cc44fec697b4d124b10ee8b987d48c (diff)
downloademacs-a9c26562b3d0790b1dadf242d8ad3b10bbafe381.tar.gz
emacs-a9c26562b3d0790b1dadf242d8ad3b10bbafe381.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/minibuf.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index c08e2d3754b..b062b9d3ddc 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -188,7 +188,7 @@ Lisp_Object get_minibuffer ();
188static Lisp_Object read_minibuf (); 188static Lisp_Object read_minibuf ();
189 189
190/* Read from the minibuffer using keymap MAP, initial contents INITIAL 190/* Read from the minibuffer using keymap MAP, initial contents INITIAL
191 (a string), putting point minus BACKUP_N chars from the end of INITIAL, 191 (a string), putting point minus BACKUP_N bytes from the end of INITIAL,
192 prompting with PROMPT (a string), using history list HISTVAR 192 prompting with PROMPT (a string), using history list HISTVAR
193 with initial position HISTPOS. (BACKUP_N should be <= 0.) 193 with initial position HISTPOS. (BACKUP_N should be <= 0.)
194 194
@@ -369,8 +369,8 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
369 if (!NILP (initial)) 369 if (!NILP (initial))
370 { 370 {
371 Finsert (1, &initial); 371 Finsert (1, &initial);
372 if (!NILP (backup_n) && INTEGERP (backup_n)) 372 if (INTEGERP (backup_n))
373 Fgoto_char (make_number (PT + XFASTINT (backup_n))); 373 Fforward_char (backup_n);
374 } 374 }
375 375
376 echo_area_glyphs = 0; 376 echo_area_glyphs = 0;
@@ -1607,7 +1607,7 @@ Return nil if there is no valid completion, else t.")
1607#else /* Rewritten code */ 1607#else /* Rewritten code */
1608 { 1608 {
1609 register unsigned char *buffer_string; 1609 register unsigned char *buffer_string;
1610 int buffer_length, completion_length; 1610 int buffer_nbytes, completion_nbytes;
1611 1611
1612 CHECK_STRING (completion, 0); 1612 CHECK_STRING (completion, 0);
1613 tem = Fbuffer_string (); 1613 tem = Fbuffer_string ();
@@ -1627,26 +1627,25 @@ Return nil if there is no valid completion, else t.")
1627 } 1627 }
1628 buffer_string = XSTRING (tem)->data; 1628 buffer_string = XSTRING (tem)->data;
1629 completion_string = XSTRING (completion)->data; 1629 completion_string = XSTRING (completion)->data;
1630 buffer_length = XSTRING (tem)->size; /* ie ZV - BEGV */ 1630 buffer_nbytes = XSTRING (tem)->size; /* ie ZV_BYTE - BEGV_BYTE */
1631 completion_length = XSTRING (completion)->size; 1631 completion_nbytes = XSTRING (completion)->size;
1632 i = buffer_length - completion_length; 1632 i = buffer_nbytes - completion_nbytes;
1633 /* Mly: I don't understand what this is supposed to do AT ALL */
1634 if (i > 0 || 1633 if (i > 0 ||
1635 0 <= scmp (buffer_string, completion_string, buffer_length)) 1634 0 <= scmp (buffer_string, completion_string, buffer_nbytes))
1636 { 1635 {
1637 /* Set buffer to longest match of buffer tail and completion head. */ 1636 /* Set buffer to longest match of buffer tail and completion head. */
1638 if (i <= 0) i = 1; 1637 if (i <= 0) i = 1;
1639 buffer_string += i; 1638 buffer_string += i;
1640 buffer_length -= i; 1639 buffer_nbytes -= i;
1641 while (0 <= scmp (buffer_string++, completion_string, buffer_length--)) 1640 while (0 <= scmp (buffer_string++, completion_string, buffer_nbytes--))
1642 i++; 1641 i++;
1643 del_range (1, i + 1); 1642 del_range_byte (1, i + 1, 1);
1644 SET_PT (ZV); 1643 SET_PT_BOTH (ZV, ZV_BYTE);
1645 } 1644 }
1646 UNGCPRO; 1645 UNGCPRO;
1647 } 1646 }
1648#endif /* Rewritten code */ 1647#endif /* Rewritten code */
1649 i = ZV - BEGV; 1648 i = ZV_BYTE - BEGV_BYTE;
1650 1649
1651 /* If completion finds next char not unique, 1650 /* If completion finds next char not unique,
1652 consider adding a space or a hyphen. */ 1651 consider adding a space or a hyphen. */
@@ -1695,7 +1694,7 @@ Return nil if there is no valid completion, else t.")
1695 1694
1696 /* If got no characters, print help for user. */ 1695 /* If got no characters, print help for user. */
1697 1696
1698 if (i == ZV - BEGV) 1697 if (i == ZV_BYTE - BEGV_BYTE)
1699 { 1698 {
1700 if (auto_help) 1699 if (auto_help)
1701 Fminibuffer_completion_help (); 1700 Fminibuffer_completion_help ();
@@ -1926,20 +1925,22 @@ temp_echo_area_glyphs (m)
1926 char *m; 1925 char *m;
1927{ 1926{
1928 int osize = ZV; 1927 int osize = ZV;
1928 int osize_byte = ZV_BYTE;
1929 int opoint = PT; 1929 int opoint = PT;
1930 int opoint_byte = PT_BYTE;
1930 Lisp_Object oinhibit; 1931 Lisp_Object oinhibit;
1931 oinhibit = Vinhibit_quit; 1932 oinhibit = Vinhibit_quit;
1932 1933
1933 /* Clear out any old echo-area message to make way for our new thing. */ 1934 /* Clear out any old echo-area message to make way for our new thing. */
1934 message (0); 1935 message (0);
1935 1936
1936 SET_PT (osize); 1937 SET_PT_BOTH (osize, osize_byte);
1937 insert_string (m); 1938 insert_string (m);
1938 SET_PT (opoint); 1939 SET_PT_BOTH (opoint, opoint_byte);
1939 Vinhibit_quit = Qt; 1940 Vinhibit_quit = Qt;
1940 Fsit_for (make_number (2), Qnil, Qnil); 1941 Fsit_for (make_number (2), Qnil, Qnil);
1941 del_range (osize, ZV); 1942 del_range_both (osize, ZV, osize_byte, ZV_BYTE, 1);
1942 SET_PT (opoint); 1943 SET_PT_BOTH (opoint, opoint_byte);
1943 if (!NILP (Vquit_flag)) 1944 if (!NILP (Vquit_flag))
1944 { 1945 {
1945 Vquit_flag = Qnil; 1946 Vquit_flag = Qnil;