233 |
|
|
234 |
GCPRO2 (val, defalt); |
GCPRO2 (val, defalt); |
235 |
|
|
236 |
if (STRINGP (val) && XSTRING (val)->size == 0 |
if (STRINGP (val) && SCHARS (val) == 0 |
237 |
&& STRINGP (defalt)) |
&& STRINGP (defalt)) |
238 |
val = defalt; |
val = defalt; |
239 |
|
|
240 |
expr_and_pos = Fread_from_string (val, Qnil, Qnil); |
expr_and_pos = Fread_from_string (val, Qnil, Qnil); |
241 |
pos = XINT (Fcdr (expr_and_pos)); |
pos = XINT (Fcdr (expr_and_pos)); |
242 |
if (pos != XSTRING (val)->size) |
if (pos != SCHARS (val)) |
243 |
{ |
{ |
244 |
/* Ignore trailing whitespace; any other trailing junk |
/* Ignore trailing whitespace; any other trailing junk |
245 |
is an error. */ |
is an error. */ |
246 |
int i; |
int i; |
247 |
pos = string_char_to_byte (val, pos); |
pos = string_char_to_byte (val, pos); |
248 |
for (i = pos; i < STRING_BYTES (XSTRING (val)); i++) |
for (i = pos; i < SBYTES (val); i++) |
249 |
{ |
{ |
250 |
int c = XSTRING (val)->data[i]; |
int c = SREF (val, i); |
251 |
if (c != ' ' && c != '\t' && c != '\n') |
if (c != ' ' && c != '\t' && c != '\n') |
252 |
error ("Trailing garbage following expression"); |
error ("Trailing garbage following expression"); |
253 |
} |
} |
280 |
char *line, *s; |
char *line, *s; |
281 |
Lisp_Object val; |
Lisp_Object val; |
282 |
|
|
283 |
fprintf (stdout, "%s", XSTRING (prompt)->data); |
fprintf (stdout, "%s", SDATA (prompt)); |
284 |
fflush (stdout); |
fflush (stdout); |
285 |
|
|
286 |
val = Qnil; |
val = Qnil; |
648 |
last_minibuf_string = val; |
last_minibuf_string = val; |
649 |
|
|
650 |
/* Add the value to the appropriate history list unless it is empty. */ |
/* Add the value to the appropriate history list unless it is empty. */ |
651 |
if (XSTRING (val)->size != 0 |
if (SCHARS (val) != 0 |
652 |
&& SYMBOLP (Vminibuffer_history_variable)) |
&& SYMBOLP (Vminibuffer_history_variable)) |
653 |
{ |
{ |
654 |
/* If the caller wanted to save the value read on a history list, |
/* If the caller wanted to save the value read on a history list, |
868 |
/* Convert to distance from end of input. */ |
/* Convert to distance from end of input. */ |
869 |
if (XINT (position) < 1) |
if (XINT (position) < 1) |
870 |
/* A number too small means the beginning of the string. */ |
/* A number too small means the beginning of the string. */ |
871 |
pos = - XSTRING (initial_contents)->size; |
pos = - SCHARS (initial_contents); |
872 |
else |
else |
873 |
pos = XINT (position) - 1 - XSTRING (initial_contents)->size; |
pos = XINT (position) - 1 - SCHARS (initial_contents); |
874 |
} |
} |
875 |
} |
} |
876 |
|
|
950 |
val = Fread_from_minibuffer (prompt, initial_input, Qnil, |
val = Fread_from_minibuffer (prompt, initial_input, Qnil, |
951 |
Qnil, history, default_value, |
Qnil, history, default_value, |
952 |
inherit_input_method); |
inherit_input_method); |
953 |
if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (default_value)) |
if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value)) |
954 |
val = default_value; |
val = default_value; |
955 |
return val; |
return val; |
956 |
} |
} |
1185 |
/* Is this element a possible completion? */ |
/* Is this element a possible completion? */ |
1186 |
|
|
1187 |
if (STRINGP (eltstring) |
if (STRINGP (eltstring) |
1188 |
&& XSTRING (string)->size <= XSTRING (eltstring)->size |
&& SCHARS (string) <= SCHARS (eltstring) |
1189 |
&& (tem = Fcompare_strings (eltstring, make_number (0), |
&& (tem = Fcompare_strings (eltstring, make_number (0), |
1190 |
make_number (XSTRING (string)->size), |
make_number (SCHARS (string)), |
1191 |
string, make_number (0), Qnil, |
string, make_number (0), Qnil, |
1192 |
completion_ignore_case ?Qt : Qnil), |
completion_ignore_case ?Qt : Qnil), |
1193 |
EQ (Qt, tem))) |
EQ (Qt, tem))) |
1233 |
{ |
{ |
1234 |
matchcount = 1; |
matchcount = 1; |
1235 |
bestmatch = eltstring; |
bestmatch = eltstring; |
1236 |
bestmatchsize = XSTRING (eltstring)->size; |
bestmatchsize = SCHARS (eltstring); |
1237 |
} |
} |
1238 |
else |
else |
1239 |
{ |
{ |
1240 |
compare = min (bestmatchsize, XSTRING (eltstring)->size); |
compare = min (bestmatchsize, SCHARS (eltstring)); |
1241 |
tem = Fcompare_strings (bestmatch, make_number (0), |
tem = Fcompare_strings (bestmatch, make_number (0), |
1242 |
make_number (compare), |
make_number (compare), |
1243 |
eltstring, make_number (0), |
eltstring, make_number (0), |
1259 |
use it as the best match rather than one that is not an |
use it as the best match rather than one that is not an |
1260 |
exact match. This way, we get the case pattern |
exact match. This way, we get the case pattern |
1261 |
of the actual match. */ |
of the actual match. */ |
1262 |
if ((matchsize == XSTRING (eltstring)->size |
if ((matchsize == SCHARS (eltstring) |
1263 |
&& matchsize < XSTRING (bestmatch)->size) |
&& matchsize < SCHARS (bestmatch)) |
1264 |
|| |
|| |
1265 |
/* If there is more than one exact match ignoring case, |
/* If there is more than one exact match ignoring case, |
1266 |
and one of them is exact including case, |
and one of them is exact including case, |
1268 |
/* If there is no exact match ignoring case, |
/* If there is no exact match ignoring case, |
1269 |
prefer a match that does not change the case |
prefer a match that does not change the case |
1270 |
of the input. */ |
of the input. */ |
1271 |
((matchsize == XSTRING (eltstring)->size) |
((matchsize == SCHARS (eltstring)) |
1272 |
== |
== |
1273 |
(matchsize == XSTRING (bestmatch)->size) |
(matchsize == SCHARS (bestmatch)) |
1274 |
&& (tem = Fcompare_strings (eltstring, make_number (0), |
&& (tem = Fcompare_strings (eltstring, make_number (0), |
1275 |
make_number (XSTRING (string)->size), |
make_number (SCHARS (string)), |
1276 |
string, make_number (0), |
string, make_number (0), |
1277 |
Qnil, |
Qnil, |
1278 |
Qnil), |
Qnil), |
1279 |
EQ (Qt, tem)) |
EQ (Qt, tem)) |
1280 |
&& (tem = Fcompare_strings (bestmatch, make_number (0), |
&& (tem = Fcompare_strings (bestmatch, make_number (0), |
1281 |
make_number (XSTRING (string)->size), |
make_number (SCHARS (string)), |
1282 |
string, make_number (0), |
string, make_number (0), |
1283 |
Qnil, |
Qnil, |
1284 |
Qnil), |
Qnil), |
1285 |
! EQ (Qt, tem)))) |
! EQ (Qt, tem)))) |
1286 |
bestmatch = eltstring; |
bestmatch = eltstring; |
1287 |
} |
} |
1288 |
if (bestmatchsize != XSTRING (eltstring)->size |
if (bestmatchsize != SCHARS (eltstring) |
1289 |
|| bestmatchsize != matchsize) |
|| bestmatchsize != matchsize) |
1290 |
/* Don't count the same string multiple times. */ |
/* Don't count the same string multiple times. */ |
1291 |
matchcount++; |
matchcount++; |
1292 |
bestmatchsize = matchsize; |
bestmatchsize = matchsize; |
1293 |
if (matchsize <= XSTRING (string)->size |
if (matchsize <= SCHARS (string) |
1294 |
&& matchcount > 1) |
&& matchcount > 1) |
1295 |
/* No need to look any further. */ |
/* No need to look any further. */ |
1296 |
break; |
break; |
1303 |
/* If we are ignoring case, and there is no exact match, |
/* If we are ignoring case, and there is no exact match, |
1304 |
and no additional text was supplied, |
and no additional text was supplied, |
1305 |
don't change the case of what the user typed. */ |
don't change the case of what the user typed. */ |
1306 |
if (completion_ignore_case && bestmatchsize == XSTRING (string)->size |
if (completion_ignore_case && bestmatchsize == SCHARS (string) |
1307 |
&& XSTRING (bestmatch)->size > bestmatchsize) |
&& SCHARS (bestmatch) > bestmatchsize) |
1308 |
return minibuf_conform_representation (string, bestmatch); |
return minibuf_conform_representation (string, bestmatch); |
1309 |
|
|
1310 |
/* Return t if the supplied string is an exact match (counting case); |
/* Return t if the supplied string is an exact match (counting case); |
1311 |
it does not require any change to be made. */ |
it does not require any change to be made. */ |
1312 |
if (matchcount == 1 && bestmatchsize == XSTRING (string)->size |
if (matchcount == 1 && bestmatchsize == SCHARS (string) |
1313 |
&& (tem = Fcompare_strings (bestmatch, make_number (0), |
&& (tem = Fcompare_strings (bestmatch, make_number (0), |
1314 |
make_number (bestmatchsize), |
make_number (bestmatchsize), |
1315 |
string, make_number (0), |
string, make_number (0), |
1423 |
/* Is this element a possible completion? */ |
/* Is this element a possible completion? */ |
1424 |
|
|
1425 |
if (STRINGP (eltstring) |
if (STRINGP (eltstring) |
1426 |
&& XSTRING (string)->size <= XSTRING (eltstring)->size |
&& SCHARS (string) <= SCHARS (eltstring) |
1427 |
/* If HIDE_SPACES, reject alternatives that start with space |
/* If HIDE_SPACES, reject alternatives that start with space |
1428 |
unless the input starts with space. */ |
unless the input starts with space. */ |
1429 |
&& ((STRING_BYTES (XSTRING (string)) > 0 |
&& ((SBYTES (string) > 0 |
1430 |
&& XSTRING (string)->data[0] == ' ') |
&& SREF (string, 0) == ' ') |
1431 |
|| XSTRING (eltstring)->data[0] != ' ' |
|| SREF (eltstring, 0) != ' ' |
1432 |
|| NILP (hide_spaces)) |
|| NILP (hide_spaces)) |
1433 |
&& (tem = Fcompare_strings (eltstring, make_number (0), |
&& (tem = Fcompare_strings (eltstring, make_number (0), |
1434 |
make_number (XSTRING (string)->size), |
make_number (SCHARS (string)), |
1435 |
string, make_number (0), |
string, make_number (0), |
1436 |
make_number (XSTRING (string)->size), |
make_number (SCHARS (string)), |
1437 |
completion_ignore_case ? Qt : Qnil), |
completion_ignore_case ? Qt : Qnil), |
1438 |
EQ (Qt, tem))) |
EQ (Qt, tem))) |
1439 |
{ |
{ |
1553 |
{ |
{ |
1554 |
CHECK_NUMBER (position); |
CHECK_NUMBER (position); |
1555 |
/* Convert to distance from end of input. */ |
/* Convert to distance from end of input. */ |
1556 |
pos = XINT (position) - XSTRING (init)->size; |
pos = XINT (position) - SCHARS (init); |
1557 |
} |
} |
1558 |
} |
} |
1559 |
|
|
1579 |
histvar, histpos, def, 0, |
histvar, histpos, def, 0, |
1580 |
!NILP (inherit_input_method)); |
!NILP (inherit_input_method)); |
1581 |
|
|
1582 |
if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (def)) |
if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (def)) |
1583 |
val = def; |
val = def; |
1584 |
|
|
1585 |
RETURN_UNGCPRO (unbind_to (count, val)); |
RETURN_UNGCPRO (unbind_to (count, val)); |
1613 |
{ |
{ |
1614 |
/* Bypass intern-soft as that loses for nil. */ |
/* Bypass intern-soft as that loses for nil. */ |
1615 |
tem = oblookup (alist, |
tem = oblookup (alist, |
1616 |
XSTRING (string)->data, |
SDATA (string), |
1617 |
XSTRING (string)->size, |
SCHARS (string), |
1618 |
STRING_BYTES (XSTRING (string))); |
SBYTES (string)); |
1619 |
if (!SYMBOLP (tem)) |
if (!SYMBOLP (tem)) |
1620 |
{ |
{ |
1621 |
if (STRING_MULTIBYTE (string)) |
if (STRING_MULTIBYTE (string)) |
1624 |
string = Fstring_make_multibyte (string); |
string = Fstring_make_multibyte (string); |
1625 |
|
|
1626 |
tem = oblookup (Vminibuffer_completion_table, |
tem = oblookup (Vminibuffer_completion_table, |
1627 |
XSTRING (string)->data, |
SDATA (string), |
1628 |
XSTRING (string)->size, |
SCHARS (string), |
1629 |
STRING_BYTES (XSTRING (string))); |
SBYTES (string)); |
1630 |
if (!SYMBOLP (tem)) |
if (!SYMBOLP (tem)) |
1631 |
return Qnil; |
return Qnil; |
1632 |
} |
} |
1716 |
/* Some completion happened */ |
/* Some completion happened */ |
1717 |
|
|
1718 |
if (! NILP (Vminibuffer_completing_file_name) |
if (! NILP (Vminibuffer_completing_file_name) |
1719 |
&& XSTRING (completion)->data[STRING_BYTES (XSTRING (completion)) - 1] == '/' |
&& SREF (completion, SBYTES (completion) - 1) == '/' |
1720 |
&& PT < ZV |
&& PT < ZV |
1721 |
&& FETCH_CHAR (PT_BYTE) == '/') |
&& FETCH_CHAR (PT_BYTE) == '/') |
1722 |
{ |
{ |
1963 |
|
|
1964 |
#if 0 /* How the below code used to look, for reference. */ |
#if 0 /* How the below code used to look, for reference. */ |
1965 |
tem = Fminibuffer_contents (); |
tem = Fminibuffer_contents (); |
1966 |
b = XSTRING (tem)->data; |
b = SDATA (tem); |
1967 |
i = ZV - 1 - XSTRING (completion)->size; |
i = ZV - 1 - SCHARS (completion); |
1968 |
p = XSTRING (completion)->data; |
p = SDATA (completion); |
1969 |
if (i > 0 || |
if (i > 0 || |
1970 |
0 <= scmp (b, p, ZV - 1)) |
0 <= scmp (b, p, ZV - 1)) |
1971 |
{ |
{ |
1996 |
Finsert (1, &tem); |
Finsert (1, &tem); |
1997 |
} |
} |
1998 |
} |
} |
1999 |
buffer_nchars = XSTRING (tem)->size; /* # chars in what we completed. */ |
buffer_nchars = SCHARS (tem); /* # chars in what we completed. */ |
2000 |
completion_nchars = XSTRING (completion)->size; |
completion_nchars = SCHARS (completion); |
2001 |
i = buffer_nchars - completion_nchars; |
i = buffer_nchars - completion_nchars; |
2002 |
if (i > 0 |
if (i > 0 |
2003 |
|| |
|| |
2042 |
|
|
2043 |
/* If completion finds next char not unique, |
/* If completion finds next char not unique, |
2044 |
consider adding a space or a hyphen. */ |
consider adding a space or a hyphen. */ |
2045 |
if (i == XSTRING (completion)->size) |
if (i == SCHARS (completion)) |
2046 |
{ |
{ |
2047 |
GCPRO1 (completion); |
GCPRO1 (completion); |
2048 |
tem = Ftry_completion (concat2 (minibuffer_completion_contents (), |
tem = Ftry_completion (concat2 (minibuffer_completion_contents (), |
2072 |
i gets index in string of where to stop completing. */ |
i gets index in string of where to stop completing. */ |
2073 |
{ |
{ |
2074 |
int len, c; |
int len, c; |
2075 |
int bytes = STRING_BYTES (XSTRING (completion)); |
int bytes = SBYTES (completion); |
2076 |
completion_string = XSTRING (completion)->data; |
completion_string = SDATA (completion); |
2077 |
for (; i_byte < STRING_BYTES (XSTRING (completion)); i_byte += len, i++) |
for (; i_byte < SBYTES (completion); i_byte += len, i++) |
2078 |
{ |
{ |
2079 |
c = STRING_CHAR_AND_LENGTH (completion_string + i_byte, |
c = STRING_CHAR_AND_LENGTH (completion_string + i_byte, |
2080 |
bytes - i_byte, |
bytes - i_byte, |
2100 |
/* Otherwise insert in minibuffer the chars we got */ |
/* Otherwise insert in minibuffer the chars we got */ |
2101 |
|
|
2102 |
if (! NILP (Vminibuffer_completing_file_name) |
if (! NILP (Vminibuffer_completing_file_name) |
2103 |
&& XSTRING (completion)->data[STRING_BYTES (XSTRING (completion)) - 1] == '/' |
&& SREF (completion, SBYTES (completion) - 1) == '/' |
2104 |
&& PT < ZV |
&& PT < ZV |
2105 |
&& FETCH_CHAR (PT_BYTE) == '/') |
&& FETCH_CHAR (PT_BYTE) == '/') |
2106 |
{ |
{ |
2163 |
{ |
{ |
2164 |
tem = XCAR (elt); |
tem = XCAR (elt); |
2165 |
CHECK_STRING (tem); |
CHECK_STRING (tem); |
2166 |
length = XSTRING (tem)->size; |
length = SCHARS (tem); |
2167 |
|
|
2168 |
tem = Fcar (XCDR (elt)); |
tem = Fcar (XCDR (elt)); |
2169 |
CHECK_STRING (tem); |
CHECK_STRING (tem); |
2170 |
length += XSTRING (tem)->size; |
length += SCHARS (tem); |
2171 |
} |
} |
2172 |
else |
else |
2173 |
{ |
{ |
2174 |
CHECK_STRING (elt); |
CHECK_STRING (elt); |
2175 |
length = XSTRING (elt)->size; |
length = SCHARS (elt); |
2176 |
} |
} |
2177 |
|
|
2178 |
/* This does a bad job for narrower than usual windows. |
/* This does a bad job for narrower than usual windows. |
2400 |
(string) |
(string) |
2401 |
Lisp_Object string; |
Lisp_Object string; |
2402 |
{ |
{ |
2403 |
temp_echo_area_glyphs (XSTRING (string)->data); |
temp_echo_area_glyphs (SDATA (string)); |
2404 |
return Qnil; |
return Qnil; |
2405 |
} |
} |
2406 |
|
|