X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/ca3fa30248b923c17c021c0fcdb945271d14e8c2..40be44e2a95cd703e49022c8f8aa0ce5b9b29ea6:/src/cmds.c diff --git a/src/cmds.c b/src/cmds.c index e12d7c370d..336bf1154f 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -1,7 +1,6 @@ /* Simple built-in editing commands. - Copyright (C) 1985, 1993, 1994, 1995, 1996, 1997, 1998, 2001, 2002, - 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + +Copyright (C) 1985, 1993-1998, 2001-2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -230,7 +229,7 @@ Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). Interactively, N is the prefix arg, and KILLFLAG is set if N was explicitly specified. -The command `delete-forward' is preferable for interactive use. */) +The command `delete-forward-char' is preferable for interactive use. */) (Lisp_Object n, Lisp_Object killflag) { EMACS_INT pos; @@ -276,9 +275,9 @@ After insertion, the value of `auto-fill-function' is called if the (Lisp_Object n) { int remove_boundary = 1; - CHECK_NUMBER (n); + CHECK_NATNUM (n); - if (!EQ (Vthis_command, current_kboard->Vlast_command)) + if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) nonundocount = 0; if (NILP (Vexecuting_kbd_macro) @@ -293,10 +292,10 @@ After insertion, the value of `auto-fill-function' is called if the } if (remove_boundary - && CONSP (current_buffer->undo_list) - && NILP (XCAR (current_buffer->undo_list))) + && CONSP (BVAR (current_buffer, undo_list)) + && NILP (XCAR (BVAR (current_buffer, undo_list)))) /* Remove the undo_boundary that was just pushed. */ - current_buffer->undo_list = XCDR (current_buffer->undo_list); + BVAR (current_buffer, undo_list) = XCDR (BVAR (current_buffer, undo_list)); /* Barf if the key that invoked this was not a character. */ if (!CHARACTERP (last_command_event)) @@ -320,7 +319,7 @@ After insertion, the value of `auto-fill-function' is called if the A value of 2 means this did things that call for an undo boundary. */ static Lisp_Object Qexpand_abbrev; -static Lisp_Object Qpost_self_insert_hook, Vpost_self_insert_hook; +static Lisp_Object Qpost_self_insert_hook; static int internal_self_insert (int c, EMACS_INT n) @@ -336,12 +335,12 @@ internal_self_insert (int c, EMACS_INT n) EMACS_INT chars_to_delete = 0; EMACS_INT spaces_to_insert = 0; - overwrite = current_buffer->overwrite_mode; + overwrite = BVAR (current_buffer, overwrite_mode); if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions)) hairy = 1; /* At first, get multi-byte form of C in STR. */ - if (!NILP (current_buffer->enable_multibyte_characters)) + if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) { len = CHAR_STRING (c, str); if (len == 1) @@ -417,11 +416,11 @@ internal_self_insert (int c, EMACS_INT n) synt = SYNTAX (c); - if (!NILP (current_buffer->abbrev_mode) + if (!NILP (BVAR (current_buffer, abbrev_mode)) && synt != Sword - && NILP (current_buffer->read_only) + && NILP (BVAR (current_buffer, read_only)) && PT > BEGV - && (SYNTAX (!NILP (current_buffer->enable_multibyte_characters) + && (SYNTAX (!NILP (BVAR (current_buffer, enable_multibyte_characters)) ? XFASTINT (Fprevious_char ()) : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) == Sword)) @@ -449,11 +448,11 @@ internal_self_insert (int c, EMACS_INT n) if (chars_to_delete) { - int mc = ((NILP (current_buffer->enable_multibyte_characters) + 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)); - + if (spaces_to_insert) { tem = Fmake_string (make_number (spaces_to_insert), @@ -467,20 +466,20 @@ internal_self_insert (int c, EMACS_INT n) else if (n > 1) { USE_SAFE_ALLOCA; - unsigned char *strn, *p; - SAFE_ALLOCA (strn, unsigned char*, n * len); + char *strn, *p; + SAFE_ALLOCA (strn, char *, n * len); for (p = strn; n > 0; n--, p += len) memcpy (p, str, len); insert_and_inherit (strn, p - strn); SAFE_FREE (); } - else - insert_and_inherit (str, len); + else if (n > 0) + insert_and_inherit ((char *) str, len); if ((CHAR_TABLE_P (Vauto_fill_chars) ? !NILP (CHAR_TABLE_REF (Vauto_fill_chars, c)) : (c == ' ' || c == '\n')) - && !NILP (current_buffer->auto_fill_function)) + && !NILP (BVAR (current_buffer, auto_fill_function))) { Lisp_Object tem; @@ -489,7 +488,7 @@ internal_self_insert (int c, EMACS_INT n) that. Must have the newline in place already so filling and justification, if any, know where the end is going to be. */ SET_PT_BOTH (PT - 1, PT_BYTE - 1); - tem = call0 (current_buffer->auto_fill_function); + tem = call0 (BVAR (current_buffer, auto_fill_function)); /* Test PT < ZV in case the auto-fill-function is strange. */ if (c == '\n' && PT < ZV) SET_PT_BOTH (PT + 1, PT_BYTE + 1); @@ -523,7 +522,7 @@ syms_of_cmds (void) Qpost_self_insert_hook = intern_c_string ("post-self-insert-hook"); staticpro (&Qpost_self_insert_hook); - DEFVAR_LISP ("post-self-insert-hook", &Vpost_self_insert_hook, + DEFVAR_LISP ("post-self-insert-hook", Vpost_self_insert_hook, doc: /* Hook run at the end of `self-insert-command'. This is run after inserting the character. */); Vpost_self_insert_hook = Qnil; @@ -560,6 +559,3 @@ keys_of_cmds (void) initial_define_key (global_map, Ctl ('E'), "end-of-line"); initial_define_key (global_map, Ctl ('F'), "forward-char"); } - -/* arch-tag: 022ba3cd-67f9-4978-9c5d-7d2b18d8644e - (do not change this comment) */