aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmds.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-09-05 11:01:04 +0300
committerEli Zaretskii2013-09-05 11:01:04 +0300
commit41306318777a942420bc4feadbfacf662ea179dc (patch)
tree669e5cca02f95d6064ce73c0d3fbbf91b8c8b563 /src/cmds.c
parent141f1ff7a40cda10f0558e891dd196a943a5082e (diff)
parent257b3b03cb1cff917e0b3b7832ad3eab5b59f257 (diff)
downloademacs-41306318777a942420bc4feadbfacf662ea179dc.tar.gz
emacs-41306318777a942420bc4feadbfacf662ea179dc.zip
Merge from trunk after a lot of time.
Diffstat (limited to 'src/cmds.c')
-rw-r--r--src/cmds.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/cmds.c b/src/cmds.c
index 225c26b082c..aeedb152f62 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -1,6 +1,6 @@
1/* Simple built-in editing commands. 1/* Simple built-in editing commands.
2 2
3Copyright (C) 1985, 1993-1998, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1985, 1993-1998, 2001-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -19,11 +19,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <setjmp.h> 22
23#include "lisp.h" 23#include "lisp.h"
24#include "commands.h" 24#include "commands.h"
25#include "buffer.h"
26#include "character.h" 25#include "character.h"
26#include "buffer.h"
27#include "syntax.h" 27#include "syntax.h"
28#include "window.h" 28#include "window.h"
29#include "keyboard.h" 29#include "keyboard.h"
@@ -47,10 +47,10 @@ DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
47 return make_number (PT + XINT (n)); 47 return make_number (PT + XINT (n));
48} 48}
49 49
50/* Add N to point; or subtract N if FORWARD is zero. N defaults to 1. 50/* Add N to point; or subtract N if FORWARD is false. N defaults to 1.
51 Validate the new location. Return nil. */ 51 Validate the new location. Return nil. */
52static Lisp_Object 52static Lisp_Object
53move_point (Lisp_Object n, int forward) 53move_point (Lisp_Object n, bool forward)
54{ 54{
55 /* This used to just set point to point + XINT (n), and then check 55 /* This used to just set point to point + XINT (n), and then check
56 to see if it was within boundaries. But now that SET_PT can 56 to see if it was within boundaries. But now that SET_PT can
@@ -85,6 +85,8 @@ move_point (Lisp_Object n, int forward)
85DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "^p", 85DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "^p",
86 doc: /* Move point N characters forward (backward if N is negative). 86 doc: /* Move point N characters forward (backward if N is negative).
87On reaching end or beginning of buffer, stop and signal error. 87On reaching end or beginning of buffer, stop and signal error.
88Interactively, N is the numeric prefix argument.
89If N is omitted or nil, move point 1 character forward.
88 90
89Depending on the bidirectional context, the movement may be to the 91Depending on the bidirectional context, the movement may be to the
90right or to the left on the screen. This is in contrast with 92right or to the left on the screen. This is in contrast with
@@ -97,6 +99,8 @@ right or to the left on the screen. This is in contrast with
97DEFUN ("backward-char", Fbackward_char, Sbackward_char, 0, 1, "^p", 99DEFUN ("backward-char", Fbackward_char, Sbackward_char, 0, 1, "^p",
98 doc: /* Move point N characters backward (forward if N is negative). 100 doc: /* Move point N characters backward (forward if N is negative).
99On attempt to pass beginning or end of buffer, stop and signal error. 101On attempt to pass beginning or end of buffer, stop and signal error.
102Interactively, N is the numeric prefix argument.
103If N is omitted or nil, move point 1 character backward.
100 104
101Depending on the bidirectional context, the movement may be to the 105Depending on the bidirectional context, the movement may be to the
102right or to the left on the screen. This is in contrast with 106right or to the left on the screen. This is in contrast with
@@ -117,9 +121,7 @@ With positive N, a non-empty line at the end counts as one line
117successfully moved (for the return value). */) 121successfully moved (for the return value). */)
118 (Lisp_Object n) 122 (Lisp_Object n)
119{ 123{
120 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; 124 ptrdiff_t opoint = PT, pos, pos_byte, shortage, count;
121 ptrdiff_t pos, pos_byte;
122 EMACS_INT count, shortage;
123 125
124 if (NILP (n)) 126 if (NILP (n))
125 count = 1; 127 count = 1;
@@ -130,16 +132,12 @@ successfully moved (for the return value). */)
130 } 132 }
131 133
132 if (count <= 0) 134 if (count <= 0)
133 shortage = scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, 1); 135 pos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
136 &shortage, &pos_byte, 1);
134 else 137 else
135 shortage = scan_newline (PT, PT_BYTE, ZV, ZV_BYTE, count, 1); 138 pos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
136 139 &shortage, &pos_byte, 1);
137 /* Since scan_newline does TEMP_SET_PT_BOTH, 140
138 and we want to set PT "for real",
139 go back to the old point and then come back here. */
140 pos = PT;
141 pos_byte = PT_BYTE;
142 TEMP_SET_PT_BOTH (opoint, opoint_byte);
143 SET_PT_BOTH (pos, pos_byte); 141 SET_PT_BOTH (pos, pos_byte);
144 142
145 if (shortage > 0 143 if (shortage > 0
@@ -277,7 +275,7 @@ After insertion, the value of `auto-fill-function' is called if the
277At the end, it runs `post-self-insert-hook'. */) 275At the end, it runs `post-self-insert-hook'. */)
278 (Lisp_Object n) 276 (Lisp_Object n)
279{ 277{
280 int remove_boundary = 1; 278 bool remove_boundary = 1;
281 CHECK_NATNUM (n); 279 CHECK_NATNUM (n);
282 280
283 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) 281 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command)))
@@ -296,14 +294,17 @@ At the end, it runs `post-self-insert-hook'. */)
296 294
297 if (remove_boundary 295 if (remove_boundary
298 && CONSP (BVAR (current_buffer, undo_list)) 296 && CONSP (BVAR (current_buffer, undo_list))
299 && NILP (XCAR (BVAR (current_buffer, undo_list)))) 297 && NILP (XCAR (BVAR (current_buffer, undo_list)))
298 /* Only remove auto-added boundaries, not boundaries
299 added be explicit calls to undo-boundary. */
300 && EQ (BVAR (current_buffer, undo_list), last_undo_boundary))
300 /* Remove the undo_boundary that was just pushed. */ 301 /* Remove the undo_boundary that was just pushed. */
301 BVAR (current_buffer, undo_list) = XCDR (BVAR (current_buffer, undo_list)); 302 bset_undo_list (current_buffer, XCDR (BVAR (current_buffer, undo_list)));
302 303
303 /* Barf if the key that invoked this was not a character. */ 304 /* Barf if the key that invoked this was not a character. */
304 if (!CHARACTERP (last_command_event)) 305 if (!CHARACTERP (last_command_event))
305 bitch_at_user (); 306 bitch_at_user ();
306 { 307 else {
307 int character = translate_char (Vtranslation_table_for_input, 308 int character = translate_char (Vtranslation_table_for_input,
308 XINT (last_command_event)); 309 XINT (last_command_event));
309 int val = internal_self_insert (character, XFASTINT (n)); 310 int val = internal_self_insert (character, XFASTINT (n));
@@ -435,7 +436,7 @@ internal_self_insert (int c, EMACS_INT n)
435 : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) 436 : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ())))
436 == Sword)) 437 == Sword))
437 { 438 {
438 int modiff = MODIFF; 439 EMACS_INT modiff = MODIFF;
439 Lisp_Object sym; 440 Lisp_Object sym;
440 441
441 sym = call0 (Qexpand_abbrev); 442 sym = call0 (Qexpand_abbrev);
@@ -443,7 +444,8 @@ internal_self_insert (int c, EMACS_INT n)
443 /* If we expanded an abbrev which has a hook, 444 /* If we expanded an abbrev which has a hook,
444 and the hook has a non-nil `no-self-insert' property, 445 and the hook has a non-nil `no-self-insert' property,
445 return right away--don't really self-insert. */ 446 return right away--don't really self-insert. */
446 if (SYMBOLP (sym) && ! NILP (sym) && ! NILP (XSYMBOL (sym)->function) 447 if (SYMBOLP (sym) && ! NILP (sym)
448 && ! NILP (XSYMBOL (sym)->function)
447 && SYMBOLP (XSYMBOL (sym)->function)) 449 && SYMBOLP (XSYMBOL (sym)->function))
448 { 450 {
449 Lisp_Object prop; 451 Lisp_Object prop;