diff options
Diffstat (limited to 'src/minibuf.c')
-rw-r--r-- | src/minibuf.c | 189 |
1 files changed, 66 insertions, 123 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index e3510105d0f..8017da194b0 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -157,7 +157,7 @@ string_to_object (Lisp_Object val, Lisp_Object defalt) } expr_and_pos = Fread_from_string (val, Qnil, Qnil); - pos = XINT (Fcdr (expr_and_pos)); + pos = XFIXNUM (Fcdr (expr_and_pos)); if (pos != SCHARS (val)) { /* Ignore trailing whitespace; any other trailing junk @@ -181,12 +181,8 @@ string_to_object (Lisp_Object val, Lisp_Object defalt) from read_minibuf to do the job if noninteractive. */ static Lisp_Object -read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, - Lisp_Object prompt, Lisp_Object backup_n, - bool expflag, - Lisp_Object histvar, Lisp_Object histpos, - Lisp_Object defalt, - bool allow_props, bool inherit_input_method) +read_minibuf_noninteractive (Lisp_Object prompt, bool expflag, + Lisp_Object defalt) { ptrdiff_t size, len; char *line; @@ -198,7 +194,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, /* Check, whether we need to suppress echoing. */ if (CHARACTERP (Vread_hide_char)) - hide_char = XFASTINT (Vread_hide_char); + hide_char = XFIXNAT (Vread_hide_char); /* Manipulate tty. */ if (hide_char) @@ -291,7 +287,7 @@ Return (point-min) if current buffer is not a minibuffer. */) { /* This function is written to be most efficient when there's a prompt. */ Lisp_Object beg, end, tem; - beg = make_number (BEGV); + beg = make_fixnum (BEGV); tem = Fmemq (Fcurrent_buffer (), Vminibuffer_list); if (NILP (tem)) @@ -299,7 +295,7 @@ Return (point-min) if current buffer is not a minibuffer. */) end = Ffield_end (beg, Qnil, Qnil); - if (XINT (end) == ZV && NILP (Fget_char_property (beg, Qfield, Qnil))) + if (XFIXNUM (end) == ZV && NILP (Fget_char_property (beg, Qfield, Qnil))) return beg; else return end; @@ -311,7 +307,7 @@ DEFUN ("minibuffer-contents", Fminibuffer_contents, If the current buffer is not a minibuffer, return its entire contents. */) (void) { - ptrdiff_t prompt_end = XINT (Fminibuffer_prompt_end ()); + ptrdiff_t prompt_end = XFIXNUM (Fminibuffer_prompt_end ()); return make_buffer_string (prompt_end, ZV, 1); } @@ -321,23 +317,10 @@ DEFUN ("minibuffer-contents-no-properties", Fminibuffer_contents_no_properties, If the current buffer is not a minibuffer, return its entire contents. */) (void) { - ptrdiff_t prompt_end = XINT (Fminibuffer_prompt_end ()); + ptrdiff_t prompt_end = XFIXNUM (Fminibuffer_prompt_end ()); return make_buffer_string (prompt_end, ZV, 0); } -DEFUN ("minibuffer-completion-contents", Fminibuffer_completion_contents, - Sminibuffer_completion_contents, 0, 0, 0, - doc: /* Return the user input in a minibuffer before point as a string. -That is what completion commands operate on. -If the current buffer is not a minibuffer, return its entire contents. */) - (void) -{ - ptrdiff_t prompt_end = XINT (Fminibuffer_prompt_end ()); - if (PT < prompt_end) - error ("Cannot do completion in the prompt"); - return make_buffer_string (prompt_end, PT, 1); -} - /* Read from the minibuffer using keymap MAP and initial contents INITIAL, putting point minus BACKUP_N bytes from the end of INITIAL, @@ -406,13 +389,13 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, CHECK_STRING (initial); if (!NILP (backup_n)) { - CHECK_NUMBER (backup_n); + CHECK_FIXNUM (backup_n); /* Convert to distance from end of input. */ - if (XINT (backup_n) < 1) + if (XFIXNUM (backup_n) < 1) /* A number too small means the beginning of the string. */ pos = - SCHARS (initial); else - pos = XINT (backup_n) - 1 - SCHARS (initial); + pos = XFIXNUM (backup_n) - 1 - SCHARS (initial); } } else @@ -443,10 +426,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, || (IS_DAEMON && DAEMON_RUNNING)) && NILP (Vexecuting_kbd_macro)) { - val = read_minibuf_noninteractive (map, initial, prompt, - make_number (pos), - expflag, histvar, histpos, defalt, - allow_props, inherit_input_method); + val = read_minibuf_noninteractive (prompt, expflag, defalt); return unbind_to (count, val); } @@ -491,7 +471,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, minibuf_save_list)); minibuf_save_list = Fcons (minibuf_prompt, - Fcons (make_number (minibuf_prompt_width), + Fcons (make_fixnum (minibuf_prompt_width), Fcons (Vhelp_form, Fcons (Vcurrent_prefix_arg, Fcons (Vminibuffer_history_position, @@ -608,9 +588,6 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, XWINDOW (minibuf_window)->hscroll = 0; XWINDOW (minibuf_window)->suspend_auto_hscroll = 0; - Fmake_local_variable (Qprint_escape_newlines); - print_escape_newlines = 1; - /* Erase the buffer. */ { ptrdiff_t count1 = SPECPDL_INDEX (); @@ -626,11 +603,11 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Finsert (1, &minibuf_prompt); if (PT > BEG) { - Fput_text_property (make_number (BEG), make_number (PT), + Fput_text_property (make_fixnum (BEG), make_fixnum (PT), Qfront_sticky, Qt, Qnil); - Fput_text_property (make_number (BEG), make_number (PT), + Fput_text_property (make_fixnum (BEG), make_fixnum (PT), Qrear_nonsticky, Qt, Qnil); - Fput_text_property (make_number (BEG), make_number (PT), + Fput_text_property (make_fixnum (BEG), make_fixnum (PT), Qfield, Qt, Qnil); if (CONSP (Vminibuffer_prompt_properties)) { @@ -649,10 +626,10 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Lisp_Object val = XCAR (list); list = XCDR (list); if (EQ (key, Qface)) - Fadd_face_text_property (make_number (BEG), - make_number (PT), val, Qt, Qnil); + Fadd_face_text_property (make_fixnum (BEG), + make_fixnum (PT), val, Qt, Qnil); else - Fput_text_property (make_number (BEG), make_number (PT), + Fput_text_property (make_fixnum (BEG), make_fixnum (PT), key, val, Qnil); } } @@ -667,7 +644,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, if (!NILP (initial)) { Finsert (1, &initial); - Fforward_char (make_number (pos)); + Fforward_char (make_fixnum (pos)); } clear_message (1, 1); @@ -718,44 +695,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, histstring = Qnil; /* Add the value to the appropriate history list, if any. */ - if (!NILP (Vhistory_add_new_input) - && SYMBOLP (Vminibuffer_history_variable) - && !NILP (histstring)) - { - /* If the caller wanted to save the value read on a history list, - then do so if the value is not already the front of the list. */ - - /* The value of the history variable must be a cons or nil. Other - values are unacceptable. We silently ignore these values. */ - - if (NILP (histval) - || (CONSP (histval) - /* Don't duplicate the most recent entry in the history. */ - && (NILP (Fequal (histstring, Fcar (histval)))))) - { - Lisp_Object length; - - if (history_delete_duplicates) Fdelete (histstring, histval); - histval = Fcons (histstring, histval); - Fset (Vminibuffer_history_variable, histval); - - /* Truncate if requested. */ - length = Fget (Vminibuffer_history_variable, Qhistory_length); - if (NILP (length)) length = Vhistory_length; - if (INTEGERP (length)) - { - if (XINT (length) <= 0) - Fset (Vminibuffer_history_variable, Qnil); - else - { - Lisp_Object temp; - - temp = Fnthcdr (Fsub1 (length), histval); - if (CONSP (temp)) Fsetcdr (temp, Qnil); - } - } - } - } + if (! (NILP (Vhistory_add_new_input) || NILP (histstring))) + call2 (intern ("add-to-history"), Vminibuffer_history_variable, histstring); /* If Lisp form desired instead of string, parse it. */ if (expflag) @@ -773,7 +714,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Lisp_Object get_minibuffer (EMACS_INT depth) { - Lisp_Object tail = Fnthcdr (make_number (depth), Vminibuffer_list); + Lisp_Object tail = Fnthcdr (make_fixnum (depth), Vminibuffer_list); if (NILP (tail)) { tail = list1 (Qnil); @@ -807,7 +748,7 @@ get_minibuffer (EMACS_INT depth) call0 (intern ("minibuffer-inactive-mode")); else Fkill_all_local_variables (); - unbind_to (count, Qnil); + buf = unbind_to (count, buf); } return buf; @@ -840,12 +781,12 @@ read_minibuf_unwind (void) /* Restore prompt, etc, from outer minibuffer level. */ Lisp_Object key_vec = Fcar (minibuf_save_list); eassert (VECTORP (key_vec)); - this_command_key_count = XFASTINT (Flength (key_vec)); + this_command_key_count = XFIXNAT (Flength (key_vec)); this_command_keys = key_vec; minibuf_save_list = Fcdr (minibuf_save_list); minibuf_prompt = Fcar (minibuf_save_list); minibuf_save_list = Fcdr (minibuf_save_list); - minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); + minibuf_prompt_width = XFIXNAT (Fcar (minibuf_save_list)); minibuf_save_list = Fcdr (minibuf_save_list); Vhelp_form = Fcar (minibuf_save_list); minibuf_save_list = Fcdr (minibuf_save_list); @@ -1047,7 +988,7 @@ the current input method and the setting of`enable-multibyte-characters'. */) { CHECK_STRING (prompt); return read_minibuf (Vminibuffer_local_ns_map, initial, prompt, - 0, Qminibuffer_history, make_number (0), Qnil, 0, + 0, Qminibuffer_history, make_fixnum (0), Qnil, 0, !NILP (inherit_input_method)); } @@ -1103,7 +1044,8 @@ A user option, or customizable variable, is one for which name = Fcompleting_read (prompt, Vobarray, Qcustom_variable_p, Qt, - Qnil, Qnil, default_string, Qnil); + Qnil, Qcustom_variable_history, + default_string, Qnil); if (NILP (name)) return name; return Fintern (name, Qnil); @@ -1246,7 +1188,7 @@ is used to further constrain the set of candidates. */) return call3 (collection, string, predicate, Qnil); bestmatch = bucket = Qnil; - zero = make_number (0); + zero = make_fixnum (0); /* If COLLECTION is not a list, set TAIL just for gc pro. */ tail = collection; @@ -1312,7 +1254,7 @@ is used to further constrain the set of candidates. */) if (STRINGP (eltstring) && SCHARS (string) <= SCHARS (eltstring) && (tem = Fcompare_strings (eltstring, zero, - make_number (SCHARS (string)), + make_fixnum (SCHARS (string)), string, zero, Qnil, completion_ignore_case ? Qt : Qnil), EQ (Qt, tem))) @@ -1325,11 +1267,12 @@ is used to further constrain the set of candidates. */) for (regexps = Vcompletion_regexp_list; CONSP (regexps); regexps = XCDR (regexps)) { - if (bindcount < 0) { - bindcount = SPECPDL_INDEX (); - specbind (Qcase_fold_search, - completion_ignore_case ? Qt : Qnil); - } + if (bindcount < 0) + { + bindcount = SPECPDL_INDEX (); + specbind (Qcase_fold_search, + completion_ignore_case ? Qt : Qnil); + } tem = Fstring_match (XCAR (regexps), eltstring, zero); if (NILP (tem)) break; @@ -1373,11 +1316,11 @@ is used to further constrain the set of candidates. */) { compare = min (bestmatchsize, SCHARS (eltstring)); tem = Fcompare_strings (bestmatch, zero, - make_number (compare), + make_fixnum (compare), eltstring, zero, - make_number (compare), + make_fixnum (compare), completion_ignore_case ? Qt : Qnil); - matchsize = EQ (tem, Qt) ? compare : eabs (XINT (tem)) - 1; + matchsize = EQ (tem, Qt) ? compare : eabs (XFIXNUM (tem)) - 1; if (completion_ignore_case) { @@ -1398,13 +1341,13 @@ is used to further constrain the set of candidates. */) == (matchsize == SCHARS (bestmatch)) && (tem = Fcompare_strings (eltstring, zero, - make_number (SCHARS (string)), + make_fixnum (SCHARS (string)), string, zero, Qnil, Qnil), EQ (Qt, tem)) && (tem = Fcompare_strings (bestmatch, zero, - make_number (SCHARS (string)), + make_fixnum (SCHARS (string)), string, zero, Qnil, Qnil), @@ -1428,10 +1371,8 @@ is used to further constrain the set of candidates. */) } } - if (bindcount >= 0) { + if (bindcount >= 0) unbind_to (bindcount, Qnil); - bindcount = -1; - } if (NILP (bestmatch)) return Qnil; /* No completions found. */ @@ -1499,7 +1440,7 @@ with a space are ignored unless STRING itself starts with a space. */) if (type == 0) return call3 (collection, string, predicate, Qt); allmatches = bucket = Qnil; - zero = make_number (0); + zero = make_fixnum (0); /* If COLLECTION is not a list, set TAIL just for gc pro. */ tail = collection; @@ -1571,9 +1512,9 @@ with a space are ignored unless STRING itself starts with a space. */) && SREF (string, 0) == ' ') || SREF (eltstring, 0) != ' ') && (tem = Fcompare_strings (eltstring, zero, - make_number (SCHARS (string)), + make_fixnum (SCHARS (string)), string, zero, - make_number (SCHARS (string)), + make_fixnum (SCHARS (string)), completion_ignore_case ? Qt : Qnil), EQ (Qt, tem))) { @@ -1585,11 +1526,12 @@ with a space are ignored unless STRING itself starts with a space. */) for (regexps = Vcompletion_regexp_list; CONSP (regexps); regexps = XCDR (regexps)) { - if (bindcount < 0) { - bindcount = SPECPDL_INDEX (); - specbind (Qcase_fold_search, - completion_ignore_case ? Qt : Qnil); - } + if (bindcount < 0) + { + bindcount = SPECPDL_INDEX (); + specbind (Qcase_fold_search, + completion_ignore_case ? Qt : Qnil); + } tem = Fstring_match (XCAR (regexps), eltstring, zero); if (NILP (tem)) break; @@ -1607,10 +1549,11 @@ with a space are ignored unless STRING itself starts with a space. */) tem = Fcommandp (elt, Qnil); else { - if (bindcount >= 0) { - unbind_to (bindcount, Qnil); - bindcount = -1; - } + if (bindcount >= 0) + { + unbind_to (bindcount, Qnil); + bindcount = -1; + } tem = type == 3 ? call2 (predicate, elt, HASH_VALUE (XHASH_TABLE (collection), idx - 1)) @@ -1623,10 +1566,8 @@ with a space are ignored unless STRING itself starts with a space. */) } } - if (bindcount >= 0) { + if (bindcount >= 0) unbind_to (bindcount, Qnil); - bindcount = -1; - } return Fnreverse (allmatches); } @@ -1746,9 +1687,9 @@ the values STRING, PREDICATE and `lambda'. */) if (SYMBOLP (tail)) while (1) { - if (EQ (Fcompare_strings (string, make_number (0), Qnil, + if (EQ (Fcompare_strings (string, make_fixnum (0), Qnil, Fsymbol_name (tail), - make_number (0) , Qnil, Qt), + make_fixnum (0) , Qnil, Qt), Qt)) { tem = tail; @@ -1891,8 +1832,8 @@ single string, rather than a cons cell whose car is a string. */) thiscar = Fsymbol_name (thiscar); else if (!STRINGP (thiscar)) continue; - tem = Fcompare_strings (thiscar, make_number (0), Qnil, - key, make_number (0), Qnil, + tem = Fcompare_strings (thiscar, make_fixnum (0), Qnil, + key, make_fixnum (0), Qnil, case_fold); if (EQ (tem, Qt)) return elt; @@ -1906,7 +1847,7 @@ DEFUN ("minibuffer-depth", Fminibuffer_depth, Sminibuffer_depth, 0, 0, 0, doc: /* Return current depth of activations of minibuffer, a nonnegative integer. */) (void) { - return make_number (minibuf_level); + return make_fixnum (minibuf_level); } DEFUN ("minibuffer-prompt", Fminibuffer_prompt, Sminibuffer_prompt, 0, 0, 0, @@ -1944,6 +1885,9 @@ syms_of_minibuf (void) staticpro (&last_minibuf_string); last_minibuf_string = Qnil; + DEFSYM (Qcustom_variable_history, "custom-variable-history"); + Fset (Qcustom_variable_history, Qnil); + DEFSYM (Qminibuffer_history, "minibuffer-history"); DEFSYM (Qbuffer_name_history, "buffer-name-history"); Fset (Qbuffer_name_history, Qnil); @@ -2130,7 +2074,6 @@ uses to hide passwords. */); defsubr (&Sminibuffer_prompt_end); defsubr (&Sminibuffer_contents); defsubr (&Sminibuffer_contents_no_properties); - defsubr (&Sminibuffer_completion_contents); defsubr (&Stry_completion); defsubr (&Sall_completions); |