aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1997-08-26 11:42:33 +0000
committerKenichi Handa1997-08-26 11:42:33 +0000
commitcee545397486bf5610fa7ab6def2b4cf8896e813 (patch)
treed6b349abfdf0be33ff49665deab9371d5170fa72 /src
parent166c822d2e424e0b067b709e8d07b8b89c39f2f0 (diff)
downloademacs-cee545397486bf5610fa7ab6def2b4cf8896e813.tar.gz
emacs-cee545397486bf5610fa7ab6def2b4cf8896e813.zip
(Qcurrent_input_method, Qactivate_input_method): New
variables. (syms_of_minibuf): Intern and staticpro them. (read_minibuf): New argument INHERIT_INPUT_METHOD. If it is nonzero, remember the current input method in INPUT_METHOD, and activate it after switching to the minibuffer. (Fread_from_minibuffer): New argument INHERIT_INPUT_METHOD. (Fread_minibuffer): Call read_minibuf with INHERIT_INPUT_METHOD nil. (Fread_string): New argument INHERIT_INPUT_METHOD. (Fread_no_blanks_input): Likewise. (Fread_command): Call Fcompleting_read with INHERIT_INPUT_METHOD nil. (Fread_function, Fread_variable, Fread_buffer): Likewise (Fcompleting_read): New argument INHERIT_INPUT_METHOD.
Diffstat (limited to 'src')
-rw-r--r--src/minibuf.c100
1 files changed, 70 insertions, 30 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index 34a33adb8b0..7dc0bf7b7ee 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -112,6 +112,9 @@ Lisp_Object Qminibuffer_default;
112extern Lisp_Object Vminibuf_scroll_window; 112extern Lisp_Object Vminibuf_scroll_window;
113 113
114extern Lisp_Object Voverriding_local_map; 114extern Lisp_Object Voverriding_local_map;
115
116Lisp_Object Qcurrent_input_method, Qactivate_input_method;
117
115 118
116/* Put minibuf on currently selected frame's minibuffer. 119/* Put minibuf on currently selected frame's minibuffer.
117 We do this whenever the user starts a new minibuffer 120 We do this whenever the user starts a new minibuffer
@@ -193,11 +196,14 @@ static Lisp_Object read_minibuf ();
193 196
194 DEFALT specifies te default value for the sake of history commands. 197 DEFALT specifies te default value for the sake of history commands.
195 198
196 If ALLOW_PROPS is nonzero, we do not throw away text properties. */ 199 If ALLOW_PROPS is nonzero, we do not throw away text properties.
200
201 if INHERIT_INPUT_METHOD is nonzeor, the minibuffer inherit the
202 current input method. */
197 203
198static Lisp_Object 204static Lisp_Object
199read_minibuf (map, initial, prompt, backup_n, expflag, 205read_minibuf (map, initial, prompt, backup_n, expflag,
200 histvar, histpos, defalt, allow_props, disable_multibyte) 206 histvar, histpos, defalt, allow_props, inherit_input_method)
201 Lisp_Object map; 207 Lisp_Object map;
202 Lisp_Object initial; 208 Lisp_Object initial;
203 Lisp_Object prompt; 209 Lisp_Object prompt;
@@ -206,12 +212,12 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
206 Lisp_Object histvar; 212 Lisp_Object histvar;
207 Lisp_Object histpos; 213 Lisp_Object histpos;
208 Lisp_Object defalt; 214 Lisp_Object defalt;
209 int disable_multibyte; 215 int inherit_input_method;
210{ 216{
211 Lisp_Object val; 217 Lisp_Object val;
212 int count = specpdl_ptr - specpdl; 218 int count = specpdl_ptr - specpdl;
213 Lisp_Object mini_frame, ambient_dir, minibuffer; 219 Lisp_Object mini_frame, ambient_dir, minibuffer, input_method;
214 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 220 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
215 221
216 specbind (Qminibuffer_default, defalt); 222 specbind (Qminibuffer_default, defalt);
217 223
@@ -219,11 +225,12 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
219 225
220 val = Qnil; 226 val = Qnil;
221 ambient_dir = current_buffer->directory; 227 ambient_dir = current_buffer->directory;
228 input_method = Qnil;
222 229
223 /* Don't need to protect PROMPT, HISTVAR, and HISTPOS because we 230 /* Don't need to protect PROMPT, HISTVAR, and HISTPOS because we
224 store them away before we can GC. Don't need to protect 231 store them away before we can GC. Don't need to protect
225 BACKUP_N because we use the value only if it is an integer. */ 232 BACKUP_N because we use the value only if it is an integer. */
226 GCPRO4 (map, initial, val, ambient_dir); 233 GCPRO5 (map, initial, val, ambient_dir, input_method);
227 234
228 if (!STRINGP (prompt)) 235 if (!STRINGP (prompt))
229 prompt = build_string (""); 236 prompt = build_string ("");
@@ -291,6 +298,11 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
291 Vminibuffer_history_variable = histvar; 298 Vminibuffer_history_variable = histvar;
292 Vhelp_form = Vminibuffer_help_form; 299 Vhelp_form = Vminibuffer_help_form;
293 300
301 if (inherit_input_method)
302 /* `current-input-method' is buffer local. So, remeber it in
303 INPUT_METHOD before changing the current buffer. */
304 input_method = Fsymbol_value (Qcurrent_input_method);
305
294 /* Switch to the minibuffer. */ 306 /* Switch to the minibuffer. */
295 307
296 minibuffer = get_minibuffer (minibuf_level); 308 minibuffer = get_minibuffer (minibuf_level);
@@ -358,6 +370,10 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
358 370
359 current_buffer->keymap = map; 371 current_buffer->keymap = map;
360 372
373 /* Turn on an input method stored in INPUT_METHOD if any. */
374 if (STRINGP (input_method) && Ffboundp (Qactivate_input_method))
375 call1 (Qactivate_input_method, input_method);
376
361 /* Run our hook, but not if it is empty. 377 /* Run our hook, but not if it is empty.
362 (run-hooks would do nothing if it is empty, 378 (run-hooks would do nothing if it is empty,
363 but it's important to save time here in the usual case). */ 379 but it's important to save time here in the usual case). */
@@ -561,7 +577,7 @@ read_minibuf_unwind (data)
561 for make-docfile to see. We cannot put this in the real DEFUN 577 for make-docfile to see. We cannot put this in the real DEFUN
562 due to limits in the Unix cpp. 578 due to limits in the Unix cpp.
563 579
564DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 6, 0, 580DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 7, 0,
565 "Read a string from the minibuffer, prompting with string PROMPT.\n\ 581 "Read a string from the minibuffer, prompting with string PROMPT.\n\
566If optional second arg INITIAL-CONTENTS is non-nil, it is a string\n\ 582If optional second arg INITIAL-CONTENTS is non-nil, it is a string\n\
567 to be inserted into the minibuffer before reading input.\n\ 583 to be inserted into the minibuffer before reading input.\n\
@@ -583,14 +599,19 @@ Fifth arg HIST, if non-nil, specifies a history list\n\
583Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is used\n\ 599Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is used\n\
584 for history commands, and as the value to return if the user enters\n\ 600 for history commands, and as the value to return if the user enters\n\
585 the empty string.\n\ 601 the empty string.\n\
602Seventh arg INHERIT-INPUT-METHOD non-nil means the minibuffer inherits\n\
603 the current input method.\n\
586If the variable `minibuffer-allow-text-properties is non-nil,\n\ 604If the variable `minibuffer-allow-text-properties is non-nil,\n\
587 then the string which is returned includes whatever text properties\n\ 605 then the string which is returned includes whatever text properties\n\
588 were present in the minibuffer. Otherwise the value has no text properties. */ 606 were present in the minibuffer. Otherwise the value has no text properties.")
607 (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method)
608 */
589 609
590DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 6, 0, 610DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 7, 0,
591 0 /* See immediately above */) 611 0 /* See immediately above */)
592 (prompt, initial_contents, keymap, read, hist, default_value) 612 (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method)
593 Lisp_Object prompt, initial_contents, keymap, read, hist, default_value; 613 Lisp_Object prompt, initial_contents, keymap, read, hist, default_value;
614 Lisp_Object inherit_input_method;
594{ 615{
595 int pos = 0; 616 int pos = 0;
596 Lisp_Object histvar, histpos, position, val; 617 Lisp_Object histvar, histpos, position, val;
@@ -643,7 +664,8 @@ DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1,
643 val = read_minibuf (keymap, initial_contents, prompt, 664 val = read_minibuf (keymap, initial_contents, prompt,
644 make_number (pos), !NILP (read), 665 make_number (pos), !NILP (read),
645 histvar, histpos, default_value, 666 histvar, histpos, default_value,
646 minibuffer_allow_text_properties, 0); 667 minibuffer_allow_text_properties,
668 !NILP (inherit_input_method));
647 if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (default_value)) 669 if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (default_value))
648 val = default_value; 670 val = default_value;
649 UNGCPRO; 671 UNGCPRO;
@@ -677,31 +699,38 @@ is a string to insert in the minibuffer before reading.")
677 699
678/* Functions that use the minibuffer to read various things. */ 700/* Functions that use the minibuffer to read various things. */
679 701
680DEFUN ("read-string", Fread_string, Sread_string, 1, 4, 0, 702DEFUN ("read-string", Fread_string, Sread_string, 1, 5, 0,
681 "Read a string from the minibuffer, prompting with string PROMPT.\n\ 703 "Read a string from the minibuffer, prompting with string PROMPT.\n\
682If non-nil, second arg INITIAL-INPUT is a string to insert before reading.\n\ 704If non-nil, second arg INITIAL-INPUT is a string to insert before reading.\n\
683The third arg HISTORY, if non-nil, specifies a history list\n\ 705The third arg HISTORY, if non-nil, specifies a history list\n\
684 and optionally the initial position in the list.\n\ 706 and optionally the initial position in the list.\n\
685See `read-from-minibuffer' for details of HISTORY argument.") 707See `read-from-minibuffer' for details of HISTORY argument.\n\
686 (prompt, initial_input, history, default_value) 708The forth arg INHERIT-INPUT-METHOD non-nil means the minibuffer inherits\n\
709 the current input method.")
710 (prompt, initial_input, history, default_value, inherit_input_method)
687 Lisp_Object prompt, initial_input, history, default_value; 711 Lisp_Object prompt, initial_input, history, default_value;
712 Lisp_Object inherit_input_method;
688{ 713{
689 return Fread_from_minibuffer (prompt, initial_input, Qnil, 714 return Fread_from_minibuffer (prompt, initial_input, Qnil,
690 Qnil, history, default_value); 715 Qnil, history, default_value,
716 inherit_input_method);
691} 717}
692 718
693DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 1, 2, 0, 719DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 1, 3, 0,
694 "Args PROMPT and INIT, strings. Read a string from the terminal, not allowing blanks.\n\ 720 "Args PROMPT and INIT, strings. Read a string from the terminal, not allowing blanks.\n\
695Prompt with PROMPT, and provide INIT as an initial value of the input string.") 721Prompt with PROMPT, and provide INIT as an initial value of the input string.\n\
696 (prompt, init) 722The third optional arg INHERIT-INPUT-METHOD non-nil means the minibuffer\n\
697 Lisp_Object prompt, init; 723 inherits the current input method.")
724 (prompt, init, inherit_input_method)
725 Lisp_Object prompt, init, inherit_input_method;
698{ 726{
699 CHECK_STRING (prompt, 0); 727 CHECK_STRING (prompt, 0);
700 if (! NILP (init)) 728 if (! NILP (init))
701 CHECK_STRING (init, 1); 729 CHECK_STRING (init, 1);
702 730
703 return read_minibuf (Vminibuffer_local_ns_map, init, prompt, Qnil, 731 return read_minibuf (Vminibuffer_local_ns_map, init, prompt, Qnil,
704 0, Qminibuffer_history, make_number (0), Qnil, 0, 0); 732 0, Qminibuffer_history, make_number (0), Qnil, 0,
733 !NILP (inherit_input_method));
705} 734}
706 735
707DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0, 736DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0,
@@ -711,7 +740,7 @@ Prompts with PROMPT. By default, return DEFAULT-VALUE.")
711 Lisp_Object prompt, default_value; 740 Lisp_Object prompt, default_value;
712{ 741{
713 return Fintern (Fcompleting_read (prompt, Vobarray, Qcommandp, Qt, 742 return Fintern (Fcompleting_read (prompt, Vobarray, Qcommandp, Qt,
714 Qnil, Qnil, default_value), 743 Qnil, Qnil, default_value, Qnil),
715 Qnil); 744 Qnil);
716} 745}
717 746
@@ -722,7 +751,7 @@ Prompts with PROMPT.")
722 (prompt) 751 (prompt)
723 Lisp_Object prompt; 752 Lisp_Object prompt;
724{ 753{
725 return Fintern (Fcompleting_read (prompt, Vobarray, Qfboundp, Qt, Qnil, Qnil, Qnil), 754 return Fintern (Fcompleting_read (prompt, Vobarray, Qfboundp, Qt, Qnil, Qnil, Qnil, Qnil),
726 Qnil); 755 Qnil);
727} 756}
728#endif /* NOTDEF */ 757#endif /* NOTDEF */
@@ -736,7 +765,7 @@ A user variable is one whose documentation starts with a `*' character.")
736{ 765{
737 return Fintern (Fcompleting_read (prompt, Vobarray, 766 return Fintern (Fcompleting_read (prompt, Vobarray,
738 Quser_variable_p, Qt, 767 Quser_variable_p, Qt,
739 Qnil, Qnil, default_value), 768 Qnil, Qnil, default_value, Qnil),
740 Qnil); 769 Qnil);
741} 770}
742 771
@@ -761,7 +790,7 @@ If optional third arg REQUIRE-MATCH is non-nil, only existing buffer names are a
761 prompt = Fformat (3, args); 790 prompt = Fformat (3, args);
762 } 791 }
763 return Fcompleting_read (prompt, Vbuffer_alist, Qnil, 792 return Fcompleting_read (prompt, Vbuffer_alist, Qnil,
764 require_match, Qnil, Qnil, def); 793 require_match, Qnil, Qnil, def, Qnil);
765} 794}
766 795
767DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0, 796DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0,
@@ -1126,7 +1155,7 @@ Lisp_Object Vminibuffer_completion_confirm, Qminibuffer_completion_confirm;
1126 for make-docfile to see. We cannot put this in the real DEFUN 1155 for make-docfile to see. We cannot put this in the real DEFUN
1127 due to limits in the Unix cpp. 1156 due to limits in the Unix cpp.
1128 1157
1129DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 7, 0, 1158DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
1130 "Read a string in the minibuffer, with completion.\n\ 1159 "Read a string in the minibuffer, with completion.\n\
1131PROMPT is a string to prompt with; normally it ends in a colon and a space.\n\ 1160PROMPT is a string to prompt with; normally it ends in a colon and a space.\n\
1132TABLE is an alist whose elements' cars are strings, or an obarray.\n\ 1161TABLE is an alist whose elements' cars are strings, or an obarray.\n\
@@ -1151,15 +1180,19 @@ HIST, if non-nil, specifies a history list\n\
1151 and HISTPOS is the initial position (the position in the list\n\ 1180 and HISTPOS is the initial position (the position in the list\n\
1152 which INITIAL-CONTENTS corresponds to).\n\ 1181 which INITIAL-CONTENTS corresponds to).\n\
1153 Positions are counted starting from 1 at the beginning of the list.\n\ 1182 Positions are counted starting from 1 at the beginning of the list.\n\
1154DEF, if non-nil, is the default value. 1183DEF, if non-nil, is the default value.\n\
1155 1184\n\
1185If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits\n\
1186 the current input method.\n\
1187\n\
1156Completion ignores case if the ambient value of\n\ 1188Completion ignores case if the ambient value of\n\
1157 `completion-ignore-case' is non-nil." 1189 `completion-ignore-case' is non-nil."
1158*/ 1190*/
1159DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 7, 0, 1191DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
1160 0 /* See immediately above */) 1192 0 /* See immediately above */)
1161 (prompt, table, predicate, require_match, init, hist, def) 1193 (prompt, table, predicate, require_match, init, hist, def, inherit_input_method)
1162 Lisp_Object prompt, table, predicate, require_match, init, hist, def; 1194 Lisp_Object prompt, table, predicate, require_match, init, hist, def;
1195 Lisp_Object inherit_input_method;
1163{ 1196{
1164 Lisp_Object val, histvar, histpos, position; 1197 Lisp_Object val, histvar, histpos, position;
1165 int pos = 0; 1198 int pos = 0;
@@ -1211,7 +1244,8 @@ DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 7, 0,
1211 ? Vminibuffer_local_completion_map 1244 ? Vminibuffer_local_completion_map
1212 : Vminibuffer_local_must_match_map, 1245 : Vminibuffer_local_must_match_map,
1213 init, prompt, make_number (pos), 0, 1246 init, prompt, make_number (pos), 0,
1214 histvar, histpos, def, 0, disable_multibyte); 1247 histvar, histpos, def, 0,
1248 !NILP (inherit_input_method));
1215 if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (def)) 1249 if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (def))
1216 val = def; 1250 val = def;
1217 RETURN_UNGCPRO (unbind_to (count, val)); 1251 RETURN_UNGCPRO (unbind_to (count, val));
@@ -1927,6 +1961,12 @@ syms_of_minibuf ()
1927 Qhistory_length = intern ("history-length"); 1961 Qhistory_length = intern ("history-length");
1928 staticpro (&Qhistory_length); 1962 staticpro (&Qhistory_length);
1929 1963
1964 Qcurrent_input_method = intern ("current-input-method");
1965 staticpro (&Qcurrent_input_method);
1966
1967 Qactivate_input_method = intern ("activate-input-method");
1968 staticpro (&Qactivate_input_method);
1969
1930 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook, 1970 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook,
1931 "Normal hook run just after entry to minibuffer."); 1971 "Normal hook run just after entry to minibuffer.");
1932 Vminibuffer_setup_hook = Qnil; 1972 Vminibuffer_setup_hook = Qnil;