comparison src/cmds.c @ 8:4b173ad71786 r19-15b5

Import from CVS: tag r19-15b5
author cvs
date Mon, 13 Aug 2007 08:47:35 +0200
parents 27bc7f280385
children 0293115a14e9
comparison
equal deleted inserted replaced
7:c153ca296910 8:4b173ad71786
135 shortage--; 135 shortage--;
136 BUF_SET_PT (buf, pos); 136 BUF_SET_PT (buf, pos);
137 return make_int (negp ? - shortage : shortage); 137 return make_int (negp ? - shortage : shortage);
138 } 138 }
139 139
140 DEFUN ("point-at-bol", Fpoint_at_bol, Spoint_at_bol, 0, 2, 0 /*
141 Return the character position of the first character on the current line.
142 With argument N not nil or 1, move forward N - 1 lines first.
143 If scan reaches end of buffer, return that position.
144 This function does not move point.
145 */ )
146 (arg, buffer)
147 Lisp_Object arg, buffer;
148 {
149 struct buffer *b = decode_buffer (buffer, 1);
150 register int orig, end;
151
152 XSETBUFFER (buffer, b);
153 if (NILP (arg))
154 arg = make_int (1);
155 else
156 CHECK_INT (arg);
157
158 orig = BUF_PT(b);
159 Fforward_line (make_int (XINT (arg) - 1), buffer);
160 end = BUF_PT(b);
161 BUF_SET_PT(b, orig);
162
163 return make_int (end);
164 }
165
140 DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 166 DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line,
141 0, 2, "_p" /* 167 0, 2, "_p" /*
142 Move point to beginning of current line. 168 Move point to beginning of current line.
143 With argument ARG not nil or 1, move forward ARG - 1 lines first. 169 With argument ARG not nil or 1, move forward ARG - 1 lines first.
144 If scan reaches end of buffer, stop there without error. 170 If scan reaches end of buffer, stop there without error.
151 177
152 BUF_SET_PT(b, XINT (Fpoint_at_bol(arg, buffer))); 178 BUF_SET_PT(b, XINT (Fpoint_at_bol(arg, buffer)));
153 return Qnil; 179 return Qnil;
154 } 180 }
155 181
156 DEFUN ("point-at-bol", Fpoint_at_bol, Spoint_at_bol, 0, 2, 0 /* 182 DEFUN ("point-at-eol", Fpoint_at_eol, Spoint_at_eol, 0, 2, 0 /*
157 Return the character position of the first character on the current line. 183 Return the character position of the last character on the current line.
158 With argument N not nil or 1, move forward N - 1 lines first. 184 With argument N not nil or 1, move forward N - 1 lines first.
159 If scan reaches end of buffer, return that position. 185 If scan reaches end of buffer, return that position.
160 This function does not move point. 186 This function does not move point.
161 */ ) 187 */ )
162 (arg, buffer) 188 (arg, buffer)
163 { 189 Lisp_Object arg, buffer;
164 struct buffer *b = decode_buffer (buffer, 1); 190 {
165 register int orig, end; 191 struct buffer *buf = decode_buffer (buffer, 1);
166 192
167 XSETBUFFER (buffer, b); 193 XSETBUFFER (buffer, buf);
194
168 if (NILP (arg)) 195 if (NILP (arg))
169 arg = make_int (1); 196 arg = make_int (1);
170 else 197 else
171 CHECK_INT (arg); 198 CHECK_INT (arg);
172 199
173 orig = BUF_PT(b); 200 return make_int (find_before_next_newline (buf, BUF_PT (buf), 0,
174 Fforward_line (make_int (XINT (arg) - 1), buffer); 201 XINT (arg) - (XINT (arg) <= 0)));
175 end = BUF_PT(b);
176 BUF_SET_PT(b, orig);
177
178 return make_int (end);
179 } 202 }
180 203
181 DEFUN ("end-of-line", Fend_of_line, Send_of_line, 204 DEFUN ("end-of-line", Fend_of_line, Send_of_line,
182 0, 2, "_p" /* 205 0, 2, "_p" /*
183 Move point to end of current line. 206 Move point to end of current line.
190 { 213 {
191 struct buffer *buf = decode_buffer (buffer, 1); 214 struct buffer *buf = decode_buffer (buffer, 1);
192 215
193 BUF_SET_PT(buf, XINT (Fpoint_at_eol (arg, buffer))); 216 BUF_SET_PT(buf, XINT (Fpoint_at_eol (arg, buffer)));
194 return Qnil; 217 return Qnil;
195 }
196
197 DEFUN ("point-at-eol", Fpoint_at_eol, Spoint_at_eol, 0, 2, 0 /*
198 Return the character position of the last character on the current line.
199 With argument N not nil or 1, move forward N - 1 lines first.
200 If scan reaches end of buffer, return that position.
201 This function does not move point.
202 */ )
203 (arg, buffer)
204 {
205 struct buffer *buf = decode_buffer (buffer, 1);
206
207 XSETBUFFER (buffer, buf);
208
209 if (NILP (arg))
210 arg = make_int (1);
211 else
212 CHECK_INT (arg);
213
214 return find_before_next_newline (buf, BUF_PT (buf), 0,
215 XINT (arg) - (XINT (arg) <= 0));
216 } 218 }
217 219
218 DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "*p\nP" /* 220 DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "*p\nP" /*
219 Delete the following ARG characters (previous, with negative arg). 221 Delete the following ARG characters (previous, with negative arg).
220 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). 222 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).