Merged from emacs@sv.gnu.org
[bpt/emacs.git] / src / cmds.c
index cc5bd90..7e07ce1 100644 (file)
@@ -1,6 +1,6 @@
 /* Simple built-in editing commands.
    Copyright (C) 1985, 1993, 1994, 1995, 1996, 1997, 1998, 2001, 2002,
-                 2003, 2004, 2005 Free Software Foundation, Inc.
+                 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -77,12 +77,12 @@ On reaching end of buffer, stop and signal error.  */)
     if (new_point < BEGV)
       {
        SET_PT (BEGV);
-       Fsignal (Qbeginning_of_buffer, Qnil);
+       xsignal0 (Qbeginning_of_buffer);
       }
     if (new_point > ZV)
       {
        SET_PT (ZV);
-       Fsignal (Qend_of_buffer, Qnil);
+       xsignal0 (Qend_of_buffer);
       }
 
     SET_PT (new_point);
@@ -157,13 +157,13 @@ DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 0, 1, "p",
 With argument N not nil or 1, move forward N - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
 
-This command does not move point across a field boundary unless doing so
-would move beyond there to a different line; If N is nil or 1, and point
-starts at a field boundary, point does not move.  To ignore field
-boundaries, either bind `inhibit-field-text-motion' to t, or use the
-`forward-line' function instead.  For instance, `(forward-line 0)' does
-the same thing as `(beginning-of-line)', except that it ignores field
-boundaries.  */)
+This function constrains point to the current field unless this moves
+point to a different line than the original, unconstrained result.  If
+N is nil or 1, and a front-sticky field starts at point, the point
+does not move.  To ignore field boundaries bind
+`inhibit-field-text-motion' to t, or use the `forward-line' function
+instead.  For instance, `(forward-line 0)' does the same thing as
+`(beginning-of-line)', except that it ignores field boundaries.  */)
      (n)
      Lisp_Object n;
 {
@@ -183,10 +183,11 @@ With argument N not nil or 1, move forward N - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
 To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
 
-This command does not move point across a field boundary unless doing so
-would move beyond there to a different line; if N is nil or 1, and
-point starts at a field boundary, point does not move.  To ignore field
-boundaries bind `inhibit-field-text-motion' to t.  */)
+This function constrains point to the current field unless this moves
+point to a different line than the original, unconstrained result.  If
+N is nil or 1, and a rear-sticky field ends at point, the point does
+not move.  To ignore field boundaries bind `inhibit-field-text-motion'
+to t.  */)
      (n)
      Lisp_Object n;
 {
@@ -244,14 +245,14 @@ N was explicitly specified.  */)
       if (XINT (n) < 0)
        {
          if (pos < BEGV)
-           Fsignal (Qbeginning_of_buffer, Qnil);
+           xsignal0 (Qbeginning_of_buffer);
          else
            del_range (pos, PT);
        }
       else
        {
          if (pos > ZV)
-           Fsignal (Qend_of_buffer, Qnil);
+           xsignal0 (Qend_of_buffer);
          else
            del_range (PT, pos);
        }
@@ -527,7 +528,8 @@ internal_self_insert (c, noautofill)
           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);
-      if (c == '\n')
+      /* Test PT < ZV in case the auto-fill-function is strange.  */
+      if (c == '\n' && PT < ZV)
        SET_PT_BOTH (PT + 1, PT_BYTE + 1);
       if (!NILP (tem))
        hairy = 2;