X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/6bc1abf2e03f91fea1a86cb3482d4544c24639a2..eddd51c2807805e47aa70008234111b601e9a050:/src/callint.c diff --git a/src/callint.c b/src/callint.c index a509dc4f32..b0e0e3c145 100644 --- a/src/callint.c +++ b/src/callint.c @@ -15,7 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ #include @@ -28,6 +29,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ extern char *index (); +extern Lisp_Object Qcursor_in_echo_area; + Lisp_Object Vcurrent_prefix_arg, Qminus, Qplus; Lisp_Object Qcall_interactively; Lisp_Object Vcommand_history; @@ -89,6 +92,7 @@ e -- Parametrized event (i.e., one that's a list) that invoked this command.\n\ This skips events that are integers or symbols.\n\ f -- Existing file name.\n\ F -- Possibly nonexistent file name.\n\ +i -- Ignored, i.e. always nil. Does not do I/O.\n\ k -- Key sequence (downcase the last event if needed to get a definition).\n\ K -- Key sequence to be redefined (do not downcase the last event).\n\ m -- Value of mark as number. Does not do I/O.\n\ @@ -102,6 +106,8 @@ S -- Any symbol.\n\ v -- Variable name: symbol that is user-variable-p.\n\ x -- Lisp expression read but not evaluated.\n\ X -- Lisp expression read and evaluated.\n\ +z -- Coding system.\n\ +Z -- Coding system, nil if no prefix arg.\n\ In addition, if the string begins with `*'\n\ then an error is signaled if the buffer is read-only.\n\ This happens before reading any arguments.\n\ @@ -175,8 +181,8 @@ See `interactive'.\n\ Optional second arg RECORD-FLAG non-nil\n\ means unconditionally put this command in the command-history.\n\ Otherwise, this is done only if an arg is read using the minibuffer.") - (function, record, keys) - Lisp_Object function, record, keys; + (function, record_flag, keys) + Lisp_Object function, record_flag, keys; { Lisp_Object *args, *visargs; unsigned char **argstrings; @@ -287,11 +293,11 @@ Otherwise, this is done only if an arg is read using the minibuffer.") else if (string == 0) { Lisp_Object input; - i = num_input_chars; + i = num_input_events; input = specs; /* Compute the arg values using the user's expression. */ specs = Feval (specs); - if (i != num_input_chars || !NILP (record)) + if (i != num_input_events || !NILP (record_flag)) { /* We should record this command on the command history. */ Lisp_Object values, car; @@ -459,7 +465,8 @@ Otherwise, this is done only if an arg is read using the minibuffer.") { case 'a': /* Symbol defined as a function */ visargs[i] = Fcompleting_read (build_string (callint_message), - Vobarray, Qfboundp, Qt, Qnil, Qnil); + Vobarray, Qfboundp, Qt, + Qnil, Qnil, Qnil); /* Passing args[i] directly stimulates compiler bug */ teml = visargs[i]; args[i] = Fintern (teml, Qnil); @@ -479,7 +486,10 @@ Otherwise, this is done only if an arg is read using the minibuffer.") break; case 'c': /* Character */ - message1_nolog (callint_message); + /* Use message_nolog rather than message1_nolog here, + so that nothing bad happens if callint_message is changed + within Fread_char (by a timer, for example). */ + message_nolog ("%s", callint_message); args[i] = Fread_char (); message1_nolog ((char *) 0); /* Passing args[i] directly stimulates compiler bug */ @@ -489,7 +499,8 @@ Otherwise, this is done only if an arg is read using the minibuffer.") case 'C': /* Command: symbol with interactive function */ visargs[i] = Fcompleting_read (build_string (callint_message), - Vobarray, Qcommandp, Qt, Qnil, Qnil); + Vobarray, Qcommandp, + Qt, Qnil, Qnil, Qnil); /* Passing args[i] directly stimulates compiler bug */ teml = visargs[i]; args[i] = Fintern (teml, Qnil); @@ -517,18 +528,32 @@ Otherwise, this is done only if an arg is read using the minibuffer.") Qnil, Qnil, Qnil, Qnil); break; + case 'i': /* Ignore an argument -- Does not do I/O */ + varies[i] = -1; + break; + case 'k': /* Key sequence. */ - args[i] = Fread_key_sequence (build_string (callint_message), - Qnil, Qnil, Qnil); - teml = args[i]; - visargs[i] = Fkey_description (teml); + { + int speccount1 = specpdl_ptr - specpdl; + specbind (Qcursor_in_echo_area, Qt); + args[i] = Fread_key_sequence (build_string (callint_message), + Qnil, Qnil, Qnil); + unbind_to (speccount1, Qnil); + teml = args[i]; + visargs[i] = Fkey_description (teml); + } break; case 'K': /* Key sequence to be defined. */ - args[i] = Fread_key_sequence (build_string (callint_message), - Qnil, Qt, Qnil); - teml = args[i]; - visargs[i] = Fkey_description (teml); + { + int speccount1 = specpdl_ptr - specpdl; + specbind (Qcursor_in_echo_area, Qt); + args[i] = Fread_key_sequence (build_string (callint_message), + Qnil, Qt, Qnil); + teml = args[i]; + visargs[i] = Fkey_description (teml); + unbind_to (speccount1, Qnil); + } break; case 'e': /* The invoking event. */ @@ -559,9 +584,27 @@ Otherwise, this is done only if an arg is read using the minibuffer.") if (!NILP (prefix_arg)) goto have_prefix_arg; case 'n': /* Read number from minibuffer. */ - do - args[i] = Fread_minibuffer (build_string (callint_message), Qnil); - while (! NUMBERP (args[i])); + { + int first = 1; + do + { + Lisp_Object tem; + if (! first) + { + message ("Please enter a number."); + sit_for (1, 0, 0, 0); + } + first = 0; + + tem = Fread_from_minibuffer (build_string (callint_message), + Qnil, Qnil, Qnil, Qnil, Qnil); + if (! STRINGP (tem) || XSTRING (tem)->size == 0) + args[i] = Qnil; + else + args[i] = Fread (tem); + } + while (! NUMBERP (args[i])); + } visargs[i] = last_minibuf_string; break; @@ -584,19 +627,20 @@ Otherwise, this is done only if an arg is read using the minibuffer.") /* visargs[i+1] = Qnil; */ foo = marker_position (current_buffer->mark); /* visargs[i] = Qnil; */ - args[i] = point < foo ? point_marker : current_buffer->mark; + args[i] = PT < foo ? point_marker : current_buffer->mark; varies[i] = 3; - args[++i] = point > foo ? point_marker : current_buffer->mark; + args[++i] = PT > foo ? point_marker : current_buffer->mark; varies[i] = 4; break; case 's': /* String read via minibuffer. */ - args[i] = Fread_string (build_string (callint_message), Qnil, Qnil); + args[i] = Fread_string (build_string (callint_message), + Qnil, Qnil, Qnil); break; case 'S': /* Any symbol. */ visargs[i] = Fread_string (build_string (callint_message), - Qnil, Qnil); + Qnil, Qnil, Qnil); /* Passing args[i] directly stimulates compiler bug */ teml = visargs[i]; args[i] = Fintern (teml, Qnil); @@ -604,7 +648,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.") case 'v': /* Variable name: symbol that is user-variable-p. */ - args[i] = Fread_variable (build_string (callint_message)); + args[i] = Fread_variable (build_string (callint_message), Qnil); visargs[i] = last_minibuf_string; break; @@ -618,6 +662,26 @@ Otherwise, this is done only if an arg is read using the minibuffer.") visargs[i] = last_minibuf_string; break; + case 'Z': /* Coding-system symbol, or ignore the + argument if no prefix */ + if (NILP (prefix_arg)) + { + args[i] = Qnil; + varies[i] = -1; + } + else + { + args[i] + = Fread_non_nil_coding_system (build_string (callint_message)); + visargs[i] = last_minibuf_string; + } + break; + + case 'z': /* Coding-system symbol or nil */ + args[i] = Fread_coding_system (build_string (callint_message)); + visargs[i] = last_minibuf_string; + break; + /* We have a case for `+' so we get an error if anyone tries to define one here. */ case '+': @@ -642,7 +706,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.") args[0] = function; - if (arg_from_tty || !NILP (record)) + if (arg_from_tty || !NILP (record_flag)) { visargs[0] = function; for (i = 1; i < count + 1; i++) @@ -676,7 +740,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.") DEFUN ("prefix-numeric-value", Fprefix_numeric_value, Sprefix_numeric_value, 1, 1, 0, - "Return numeric meaning of raw prefix argument ARG.\n\ + "Return numeric meaning of raw prefix argument RAW.\n\ A raw prefix argument is what you get from `(interactive \"P\")'.\n\ Its numeric meaning is what you would get from `(interactive \"p\")'.") (raw)