]> code.delx.au - gnu-emacs/blobdiff - src/cmds.c
Update copyright year to 2015
[gnu-emacs] / src / cmds.c
index ce91877f85e85f051a7fba22dbaf09895d6ab0ca..485a235b5abd5bcbb714092a7128e4e222e6de43 100644 (file)
@@ -1,6 +1,6 @@
 /* Simple built-in editing commands.
 
-Copyright (C) 1985, 1993-1998, 2001-2013 Free Software Foundation, Inc.
+Copyright (C) 1985, 1993-1998, 2001-2015 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -121,9 +121,7 @@ With positive N, a non-empty line at the end counts as one line
 successfully moved (for the return value).  */)
   (Lisp_Object n)
 {
-  ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
-  ptrdiff_t pos, pos_byte;
-  EMACS_INT count, shortage;
+  ptrdiff_t opoint = PT, pos, pos_byte, shortage, count;
 
   if (NILP (n))
     count = 1;
@@ -133,17 +131,8 @@ successfully moved (for the return value).  */)
       count = XINT (n);
     }
 
-  if (count <= 0)
-    shortage = scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, 1);
-  else
-    shortage = scan_newline (PT, PT_BYTE, ZV, ZV_BYTE, count, 1);
-
-  /* Since scan_newline does TEMP_SET_PT_BOTH,
-     and we want to set PT "for real",
-     go back to the old point and then come back here.  */
-  pos = PT;
-  pos_byte = PT_BYTE;
-  TEMP_SET_PT_BOTH (opoint, opoint_byte);
+  shortage = scan_newline_from_point (count, &pos, &pos_byte);
+
   SET_PT_BOTH (pos, pos_byte);
 
   if (shortage > 0
@@ -235,7 +224,8 @@ 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-char' is preferable for interactive use.  */)
+The command `delete-forward-char' is preferable for interactive use, e.g.
+because it respects values of `delete-active-region' and `overwrite-mode'.  */)
   (Lisp_Object n, Lisp_Object killflag)
 {
   EMACS_INT pos;
@@ -274,6 +264,7 @@ static int nonundocount;
 DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p",
        doc: /* Insert the character you type.
 Whichever character 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.
 After insertion, the value of `auto-fill-function' is called if the
@@ -282,7 +273,10 @@ At the end, it runs `post-self-insert-hook'.  */)
   (Lisp_Object n)
 {
   bool remove_boundary = 1;
-  CHECK_NATNUM (n);
+  CHECK_NUMBER (n);
+
+  if (XFASTINT (n) < 0)
+    error ("Negative repetition argument %"pI"d", XFASTINT (n));
 
   if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command)))
     nonundocount = 0;
@@ -310,13 +304,13 @@ At the end, it runs `post-self-insert-hook'.  */)
   /* Barf if the key that invoked this was not a character.  */
   if (!CHARACTERP (last_command_event))
     bitch_at_user ();
-  {
+  else {
     int character = translate_char (Vtranslation_table_for_input,
                                    XINT (last_command_event));
     int val = internal_self_insert (character, XFASTINT (n));
     if (val == 2)
       nonundocount = 0;
-    frame_make_pointer_invisible ();
+    frame_make_pointer_invisible (SELECTED_FRAME ());
   }
 
   return Qnil;
@@ -360,9 +354,7 @@ internal_self_insert (int c, EMACS_INT n)
     }
   else
     {
-      str[0] = (SINGLE_BYTE_CHAR_P (c)
-               ? c
-               : multibyte_char_to_unibyte (c));
+      str[0] = SINGLE_BYTE_CHAR_P (c) ? c : CHAR_TO_BYTE8 (c);
       len = 1;
     }
   if (!NILP (overwrite)