comparison src/extents.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 8fc7fe29b841
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
443 Lisp_Object Qend_closed; 443 Lisp_Object Qend_closed;
444 Lisp_Object Qread_only; 444 Lisp_Object Qread_only;
445 /* Qhighlight defined in general.c */ 445 /* Qhighlight defined in general.c */
446 Lisp_Object Qunique; 446 Lisp_Object Qunique;
447 Lisp_Object Qduplicable; 447 Lisp_Object Qduplicable;
448 Lisp_Object Qreplicating;
449 Lisp_Object Qdetachable; 448 Lisp_Object Qdetachable;
450 Lisp_Object Qpriority; 449 Lisp_Object Qpriority;
451 Lisp_Object Qmouse_face; 450 Lisp_Object Qmouse_face;
452 451
453 Lisp_Object Qglyph_layout; /* This exists only for backwards compatibility. */ 452 Lisp_Object Qglyph_layout; /* This exists only for backwards compatibility. */
2957 *bp++ = ' '; 2956 *bp++ = ' ';
2958 2957
2959 if (!NILP (extent_read_only (anc))) *bp++ = '%'; 2958 if (!NILP (extent_read_only (anc))) *bp++ = '%';
2960 if (!NILP (extent_mouse_face (anc))) *bp++ = 'H'; 2959 if (!NILP (extent_mouse_face (anc))) *bp++ = 'H';
2961 if (extent_unique_p (anc)) *bp++ = 'U'; 2960 if (extent_unique_p (anc)) *bp++ = 'U';
2962 else if (extent_replicating_p (anc)) *bp++ = 'R';
2963 else if (extent_duplicable_p (anc)) *bp++ = 'D'; 2961 else if (extent_duplicable_p (anc)) *bp++ = 'D';
2964 if (!NILP (extent_invisible (anc))) *bp++ = 'I'; 2962 if (!NILP (extent_invisible (anc))) *bp++ = 'I';
2965 2963
2966 if (!NILP (extent_read_only (anc)) || !NILP (extent_mouse_face (anc)) || 2964 if (!NILP (extent_read_only (anc)) || !NILP (extent_mouse_face (anc)) ||
2967 extent_unique_p (anc) || extent_replicating_p (anc) || 2965 extent_unique_p (anc) ||
2968 extent_duplicable_p (anc) || !NILP (extent_invisible (anc))) 2966 extent_duplicable_p (anc) || !NILP (extent_invisible (anc)))
2969 *bp++ = ' '; 2967 *bp++ = ' ';
2970 2968
2971 tail = extent_plist_slot (anc); 2969 tail = extent_plist_slot (anc);
2972 2970
3220 return Qnil; 3218 return Qnil;
3221 else 3219 else
3222 return make_int (extent_endpoint_bufpos (extent, endp)); 3220 return make_int (extent_endpoint_bufpos (extent, endp));
3223 } 3221 }
3224 3222
3225 DEFUN ("extentp", Fextentp, Sextentp, 1, 1, 0 /* 3223 DEFUN ("extentp", Fextentp, 1, 1, 0, /*
3226 T if OBJECT is an extent. 3224 T if OBJECT is an extent.
3227 */ ) 3225 */
3228 (object) 3226 (object))
3229 Lisp_Object object;
3230 { 3227 {
3231 if (EXTENTP (object)) 3228 if (EXTENTP (object))
3232 return Qt; 3229 return Qt;
3233 return Qnil; 3230 return Qnil;
3234 } 3231 }
3235 3232
3236 DEFUN ("extent-live-p", Fextent_live_p, Sextent_live_p, 1, 1, 0 /* 3233 DEFUN ("extent-live-p", Fextent_live_p, 1, 1, 0, /*
3237 T if OBJECT is an extent and the extent has not been destroyed. 3234 T if OBJECT is an extent and the extent has not been destroyed.
3238 */ ) 3235 */
3239 (object) 3236 (object))
3240 Lisp_Object object;
3241 { 3237 {
3242 if (EXTENTP (object) && EXTENT_LIVE_P (XEXTENT (object))) 3238 if (EXTENTP (object) && EXTENT_LIVE_P (XEXTENT (object)))
3243 return Qt; 3239 return Qt;
3244 return Qnil; 3240 return Qnil;
3245 } 3241 }
3246 3242
3247 DEFUN ("extent-detached-p", Fextent_detached_p, Sextent_detached_p, 1, 1, 0 /* 3243 DEFUN ("extent-detached-p", Fextent_detached_p, 1, 1, 0, /*
3248 T if EXTENT is detached. 3244 T if EXTENT is detached.
3249 */ ) 3245 */
3250 (extent) 3246 (extent))
3251 Lisp_Object extent;
3252 { 3247 {
3253 if (extent_detached_p (decode_extent (extent, 0))) 3248 if (extent_detached_p (decode_extent (extent, 0)))
3254 return Qt; 3249 return Qt;
3255 return Qnil; 3250 return Qnil;
3256 } 3251 }
3257 3252
3258 DEFUN ("extent-object", Fextent_object, Sextent_object, 1, 1, 0 /* 3253 DEFUN ("extent-object", Fextent_object, 1, 1, 0, /*
3259 Return object (buffer or string) EXTENT refers to. 3254 Return object (buffer or string) EXTENT refers to.
3260 */ ) 3255 */
3261 (extent) 3256 (extent))
3262 Lisp_Object extent;
3263 { 3257 {
3264 return extent_object (decode_extent (extent, 0)); 3258 return extent_object (decode_extent (extent, 0));
3265 } 3259 }
3266 3260
3267 DEFUN ("extent-start-position", Fextent_start_position, 3261 DEFUN ("extent-start-position", Fextent_start_position, 1, 1, 0, /*
3268 Sextent_start_position, 1, 1, 0 /*
3269 Return start position of EXTENT, or nil if EXTENT is detached. 3262 Return start position of EXTENT, or nil if EXTENT is detached.
3270 */ ) 3263 */
3271 (extent) 3264 (extent))
3272 Lisp_Object extent;
3273 { 3265 {
3274 return extent_endpoint_external (extent, 0); 3266 return extent_endpoint_external (extent, 0);
3275 } 3267 }
3276 3268
3277 DEFUN ("extent-end-position", Fextent_end_position, 3269 DEFUN ("extent-end-position", Fextent_end_position, 1, 1, 0, /*
3278 Sextent_end_position, 1, 1, 0 /*
3279 Return end position of EXTENT, or nil if EXTENT is detached. 3270 Return end position of EXTENT, or nil if EXTENT is detached.
3280 */ ) 3271 */
3281 (extent) 3272 (extent))
3282 Lisp_Object extent;
3283 { 3273 {
3284 return extent_endpoint_external (extent, 1); 3274 return extent_endpoint_external (extent, 1);
3285 } 3275 }
3286 3276
3287 DEFUN ("extent-length", Fextent_length, Sextent_length, 1, 1, 0 /* 3277 DEFUN ("extent-length", Fextent_length, 1, 1, 0, /*
3288 Return length of EXTENT in characters. 3278 Return length of EXTENT in characters.
3289 */ ) 3279 */
3290 (extent) 3280 (extent))
3291 Lisp_Object extent;
3292 { 3281 {
3293 EXTENT e = decode_extent (extent, DE_MUST_BE_ATTACHED); 3282 EXTENT e = decode_extent (extent, DE_MUST_BE_ATTACHED);
3294 return make_int (extent_endpoint_bufpos (e, 1) 3283 return make_int (extent_endpoint_bufpos (e, 1)
3295 - extent_endpoint_bufpos (e, 0)); 3284 - extent_endpoint_bufpos (e, 0));
3296 } 3285 }
3297 3286
3298 DEFUN ("next-extent", Fnext_extent, Snext_extent, 1, 1, 0 /* 3287 DEFUN ("next-extent", Fnext_extent, 1, 1, 0, /*
3299 Find next extent after EXTENT. 3288 Find next extent after EXTENT.
3300 If EXTENT is a buffer return the first extent in the buffer; likewise 3289 If EXTENT is a buffer return the first extent in the buffer; likewise
3301 for strings. 3290 for strings.
3302 Extents in a buffer are ordered in what is called the \"display\" 3291 Extents in a buffer are ordered in what is called the \"display\"
3303 order, which sorts by increasing start positions and then by *decreasing* 3292 order, which sorts by increasing start positions and then by *decreasing*
3306 `map-extents' instead of this function; it is much more efficient. 3295 `map-extents' instead of this function; it is much more efficient.
3307 The primary use of this function should be to enumerate all the 3296 The primary use of this function should be to enumerate all the
3308 extents in a buffer. 3297 extents in a buffer.
3309 Note: The display order is not necessarily the order that `map-extents' 3298 Note: The display order is not necessarily the order that `map-extents'
3310 processes extents in! 3299 processes extents in!
3311 */ ) 3300 */
3312 (extent) 3301 (extent))
3313 Lisp_Object extent;
3314 { 3302 {
3315 Lisp_Object val; 3303 Lisp_Object val;
3316 EXTENT next; 3304 EXTENT next;
3317 3305
3318 if (EXTENTP (extent)) 3306 if (EXTENTP (extent))
3324 return (Qnil); 3312 return (Qnil);
3325 XSETEXTENT (val, next); 3313 XSETEXTENT (val, next);
3326 return (val); 3314 return (val);
3327 } 3315 }
3328 3316
3329 DEFUN ("previous-extent", Fprevious_extent, Sprevious_extent, 1, 1, 0 /* 3317 DEFUN ("previous-extent", Fprevious_extent, 1, 1, 0, /*
3330 Find last extent before EXTENT. 3318 Find last extent before EXTENT.
3331 If EXTENT is a buffer return the last extent in the buffer; likewise 3319 If EXTENT is a buffer return the last extent in the buffer; likewise
3332 for strings. 3320 for strings.
3333 This function is analogous to `next-extent'. 3321 This function is analogous to `next-extent'.
3334 */ ) 3322 */
3335 (extent) 3323 (extent))
3336 Lisp_Object extent;
3337 { 3324 {
3338 Lisp_Object val; 3325 Lisp_Object val;
3339 EXTENT prev; 3326 EXTENT prev;
3340 3327
3341 if (EXTENTP (extent)) 3328 if (EXTENTP (extent))
3349 return (val); 3336 return (val);
3350 } 3337 }
3351 3338
3352 #ifdef DEBUG_XEMACS 3339 #ifdef DEBUG_XEMACS
3353 3340
3354 DEFUN ("next-e-extent", Fnext_e_extent, Snext_e_extent, 1, 1, 0 /* 3341 DEFUN ("next-e-extent", Fnext_e_extent, 1, 1, 0, /*
3355 Find next extent after EXTENT using the \"e\" order. 3342 Find next extent after EXTENT using the \"e\" order.
3356 If EXTENT is a buffer return the first extent in the buffer; likewise 3343 If EXTENT is a buffer return the first extent in the buffer; likewise
3357 for strings. 3344 for strings.
3358 */ ) 3345 */
3359 (extent) 3346 (extent))
3360 Lisp_Object extent;
3361 { 3347 {
3362 Lisp_Object val; 3348 Lisp_Object val;
3363 EXTENT next; 3349 EXTENT next;
3364 3350
3365 if (EXTENTP (extent)) 3351 if (EXTENTP (extent))
3371 return (Qnil); 3357 return (Qnil);
3372 XSETEXTENT (val, next); 3358 XSETEXTENT (val, next);
3373 return (val); 3359 return (val);
3374 } 3360 }
3375 3361
3376 DEFUN ("previous-e-extent", Fprevious_e_extent, Sprevious_e_extent, 1, 1, 0 /* 3362 DEFUN ("previous-e-extent", Fprevious_e_extent, 1, 1, 0, /*
3377 Find last extent before EXTENT using the \"e\" order. 3363 Find last extent before EXTENT using the \"e\" order.
3378 If EXTENT is a buffer return the last extent in the buffer; likewise 3364 If EXTENT is a buffer return the last extent in the buffer; likewise
3379 for strings. 3365 for strings.
3380 This function is analogous to `next-e-extent'. 3366 This function is analogous to `next-e-extent'.
3381 */ ) 3367 */
3382 (extent) 3368 (extent))
3383 Lisp_Object extent;
3384 { 3369 {
3385 Lisp_Object val; 3370 Lisp_Object val;
3386 EXTENT prev; 3371 EXTENT prev;
3387 3372
3388 if (EXTENTP (extent)) 3373 if (EXTENTP (extent))
3396 return (val); 3381 return (val);
3397 } 3382 }
3398 3383
3399 #endif 3384 #endif
3400 3385
3401 DEFUN ("next-extent-change", Fnext_extent_change, Snext_extent_change, 3386 DEFUN ("next-extent-change", Fnext_extent_change, 1, 2, 0, /*
3402 1, 2, 0 /*
3403 Return the next position after POS where an extent begins or ends. 3387 Return the next position after POS where an extent begins or ends.
3404 If POS is at the end of the buffer or string, POS will be returned; 3388 If POS is at the end of the buffer or string, POS will be returned;
3405 otherwise a position greater than POS will always be returned. 3389 otherwise a position greater than POS will always be returned.
3406 If BUFFER is nil, the current buffer is assumed. 3390 If BUFFER is nil, the current buffer is assumed.
3407 */ ) 3391 */
3408 (pos, object) 3392 (pos, object))
3409 Lisp_Object pos, object;
3410 { 3393 {
3411 Lisp_Object obj = decode_buffer_or_string (object); 3394 Lisp_Object obj = decode_buffer_or_string (object);
3412 Bytind bpos; 3395 Bytind bpos;
3413 3396
3414 bpos = get_buffer_or_string_pos_byte (obj, pos, GB_ALLOW_PAST_ACCESSIBLE); 3397 bpos = get_buffer_or_string_pos_byte (obj, pos, GB_ALLOW_PAST_ACCESSIBLE);
3415 bpos = extent_find_end_of_run (obj, bpos, 1); 3398 bpos = extent_find_end_of_run (obj, bpos, 1);
3416 return make_int (buffer_or_string_bytind_to_bufpos (obj, bpos)); 3399 return make_int (buffer_or_string_bytind_to_bufpos (obj, bpos));
3417 } 3400 }
3418 3401
3419 DEFUN ("previous-extent-change", Fprevious_extent_change, 3402 DEFUN ("previous-extent-change", Fprevious_extent_change, 1, 2, 0, /*
3420 Sprevious_extent_change, 1, 2, 0 /*
3421 Return the last position before POS where an extent begins or ends. 3403 Return the last position before POS where an extent begins or ends.
3422 If POS is at the beginning of the buffer or string, POS will be returned; 3404 If POS is at the beginning of the buffer or string, POS will be returned;
3423 otherwise a position less than POS will always be returned. 3405 otherwise a position less than POS will always be returned.
3424 If OBJECT is nil, the current buffer is assumed. 3406 If OBJECT is nil, the current buffer is assumed.
3425 */ ) 3407 */
3426 (pos, object) 3408 (pos, object))
3427 Lisp_Object pos, object;
3428 { 3409 {
3429 Lisp_Object obj = decode_buffer_or_string (object); 3410 Lisp_Object obj = decode_buffer_or_string (object);
3430 Bytind bpos; 3411 Bytind bpos;
3431 3412
3432 bpos = get_buffer_or_string_pos_byte (obj, pos, GB_ALLOW_PAST_ACCESSIBLE); 3413 bpos = get_buffer_or_string_pos_byte (obj, pos, GB_ALLOW_PAST_ACCESSIBLE);
3437 3418
3438 /************************************************************************/ 3419 /************************************************************************/
3439 /* parent and children stuff */ 3420 /* parent and children stuff */
3440 /************************************************************************/ 3421 /************************************************************************/
3441 3422
3442 DEFUN ("extent-parent", Fextent_parent, Sextent_parent, 1, 1, 0 /* 3423 DEFUN ("extent-parent", Fextent_parent, 1, 1, 0, /*
3443 Return the parent (if any) of EXTENT. 3424 Return the parent (if any) of EXTENT.
3444 If an extent has a parent, it derives all its properties from that extent 3425 If an extent has a parent, it derives all its properties from that extent
3445 and has no properties of its own. (The only \"properties\" that the 3426 and has no properties of its own. (The only \"properties\" that the
3446 extent keeps are the buffer/string it refers to and the start and end 3427 extent keeps are the buffer/string it refers to and the start and end
3447 points.) It is possible for an extent's parent to itself have a parent. 3428 points.) It is possible for an extent's parent to itself have a parent.
3448 */ ) 3429 */
3449 (extent) 3430 (extent))
3450 Lisp_Object extent;
3451 /* do I win the prize for the strangest split infinitive? */ 3431 /* do I win the prize for the strangest split infinitive? */
3452 { 3432 {
3453 EXTENT e = decode_extent (extent, 0); 3433 EXTENT e = decode_extent (extent, 0);
3454 return extent_parent (e); 3434 return extent_parent (e);
3455 } 3435 }
3456 3436
3457 DEFUN ("extent-children", Fextent_children, Sextent_children, 1, 1, 0 /* 3437 DEFUN ("extent-children", Fextent_children, 1, 1, 0, /*
3458 Return a list of the children (if any) of EXTENT. 3438 Return a list of the children (if any) of EXTENT.
3459 The children of an extent are all those extents whose parent is that extent. 3439 The children of an extent are all those extents whose parent is that extent.
3460 This function does not recursively trace children of children. 3440 This function does not recursively trace children of children.
3461 \(To do that, use `extent-descendants'.) 3441 \(To do that, use `extent-descendants'.)
3462 */ ) 3442 */
3463 (extent) 3443 (extent))
3464 Lisp_Object extent;
3465 { 3444 {
3466 EXTENT e = decode_extent (extent, 0); 3445 EXTENT e = decode_extent (extent, 0);
3467 Lisp_Object children = extent_children (e); 3446 Lisp_Object children = extent_children (e);
3468 3447
3469 if (!NILP (children)) 3448 if (!NILP (children))
3499 assert (NILP (memq_no_quit (child, XWEAK_LIST_LIST (children)))); 3478 assert (NILP (memq_no_quit (child, XWEAK_LIST_LIST (children))));
3500 #endif 3479 #endif
3501 XWEAK_LIST_LIST (children) = Fcons (child, XWEAK_LIST_LIST (children)); 3480 XWEAK_LIST_LIST (children) = Fcons (child, XWEAK_LIST_LIST (children));
3502 } 3481 }
3503 3482
3504 DEFUN ("set-extent-parent", Fset_extent_parent, Sset_extent_parent, 2, 2, 0 /* 3483 DEFUN ("set-extent-parent", Fset_extent_parent, 2, 2, 0, /*
3505 Set the parent of EXTENT to PARENT (may be nil). 3484 Set the parent of EXTENT to PARENT (may be nil).
3506 See `extent-parent'. 3485 See `extent-parent'.
3507 */ ) 3486 */
3508 (extent, parent) 3487 (extent, parent))
3509 Lisp_Object extent, parent;
3510 { 3488 {
3511 EXTENT e = decode_extent (extent, 0); 3489 EXTENT e = decode_extent (extent, 0);
3512 Lisp_Object cur_parent = extent_parent (e); 3490 Lisp_Object cur_parent = extent_parent (e);
3513 Lisp_Object rest; 3491 Lisp_Object rest;
3514 3492
3701 Fset_extent_parent (extent_obj, Qnil); 3679 Fset_extent_parent (extent_obj, Qnil);
3702 /* mark the extent as destroyed */ 3680 /* mark the extent as destroyed */
3703 extent_object (extent) = Qt; 3681 extent_object (extent) = Qt;
3704 } 3682 }
3705 3683
3706 DEFUN ("make-extent", Fmake_extent, Smake_extent, 2, 3, 0 /* 3684 DEFUN ("make-extent", Fmake_extent, 2, 3, 0, /*
3707 Make an extent for the range [FROM, TO) in BUFFER-OR-STRING. 3685 Make an extent for the range [FROM, TO) in BUFFER-OR-STRING.
3708 BUFFER-OR-STRING defaults to the current buffer. Insertions at point 3686 BUFFER-OR-STRING defaults to the current buffer. Insertions at point
3709 TO will be outside of the extent; insertions at FROM will be inside the 3687 TO will be outside of the extent; insertions at FROM will be inside the
3710 extent, causing the extent to grow. (This is the same way that markers 3688 extent, causing the extent to grow. (This is the same way that markers
3711 behave.) You can change the behavior of insertions at the endpoints 3689 behave.) You can change the behavior of insertions at the endpoints
3712 using `set-extent-property'. The extent is initially detached if both 3690 using `set-extent-property'. The extent is initially detached if both
3713 FROM and TO are nil, and in this case BUFFER-OR-STRING defaults to nil, 3691 FROM and TO are nil, and in this case BUFFER-OR-STRING defaults to nil,
3714 meaning the extent is in no buffer and no string. 3692 meaning the extent is in no buffer and no string.
3715 */ ) 3693 */
3716 (from, to, buffer_or_string) 3694 (from, to, buffer_or_string))
3717 Lisp_Object from, to, buffer_or_string;
3718 { 3695 {
3719 Lisp_Object extent_obj = Qnil; 3696 Lisp_Object extent_obj = Qnil;
3720 Lisp_Object obj; 3697 Lisp_Object obj;
3721 3698
3722 obj = decode_buffer_or_string (buffer_or_string); 3699 obj = decode_buffer_or_string (buffer_or_string);
3735 XSETEXTENT (extent_obj, make_extent_internal (obj, start, end)); 3712 XSETEXTENT (extent_obj, make_extent_internal (obj, start, end));
3736 } 3713 }
3737 return extent_obj; 3714 return extent_obj;
3738 } 3715 }
3739 3716
3740 DEFUN ("copy-extent", Fcopy_extent, Scopy_extent, 1, 2, 0 /* 3717 DEFUN ("copy-extent", Fcopy_extent, 1, 2, 0, /*
3741 Make a copy of EXTENT. It is initially detached. 3718 Make a copy of EXTENT. It is initially detached.
3742 Optional argument BUFFER-OR-STRING defaults to EXTENT's buffer or string. 3719 Optional argument BUFFER-OR-STRING defaults to EXTENT's buffer or string.
3743 */ ) 3720 */
3744 (extent, buffer_or_string) 3721 (extent, buffer_or_string))
3745 Lisp_Object extent, buffer_or_string;
3746 { 3722 {
3747 EXTENT ext = decode_extent (extent, 0); 3723 EXTENT ext = decode_extent (extent, 0);
3748 3724
3749 if (NILP (buffer_or_string)) 3725 if (NILP (buffer_or_string))
3750 buffer_or_string = extent_object (ext); 3726 buffer_or_string = extent_object (ext);
3753 3729
3754 XSETEXTENT (extent, copy_extent (ext, -1, -1, buffer_or_string)); 3730 XSETEXTENT (extent, copy_extent (ext, -1, -1, buffer_or_string));
3755 return extent; 3731 return extent;
3756 } 3732 }
3757 3733
3758 DEFUN ("delete-extent", Fdelete_extent, Sdelete_extent, 1, 1, 0 /* 3734 DEFUN ("delete-extent", Fdelete_extent, 1, 1, 0, /*
3759 Remove EXTENT from its buffer and destroy it. 3735 Remove EXTENT from its buffer and destroy it.
3760 This does not modify the buffer's text, only its display properties. 3736 This does not modify the buffer's text, only its display properties.
3761 The extent cannot be used thereafter. 3737 The extent cannot be used thereafter.
3762 */ ) 3738 */
3763 (extent) 3739 (extent))
3764 Lisp_Object extent;
3765 { 3740 {
3766 EXTENT ext; 3741 EXTENT ext;
3767 3742
3768 /* We do not call decode_extent() here because already-destroyed 3743 /* We do not call decode_extent() here because already-destroyed
3769 extents are OK. */ 3744 extents are OK. */
3774 return Qnil; 3749 return Qnil;
3775 destroy_extent (ext); 3750 destroy_extent (ext);
3776 return Qnil; 3751 return Qnil;
3777 } 3752 }
3778 3753
3779 DEFUN ("detach-extent", Fdetach_extent, Sdetach_extent, 1, 1, 0 /* 3754 DEFUN ("detach-extent", Fdetach_extent, 1, 1, 0, /*
3780 Remove EXTENT from its buffer in such a way that it can be re-inserted. 3755 Remove EXTENT from its buffer in such a way that it can be re-inserted.
3781 An extent is also detached when all of its characters are all killed by a 3756 An extent is also detached when all of its characters are all killed by a
3782 deletion, unless its `detachable' property has been unset. 3757 deletion, unless its `detachable' property has been unset.
3783 3758
3784 Extents which have the `duplicable' attribute are tracked by the undo 3759 Extents which have the `duplicable' attribute are tracked by the undo
3786 as is attachment via `insert-extent' and string insertion. Extent motion, 3761 as is attachment via `insert-extent' and string insertion. Extent motion,
3787 face changes, and attachment via `make-extent' and `set-extent-endpoints' 3762 face changes, and attachment via `make-extent' and `set-extent-endpoints'
3788 are not recorded. This means that extent changes which are to be undo-able 3763 are not recorded. This means that extent changes which are to be undo-able
3789 must be performed by character editing, or by insertion and detachment of 3764 must be performed by character editing, or by insertion and detachment of
3790 duplicable extents. 3765 duplicable extents.
3791 */ ) 3766 */
3792 (extent) 3767 (extent))
3793 Lisp_Object extent;
3794 { 3768 {
3795 EXTENT ext = decode_extent (extent, 0); 3769 EXTENT ext = decode_extent (extent, 0);
3796 3770
3797 if (extent_detached_p (ext)) 3771 if (extent_detached_p (ext))
3798 return extent; 3772 return extent;
3801 extent_detach (ext); 3775 extent_detach (ext);
3802 3776
3803 return extent; 3777 return extent;
3804 } 3778 }
3805 3779
3806 DEFUN ("set-extent-endpoints", Fset_extent_endpoints, Sset_extent_endpoints, 3780 DEFUN ("set-extent-endpoints", Fset_extent_endpoints, 3, 4, 0, /*
3807 3, 4, 0 /*
3808 Set the endpoints of EXTENT to START, END. 3781 Set the endpoints of EXTENT to START, END.
3809 If START and END are null, call detach-extent on EXTENT. 3782 If START and END are null, call detach-extent on EXTENT.
3810 BUFFER-OR-STRING specifies the new buffer or string that the extent should 3783 BUFFER-OR-STRING specifies the new buffer or string that the extent should
3811 be in, and defaults to EXTENT's buffer or string. (If nil, and EXTENT 3784 be in, and defaults to EXTENT's buffer or string. (If nil, and EXTENT
3812 is in no buffer and no string, it defaults to the current buffer.) 3785 is in no buffer and no string, it defaults to the current buffer.)
3813 See documentation on `detach-extent' for a discussion of undo recording. 3786 See documentation on `detach-extent' for a discussion of undo recording.
3814 */ ) 3787 */
3815 (extent, start, end, buffer_or_string) 3788 (extent, start, end, buffer_or_string))
3816 Lisp_Object extent, start, end, buffer_or_string;
3817 { 3789 {
3818 EXTENT ext; 3790 EXTENT ext;
3819 Bytind s, e; 3791 Bytind s, e;
3820 3792
3821 ext = decode_extent (extent, 0); 3793 ext = decode_extent (extent, 0);
3898 flags = XCDR (flags); 3870 flags = XCDR (flags);
3899 } 3871 }
3900 return retval; 3872 return retval;
3901 } 3873 }
3902 3874
3903 DEFUN ("extent-in-region-p", Fextent_in_region_p, Sextent_in_region_p, 3875 DEFUN ("extent-in-region-p", Fextent_in_region_p, 1, 4, 0, /*
3904 1, 4, 0 /*
3905 Return whether EXTENT overlaps a specified region. 3876 Return whether EXTENT overlaps a specified region.
3906 This is equivalent to whether `map-extents' would visit EXTENT when called 3877 This is equivalent to whether `map-extents' would visit EXTENT when called
3907 with these args. 3878 with these args.
3908 */ ) 3879 */
3909 (extent, from, to, flags) 3880 (extent, from, to, flags))
3910 Lisp_Object extent, from, to, flags;
3911 { 3881 {
3912 EXTENT ext; 3882 EXTENT ext;
3913 Lisp_Object obj; 3883 Lisp_Object obj;
3914 Bytind start, end; 3884 Bytind start, end;
3915 3885
3959 return 0; 3929 return 0;
3960 else 3930 else
3961 return 1; 3931 return 1;
3962 } 3932 }
3963 3933
3964 DEFUN ("map-extents", Fmap_extents, Smap_extents, 1, 8, 0 /* 3934 DEFUN ("map-extents", Fmap_extents, 1, 8, 0, /*
3965 Map FUNCTION over the extents which overlap a region in OBJECT. 3935 Map FUNCTION over the extents which overlap a region in OBJECT.
3966 OBJECT is normally a buffer or string but could be an extent (see below). 3936 OBJECT is normally a buffer or string but could be an extent (see below).
3967 The region is normally bounded by [FROM, TO) (i.e. the beginning of the 3937 The region is normally bounded by [FROM, TO) (i.e. the beginning of the
3968 region is closed and the end of the region is open), but this can be 3938 region is closed and the end of the region is open), but this can be
3969 changed with the FLAGS argument (see below for a complete discussion). 3939 changed with the FLAGS argument (see below for a complete discussion).
4031 `start-and-end-in-region', and `start-or-end-in-region' may be specified. 4001 `start-and-end-in-region', and `start-or-end-in-region' may be specified.
4032 4002
4033 If optional arg PROPERTY is non-nil, only extents with that property set 4003 If optional arg PROPERTY is non-nil, only extents with that property set
4034 on them will be visited. If optional arg VALUE is non-nil, only extents 4004 on them will be visited. If optional arg VALUE is non-nil, only extents
4035 whose value for that property is `eq' to VALUE will be visited. 4005 whose value for that property is `eq' to VALUE will be visited.
4036 */ ) 4006 */
4037 (function, object, from, to, maparg, flags, property, value) 4007 (function, object, from, to, maparg, flags, property, value))
4038 Lisp_Object function, object, from, to, maparg, flags, property, value;
4039 { 4008 {
4040 /* This function can GC */ 4009 /* This function can GC */
4041 struct slow_map_extents_arg closure; 4010 struct slow_map_extents_arg closure;
4042 unsigned int me_flags; 4011 unsigned int me_flags;
4043 Bytind start, end; 4012 Bytind start, end;
4164 return 0; 4133 return 0;
4165 else 4134 else
4166 return 1; 4135 return 1;
4167 } 4136 }
4168 4137
4169 DEFUN ("map-extent-children", Fmap_extent_children, Smap_extent_children, 4138 DEFUN ("map-extent-children", Fmap_extent_children, 1, 8, 0, /*
4170 1, 8, 0 /*
4171 Map FUNCTION over the extents in the region from FROM to TO. 4139 Map FUNCTION over the extents in the region from FROM to TO.
4172 FUNCTION is called with arguments (extent, MAPARG). See `map-extents' 4140 FUNCTION is called with arguments (extent, MAPARG). See `map-extents'
4173 for a full discussion of the arguments FROM, TO, and FLAGS. 4141 for a full discussion of the arguments FROM, TO, and FLAGS.
4174 4142
4175 The arguments are the same as for `map-extents', but this function differs 4143 The arguments are the same as for `map-extents', but this function differs
4178 inside E but end before E's end. 4146 inside E but end before E's end.
4179 4147
4180 Thus, this function may be used to walk a tree of extents in a buffer: 4148 Thus, this function may be used to walk a tree of extents in a buffer:
4181 (defun walk-extents (buffer &optional ignore) 4149 (defun walk-extents (buffer &optional ignore)
4182 (map-extent-children 'walk-extents buffer)) 4150 (map-extent-children 'walk-extents buffer))
4183 */ ) 4151 */
4184 (function, object, from, to, maparg, flags, property, value) 4152 (function, object, from, to, maparg, flags, property, value))
4185 Lisp_Object function, object, from, to, maparg, flags, property, value;
4186 { 4153 {
4187 /* This function can GC */ 4154 /* This function can GC */
4188 struct slow_map_extent_children_arg closure; 4155 struct slow_map_extent_children_arg closure;
4189 unsigned int me_flags; 4156 unsigned int me_flags;
4190 Bytind start, end; 4157 Bytind start, end;
4366 4333
4367 XSETEXTENT (extent_obj, closure.best_match); 4334 XSETEXTENT (extent_obj, closure.best_match);
4368 return extent_obj; 4335 return extent_obj;
4369 } 4336 }
4370 4337
4371 DEFUN ("extent-at", Fextent_at, Sextent_at, 1, 5, 0 /* 4338 DEFUN ("extent-at", Fextent_at, 1, 5, 0, /*
4372 Find \"smallest\" extent at POS in OBJECT having PROPERTY set. 4339 Find \"smallest\" extent at POS in OBJECT having PROPERTY set.
4373 Normally, an extent is \"at\" POS if it overlaps the region (POS, POS+1); 4340 Normally, an extent is \"at\" POS if it overlaps the region (POS, POS+1);
4374 i.e. if it covers the character after POS. (However, see the definition 4341 i.e. if it covers the character after POS. (However, see the definition
4375 of AT-FLAG.) \"Smallest\" means the extent that comes last in the display 4342 of AT-FLAG.) \"Smallest\" means the extent that comes last in the display
4376 order; this normally means the extent whose start position is closest to 4343 order; this normally means the extent whose start position is closest to
4393 This includes all zero-length extents at POS. 4360 This includes all zero-length extents at POS.
4394 4361
4395 Note that in all cases, the start-openness and end-openness of the extents 4362 Note that in all cases, the start-openness and end-openness of the extents
4396 considered is ignored. If you want to pay attention to those properties, 4363 considered is ignored. If you want to pay attention to those properties,
4397 you should use `map-extents', which gives you more control. 4364 you should use `map-extents', which gives you more control.
4398 */ ) 4365 */
4399 (pos, object, property, before, at_flag) 4366 (pos, object, property, before, at_flag))
4400 Lisp_Object pos, object, property, before, at_flag;
4401 { 4367 {
4402 Bytind position; 4368 Bytind position;
4403 EXTENT before_extent; 4369 EXTENT before_extent;
4404 enum extent_at_flag fl; 4370 enum extent_at_flag fl;
4405 4371
4774 value = (external_of_internal_memoized_face 4740 value = (external_of_internal_memoized_face
4775 (memoize_extent_face_internal (value))); 4741 (memoize_extent_face_internal (value)));
4776 return value; 4742 return value;
4777 } 4743 }
4778 4744
4779 DEFUN ("extent-face", Fextent_face, Sextent_face, 1, 1, 0 /* 4745 DEFUN ("extent-face", Fextent_face, 1, 1, 0, /*
4780 Return the name of the face in which EXTENT is displayed, or nil 4746 Return the name of the face in which EXTENT is displayed, or nil
4781 if the extent's face is unspecified. This might also return a list 4747 if the extent's face is unspecified. This might also return a list
4782 of face names. 4748 of face names.
4783 */ ) 4749 */
4784 (extent) 4750 (extent))
4785 Lisp_Object extent;
4786 { 4751 {
4787 Lisp_Object face; 4752 Lisp_Object face;
4788 4753
4789 CHECK_EXTENT (extent); 4754 CHECK_EXTENT (extent);
4790 face = extent_face (XEXTENT (extent)); 4755 face = extent_face (XEXTENT (extent));
4791 4756
4792 return external_of_internal_memoized_face (face); 4757 return external_of_internal_memoized_face (face);
4793 } 4758 }
4794 4759
4795 DEFUN ("set-extent-face", Fset_extent_face, Sset_extent_face, 2, 2, 0 /* 4760 DEFUN ("set-extent-face", Fset_extent_face, 2, 2, 0, /*
4796 Make the given EXTENT have the graphic attributes specified by FACE. 4761 Make the given EXTENT have the graphic attributes specified by FACE.
4797 FACE can also be a list of faces, and all faces listed will apply, 4762 FACE can also be a list of faces, and all faces listed will apply,
4798 with faces earlier in the list taking priority over those later in the 4763 with faces earlier in the list taking priority over those later in the
4799 list. 4764 list.
4800 */ ) 4765 */
4801 (extent, face) 4766 (extent, face))
4802 Lisp_Object extent, face;
4803 { 4767 {
4804 EXTENT e; 4768 EXTENT e;
4805 Lisp_Object orig_face = face; 4769 Lisp_Object orig_face = face;
4806 4770
4807 CHECK_EXTENT (extent); 4771 CHECK_EXTENT (extent);
4816 4780
4817 return orig_face; 4781 return orig_face;
4818 } 4782 }
4819 4783
4820 4784
4821 DEFUN ("extent-mouse-face", Fextent_mouse_face, Sextent_mouse_face, 1, 1, 0 /* 4785 DEFUN ("extent-mouse-face", Fextent_mouse_face, 1, 1, 0, /*
4822 Return the face used to highlight EXTENT when the mouse passes over it. 4786 Return the face used to highlight EXTENT when the mouse passes over it.
4823 The return value will be a face name, a list of face names, or nil 4787 The return value will be a face name, a list of face names, or nil
4824 if the extent's mouse face is unspecified. 4788 if the extent's mouse face is unspecified.
4825 */ ) 4789 */
4826 (extent) 4790 (extent))
4827 Lisp_Object extent;
4828 { 4791 {
4829 Lisp_Object face; 4792 Lisp_Object face;
4830 4793
4831 CHECK_EXTENT (extent); 4794 CHECK_EXTENT (extent);
4832 face = extent_mouse_face (XEXTENT (extent)); 4795 face = extent_mouse_face (XEXTENT (extent));
4833 4796
4834 return external_of_internal_memoized_face (face); 4797 return external_of_internal_memoized_face (face);
4835 } 4798 }
4836 4799
4837 DEFUN ("set-extent-mouse-face", Fset_extent_mouse_face, Sset_extent_mouse_face, 4800 DEFUN ("set-extent-mouse-face", Fset_extent_mouse_face, 2, 2, 0, /*
4838 2, 2, 0 /*
4839 Set the face used to highlight EXTENT when the mouse passes over it. 4801 Set the face used to highlight EXTENT when the mouse passes over it.
4840 FACE can also be a list of faces, and all faces listed will apply, 4802 FACE can also be a list of faces, and all faces listed will apply,
4841 with faces earlier in the list taking priority over those later in the 4803 with faces earlier in the list taking priority over those later in the
4842 list. 4804 list.
4843 */ ) 4805 */
4844 (extent, face) 4806 (extent, face))
4845 Lisp_Object extent, face;
4846 { 4807 {
4847 EXTENT e; 4808 EXTENT e;
4848 Lisp_Object orig_face = face; 4809 Lisp_Object orig_face = face;
4849 4810
4850 CHECK_EXTENT (extent); 4811 CHECK_EXTENT (extent);
4932 4893
4933 set_extent_glyph (extent, glyph, endp, layout); 4894 set_extent_glyph (extent, glyph, endp, layout);
4934 return glyph; 4895 return glyph;
4935 } 4896 }
4936 4897
4937 DEFUN ("set-extent-begin-glyph", Fset_extent_begin_glyph, 4898 DEFUN ("set-extent-begin-glyph", Fset_extent_begin_glyph, 2, 3, 0, /*
4938 Sset_extent_begin_glyph, 2, 3, 0 /*
4939 Display a bitmap, subwindow or string at the beginning of EXTENT. 4899 Display a bitmap, subwindow or string at the beginning of EXTENT.
4940 BEGIN-GLYPH must be a glyph object. The layout policy defaults to `text'. 4900 BEGIN-GLYPH must be a glyph object. The layout policy defaults to `text'.
4941 */ ) 4901 */
4942 (extent, begin_glyph, layout) 4902 (extent, begin_glyph, layout))
4943 Lisp_Object extent, begin_glyph, layout;
4944 { 4903 {
4945 return set_extent_glyph_1 (extent, begin_glyph, 0, layout); 4904 return set_extent_glyph_1 (extent, begin_glyph, 0, layout);
4946 } 4905 }
4947 4906
4948 DEFUN ("set-extent-end-glyph", Fset_extent_end_glyph, 4907 DEFUN ("set-extent-end-glyph", Fset_extent_end_glyph, 2, 3, 0, /*
4949 Sset_extent_end_glyph, 2, 3, 0 /*
4950 Display a bitmap, subwindow or string at the end of the EXTENT. 4908 Display a bitmap, subwindow or string at the end of the EXTENT.
4951 END-GLYPH must be a glyph object. The layout policy defaults to `text'. 4909 END-GLYPH must be a glyph object. The layout policy defaults to `text'.
4952 */ ) 4910 */
4953 (extent, end_glyph, layout) 4911 (extent, end_glyph, layout))
4954 Lisp_Object extent, end_glyph, layout;
4955 { 4912 {
4956 return set_extent_glyph_1 (extent, end_glyph, 1, layout); 4913 return set_extent_glyph_1 (extent, end_glyph, 1, layout);
4957 } 4914 }
4958 4915
4959 DEFUN ("extent-begin-glyph", Fextent_begin_glyph, Sextent_begin_glyph, 4916 DEFUN ("extent-begin-glyph", Fextent_begin_glyph, 1, 1, 0, /*
4960 1, 1, 0 /*
4961 Return the glyph object displayed at the beginning of EXTENT. 4917 Return the glyph object displayed at the beginning of EXTENT.
4962 If there is none, nil is returned. 4918 If there is none, nil is returned.
4963 */ ) 4919 */
4964 (extent_obj) 4920 (extent_obj))
4965 Lisp_Object extent_obj;
4966 { 4921 {
4967 return extent_begin_glyph (decode_extent (extent_obj, 0)); 4922 return extent_begin_glyph (decode_extent (extent_obj, 0));
4968 } 4923 }
4969 4924
4970 DEFUN ("extent-end-glyph", Fextent_end_glyph, Sextent_end_glyph, 1, 1, 0 /* 4925 DEFUN ("extent-end-glyph", Fextent_end_glyph, 1, 1, 0, /*
4971 Return the glyph object displayed at the end of EXTENT. 4926 Return the glyph object displayed at the end of EXTENT.
4972 If there is none, nil is returned. 4927 If there is none, nil is returned.
4973 */ ) 4928 */
4974 (extent_obj) 4929 (extent_obj))
4975 Lisp_Object extent_obj;
4976 { 4930 {
4977 return extent_end_glyph (decode_extent (extent_obj, 0)); 4931 return extent_end_glyph (decode_extent (extent_obj, 0));
4978 } 4932 }
4979 4933
4980 DEFUN ("set-extent-begin-glyph-layout", Fset_extent_begin_glyph_layout, 4934 DEFUN ("set-extent-begin-glyph-layout", Fset_extent_begin_glyph_layout, 2, 2, 0, /*
4981 Sset_extent_begin_glyph_layout, 2, 2, 0 /*
4982 Set the layout policy of the given extent's begin glyph. 4935 Set the layout policy of the given extent's begin glyph.
4983 Access this using the `extent-begin-glyph-layout' function. 4936 Access this using the `extent-begin-glyph-layout' function.
4984 */ ) 4937 */
4985 (extent, layout) 4938 (extent, layout))
4986 Lisp_Object extent, layout;
4987 { 4939 {
4988 EXTENT e = decode_extent (extent, 0); 4940 EXTENT e = decode_extent (extent, 0);
4989 e = extent_ancestor (e); 4941 e = extent_ancestor (e);
4990 extent_begin_glyph_layout (e) = symbol_to_glyph_layout (layout); 4942 extent_begin_glyph_layout (e) = symbol_to_glyph_layout (layout);
4991 extent_maybe_changed_for_redisplay (e, 1); 4943 extent_maybe_changed_for_redisplay (e, 1);
4992 return layout; 4944 return layout;
4993 } 4945 }
4994 4946
4995 DEFUN ("set-extent-end-glyph-layout", Fset_extent_end_glyph_layout, 4947 DEFUN ("set-extent-end-glyph-layout", Fset_extent_end_glyph_layout, 2, 2, 0, /*
4996 Sset_extent_end_glyph_layout, 2, 2, 0 /*
4997 Set the layout policy of the given extent's end glyph. 4948 Set the layout policy of the given extent's end glyph.
4998 Access this using the `extent-end-glyph-layout' function. 4949 Access this using the `extent-end-glyph-layout' function.
4999 */ ) 4950 */
5000 (extent, layout) 4951 (extent, layout))
5001 Lisp_Object extent, layout;
5002 { 4952 {
5003 EXTENT e = decode_extent (extent, 0); 4953 EXTENT e = decode_extent (extent, 0);
5004 e = extent_ancestor (e); 4954 e = extent_ancestor (e);
5005 extent_end_glyph_layout (e) = symbol_to_glyph_layout (layout); 4955 extent_end_glyph_layout (e) = symbol_to_glyph_layout (layout);
5006 extent_maybe_changed_for_redisplay (e, 1); 4956 extent_maybe_changed_for_redisplay (e, 1);
5007 return layout; 4957 return layout;
5008 } 4958 }
5009 4959
5010 DEFUN ("extent-begin-glyph-layout", Fextent_begin_glyph_layout, 4960 DEFUN ("extent-begin-glyph-layout", Fextent_begin_glyph_layout, 1, 1, 0, /*
5011 Sextent_begin_glyph_layout, 1, 1, 0 /*
5012 Return the layout policy associated with the given extent's begin glyph. 4961 Return the layout policy associated with the given extent's begin glyph.
5013 Set this using the `set-extent-begin-glyph-layout' function. 4962 Set this using the `set-extent-begin-glyph-layout' function.
5014 */ ) 4963 */
5015 (extent) 4964 (extent))
5016 Lisp_Object extent;
5017 { 4965 {
5018 EXTENT e = decode_extent (extent, 0); 4966 EXTENT e = decode_extent (extent, 0);
5019 return glyph_layout_to_symbol (extent_begin_glyph_layout (e)); 4967 return glyph_layout_to_symbol (extent_begin_glyph_layout (e));
5020 } 4968 }
5021 4969
5022 DEFUN ("extent-end-glyph-layout", Fextent_end_glyph_layout, 4970 DEFUN ("extent-end-glyph-layout", Fextent_end_glyph_layout, 1, 1, 0, /*
5023 Sextent_end_glyph_layout, 1, 1, 0 /*
5024 Return the layout policy associated with the given extent's end glyph. 4971 Return the layout policy associated with the given extent's end glyph.
5025 Set this using the `set-extent-end-glyph-layout' function. 4972 Set this using the `set-extent-end-glyph-layout' function.
5026 */ ) 4973 */
5027 (extent) 4974 (extent))
5028 Lisp_Object extent;
5029 { 4975 {
5030 EXTENT e = decode_extent (extent, 0); 4976 EXTENT e = decode_extent (extent, 0);
5031 return glyph_layout_to_symbol (extent_end_glyph_layout (e)); 4977 return glyph_layout_to_symbol (extent_end_glyph_layout (e));
5032 } 4978 }
5033 4979
5034 DEFUN ("set-extent-priority", Fset_extent_priority, Sset_extent_priority, 4980 DEFUN ("set-extent-priority", Fset_extent_priority, 2, 2, 0, /*
5035 2, 2, 0 /*
5036 Changes the display priority of EXTENT. 4981 Changes the display priority of EXTENT.
5037 When the extent attributes are being merged for display, the priority 4982 When the extent attributes are being merged for display, the priority
5038 is used to determine which extent takes precedence in the event of a 4983 is used to determine which extent takes precedence in the event of a
5039 conflict (two extents whose faces both specify font, for example: the 4984 conflict (two extents whose faces both specify font, for example: the
5040 font of the extent with the higher priority will be used). 4985 font of the extent with the higher priority will be used).
5041 Extents are created with priority 0; priorities may be negative. 4986 Extents are created with priority 0; priorities may be negative.
5042 */ ) 4987 */
5043 (extent, pri) 4988 (extent, pri))
5044 Lisp_Object extent, pri;
5045 { 4989 {
5046 EXTENT e = decode_extent (extent, 0); 4990 EXTENT e = decode_extent (extent, 0);
5047 4991
5048 CHECK_INT (pri); 4992 CHECK_INT (pri);
5049 e = extent_ancestor (e); 4993 e = extent_ancestor (e);
5050 set_extent_priority (e, XINT (pri)); 4994 set_extent_priority (e, XINT (pri));
5051 extent_maybe_changed_for_redisplay (e, 1); 4995 extent_maybe_changed_for_redisplay (e, 1);
5052 return pri; 4996 return pri;
5053 } 4997 }
5054 4998
5055 DEFUN ("extent-priority", Fextent_priority, Sextent_priority, 1, 1, 0 /* 4999 DEFUN ("extent-priority", Fextent_priority, 1, 1, 0, /*
5056 Return the display priority of EXTENT; see `set-extent-priority'. 5000 Return the display priority of EXTENT; see `set-extent-priority'.
5057 */ ) 5001 */
5058 (extent) 5002 (extent))
5059 Lisp_Object extent;
5060 { 5003 {
5061 EXTENT e = decode_extent (extent, 0); 5004 EXTENT e = decode_extent (extent, 0);
5062 return make_int (extent_priority (e)); 5005 return make_int (extent_priority (e));
5063 } 5006 }
5064 5007
5065 DEFUN ("set-extent-property", Fset_extent_property, Sset_extent_property, 5008 DEFUN ("set-extent-property", Fset_extent_property, 3, 3, 0, /*
5066 3, 3, 0 /*
5067 Change a property of an extent. 5009 Change a property of an extent.
5068 PROPERTY may be any symbol; the value stored may be accessed with 5010 PROPERTY may be any symbol; the value stored may be accessed with
5069 the `extent-property' function. 5011 the `extent-property' function.
5070 The following symbols have predefined meanings: 5012 The following symbols have predefined meanings:
5071 5013
5132 from the string using `concat' or `substring'. 5074 from the string using `concat' or `substring'.
5133 When `insert' or a similar function inserts the 5075 When `insert' or a similar function inserts the
5134 string into a buffer, the extents are copied back 5076 string into a buffer, the extents are copied back
5135 into the buffer. 5077 into the buffer.
5136 5078
5137 replicating Meaningful only in conjunction with `duplicable'. 5079 unique Meaningful only in conjunction with `duplicable'.
5138 If this flag is set, extents that are copied from 5080 When this is set, there may be only one instance
5139 buffers into strings are made children of the 5081 of this extent attached at a time: if it is copied
5140 original extent. When the string is pasted back 5082 to the kill ring and then yanked, the extent is
5141 into a buffer, the same extent (i.e. the `eq' 5083 not copied. If, however, it is killed (removed
5142 predicate applies) that was originally in the 5084 from the buffer) and then yanked, it will be
5143 buffer will be used if possible -- i.e. if the 5085 re-attached at the new position.
5144 extent is detached or the paste location abuts or
5145 overlaps the extent. This behavior is compatible
5146 with the old "extent replica" behavior and was
5147 apparently required by Energize.
5148
5149 unique Meaningful only in conjunction with `duplicable'
5150 and `replicating'. When this is set, there may be
5151 only one instance of this extent attached at a
5152 time: if it is copied to the kill ring and then
5153 yanked, the extent is not copied. If, however, it
5154 is killed (removed from the buffer) and then
5155 yanked, it will be re-attached at the new
5156 position.
5157 5086
5158 invisible If the value is non-nil, text under this extent 5087 invisible If the value is non-nil, text under this extent
5159 may be treated as not present for the purpose of 5088 may be treated as not present for the purpose of
5160 redisplay, or may be displayed using an ellipsis 5089 redisplay, or may be displayed using an ellipsis
5161 or other marker; see `buffer-invisibility-spec' 5090 or other marker; see `buffer-invisibility-spec'
5207 5136
5208 begin-glyph-layout The layout policy (one of `text', `whitespace', 5137 begin-glyph-layout The layout policy (one of `text', `whitespace',
5209 `inside-margin', or `outside-margin') of the extent's 5138 `inside-margin', or `outside-margin') of the extent's
5210 begin glyph. 5139 begin glyph.
5211 5140
5212 end-glyph-layout The layout policy of the extent's end glyph. 5141 end-glyph-layout The layout policy of the extent's end glyph. */
5213 */ ) 5142 (extent, property, value))
5214 (extent, property, value)
5215 Lisp_Object extent, property, value;
5216 { 5143 {
5217 /* This function can GC if property is `keymap' */ 5144 /* This function can GC if property is `keymap' */
5218 EXTENT e = decode_extent (extent, 0); 5145 EXTENT e = decode_extent (extent, 0);
5219 CHECK_SYMBOL (property); 5146 CHECK_SYMBOL (property);
5220 5147
5222 set_extent_read_only (e, value); 5149 set_extent_read_only (e, value);
5223 else if (EQ (property, Qunique)) 5150 else if (EQ (property, Qunique))
5224 extent_unique_p (e) = !NILP (value); 5151 extent_unique_p (e) = !NILP (value);
5225 else if (EQ (property, Qduplicable)) 5152 else if (EQ (property, Qduplicable))
5226 extent_duplicable_p (e) = !NILP (value); 5153 extent_duplicable_p (e) = !NILP (value);
5227 else if (EQ (property, Qreplicating))
5228 extent_replicating_p (e) = !NILP (value);
5229 else if (EQ (property, Qinvisible)) 5154 else if (EQ (property, Qinvisible))
5230 set_extent_invisible (e, value); 5155 set_extent_invisible (e, value);
5231 else if (EQ (property, Qdetachable)) 5156 else if (EQ (property, Qdetachable))
5232 extent_detachable_p (e) = !NILP (value); 5157 extent_detachable_p (e) = !NILP (value);
5233 5158
5291 } 5216 }
5292 5217
5293 return value; 5218 return value;
5294 } 5219 }
5295 5220
5296 DEFUN ("extent-property", Fextent_property, Sextent_property, 2, 3, 0 /* 5221 DEFUN ("extent-property", Fextent_property, 2, 3, 0, /*
5297 Return EXTENT's value for property PROPERTY. 5222 Return EXTENT's value for property PROPERTY.
5298 See `set-extent-property' for the built-in property names. 5223 See `set-extent-property' for the built-in property names.
5299 */ ) 5224 */
5300 (extent, property, defalt) 5225 (extent, property, defalt))
5301 Lisp_Object extent, property, defalt;
5302 { 5226 {
5303 EXTENT e = decode_extent (extent, 0); 5227 EXTENT e = decode_extent (extent, 0);
5304 CHECK_SYMBOL (property); 5228 CHECK_SYMBOL (property);
5305 5229
5306 if (EQ (property, Qdetached)) 5230 if (EQ (property, Qdetached))
5311 return (extent_normal_field (e, flag) ? Qt : Qnil) 5235 return (extent_normal_field (e, flag) ? Qt : Qnil)
5312 else if (EQ (property, Qstart_open)) RETURN_FLAG (start_open); 5236 else if (EQ (property, Qstart_open)) RETURN_FLAG (start_open);
5313 else if (EQ (property, Qend_open)) RETURN_FLAG (end_open); 5237 else if (EQ (property, Qend_open)) RETURN_FLAG (end_open);
5314 else if (EQ (property, Qunique)) RETURN_FLAG (unique); 5238 else if (EQ (property, Qunique)) RETURN_FLAG (unique);
5315 else if (EQ (property, Qduplicable)) RETURN_FLAG (duplicable); 5239 else if (EQ (property, Qduplicable)) RETURN_FLAG (duplicable);
5316 else if (EQ (property, Qreplicating)) RETURN_FLAG (replicating);
5317 else if (EQ (property, Qdetachable)) RETURN_FLAG (detachable); 5240 else if (EQ (property, Qdetachable)) RETURN_FLAG (detachable);
5318 #undef RETURN_FLAG 5241 #undef RETURN_FLAG
5319 /* Support (but don't document...) the obvious antonyms. */ 5242 /* Support (but don't document...) the obvious antonyms. */
5320 else if (EQ (property, Qstart_closed)) 5243 else if (EQ (property, Qstart_closed))
5321 return (extent_start_open_p (e) ? Qnil : Qt); 5244 return (extent_start_open_p (e) ? Qnil : Qt);
5356 return defalt; 5279 return defalt;
5357 return value; 5280 return value;
5358 } 5281 }
5359 } 5282 }
5360 5283
5361 DEFUN ("extent-properties", Fextent_properties, Sextent_properties, 1, 1, 0 /* 5284 DEFUN ("extent-properties", Fextent_properties, 1, 1, 0, /*
5362 Return a property list of the attributes of the given extent. 5285 Return a property list of the attributes of the given extent.
5363 Do not modify this list; use `set-extent-property' instead. 5286 Do not modify this list; use `set-extent-property' instead.
5364 */ ) 5287 */
5365 (extent) 5288 (extent))
5366 Lisp_Object extent;
5367 { 5289 {
5368 EXTENT e, anc; 5290 EXTENT e, anc;
5369 Lisp_Object result, face, anc_obj = Qnil; 5291 Lisp_Object result, face, anc_obj = Qnil;
5370 5292
5371 CHECK_EXTENT (extent); 5293 CHECK_EXTENT (extent);
5415 5337
5416 #define CONS_FLAG(flag, sym) if (extent_normal_field (anc, flag)) \ 5338 #define CONS_FLAG(flag, sym) if (extent_normal_field (anc, flag)) \
5417 result = Fcons (sym, Fcons (Qt, result)) 5339 result = Fcons (sym, Fcons (Qt, result))
5418 CONS_FLAG (end_open, Qend_open); 5340 CONS_FLAG (end_open, Qend_open);
5419 CONS_FLAG (start_open, Qstart_open); 5341 CONS_FLAG (start_open, Qstart_open);
5420 CONS_FLAG (replicating, Qreplicating);
5421 CONS_FLAG (detachable, Qdetachable); 5342 CONS_FLAG (detachable, Qdetachable);
5422 CONS_FLAG (duplicable, Qduplicable); 5343 CONS_FLAG (duplicable, Qduplicable);
5423 CONS_FLAG (unique, Qunique); 5344 CONS_FLAG (unique, Qunique);
5424 #undef CONS_FLAG 5345 #undef CONS_FLAG
5425 5346
5460 extent_changed_for_redisplay (XEXTENT (extent_obj), 0); 5381 extent_changed_for_redisplay (XEXTENT (extent_obj), 0);
5461 Vlast_highlighted_extent = extent_obj; 5382 Vlast_highlighted_extent = extent_obj;
5462 } 5383 }
5463 } 5384 }
5464 5385
5465 DEFUN ("force-highlight-extent", Fforce_highlight_extent, 5386 DEFUN ("force-highlight-extent", Fforce_highlight_extent, 1, 2, 0, /*
5466 Sforce_highlight_extent, 1, 2, 0 /*
5467 Highlight or unhighlight the given extent. 5387 Highlight or unhighlight the given extent.
5468 If the second arg is non-nil, it will be highlighted, else dehighlighted. 5388 If the second arg is non-nil, it will be highlighted, else dehighlighted.
5469 This is the same as `highlight-extent', except that it will work even 5389 This is the same as `highlight-extent', except that it will work even
5470 on extents without the `mouse-face' property. 5390 on extents without the `mouse-face' property.
5471 */ ) 5391 */
5472 (extent_obj, highlight_p) 5392 (extent_obj, highlight_p))
5473 Lisp_Object extent_obj, highlight_p;
5474 { 5393 {
5475 if (NILP (extent_obj)) 5394 if (NILP (extent_obj))
5476 highlight_p = Qnil; 5395 highlight_p = Qnil;
5477 else 5396 else
5478 XSETEXTENT (extent_obj, decode_extent (extent_obj, DE_MUST_BE_ATTACHED)); 5397 XSETEXTENT (extent_obj, decode_extent (extent_obj, DE_MUST_BE_ATTACHED));
5479 do_highlight (extent_obj, !NILP (highlight_p)); 5398 do_highlight (extent_obj, !NILP (highlight_p));
5480 return Qnil; 5399 return Qnil;
5481 } 5400 }
5482 5401
5483 DEFUN ("highlight-extent", Fhighlight_extent, Shighlight_extent, 1, 2, 0 /* 5402 DEFUN ("highlight-extent", Fhighlight_extent, 1, 2, 0, /*
5484 Highlight the given extent, if it is highlightable 5403 Highlight the given extent, if it is highlightable
5485 \(that is, if it has the `mouse-face' property). 5404 \(that is, if it has the `mouse-face' property).
5486 If the second arg is non-nil, it will be highlighted, else dehighlighted. 5405 If the second arg is non-nil, it will be highlighted, else dehighlighted.
5487 Highlighted extents are displayed as if they were merged with the face 5406 Highlighted extents are displayed as if they were merged with the face
5488 or faces specified by the `mouse-face' property. 5407 or faces specified by the `mouse-face' property.
5489 */ ) 5408 */
5490 (extent_obj, highlight_p) 5409 (extent_obj, highlight_p))
5491 Lisp_Object extent_obj, highlight_p;
5492 { 5410 {
5493 if (EXTENTP (extent_obj) && NILP (extent_mouse_face (XEXTENT (extent_obj)))) 5411 if (EXTENTP (extent_obj) && NILP (extent_mouse_face (XEXTENT (extent_obj))))
5494 return Qnil; 5412 return Qnil;
5495 else 5413 else
5496 return (Fforce_highlight_extent (extent_obj, highlight_p)); 5414 return (Fforce_highlight_extent (extent_obj, highlight_p));
5614 XSETEXTENT (tmp, copy_extent (extent, new_start, new_end, object)); 5532 XSETEXTENT (tmp, copy_extent (extent, new_start, new_end, object));
5615 return tmp; 5533 return tmp;
5616 } 5534 }
5617 } 5535 }
5618 5536
5619 DEFUN ("insert-extent", Finsert_extent, Sinsert_extent, 1, 5, 0 /* 5537 DEFUN ("insert-extent", Finsert_extent, 1, 5, 0, /*
5620 Insert EXTENT from START to END in BUFFER-OR-STRING. 5538 Insert EXTENT from START to END in BUFFER-OR-STRING.
5621 BUFFER-OR-STRING defaults to the current buffer if omitted. 5539 BUFFER-OR-STRING defaults to the current buffer if omitted.
5622 This operation does not insert any characters, 5540 This operation does not insert any characters,
5623 but otherwise acts as if there were a replicating extent whose 5541 but otherwise acts as if there were a replicating extent whose
5624 parent is EXTENT in some string that was just inserted. 5542 parent is EXTENT in some string that was just inserted.
5625 Returns the newly-inserted extent. 5543 Returns the newly-inserted extent.
5626 The fourth arg, NO-HOOKS, can be used to inhibit the running of the 5544 The fourth arg, NO-HOOKS, can be used to inhibit the running of the
5627 extent's `paste-function' property if it has one. 5545 extent's `paste-function' property if it has one.
5628 See documentation on `detach-extent' for a discussion of undo recording. 5546 See documentation on `detach-extent' for a discussion of undo recording.
5629 */ ) 5547 */
5630 (extent, start, end, no_hooks, buffer_or_string) 5548 (extent, start, end, no_hooks, buffer_or_string))
5631 Lisp_Object extent, start, end, no_hooks, buffer_or_string;
5632 { 5549 {
5633 EXTENT ext = decode_extent (extent, 0); 5550 EXTENT ext = decode_extent (extent, 0);
5634 Lisp_Object copy; 5551 Lisp_Object copy;
5635 Bytind s, e; 5552 Bytind s, e;
5636 5553
5679 if (extent_duplicable_p (extent) && 5596 if (extent_duplicable_p (extent) &&
5680 !run_extent_copy_function (extent, start + closure->from, 5597 !run_extent_copy_function (extent, start + closure->from,
5681 end + closure->from)) 5598 end + closure->from))
5682 return 0; 5599 return 0;
5683 e = copy_extent (extent, start, end, closure->string); 5600 e = copy_extent (extent, start, end, closure->string);
5684 if (extent_replicating_p (extent))
5685 {
5686 Lisp_Object e_obj = Qnil, extent_obj = Qnil;
5687
5688 XSETEXTENT (e_obj, e);
5689 XSETEXTENT (extent_obj, extent);
5690 Fset_extent_parent (e_obj, extent_obj);
5691 }
5692 } 5601 }
5693 5602
5694 return 0; 5603 return 0;
5695 } 5604 }
5696 5605
5754 return 0; 5663 return 0;
5755 5664
5756 if (!extent_duplicable_p (extent)) 5665 if (!extent_duplicable_p (extent))
5757 return 0; 5666 return 0;
5758 5667
5759 if (!extent_replicating_p (extent)) 5668 if (!inside_undo &&
5760 { 5669 !run_extent_paste_function (extent, new_start, new_end,
5761 if (!inside_undo && 5670 closure->buffer))
5762 !run_extent_paste_function (extent, new_start, new_end, 5671 return 0;
5763 closure->buffer)) 5672 copy_extent (extent, new_start, new_end, closure->buffer);
5764 return 0; 5673
5765 copy_extent (extent, new_start, new_end, closure->buffer);
5766 }
5767 else
5768 {
5769 Bytind parstart = 0;
5770 Bytind parend = 0;
5771 Lisp_Object parent_obj = extent_parent (extent);
5772 EXTENT parent;
5773
5774 if (!EXTENTP (parent_obj))
5775 return 0;
5776 parent = XEXTENT (parent_obj);
5777 if (!EXTENT_LIVE_P (parent))
5778 return 0;
5779
5780 if (!extent_detached_p (parent))
5781 {
5782 parstart = extent_endpoint_bytind (parent, 0);
5783 parend = extent_endpoint_bytind (parent, 1);
5784 }
5785
5786 /* #### remove this crap */
5787 #ifdef ENERGIZE
5788 /* Energize extents like toplevel-forms can only be pasted
5789 in the buffer they come from. This should be parametrized
5790 in the generic extent objects. Right now just silently
5791 skip the extents if it's not from the same buffer.
5792 */
5793 if (!EQ (extent_object (parent), closure->buffer)
5794 && energize_extent_data (parent))
5795 return 0;
5796 #endif
5797
5798 /* If this is a `unique' extent, and it is currently attached
5799 somewhere other than here (non-overlapping), then don't copy
5800 it (that's what `unique' means). If however it is detached,
5801 or if we are inserting inside/adjacent to the original
5802 extent, then insert_extent() will simply reattach it, which
5803 is what we want.
5804 */
5805 if (extent_unique_p (parent)
5806 && !extent_detached_p (parent)
5807 && (!EQ (extent_object (parent), closure->buffer)
5808 || parend > new_end
5809 || parstart < new_start))
5810 return 0;
5811
5812 insert_extent (parent, new_start, new_end,
5813 closure->buffer, !inside_undo);
5814 }
5815 return 0; 5674 return 0;
5816 } 5675 }
5817 5676
5818 /* We have just inserted a section of STRING (starting at POS, of 5677 /* We have just inserted a section of STRING (starting at POS, of
5819 length LENGTH) into buffer BUF at OPOINT. Do whatever is necessary 5678 length LENGTH) into buffer BUF at OPOINT. Do whatever is necessary
5862 copy_string_extents_1_mapper (EXTENT extent, void *arg) 5721 copy_string_extents_1_mapper (EXTENT extent, void *arg)
5863 { 5722 {
5864 struct copy_string_extents_1_arg *closure = 5723 struct copy_string_extents_1_arg *closure =
5865 (struct copy_string_extents_1_arg *) arg; 5724 (struct copy_string_extents_1_arg *) arg;
5866 5725
5867 if (extent_replicating_p (extent) &&
5868 EQ (extent_parent (extent), closure->parent_in_question))
5869 {
5870 closure->found_extent = extent;
5871 return 1; /* stop mapping */
5872 }
5873
5874 return 0; 5726 return 0;
5875 } 5727 }
5876 5728
5877 static int 5729 static int
5878 copy_string_extents_mapper (EXTENT extent, void *arg) 5730 copy_string_extents_mapper (EXTENT extent, void *arg)
5892 return 0; 5744 return 0;
5893 5745
5894 new_start = old_start + closure->new_pos - closure->old_pos; 5746 new_start = old_start + closure->new_pos - closure->old_pos;
5895 new_end = old_end + closure->new_pos - closure->old_pos; 5747 new_end = old_end + closure->new_pos - closure->old_pos;
5896 5748
5897 if (extent_replicating_p (extent))
5898 {
5899 struct copy_string_extents_1_arg closure_1;
5900
5901 closure_1.parent_in_question = extent_parent (extent);
5902 closure_1.found_extent = 0;
5903
5904 /* When adding a replicating extent, we need to make sure
5905 that there isn't an existing replicating extent referring
5906 to the same parent extent that abuts or overlaps. If so,
5907 we merge with that extent rather than adding anew. */
5908 map_extents_bytind (closure->old_pos, closure->old_pos + closure->length,
5909 copy_string_extents_1_mapper,
5910 (void *) &closure, closure->new_string, 0,
5911 /* get all extents that abut the region */
5912 ME_END_CLOSED | ME_ALL_EXTENTS_CLOSED);
5913 if (closure_1.found_extent)
5914 {
5915 Bytecount exstart =
5916 extent_endpoint_bytind (closure_1.found_extent, 0);
5917 Bytecount exend =
5918 extent_endpoint_bytind (closure_1.found_extent, 1);
5919 exstart = min (exstart, new_start);
5920 exend = max (exend, new_end);
5921 set_extent_endpoints (closure_1.found_extent, exstart, exend, Qnil);
5922 return 0;
5923 }
5924 }
5925
5926 copy_extent (extent, 5749 copy_extent (extent,
5927 old_start + closure->new_pos - closure->old_pos, 5750 old_start + closure->new_pos - closure->old_pos,
5928 old_end + closure->new_pos - closure->old_pos, 5751 old_end + closure->new_pos - closure->old_pos,
5929 closure->new_string); 5752 closure->new_string);
5930 return 0; 5753 return 0;
6046 val = NILP (val) ? Qt : Qnil; 5869 val = NILP (val) ? Qt : Qnil;
6047 return val; 5870 return val;
6048 } 5871 }
6049 } 5872 }
6050 5873
6051 DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 4, 0 /* 5874 DEFUN ("get-text-property", Fget_text_property, 2, 4, 0, /*
6052 Returns the value of the PROP property at the given position. 5875 Returns the value of the PROP property at the given position.
6053 Optional arg OBJECT specifies the buffer or string to look in, and 5876 Optional arg OBJECT specifies the buffer or string to look in, and
6054 defaults to the current buffer. 5877 defaults to the current buffer.
6055 Optional arg AT-FLAG controls what it means for a property to be \"at\" 5878 Optional arg AT-FLAG controls what it means for a property to be \"at\"
6056 a position, and has the same meaning as in `extent-at'. 5879 a position, and has the same meaning as in `extent-at'.
6057 This examines only those properties added with `put-text-property'. 5880 This examines only those properties added with `put-text-property'.
6058 See also `get-char-property'. 5881 See also `get-char-property'.
6059 */ ) 5882 */
6060 (pos, prop, object, at_flag) 5883 (pos, prop, object, at_flag))
6061 Lisp_Object pos, prop, object, at_flag;
6062 { 5884 {
6063 return get_text_property_1 (pos, prop, object, at_flag, 1); 5885 return get_text_property_1 (pos, prop, object, at_flag, 1);
6064 } 5886 }
6065 5887
6066 DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 4, 0 /* 5888 DEFUN ("get-char-property", Fget_char_property, 2, 4, 0, /*
6067 Returns the value of the PROP property at the given position. 5889 Returns the value of the PROP property at the given position.
6068 Optional arg OBJECT specifies the buffer or string to look in, and 5890 Optional arg OBJECT specifies the buffer or string to look in, and
6069 defaults to the current buffer. 5891 defaults to the current buffer.
6070 Optional arg AT-FLAG controls what it means for a property to be \"at\" 5892 Optional arg AT-FLAG controls what it means for a property to be \"at\"
6071 a position, and has the same meaning as in `extent-at'. 5893 a position, and has the same meaning as in `extent-at'.
6072 This examines properties on all extents. 5894 This examines properties on all extents.
6073 See also `get-text-property'. 5895 See also `get-text-property'.
6074 */ ) 5896 */
6075 (pos, prop, object, at_flag) 5897 (pos, prop, object, at_flag))
6076 Lisp_Object pos, prop, object, at_flag;
6077 { 5898 {
6078 return get_text_property_1 (pos, prop, object, at_flag, 0); 5899 return get_text_property_1 (pos, prop, object, at_flag, 0);
6079 } 5900 }
6080 5901
6081 /* About start/end-open/closed: 5902 /* About start/end-open/closed:
6386 } 6207 }
6387 6208
6388 return closure.changed_p; 6209 return closure.changed_p;
6389 } 6210 }
6390 6211
6391 DEFUN ("put-text-property", Fput_text_property, Sput_text_property, 4, 5, 0 /* 6212 DEFUN ("put-text-property", Fput_text_property, 4, 5, 0, /*
6392 Adds the given property/value to all characters in the specified region. 6213 Adds the given property/value to all characters in the specified region.
6393 The property is conceptually attached to the characters rather than the 6214 The property is conceptually attached to the characters rather than the
6394 region. The properties are copied when the characters are copied/pasted. 6215 region. The properties are copied when the characters are copied/pasted.
6395 Fifth argument OBJECT is the buffer or string containing the text, and 6216 Fifth argument OBJECT is the buffer or string containing the text, and
6396 defaults to the current buffer. 6217 defaults to the current buffer.
6397 */ ) 6218 */
6398 (start, end, prop, value, object) 6219 (start, end, prop, value, object))
6399 Lisp_Object start, end, prop, value, object;
6400 { 6220 {
6401 /* This function can GC */ 6221 /* This function can GC */
6402 Bytind s, e; 6222 Bytind s, e;
6403 6223
6404 object = decode_buffer_or_string (object); 6224 object = decode_buffer_or_string (object);
6406 CHECK_SYMBOL (prop); 6226 CHECK_SYMBOL (prop);
6407 put_text_prop (s, e, object, prop, value, 1); 6227 put_text_prop (s, e, object, prop, value, 1);
6408 return prop; 6228 return prop;
6409 } 6229 }
6410 6230
6411 DEFUN ("put-nonduplicable-text-property", Fput_nonduplicable_text_property, 6231 DEFUN ("put-nonduplicable-text-property",
6412 Sput_nonduplicable_text_property, 4, 5, 0 /* 6232 Fput_nonduplicable_text_property, 4, 5, 0, /*
6413 Adds the given property/value to all characters in the specified region. 6233 Adds the given property/value to all characters in the specified region.
6414 The property is conceptually attached to the characters rather than the 6234 The property is conceptually attached to the characters rather than the
6415 region, however the properties will not be copied when the characters 6235 region, however the properties will not be copied when the characters
6416 are copied. 6236 are copied.
6417 Fifth argument OBJECT is the buffer or string containing the text, and 6237 Fifth argument OBJECT is the buffer or string containing the text, and
6418 defaults to the current buffer. 6238 defaults to the current buffer.
6419 */ ) 6239 */
6420 (start, end, prop, value, object) 6240 (start, end, prop, value, object))
6421 Lisp_Object start, end, prop, value, object;
6422 { 6241 {
6423 /* This function can GC */ 6242 /* This function can GC */
6424 Bytind s, e; 6243 Bytind s, e;
6425 6244
6426 object = decode_buffer_or_string (object); 6245 object = decode_buffer_or_string (object);
6428 CHECK_SYMBOL (prop); 6247 CHECK_SYMBOL (prop);
6429 put_text_prop (s, e, object, prop, value, 0); 6248 put_text_prop (s, e, object, prop, value, 0);
6430 return prop; 6249 return prop;
6431 } 6250 }
6432 6251
6433 DEFUN ("add-text-properties", Fadd_text_properties, Sadd_text_properties, 6252 DEFUN ("add-text-properties", Fadd_text_properties, 3, 4, 0, /*
6434 3, 4, 0 /*
6435 Add properties to the characters from START to END. 6253 Add properties to the characters from START to END.
6436 The third argument PROPS is a property list specifying the property values 6254 The third argument PROPS is a property list specifying the property values
6437 to add. The optional fourth argument, OBJECT, is the buffer or string 6255 to add. The optional fourth argument, OBJECT, is the buffer or string
6438 containing the text and defaults to the current buffer. Returns t if 6256 containing the text and defaults to the current buffer. Returns t if
6439 any property was changed, nil otherwise. 6257 any property was changed, nil otherwise.
6440 */ ) 6258 */
6441 (start, end, props, object) 6259 (start, end, props, object))
6442 Lisp_Object start, end, props, object;
6443 { 6260 {
6444 /* This function can GC */ 6261 /* This function can GC */
6445 int changed = 0; 6262 int changed = 0;
6446 Bytind s, e; 6263 Bytind s, e;
6447 6264
6458 return (changed ? Qt : Qnil); 6275 return (changed ? Qt : Qnil);
6459 } 6276 }
6460 6277
6461 6278
6462 DEFUN ("add-nonduplicable-text-properties", 6279 DEFUN ("add-nonduplicable-text-properties",
6463 Fadd_nonduplicable_text_properties, 6280 Fadd_nonduplicable_text_properties, 3, 4, 0, /*
6464 Sadd_nonduplicable_text_properties,
6465 3, 4, 0 /*
6466 Add nonduplicable properties to the characters from START to END. 6281 Add nonduplicable properties to the characters from START to END.
6467 (The properties will not be copied when the characters are copied.) 6282 (The properties will not be copied when the characters are copied.)
6468 The third argument PROPS is a property list specifying the property values 6283 The third argument PROPS is a property list specifying the property values
6469 to add. The optional fourth argument, OBJECT, is the buffer or string 6284 to add. The optional fourth argument, OBJECT, is the buffer or string
6470 containing the text and defaults to the current buffer. Returns t if 6285 containing the text and defaults to the current buffer. Returns t if
6471 any property was changed, nil otherwise. 6286 any property was changed, nil otherwise.
6472 */ ) 6287 */
6473 (start, end, props, object) 6288 (start, end, props, object))
6474 Lisp_Object start, end, props, object;
6475 { 6289 {
6476 /* This function can GC */ 6290 /* This function can GC */
6477 int changed = 0; 6291 int changed = 0;
6478 Bytind s, e; 6292 Bytind s, e;
6479 6293
6488 changed |= put_text_prop (s, e, object, prop, value, 0); 6302 changed |= put_text_prop (s, e, object, prop, value, 0);
6489 } 6303 }
6490 return (changed ? Qt : Qnil); 6304 return (changed ? Qt : Qnil);
6491 } 6305 }
6492 6306
6493 DEFUN ("remove-text-properties", Fremove_text_properties, 6307 DEFUN ("remove-text-properties", Fremove_text_properties, 3, 4, 0, /*
6494 Sremove_text_properties, 3, 4, 0 /*
6495 Remove the given properties from all characters in the specified region. 6308 Remove the given properties from all characters in the specified region.
6496 PROPS should be a plist, but the values in that plist are ignored (treated 6309 PROPS should be a plist, but the values in that plist are ignored (treated
6497 as nil). Returns t if any property was changed, nil otherwise. 6310 as nil). Returns t if any property was changed, nil otherwise.
6498 Fourth argument OBJECT is the buffer or string containing the text, and 6311 Fourth argument OBJECT is the buffer or string containing the text, and
6499 defaults to the current buffer. 6312 defaults to the current buffer.
6500 */ ) 6313 */
6501 (start, end, props, object) 6314 (start, end, props, object))
6502 Lisp_Object start, end, props, object;
6503 { 6315 {
6504 /* This function can GC */ 6316 /* This function can GC */
6505 int changed = 0; 6317 int changed = 0;
6506 Bytind s, e; 6318 Bytind s, e;
6507 6319
6527 6339
6528 The lisp implementation of this was probably fast enough, but since I moved 6340 The lisp implementation of this was probably fast enough, but since I moved
6529 the rest of the put-text-prop code here, I moved this as well for 6341 the rest of the put-text-prop code here, I moved this as well for
6530 completeness. 6342 completeness.
6531 */ 6343 */
6532 DEFUN ("text-prop-extent-paste-function", Ftext_prop_extent_paste_function, 6344 DEFUN ("text-prop-extent-paste-function",
6533 Stext_prop_extent_paste_function, 3, 3, 0 /* 6345 Ftext_prop_extent_paste_function, 3, 3, 0, /*
6534 Used as the `paste-function' property of `text-prop' extents. 6346 Used as the `paste-function' property of `text-prop' extents.
6535 */ ) 6347 */
6536 (extent, from, to) 6348 (extent, from, to))
6537 Lisp_Object extent, from, to;
6538 { 6349 {
6539 /* This function can GC */ 6350 /* This function can GC */
6540 Lisp_Object prop, val; 6351 Lisp_Object prop, val;
6541 6352
6542 prop = Fextent_property (extent, Qtext_prop, Qnil); 6353 prop = Fextent_property (extent, Qtext_prop, Qnil);
6543 if (NILP (prop)) 6354 if (NILP (prop))
6544 signal_simple_error ("internal error: no text-prop", extent); 6355 signal_simple_error ("internal error: no text-prop", extent);
6545 val = Fextent_property (extent, prop, Qnil); 6356 val = Fextent_property (extent, prop, Qnil);
6357 #if 0
6358 /* removed by bill perry, 2/9/97
6359 ** This little bit of code would not allow you to have a text property
6360 ** with a value of Qnil. This is bad bad bad.
6361 */
6546 if (NILP (val)) 6362 if (NILP (val))
6547 signal_simple_error_2 ("internal error: no text-prop", 6363 signal_simple_error_2 ("internal error: no text-prop",
6548 extent, prop); 6364 extent, prop);
6365 #endif
6549 Fput_text_property (from, to, prop, val, Qnil); 6366 Fput_text_property (from, to, prop, val, Qnil);
6550 return Qnil; /* important! */ 6367 return Qnil; /* important! */
6551 } 6368 }
6552 6369
6553 /* This function could easily be written in Lisp but the C code wants 6370 /* This function could easily be written in Lisp but the C code wants
6554 to use it in connection with invisible extents (at least currently). 6371 to use it in connection with invisible extents (at least currently).
6555 If this changes, consider moving this back into Lisp. */ 6372 If this changes, consider moving this back into Lisp. */
6556 6373
6557 DEFUN ("next-single-property-change", Fnext_single_property_change, 6374 DEFUN ("next-single-property-change", Fnext_single_property_change, 2, 4, 0, /*
6558 Snext_single_property_change, 2, 4, 0 /*
6559 Return the position of next property change for a specific property. 6375 Return the position of next property change for a specific property.
6560 Scans characters forward from POS till it finds a change in the PROP 6376 Scans characters forward from POS till it finds a change in the PROP
6561 property, then returns the position of the change. The optional third 6377 property, then returns the position of the change. The optional third
6562 argument OBJECT is the buffer or string to scan (defaults to the current 6378 argument OBJECT is the buffer or string to scan (defaults to the current
6563 buffer). 6379 buffer).
6569 past position LIMIT; return LIMIT if nothing is found before LIMIT. 6385 past position LIMIT; return LIMIT if nothing is found before LIMIT.
6570 If two or more extents with conflicting non-nil values for PROP overlap 6386 If two or more extents with conflicting non-nil values for PROP overlap
6571 a particular character, it is undefined which value is considered to be 6387 a particular character, it is undefined which value is considered to be
6572 the value of PROP. (Note that this situation will not happen if you always 6388 the value of PROP. (Note that this situation will not happen if you always
6573 use the text-property primitives.) 6389 use the text-property primitives.)
6574 */ ) 6390 */
6575 (pos, prop, object, limit) 6391 (pos, prop, object, limit))
6576 Lisp_Object pos, prop, object, limit;
6577 { 6392 {
6578 Bufpos bpos; 6393 Bufpos bpos;
6579 Bufpos blim; 6394 Bufpos blim;
6580 Lisp_Object extent, value; 6395 Lisp_Object extent, value;
6581 int limit_was_nil; 6396 int limit_was_nil;
6621 return make_int (blim); 6436 return make_int (blim);
6622 } 6437 }
6623 6438
6624 /* See comment on previous function about why this is written in C. */ 6439 /* See comment on previous function about why this is written in C. */
6625 6440
6626 DEFUN ("previous-single-property-change", Fprevious_single_property_change, 6441 DEFUN ("previous-single-property-change",
6627 Sprevious_single_property_change, 2, 4, 0 /* 6442 Fprevious_single_property_change, 2, 4, 0, /*
6628 Return the position of next property change for a specific property. 6443 Return the position of next property change for a specific property.
6629 Scans characters backward from POS till it finds a change in the PROP 6444 Scans characters backward from POS till it finds a change in the PROP
6630 property, then returns the position of the change. The optional third 6445 property, then returns the position of the change. The optional third
6631 argument OBJECT is the buffer or string to scan (defaults to the current 6446 argument OBJECT is the buffer or string to scan (defaults to the current
6632 buffer). 6447 buffer).
6638 past position LIMIT; return LIMIT if nothing is found until LIMIT. 6453 past position LIMIT; return LIMIT if nothing is found until LIMIT.
6639 If two or more extents with conflicting non-nil values for PROP overlap 6454 If two or more extents with conflicting non-nil values for PROP overlap
6640 a particular character, it is undefined which value is considered to be 6455 a particular character, it is undefined which value is considered to be
6641 the value of PROP. (Note that this situation will not happen if you always 6456 the value of PROP. (Note that this situation will not happen if you always
6642 use the text-property primitives.) 6457 use the text-property primitives.)
6643 */ ) 6458 */
6644 (pos, prop, object, limit) 6459 (pos, prop, object, limit))
6645 Lisp_Object pos, prop, object, limit;
6646 { 6460 {
6647 Bufpos bpos; 6461 Bufpos bpos;
6648 Bufpos blim; 6462 Bufpos blim;
6649 Lisp_Object extent, value; 6463 Lisp_Object extent, value;
6650 int limit_was_nil; 6464 int limit_was_nil;
6738 defsymbol (&Qend_closed, "end-closed"); 6552 defsymbol (&Qend_closed, "end-closed");
6739 defsymbol (&Qread_only, "read-only"); 6553 defsymbol (&Qread_only, "read-only");
6740 /* defsymbol (&Qhighlight, "highlight"); in faces.c */ 6554 /* defsymbol (&Qhighlight, "highlight"); in faces.c */
6741 defsymbol (&Qunique, "unique"); 6555 defsymbol (&Qunique, "unique");
6742 defsymbol (&Qduplicable, "duplicable"); 6556 defsymbol (&Qduplicable, "duplicable");
6743 defsymbol (&Qreplicating, "replicating");
6744 defsymbol (&Qdetachable, "detachable"); 6557 defsymbol (&Qdetachable, "detachable");
6745 defsymbol (&Qpriority, "priority"); 6558 defsymbol (&Qpriority, "priority");
6746 defsymbol (&Qmouse_face, "mouse-face"); 6559 defsymbol (&Qmouse_face, "mouse-face");
6747 6560
6748 defsymbol (&Qglyph_layout, "glyph-layout"); /* backwards compatibility */ 6561 defsymbol (&Qglyph_layout, "glyph-layout"); /* backwards compatibility */
6760 6573
6761 defsymbol (&Qtext_prop, "text-prop"); 6574 defsymbol (&Qtext_prop, "text-prop");
6762 defsymbol (&Qtext_prop_extent_paste_function, 6575 defsymbol (&Qtext_prop_extent_paste_function,
6763 "text-prop-extent-paste-function"); 6576 "text-prop-extent-paste-function");
6764 6577
6765 defsubr (&Sextentp); 6578 DEFSUBR (Fextentp);
6766 defsubr (&Sextent_live_p); 6579 DEFSUBR (Fextent_live_p);
6767 defsubr (&Sextent_detached_p); 6580 DEFSUBR (Fextent_detached_p);
6768 defsubr (&Sextent_start_position); 6581 DEFSUBR (Fextent_start_position);
6769 defsubr (&Sextent_end_position); 6582 DEFSUBR (Fextent_end_position);
6770 defsubr (&Sextent_object); 6583 DEFSUBR (Fextent_object);
6771 defsubr (&Sextent_length); 6584 DEFSUBR (Fextent_length);
6772 #if 0 6585 #if 0
6773 defsubr (&Sstack_of_extents); 6586 DEFSUBR (Fstack_of_extents);
6774 #endif 6587 #endif
6775 6588
6776 defsubr (&Smake_extent); 6589 DEFSUBR (Fmake_extent);
6777 defsubr (&Scopy_extent); 6590 DEFSUBR (Fcopy_extent);
6778 defsubr (&Sdelete_extent); 6591 DEFSUBR (Fdelete_extent);
6779 defsubr (&Sdetach_extent); 6592 DEFSUBR (Fdetach_extent);
6780 defsubr (&Sset_extent_endpoints); 6593 DEFSUBR (Fset_extent_endpoints);
6781 defsubr (&Snext_extent); 6594 DEFSUBR (Fnext_extent);
6782 defsubr (&Sprevious_extent); 6595 DEFSUBR (Fprevious_extent);
6783 #if DEBUG_XEMACS 6596 #if DEBUG_XEMACS
6784 defsubr (&Snext_e_extent); 6597 DEFSUBR (Fnext_e_extent);
6785 defsubr (&Sprevious_e_extent); 6598 DEFSUBR (Fprevious_e_extent);
6786 #endif 6599 #endif
6787 defsubr (&Snext_extent_change); 6600 DEFSUBR (Fnext_extent_change);
6788 defsubr (&Sprevious_extent_change); 6601 DEFSUBR (Fprevious_extent_change);
6789 6602
6790 defsubr (&Sextent_parent); 6603 DEFSUBR (Fextent_parent);
6791 defsubr (&Sextent_children); 6604 DEFSUBR (Fextent_children);
6792 defsubr (&Sset_extent_parent); 6605 DEFSUBR (Fset_extent_parent);
6793 6606
6794 defsubr (&Sextent_in_region_p); 6607 DEFSUBR (Fextent_in_region_p);
6795 defsubr (&Smap_extents); 6608 DEFSUBR (Fmap_extents);
6796 defsubr (&Smap_extent_children); 6609 DEFSUBR (Fmap_extent_children);
6797 defsubr (&Sextent_at); 6610 DEFSUBR (Fextent_at);
6798 6611
6799 defsubr (&Sextent_face); 6612 DEFSUBR (Fextent_face);
6800 defsubr (&Sset_extent_face); 6613 DEFSUBR (Fset_extent_face);
6801 defsubr (&Sextent_mouse_face); 6614 DEFSUBR (Fextent_mouse_face);
6802 defsubr (&Sset_extent_mouse_face); 6615 DEFSUBR (Fset_extent_mouse_face);
6803 defsubr (&Sset_extent_begin_glyph); 6616 DEFSUBR (Fset_extent_begin_glyph);
6804 defsubr (&Sset_extent_end_glyph); 6617 DEFSUBR (Fset_extent_end_glyph);
6805 defsubr (&Sextent_begin_glyph); 6618 DEFSUBR (Fextent_begin_glyph);
6806 defsubr (&Sextent_end_glyph); 6619 DEFSUBR (Fextent_end_glyph);
6807 defsubr (&Sset_extent_begin_glyph_layout); 6620 DEFSUBR (Fset_extent_begin_glyph_layout);
6808 defsubr (&Sset_extent_end_glyph_layout); 6621 DEFSUBR (Fset_extent_end_glyph_layout);
6809 defsubr (&Sextent_begin_glyph_layout); 6622 DEFSUBR (Fextent_begin_glyph_layout);
6810 defsubr (&Sextent_end_glyph_layout); 6623 DEFSUBR (Fextent_end_glyph_layout);
6811 defsubr (&Sset_extent_priority); 6624 DEFSUBR (Fset_extent_priority);
6812 defsubr (&Sextent_priority); 6625 DEFSUBR (Fextent_priority);
6813 defsubr (&Sset_extent_property); 6626 DEFSUBR (Fset_extent_property);
6814 defsubr (&Sextent_property); 6627 DEFSUBR (Fextent_property);
6815 defsubr (&Sextent_properties); 6628 DEFSUBR (Fextent_properties);
6816 6629
6817 defsubr (&Shighlight_extent); 6630 DEFSUBR (Fhighlight_extent);
6818 defsubr (&Sforce_highlight_extent); 6631 DEFSUBR (Fforce_highlight_extent);
6819 6632
6820 defsubr (&Sinsert_extent); 6633 DEFSUBR (Finsert_extent);
6821 6634
6822 defsubr (&Sget_text_property); 6635 DEFSUBR (Fget_text_property);
6823 defsubr (&Sget_char_property); 6636 DEFSUBR (Fget_char_property);
6824 defsubr (&Sput_text_property); 6637 DEFSUBR (Fput_text_property);
6825 defsubr (&Sput_nonduplicable_text_property); 6638 DEFSUBR (Fput_nonduplicable_text_property);
6826 defsubr (&Sadd_text_properties); 6639 DEFSUBR (Fadd_text_properties);
6827 defsubr (&Sadd_nonduplicable_text_properties); 6640 DEFSUBR (Fadd_nonduplicable_text_properties);
6828 defsubr (&Sremove_text_properties); 6641 DEFSUBR (Fremove_text_properties);
6829 defsubr (&Stext_prop_extent_paste_function); 6642 DEFSUBR (Ftext_prop_extent_paste_function);
6830 defsubr (&Snext_single_property_change); 6643 DEFSUBR (Fnext_single_property_change);
6831 defsubr (&Sprevious_single_property_change); 6644 DEFSUBR (Fprevious_single_property_change);
6832 } 6645 }
6833 6646
6834 void 6647 void
6835 vars_of_extents (void) 6648 vars_of_extents (void)
6836 { 6649 {