diff options
Diffstat (limited to 'src/cmds.c')
-rw-r--r-- | src/cmds.c | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/src/cmds.c b/src/cmds.c index c92df6a8356..1f81b9986a7 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -35,9 +35,9 @@ DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, doc: /* Return buffer position N characters after (before if N negative) point. */) (Lisp_Object n) { - CHECK_NUMBER (n); + CHECK_FIXNUM (n); - return make_number (PT + XINT (n)); + return make_fixnum (PT + XFIXNUM (n)); } /* Add N to point; or subtract N if FORWARD is false. N defaults to 1. @@ -45,7 +45,7 @@ DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, static Lisp_Object move_point (Lisp_Object n, bool forward) { - /* This used to just set point to point + XINT (n), and then check + /* This used to just set point to point + XFIXNUM (n), and then check to see if it was within boundaries. But now that SET_PT can potentially do a lot of stuff (calling entering and exiting hooks, etcetera), that's not a good approach. So we validate the @@ -56,9 +56,9 @@ move_point (Lisp_Object n, bool forward) if (NILP (n)) XSETFASTINT (n, 1); else - CHECK_NUMBER (n); + CHECK_FIXNUM (n); - new_point = PT + (forward ? XINT (n) : - XINT (n)); + new_point = PT + (forward ? XFIXNUM (n) : - XFIXNUM (n)); if (new_point < BEGV) { @@ -127,8 +127,8 @@ go to its beginning. */) count = 1; else { - CHECK_NUMBER (n); - count = XINT (n); + CHECK_FIXNUM (n); + count = XFIXNUM (n); } shortage = scan_newline_from_point (count, &pos, &pos_byte); @@ -142,7 +142,7 @@ go to its beginning. */) && (FETCH_BYTE (PT_BYTE - 1) != '\n')))) shortage--; - return make_number (count <= 0 ? - shortage : shortage); + return make_fixnum (count <= 0 ? - shortage : shortage); } DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 0, 1, "^p", @@ -162,9 +162,9 @@ instead. For instance, `(forward-line 0)' does the same thing as if (NILP (n)) XSETFASTINT (n, 1); else - CHECK_NUMBER (n); + CHECK_FIXNUM (n); - SET_PT (XINT (Fline_beginning_position (n))); + SET_PT (XFIXNUM (Fline_beginning_position (n))); return Qnil; } @@ -187,11 +187,11 @@ to t. */) if (NILP (n)) XSETFASTINT (n, 1); else - CHECK_NUMBER (n); + CHECK_FIXNUM (n); while (1) { - newpos = XINT (Fline_end_position (n)); + newpos = XFIXNUM (Fline_end_position (n)); SET_PT (newpos); if (PT > newpos @@ -210,7 +210,7 @@ to t. */) /* If we skipped something intangible and now we're not really at eol, keep going. */ - n = make_number (1); + n = make_fixnum (1); else break; } @@ -230,15 +230,15 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */) { EMACS_INT pos; - CHECK_NUMBER (n); + CHECK_FIXNUM (n); - if (eabs (XINT (n)) < 2) + if (eabs (XFIXNUM (n)) < 2) call0 (Qundo_auto_amalgamate); - pos = PT + XINT (n); + pos = PT + XFIXNUM (n); if (NILP (killflag)) { - if (XINT (n) < 0) + if (XFIXNUM (n) < 0) { if (pos < BEGV) xsignal0 (Qbeginning_of_buffer); @@ -260,11 +260,10 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */) return Qnil; } -/* Note that there's code in command_loop_1 which typically avoids - calling this. */ -DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p", +DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 2, + "(list (prefix-numeric-value current-prefix-arg) last-command-event)", doc: /* Insert the character you type. -Whichever character you type to run this command is inserted. +Whichever character C you type to run this command is inserted. The numeric prefix argument N says how many times to repeat the insertion. Before insertion, `expand-abbrev' is executed if the inserted character does not have word syntax and the previous character in the buffer does. @@ -272,23 +271,27 @@ After insertion, `internal-auto-fill' is called if `auto-fill-function' is non-nil and if the `auto-fill-chars' table has a non-nil value for the inserted character. At the end, it runs `post-self-insert-hook'. */) - (Lisp_Object n) + (Lisp_Object n, Lisp_Object c) { - CHECK_NUMBER (n); + CHECK_FIXNUM (n); + + /* Backward compatibility. */ + if (NILP (c)) + c = last_command_event; - if (XINT (n) < 0) - error ("Negative repetition argument %"pI"d", XINT (n)); + if (XFIXNUM (n) < 0) + error ("Negative repetition argument %"pI"d", XFIXNUM (n)); - if (XFASTINT (n) < 2) + if (XFIXNAT (n) < 2) call0 (Qundo_auto_amalgamate); /* Barf if the key that invoked this was not a character. */ - if (!CHARACTERP (last_command_event)) + if (!CHARACTERP (c)) bitch_at_user (); else { int character = translate_char (Vtranslation_table_for_input, - XINT (last_command_event)); - int val = internal_self_insert (character, XFASTINT (n)); + XFIXNUM (c)); + int val = internal_self_insert (character, XFIXNAT (n)); if (val == 2) Fset (Qundo_auto__this_command_amalgamating, Qnil); frame_make_pointer_invisible (SELECTED_FRAME ()); @@ -360,7 +363,7 @@ internal_self_insert (int c, EMACS_INT n) if (EQ (overwrite, Qoverwrite_mode_binary)) chars_to_delete = min (n, PTRDIFF_MAX); else if (c != '\n' && c2 != '\n' - && (cwidth = XFASTINT (Fchar_width (make_number (c)))) != 0) + && (cwidth = XFIXNAT (Fchar_width (make_fixnum (c)))) != 0) { ptrdiff_t pos = PT; ptrdiff_t pos_byte = PT_BYTE; @@ -378,7 +381,7 @@ internal_self_insert (int c, EMACS_INT n) character. In that case, the new point is set after that character. */ ptrdiff_t actual_clm - = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil)); + = XFIXNAT (Fmove_to_column (make_fixnum (target_clm), Qnil)); chars_to_delete = PT - pos; @@ -408,8 +411,8 @@ internal_self_insert (int c, EMACS_INT n) && NILP (BVAR (current_buffer, read_only)) && PT > BEGV && (SYNTAX (!NILP (BVAR (current_buffer, enable_multibyte_characters)) - ? XFASTINT (Fprevious_char ()) - : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) + ? XFIXNAT (Fprevious_char ()) + : UNIBYTE_TO_CHAR (XFIXNAT (Fprevious_char ()))) == Sword)) { EMACS_INT modiff = MODIFF; @@ -439,17 +442,18 @@ internal_self_insert (int c, EMACS_INT n) int mc = ((NILP (BVAR (current_buffer, enable_multibyte_characters)) && SINGLE_BYTE_CHAR_P (c)) ? UNIBYTE_TO_CHAR (c) : c); - Lisp_Object string = Fmake_string (make_number (n), make_number (mc)); + Lisp_Object string = Fmake_string (make_fixnum (n), make_fixnum (mc), + Qnil); if (spaces_to_insert) { - tem = Fmake_string (make_number (spaces_to_insert), - make_number (' ')); + tem = Fmake_string (make_fixnum (spaces_to_insert), + make_fixnum (' '), Qnil); string = concat2 (string, tem); } replace_range (PT, PT + chars_to_delete, string, 1, 1, 1, 0); - Fforward_char (make_number (n)); + Fforward_char (make_fixnum (n)); } else if (n > 1) { |