comparison src/marker.c @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 183866b06e0b
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
166 } 166 }
167 167
168 #endif 168 #endif
169 169
170 static Lisp_Object 170 static Lisp_Object
171 set_marker_internal (Lisp_Object marker, Lisp_Object pos, Lisp_Object buffer, 171 set_marker_internal (Lisp_Object marker, Lisp_Object position,
172 int restricted_p) 172 Lisp_Object buffer, int restricted_p)
173 { 173 {
174 Bufpos charno; 174 Bufpos charno;
175 struct buffer *b; 175 struct buffer *b;
176 Lisp_Marker *m; 176 Lisp_Marker *m;
177 int point_p; 177 int point_p;
180 180
181 point_p = POINT_MARKER_P (marker); 181 point_p = POINT_MARKER_P (marker);
182 182
183 /* If position is nil or a marker that points nowhere, 183 /* If position is nil or a marker that points nowhere,
184 make this marker point nowhere. */ 184 make this marker point nowhere. */
185 if (NILP (pos) || 185 if (NILP (position) ||
186 (MARKERP (pos) && !XMARKER (pos)->buffer)) 186 (MARKERP (position) && !XMARKER (position)->buffer))
187 { 187 {
188 if (point_p) 188 if (point_p)
189 signal_simple_error ("Can't make point-marker point nowhere", 189 signal_simple_error ("Can't make point-marker point nowhere",
190 marker); 190 marker);
191 if (XMARKER (marker)->buffer) 191 if (XMARKER (marker)->buffer)
192 unchain_marker (marker); 192 unchain_marker (marker);
193 return marker; 193 return marker;
194 } 194 }
195 195
196 CHECK_INT_COERCE_MARKER (pos); 196 CHECK_INT_COERCE_MARKER (position);
197 if (NILP (buffer)) 197 if (NILP (buffer))
198 b = current_buffer; 198 b = current_buffer;
199 else 199 else
200 { 200 {
201 CHECK_BUFFER (buffer); 201 CHECK_BUFFER (buffer);
210 unchain_marker (marker); 210 unchain_marker (marker);
211 return marker; 211 return marker;
212 } 212 }
213 } 213 }
214 214
215 charno = XINT (pos); 215 charno = XINT (position);
216 m = XMARKER (marker); 216 m = XMARKER (marker);
217 217
218 if (restricted_p) 218 if (restricted_p)
219 { 219 {
220 if (charno < BUF_BEGV (b)) charno = BUF_BEGV (b); 220 if (charno < BUF_BEGV (b)) charno = BUF_BEGV (b);
257 return marker; 257 return marker;
258 } 258 }
259 259
260 260
261 DEFUN ("set-marker", Fset_marker, 2, 3, 0, /* 261 DEFUN ("set-marker", Fset_marker, 2, 3, 0, /*
262 Position MARKER before character number NUMBER in BUFFER. 262 Move MARKER to position POSITION in BUFFER.
263 POSITION can be a marker, an integer or nil. If POSITION is an
264 integer, make MARKER point before the POSITIONth character in BUFFER.
265 If POSITION is nil, makes MARKER point nowhere. Then it no longer
266 slows down editing in any buffer. If POSITION is less than 1, move
267 MARKER to the beginning of BUFFER. If POSITION is greater than the
268 size of BUFFER, move MARKER to the end of BUFFER.
263 BUFFER defaults to the current buffer. 269 BUFFER defaults to the current buffer.
264 If NUMBER is nil, makes marker point nowhere. 270 If this marker was returned by (point-marker t), then changing its
265 Then it no longer slows down editing in any buffer. 271 position moves point. You cannot change its buffer or make it point
266 If this marker was returned by (point-marker t), then changing its position 272 nowhere.
267 moves point. You cannot change its buffer or make it point nowhere. 273 The return value is MARKER.
268 Returns MARKER. 274 */
269 */ 275 (marker, position, buffer))
270 (marker, number, buffer)) 276 {
271 { 277 return set_marker_internal (marker, position, buffer, 0);
272 return set_marker_internal (marker, number, buffer, 0);
273 } 278 }
274 279
275 280
276 /* This version of Fset_marker won't let the position 281 /* This version of Fset_marker won't let the position
277 be outside the visible part. */ 282 be outside the visible part. */
278 Lisp_Object 283 Lisp_Object
279 set_marker_restricted (Lisp_Object marker, Lisp_Object pos, Lisp_Object buffer) 284 set_marker_restricted (Lisp_Object marker, Lisp_Object position,
280 { 285 Lisp_Object buffer)
281 return set_marker_internal (marker, pos, buffer, 1); 286 {
287 return set_marker_internal (marker, position, buffer, 1);
282 } 288 }
283 289
284 290
285 /* This is called during garbage collection, 291 /* This is called during garbage collection,
286 so we must be careful to ignore and preserve mark bits, 292 so we must be careful to ignore and preserve mark bits,
402 408
403 RETURN_NOT_REACHED (Qnil) /* not reached */ 409 RETURN_NOT_REACHED (Qnil) /* not reached */
404 } 410 }
405 411
406 DEFUN ("copy-marker", Fcopy_marker, 1, 2, 0, /* 412 DEFUN ("copy-marker", Fcopy_marker, 1, 2, 0, /*
407 Return a new marker pointing at the same place as MARKER. 413 Return a new marker pointing at the same place as MARKER-OR-INTEGER.
408 If argument is a number, makes a new marker pointing 414 If MARKER-OR-INTEGER is an integer, return a new marker pointing
409 at that position in the current buffer. 415 at that position in the current buffer.
410 The optional argument TYPE specifies the insertion type of the new marker; 416 Optional argument MARKER-TYPE specifies the insertion type of the new
411 see `marker-insertion-type'. 417 marker; see `marker-insertion-type'.
412 */ 418 */
413 (marker, type)) 419 (marker_or_integer, marker_type))
414 { 420 {
415 return copy_marker_1 (marker, type, 0); 421 return copy_marker_1 (marker_or_integer, marker_type, 0);
416 } 422 }
417 423
418 Lisp_Object 424 Lisp_Object
419 noseeum_copy_marker (Lisp_Object marker, Lisp_Object type) 425 noseeum_copy_marker (Lisp_Object marker, Lisp_Object marker_type)
420 { 426 {
421 return copy_marker_1 (marker, type, 1); 427 return copy_marker_1 (marker, marker_type, 1);
422 } 428 }
423 429
424 DEFUN ("marker-insertion-type", Fmarker_insertion_type, 1, 1, 0, /* 430 DEFUN ("marker-insertion-type", Fmarker_insertion_type, 1, 1, 0, /*
425 Return insertion type of MARKER: t if it stays after inserted text. 431 Return insertion type of MARKER: t if it stays after inserted text.
426 nil means the marker stays before text inserted there. 432 nil means the marker stays before text inserted there.