Mercurial > emacs
changeset 7952:9e2e0fdd1710
(minibuf_save_list): New variable, replaces minibuf_save_vector.
(read_minibuf): Cons it up.
(read_minibuf_unwind): Pop back the saved values.
(syms_of_minibuf): staticpro it.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 18 Jun 1994 00:18:28 +0000 |
parents | e609577aa2f3 |
children | e5e842ead52c |
files | src/minibuf.c |
diffstat | 1 files changed, 35 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/src/minibuf.c Sat Jun 18 00:13:37 1994 +0000 +++ b/src/minibuf.c Sat Jun 18 00:18:28 1994 +0000 @@ -32,23 +32,14 @@ extern int quit_char; /* List of buffers for use as minibuffers. - The first element of the list is used for the outermost minibuffer invocation, - the next element is used for a recursive minibuffer invocation, etc. - The list is extended at the end as deeped minibuffer recursions are encountered. */ + The first element of the list is used for the outermost minibuffer + invocation, the next element is used for a recursive minibuffer + invocation, etc. The list is extended at the end as deeper + minibuffer recursions are encountered. */ Lisp_Object Vminibuffer_list; -struct minibuf_save_data - { - char *prompt; - int prompt_width; - Lisp_Object help_form; - Lisp_Object current_prefix_arg; - Lisp_Object history_position; - Lisp_Object history_variable; - }; - -int minibuf_save_vector_size; -struct minibuf_save_data *minibuf_save_vector; +/* Data to remember during recursive minibuffer invocations */ +Lisp_Object minibuf_save_list; /* Depth in minibuffer invocations. */ int minibuf_level; @@ -139,7 +130,6 @@ register Lisp_Object val; int count = specpdl_ptr - specpdl; Lisp_Object mini_frame; - struct gcpro gcpro1, gcpro2; if (XTYPE (prompt) != Lisp_String) prompt = build_string (""); @@ -156,22 +146,16 @@ #endif error ("Command attempted to use minibuffer while in minibuffer"); - if (minibuf_level == minibuf_save_vector_size) - minibuf_save_vector = - (struct minibuf_save_data *) - xrealloc (minibuf_save_vector, - (minibuf_save_vector_size *= 2) - * sizeof (struct minibuf_save_data)); - minibuf_save_vector[minibuf_level].prompt = minibuf_prompt; - minibuf_save_vector[minibuf_level].prompt_width = minibuf_prompt_width; + /* Could we simply bind these variables instead? */ + minibuf_save_list + = Fcons (minibuf_prompt, + Fcons (make_number (minibuf_prompt_width), + Fcons (Vhelp_form, + Fcons (Vcurrent_prefix_arg, + Fcons (Vminibuffer_history_position, + Fcons (Vminibuffer_history_variable, + minibuf_save_list)))))); minibuf_prompt_width = 0; - /* >> Why is this done this way rather than binding these variables? */ - minibuf_save_vector[minibuf_level].help_form = Vhelp_form; - minibuf_save_vector[minibuf_level].current_prefix_arg = Vcurrent_prefix_arg; - minibuf_save_vector[minibuf_level].history_position = Vminibuffer_history_position; - minibuf_save_vector[minibuf_level].history_variable = Vminibuffer_history_variable; - GCPRO2 (minibuf_save_vector[minibuf_level].help_form, - minibuf_save_vector[minibuf_level].current_prefix_arg); record_unwind_protect (Fset_window_configuration, Fcurrent_window_configuration (Qnil)); @@ -248,8 +232,7 @@ Fforward_char (backup_n); } - minibuf_prompt = (char *) alloca (XSTRING (prompt)->size + 1); - bcopy (XSTRING (prompt)->data, minibuf_prompt, XSTRING (prompt)->size + 1); + minibuf_prompt = Fcopy_sequence (prompt); echo_area_glyphs = 0; /* This is in case the minibuffer-setup-hook calls Fsit_for. */ previous_echo_glyphs = 0; @@ -322,7 +305,6 @@ val = Fcar (expr_and_pos); } - UNGCPRO; return unbind_to (count, val); /* The appropriate frame will get selected in set-window-configuration. */ } @@ -385,15 +367,19 @@ windows_or_buffers_changed++; XFASTINT (XWINDOW (minibuf_window)->last_modified) = 0; - /* Restore prompt from outer minibuffer */ - minibuf_prompt = minibuf_save_vector[minibuf_level].prompt; - minibuf_prompt_width = minibuf_save_vector[minibuf_level].prompt_width; - Vhelp_form = minibuf_save_vector[minibuf_level].help_form; - Vcurrent_prefix_arg = minibuf_save_vector[minibuf_level].current_prefix_arg; - Vminibuffer_history_position - = minibuf_save_vector[minibuf_level].history_position; - Vminibuffer_history_variable - = minibuf_save_vector[minibuf_level].history_variable; + /* Restore prompt, etc from outer minibuffer */ + minibuf_prompt = Fcar (minibuf_save_list); + minibuf_save_list = Fcdr (minibuf_save_list); + minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); + minibuf_save_list = Fcdr (minibuf_save_list); + Vhelp_form = Fcar (minibuf_save_list); + minibuf_save_list = Fcdr (minibuf_save_list); + Vcurrent_prefix_arg = Fcar (minibuf_save_list); + minibuf_save_list = Fcdr (minibuf_save_list); + Vminibuffer_history_position = Fcar (minibuf_save_list); + minibuf_save_list = Fcdr (minibuf_save_list); + Vminibuffer_history_variable = Fcar (minibuf_save_list); + minibuf_save_list = Fcdr (minibuf_save_list); } @@ -1544,9 +1530,7 @@ If no minibuffer is active, return nil.") () { - if (!minibuf_prompt) - return Qnil; - return build_string (minibuf_prompt); + return Fcopy_sequence (minibuf_prompt); } DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, @@ -1568,9 +1552,11 @@ syms_of_minibuf () { minibuf_level = 0; - minibuf_prompt = 0; - minibuf_save_vector_size = 5; - minibuf_save_vector = (struct minibuf_save_data *) malloc (5 * sizeof (struct minibuf_save_data)); + minibuf_prompt = Qnil; + staticpro (&minibuf_prompt); + + minibuf_save_list = Qnil; + staticpro (&minibuf_save_list); Qread_file_name_internal = intern ("read-file-name-internal"); staticpro (&Qread_file_name_internal);