Mercurial > emacs
comparison src/minibuf.c @ 21854:67719e401cce
(minibuf_conform_representation): New function.
(Ftry_completion): Use it to return multibyte string
if and only if the completion table has a multibyte string.
(Fdisplay_completion_list):
Convert string to unibyte before displaying it, if default is unibyte.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 30 Apr 1998 03:16:00 +0000 |
parents | 79703e781c0a |
children | 547e4c0a42c0 |
comparison
equal
deleted
inserted
replaced
21853:6e93713b7d30 | 21854:67719e401cce |
---|---|
865 args[3] = require_match; | 865 args[3] = require_match; |
866 return Ffuncall(4, args); | 866 return Ffuncall(4, args); |
867 } | 867 } |
868 } | 868 } |
869 | 869 |
870 static Lisp_Object | |
871 minibuf_conform_representation (string, basis) | |
872 Lisp_Object string, basis; | |
873 { | |
874 if (STRING_MULTIBYTE (string) == STRING_MULTIBYTE (basis)) | |
875 return string; | |
876 | |
877 if (STRING_MULTIBYTE (string)) | |
878 return Fstring_make_unibyte (string); | |
879 else | |
880 return Fstring_make_multibyte (string); | |
881 } | |
882 | |
870 DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0, | 883 DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0, |
871 "Return common substring of all completions of STRING in ALIST.\n\ | 884 "Return common substring of all completions of STRING in ALIST.\n\ |
872 Each car of each element of ALIST is tested to see if it begins with STRING.\n\ | 885 Each car of each element of ALIST is tested to see if it begins with STRING.\n\ |
873 All that match are compared together; the longest initial sequence\n\ | 886 All that match are compared together; the longest initial sequence\n\ |
874 common to all matches is returned as a string.\n\ | 887 common to all matches is returned as a string.\n\ |
1060 /* If we are ignoring case, and there is no exact match, | 1073 /* If we are ignoring case, and there is no exact match, |
1061 and no additional text was supplied, | 1074 and no additional text was supplied, |
1062 don't change the case of what the user typed. */ | 1075 don't change the case of what the user typed. */ |
1063 if (completion_ignore_case && bestmatchsize == XSTRING (string)->size | 1076 if (completion_ignore_case && bestmatchsize == XSTRING (string)->size |
1064 && XSTRING (bestmatch)->size > bestmatchsize) | 1077 && XSTRING (bestmatch)->size > bestmatchsize) |
1065 return string; | 1078 return minibuf_conform_representation (string, bestmatch); |
1066 | 1079 |
1067 /* Return t if the supplied string is an exact match (counting case); | 1080 /* Return t if the supplied string is an exact match (counting case); |
1068 it does not require any change to be made. */ | 1081 it does not require any change to be made. */ |
1069 if (matchcount == 1 && bestmatchsize == XSTRING (string)->size | 1082 if (matchcount == 1 && bestmatchsize == XSTRING (string)->size |
1070 && (tem = Fcompare_strings (bestmatch, make_number (0), | 1083 && (tem = Fcompare_strings (bestmatch, make_number (0), |
1819 else | 1832 else |
1820 { | 1833 { |
1821 write_string ("Possible completions are:", -1); | 1834 write_string ("Possible completions are:", -1); |
1822 for (tail = completions, i = 0; !NILP (tail); tail = Fcdr (tail), i++) | 1835 for (tail = completions, i = 0; !NILP (tail); tail = Fcdr (tail), i++) |
1823 { | 1836 { |
1824 Lisp_Object tem; | 1837 Lisp_Object tem, string; |
1825 int length; | 1838 int length; |
1826 Lisp_Object startpos, endpos; | 1839 Lisp_Object startpos, endpos; |
1827 | 1840 |
1828 elt = Fcar (tail); | 1841 elt = Fcar (tail); |
1829 /* Compute the length of this element. */ | 1842 /* Compute the length of this element. */ |
1885 XSETINT (endpos, BUF_PT (XBUFFER (Vstandard_output))); | 1898 XSETINT (endpos, BUF_PT (XBUFFER (Vstandard_output))); |
1886 Fset_text_properties (startpos, endpos, | 1899 Fset_text_properties (startpos, endpos, |
1887 Qnil, Vstandard_output); | 1900 Qnil, Vstandard_output); |
1888 } | 1901 } |
1889 | 1902 |
1890 /* Output this element and update COLUMN. */ | 1903 /* Output this element. |
1904 If necessary, convert it to unibyte first. */ | |
1891 if (CONSP (elt)) | 1905 if (CONSP (elt)) |
1892 { | 1906 string = Fcar (elt); |
1893 Fprinc (Fcar (elt), Qnil); | |
1894 Fprinc (Fcar (Fcdr (elt)), Qnil); | |
1895 } | |
1896 else | 1907 else |
1897 Fprinc (elt, Qnil); | 1908 string = elt; |
1898 | 1909 if (NILP (current_buffer->enable_multibyte_characters) |
1910 && STRING_MULTIBYTE (string)) | |
1911 string = Fstring_make_unibyte (string); | |
1912 Fprinc (string, Qnil); | |
1913 | |
1914 /* Output the annotation for this element. */ | |
1915 if (CONSP (elt)) | |
1916 Fprinc (Fcar (Fcdr (elt)), Qnil); | |
1917 | |
1918 /* Update COLUMN for what we have output. */ | |
1899 column += length; | 1919 column += length; |
1900 | 1920 |
1901 /* If output is to a buffer, recompute COLUMN in a way | 1921 /* If output is to a buffer, recompute COLUMN in a way |
1902 that takes account of character widths. */ | 1922 that takes account of character widths. */ |
1903 if (BUFFERP (Vstandard_output)) | 1923 if (BUFFERP (Vstandard_output)) |