/* Simple built-in editing commands.
-Copyright (C) 1985, 1993-1998, 2001-2012 Free Software Foundation, Inc.
+Copyright (C) 1985, 1993-1998, 2001-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
-#include <setjmp.h>
+
#include "lisp.h"
#include "commands.h"
#include "character.h"
return make_number (PT + XINT (n));
}
-/* Add N to point; or subtract N if FORWARD is zero. N defaults to 1.
+/* Add N to point; or subtract N if FORWARD is false. N defaults to 1.
Validate the new location. Return nil. */
static Lisp_Object
-move_point (Lisp_Object n, int forward)
+move_point (Lisp_Object n, bool forward)
{
/* This used to just set point to point + XINT (n), and then check
to see if it was within boundaries. But now that SET_PT can
DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "^p",
doc: /* Move point N characters forward (backward if N is negative).
On reaching end or beginning of buffer, stop and signal error.
+Interactively, N is the numeric prefix argument.
+If N is omitted or nil, move point 1 character forward.
Depending on the bidirectional context, the movement may be to the
right or to the left on the screen. This is in contrast with
DEFUN ("backward-char", Fbackward_char, Sbackward_char, 0, 1, "^p",
doc: /* Move point N characters backward (forward if N is negative).
On attempt to pass beginning or end of buffer, stop and signal error.
+Interactively, N is the numeric prefix argument.
+If N is omitted or nil, move point 1 character backward.
Depending on the bidirectional context, the movement may be to the
right or to the left on the screen. This is in contrast with
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;
}
if (count <= 0)
- shortage = scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, 1);
+ pos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
+ &shortage, &pos_byte, 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);
+ pos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
+ &shortage, &pos_byte, 1);
+
SET_PT_BOTH (pos, pos_byte);
if (shortage > 0
At the end, it runs `post-self-insert-hook'. */)
(Lisp_Object n)
{
- int remove_boundary = 1;
+ bool remove_boundary = 1;
CHECK_NATNUM (n);
if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command)))
/* 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));
: UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ())))
== Sword))
{
- int modiff = MODIFF;
+ EMACS_INT modiff = MODIFF;
Lisp_Object sym;
sym = call0 (Qexpand_abbrev);