diff src/cmds.c @ 6:27bc7f280385 r19-15b4

Import from CVS: tag r19-15b4
author cvs
date Mon, 13 Aug 2007 08:47:15 +0200
parents 376386a54a3c
children 4b173ad71786
line wrap: on
line diff
--- a/src/cmds.c	Mon Aug 13 08:46:57 2007 +0200
+++ b/src/cmds.c	Mon Aug 13 08:47:15 2007 +0200
@@ -149,14 +149,33 @@
 {
   struct buffer *b = decode_buffer (buffer, 1);
 
+  BUF_SET_PT(b, XINT (Fpoint_at_bol(arg, buffer)));
+  return Qnil;
+}
+
+DEFUN ("point-at-bol", Fpoint_at_bol, Spoint_at_bol, 0, 2, 0 /*
+Return the character position of the first character on the current line.
+With argument N not nil or 1, move forward N - 1 lines first.
+If scan reaches end of buffer, return that position.
+This function does not move point.
+*/ )
+       (arg, buffer)
+{
+  struct buffer *b = decode_buffer (buffer, 1);
+  register int orig, end;
+
   XSETBUFFER (buffer, b);
   if (NILP (arg))
     arg = make_int (1);
   else
     CHECK_INT (arg);
 
+  orig = BUF_PT(b);
   Fforward_line (make_int (XINT (arg) - 1), buffer);
-  return Qnil;
+  end = BUF_PT(b);
+  BUF_SET_PT(b, orig);
+
+  return make_int (end);
 }
 
 DEFUN ("end-of-line", Fend_of_line, Send_of_line,
@@ -171,6 +190,20 @@
 {
   struct buffer *buf = decode_buffer (buffer, 1);
 
+  BUF_SET_PT(buf, XINT (Fpoint_at_eol (arg, buffer)));
+  return Qnil;
+}
+
+DEFUN ("point-at-eol", Fpoint_at_eol, Spoint_at_eol, 0, 2, 0 /*
+Return the character position of the last character on the current line.
+With argument N not nil or 1, move forward N - 1 lines first.
+If scan reaches end of buffer, return that position.
+This function does not move point.
+*/ )
+       (arg, buffer)
+{
+  struct buffer *buf = decode_buffer (buffer, 1);
+
   XSETBUFFER (buffer, buf);
 
   if (NILP (arg))
@@ -178,9 +211,8 @@
   else
     CHECK_INT (arg);
 
-  BUF_SET_PT (buf, find_before_next_newline (buf, BUF_PT (buf), 0,
-					     XINT (arg) - (XINT (arg) <= 0)));
-  return Qnil;
+  return find_before_next_newline (buf, BUF_PT (buf), 0,
+				   XINT (arg) - (XINT (arg) <= 0));
 }
 
 DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "*p\nP" /*