comparison src/marker.c @ 12999:b889a50f71db

(Fcopy_marker): New arg TYPE. (Fmarker_insertion_type, Fset_marker_insertion_type): New functions. (syms_of_marker): defsubr them.
author Richard M. Stallman <rms@gnu.org>
date Sun, 03 Sep 1995 18:53:58 +0000
parents ac7375e60931
children e518c2be8d7b
comparison
equal deleted inserted replaced
12998:404ae27d5148 12999:b889a50f71db
68 XSETFASTINT (pos, i); 68 XSETFASTINT (pos, i);
69 return pos; 69 return pos;
70 } 70 }
71 return Qnil; 71 return Qnil;
72 } 72 }
73 73
74 DEFUN ("set-marker", Fset_marker, Sset_marker, 2, 3, 0, 74 DEFUN ("set-marker", Fset_marker, Sset_marker, 2, 3, 0,
75 "Position MARKER before character number NUMBER in BUFFER.\n\ 75 "Position MARKER before character number NUMBER in BUFFER.\n\
76 BUFFER defaults to the current buffer.\n\ 76 BUFFER defaults to the current buffer.\n\
77 If NUMBER is nil, makes marker point nowhere.\n\ 77 If NUMBER is nil, makes marker point nowhere.\n\
78 Then it no longer slows down editing in any buffer.\n\ 78 Then it no longer slows down editing in any buffer.\n\
261 if (i < BUF_BEG (buf) || i > BUF_Z (buf)) 261 if (i < BUF_BEG (buf) || i > BUF_Z (buf))
262 abort (); 262 abort ();
263 263
264 return i; 264 return i;
265 } 265 }
266 266
267 DEFUN ("copy-marker", Fcopy_marker, Scopy_marker, 1, 1, 0, 267 DEFUN ("copy-marker", Fcopy_marker, Scopy_marker, 1, 2, 0,
268 "Return a new marker pointing at the same place as MARKER.\n\ 268 "Return a new marker pointing at the same place as MARKER.\n\
269 If argument is a number, makes a new marker pointing\n\ 269 If argument is a number, makes a new marker pointing\n\
270 at that position in the current buffer.") 270 at that position in the current buffer.\n\
271 The optional argument TYPE specifies the insertion type of the new marker;\n\
272 see `marker-insertion-type'.")
273 (marker, type)
274 register Lisp_Object marker, type;
275 {
276 register Lisp_Object new;
277
278 if (INTEGERP (marker) || MARKERP (marker))
279 {
280 new = Fmake_marker ();
281 Fset_marker (new, marker,
282 (MARKERP (marker) ? Fmarker_buffer (marker) : Qnil));
283 XMARKER (new)->insertion_type = !NILP (type);
284 return new;
285 }
286 else
287 marker = wrong_type_argument (Qinteger_or_marker_p, marker);
288 }
289
290 DEFUN ("marker-insertion-type", Fmarker_insertion_type,
291 Smarker_insertion_type, 1, 1, 0,
292 "Return insertion type of MARKER: t if it stays after inserted text.\n\
293 nil means the marker stays before text inserted there.")
271 (marker) 294 (marker)
272 register Lisp_Object marker; 295 register Lisp_Object marker;
273 { 296 {
274 register Lisp_Object new; 297 register Lisp_Object buf;
275 298 CHECK_MARKER (marker, 0);
276 while (1) 299 return XMARKER (marker)->insertion_type ? Qt : Qnil;
277 { 300 }
278 if (INTEGERP (marker) || MARKERP (marker)) 301
279 { 302 DEFUN ("set-marker-insertion-type", Fset_marker_insertion_type,
280 new = Fmake_marker (); 303 Sset_marker_insertion_type, 2, 2, 0,
281 Fset_marker (new, marker, 304 "Set the insertion-type of MARKER to TYPE.\n\
282 (MARKERP (marker) ? Fmarker_buffer (marker) : Qnil)); 305 If TYPE is t, it means the marker advances when you insert text at it.\n\
283 return new; 306 If TYPE is t, it means the marker stays behind when you insert text at it.")
284 } 307 (marker, type)
285 else 308 Lisp_Object marker, type;
286 marker = wrong_type_argument (Qinteger_or_marker_p, marker); 309 {
287 } 310 CHECK_MARKER (marker, 0);
311
312 XMARKER (marker)->insertion_type = ! NILP (type);
313 return type;
288 } 314 }
289 315
290 syms_of_marker () 316 syms_of_marker ()
291 { 317 {
292 defsubr (&Smarker_position); 318 defsubr (&Smarker_position);
293 defsubr (&Smarker_buffer); 319 defsubr (&Smarker_buffer);
294 defsubr (&Sset_marker); 320 defsubr (&Sset_marker);
295 defsubr (&Scopy_marker); 321 defsubr (&Scopy_marker);
296 } 322 defsubr (&Smarker_insertion_type);
323 defsubr (&Sset_marker_insertion_type);
324 }