comparison src/extents.c @ 793:e38acbeb1cae

[xemacs-hg @ 2002-03-29 04:46:17 by ben] lots o' fixes etc/ChangeLog: New file. Separated out all entries for etc/ into their own ChangeLog. Includes entries for the following files: etc/BABYL, etc/BETA, etc/CHARSETS, etc/DISTRIB, etc/Emacs.ad, etc/FTP, etc/GNUS-NEWS, etc/GOATS, etc/HELLO, etc/INSTALL, etc/MACHINES, etc/MAILINGLISTS, etc/MSDOS, etc/MYTHOLOGY, etc/NEWS, etc/OXYMORONS, etc/PACKAGES, etc/README, etc/TUTORIAL, etc/TUTORIAL.de, etc/TUTORIAL.ja, etc/TUTORIAL.ko, etc/TUTORIAL.se, etc/aliases.ksh, etc/altrasoft-logo.xpm, etc/check_cygwin_setup.sh, etc/custom/example-themes/europe-theme.el, etc/custom/example-themes/ex-custom-file, etc/custom/example-themes/example-theme.el, etc/e/eterm.ti, etc/edt-user.doc, etc/enriched.doc, etc/etags.1, etc/gnuserv.1, etc/gnuserv.README, etc/package-index.LATEST.gpg, etc/package-index.LATEST.pgp, etc/photos/jan.png, etc/recycle.xpm, etc/refcard.tex, etc/sample.Xdefaults, etc/sample.emacs, etc/sgml/CATALOG, etc/sgml/HTML32.dtd, etc/skk/SKK.tut.E, etc/smilies/Face_ase.xbm, etc/smilies/Face_ase2.xbm, etc/smilies/Face_ase3.xbm, etc/smilies/Face_smile.xbm, etc/smilies/Face_weep.xbm, etc/sounds, etc/toolbar, etc/toolbar/workshop-cap-up.xpm, etc/xemacs-ja.1, etc/xemacs.1, etc/yow.lines, etc\BETA, etc\NEWS, etc\README, etc\TUTORIAL, etc\TUTORIAL.de, etc\check_cygwin_setup.sh, etc\sample.init.el, etc\unicode\README, etc\unicode\mule-ucs\*, etc\unicode\other\* unicode/unicode-consortium/8859-16.TXT: New file. mule/english.el: Define this charset now, since a bug was fixed that formerly prevented it. mule/ethio-util.el: Fix compile errors involving Unicode `characters', which should be integers. Makefile.in.in: Always include gui.c, to fix compile error when TTY-only. EmacsFrame.c, abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, bytecode.h, callint.c, callproc.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.c, console-msw.h, console-tty.c, console-x.c, console-x.h, console.c, console.h, data.c, database.c, device-gtk.c, device-msw.c, device-x.c, device.c, device.h, dialog-msw.c, doc.c, doprnt.c, dumper.c, dynarr.c, editfns.c, eldap.c, eldap.h, elhash.c, elhash.h, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.c, events.h, extents.c, extents.h, faces.c, faces.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, frame-gtk.c, frame-msw.c, frame-tty.c, frame-x.c, frame.c, frame.h, free-hook.c, general-slots.h, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gtk-xemacs.c, gui-msw.c, gui-x.c, gui-x.h, gui.c, gui.h, gutter.c, gutter.h, indent.c, input-method-xlib.c, insdel.c, keymap.c, keymap.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, marker.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-canna.c, mule-ccl.c, mule-charset.c, mule-wnnfns.c, native-gtk-toolbar.c, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, opaque.c, opaque.h, postgresql.c, postgresql.h, print.c, process-unix.c, process.c, process.h, rangetab.c, rangetab.h, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, search.c, select-gtk.c, select-x.c, sound.c, specifier.c, specifier.h, strftime.c, symbols.c, symeval.h, syntax.h, text.c, text.h, toolbar-common.c, toolbar-msw.c, toolbar.c, toolbar.h, tooltalk.c, tooltalk.h, ui-gtk.c, ui-gtk.h, undo.c, vm-limit.c, window.c, window.h: Eliminate XSETFOO. Replace all usages with wrap_foo(). Make symbol->name a Lisp_Object, not Lisp_String *. Eliminate nearly all uses of Lisp_String * in favor of Lisp_Object, and correct macros so most of them favor Lisp_Object. Create new error-behavior ERROR_ME_DEBUG_WARN -- output warnings, but at level `debug' (usually ignored). Use it when instantiating specifiers, so problems can be debugged. Move log-warning-minimum-level into C so that we can optimize ERROR_ME_DEBUG_WARN. Fix warning levels consistent with new definitions. Add default_ and parent fields to char table; not yet implemented. New fun Dynarr_verify(); use for further error checking on Dynarrs. Rearrange code at top of lisp.h in conjunction with dynarr changes. Fix eifree(). Use Eistrings in various places (format_event_object(), where_is_to_char(), and callers thereof) to avoid fixed-size strings buffers. New fun write_eistring(). Reindent and fix GPM code to follow standards. Set default MS Windows font to Lucida Console (same size as Courier New but less interline spacing, so more lines fit). Increase default frame size on Windows to 50 lines. (If that's too big for the workspace, the frame will be shrunk as necessary.) Fix problem with text files with no newlines (). (Change `convert-eol' coding system to use `nil' for autodetect, consistent with make-coding-system.) Correct compile warnings in vm-limit.c. Fix handling of reverse-direction charsets to avoid errors when opening (e.g.) mule-ucs/lisp/reldata/uiso8859-6.el. Recode some object printing methods to use write_fmt_string() instead of a fixed buffer and sprintf. Turn on display of png comments as warnings (level `info'), now that they're unobtrusive. Revamped the sound documentation. Fixed bug in redisplay w.r.t. hscroll/truncation/continuation glyphs causing jumping up and down of the lines, since they're bigger than the line size. (It was seen most obviously when there's a horizontal scroll bar, e.g. do C-h a glyph or something like that.) The problem was that the glyph-contrib-p setting on glyphs was ignored even if it was set properly, which it wasn't until now.
author ben
date Fri, 29 Mar 2002 04:49:13 +0000
parents 943eaba38521
children a5954632b187
comparison
equal deleted inserted replaced
792:4e83fdb13eb9 793:e38acbeb1cae
1 /* Copyright (c) 1994, 1995 Free Software Foundation, Inc. 1 /* Copyright (c) 1994, 1995 Free Software Foundation, Inc.
2 Copyright (c) 1995 Sun Microsystems, Inc. 2 Copyright (c) 1995 Sun Microsystems, Inc.
3 Copyright (c) 1995, 1996, 2000 Ben Wing. 3 Copyright (c) 1995, 1996, 2000, 2002 Ben Wing.
4 4
5 This file is part of XEmacs. 5 This file is part of XEmacs.
6 6
7 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
936 Lisp_Object extent_aux; 936 Lisp_Object extent_aux;
937 struct extent_auxiliary *data = 937 struct extent_auxiliary *data =
938 alloc_lcrecord_type (struct extent_auxiliary, &lrecord_extent_auxiliary); 938 alloc_lcrecord_type (struct extent_auxiliary, &lrecord_extent_auxiliary);
939 939
940 copy_lcrecord (data, &extent_auxiliary_defaults); 940 copy_lcrecord (data, &extent_auxiliary_defaults);
941 XSETEXTENT_AUXILIARY (extent_aux, data); 941 extent_aux = wrap_extent_auxiliary (data);
942 ext->plist = Fcons (extent_aux, ext->plist); 942 ext->plist = Fcons (extent_aux, ext->plist);
943 ext->flags.has_aux = 1; 943 ext->flags.has_aux = 1;
944 } 944 }
945 945
946 946
992 if (list) 992 if (list)
993 { 993 {
994 for (i = 0; i < extent_list_num_els (list); i++) 994 for (i = 0; i < extent_list_num_els (list); i++)
995 { 995 {
996 struct extent *extent = extent_list_at (list, i, 0); 996 struct extent *extent = extent_list_at (list, i, 0);
997 Lisp_Object exobj; 997 Lisp_Object exobj = wrap_extent (extent);
998 998
999 XSETEXTENT (exobj, extent);
1000 mark_object (exobj); 999 mark_object (exobj);
1001 } 1000 }
1002 } 1001 }
1003 1002
1004 return Qnil; 1003 return Qnil;
1034 { 1033 {
1035 Lisp_Object extent_info; 1034 Lisp_Object extent_info;
1036 struct extent_info *data = 1035 struct extent_info *data =
1037 alloc_lcrecord_type (struct extent_info, &lrecord_extent_info); 1036 alloc_lcrecord_type (struct extent_info, &lrecord_extent_info);
1038 1037
1039 XSETEXTENT_INFO (extent_info, data); 1038 extent_info = wrap_extent_info (data);
1040 data->extents = allocate_extent_list (); 1039 data->extents = allocate_extent_list ();
1041 data->soe = 0; 1040 data->soe = 0;
1042 return extent_info; 1041 return extent_info;
1043 } 1042 }
1044 1043
1072 1071
1073 static Lisp_Object 1072 static Lisp_Object
1074 decode_buffer_or_string (Lisp_Object object) 1073 decode_buffer_or_string (Lisp_Object object)
1075 { 1074 {
1076 if (NILP (object)) 1075 if (NILP (object))
1077 XSETBUFFER (object, current_buffer); 1076 object = wrap_buffer (current_buffer);
1078 else if (BUFFERP (object)) 1077 else if (BUFFERP (object))
1079 CHECK_LIVE_BUFFER (object); 1078 CHECK_LIVE_BUFFER (object);
1080 else if (STRINGP (object)) 1079 else if (STRINGP (object))
1081 ; 1080 ;
1082 else 1081 else
1103 static struct extent_info * 1102 static struct extent_info *
1104 buffer_or_string_extent_info (Lisp_Object object) 1103 buffer_or_string_extent_info (Lisp_Object object)
1105 { 1104 {
1106 if (STRINGP (object)) 1105 if (STRINGP (object))
1107 { 1106 {
1108 Lisp_Object plist = XSTRING (object)->plist; 1107 Lisp_Object plist = XSTRING_PLIST (object);
1109 if (!CONSP (plist) || !EXTENT_INFOP (XCAR (plist))) 1108 if (!CONSP (plist) || !EXTENT_INFOP (XCAR (plist)))
1110 return 0; 1109 return 0;
1111 return XEXTENT_INFO (XCAR (plist)); 1110 return XEXTENT_INFO (XCAR (plist));
1112 } 1111 }
1113 else if (NILP (object)) 1112 else if (NILP (object))
1145 the only buffers without an extent 1144 the only buffers without an extent
1146 info are those after finalization, 1145 info are those after finalization,
1147 destroyed buffers, or special 1146 destroyed buffers, or special
1148 Lisp-inaccessible buffer objects. */ 1147 Lisp-inaccessible buffer objects. */
1149 extent_info = allocate_extent_info (); 1148 extent_info = allocate_extent_info ();
1150 XSTRING (object)->plist = Fcons (extent_info, XSTRING (object)->plist); 1149 XSTRING_PLIST (object) = Fcons (extent_info, XSTRING_PLIST (object));
1151 return XEXTENT_INFO (extent_info); 1150 return XEXTENT_INFO (extent_info);
1152 } 1151 }
1153 1152
1154 return info; 1153 return info;
1155 } 1154 }
1279 print_extent_2 (EXTENT e) 1278 print_extent_2 (EXTENT e)
1280 { 1279 {
1281 Lisp_Object extent; 1280 Lisp_Object extent;
1282 char buf[200]; 1281 char buf[200];
1283 1282
1284 XSETEXTENT (extent, e); 1283 extent = wrap_extent (e);
1285 print_extent_1 (buf, extent); 1284 print_extent_1 (buf, extent);
1286 fputs (buf, stdout); 1285 fputs (buf, stdout);
1287 } 1286 }
1288 1287
1289 static void 1288 static void
2799 { 2798 {
2800 Lisp_Object glyph = extent_begin_glyph (e); 2799 Lisp_Object glyph = extent_begin_glyph (e);
2801 struct glyph_block gb; 2800 struct glyph_block gb;
2802 2801
2803 gb.glyph = glyph; 2802 gb.glyph = glyph;
2804 XSETEXTENT (gb.extent, e); 2803 gb.extent = wrap_extent (e);
2805 Dynarr_add (ef->begin_glyphs, gb); 2804 Dynarr_add (ef->begin_glyphs, gb);
2806 } 2805 }
2807 } 2806 }
2808 2807
2809 /* Determine the end glyphs at POS. */ 2808 /* Determine the end glyphs at POS. */
2814 { 2813 {
2815 Lisp_Object glyph = extent_end_glyph (e); 2814 Lisp_Object glyph = extent_end_glyph (e);
2816 struct glyph_block gb; 2815 struct glyph_block gb;
2817 2816
2818 gb.glyph = glyph; 2817 gb.glyph = glyph;
2819 XSETEXTENT (gb.extent, e); 2818 gb.extent = wrap_extent (e);
2820 Dynarr_add (ef->end_glyphs, gb); 2819 Dynarr_add (ef->end_glyphs, gb);
2821 } 2820 }
2822 } 2821 }
2823 2822
2824 /* We tried determining all the charsets used in the run here, 2823 /* We tried determining all the charsets used in the run here,
2899 /* print_extent_2 (e); 2898 /* print_extent_2 (e);
2900 printf ("\n"); */ 2899 printf ("\n"); */
2901 2900
2902 /* FIXME: One should probably inhibit the displaying of 2901 /* FIXME: One should probably inhibit the displaying of
2903 this extent to reduce flicker */ 2902 this extent to reduce flicker */
2904 extent_in_red_event_p(e) = 1; 2903 extent_in_red_event_p (e) = 1;
2905 2904
2906 /* call the function */ 2905 /* call the function */
2907 XSETEXTENT(obj,e); 2906 obj = wrap_extent (e);
2908 if(!NILP(function)) 2907 if (!NILP (function))
2909 Fenqueue_eval_event(function,obj); 2908 Fenqueue_eval_event (function, obj);
2910 } 2909 }
2911 } 2910 }
2912 } 2911 }
2913 2912
2914 extent_fragment_sort_by_priority (ef->extents); 2913 extent_fragment_sort_by_priority (ef->extents);
3339 Note: The display order is not necessarily the order that `map-extents' 3338 Note: The display order is not necessarily the order that `map-extents'
3340 processes extents in! 3339 processes extents in!
3341 */ 3340 */
3342 (extent)) 3341 (extent))
3343 { 3342 {
3344 Lisp_Object val;
3345 EXTENT next; 3343 EXTENT next;
3346 3344
3347 if (EXTENTP (extent)) 3345 if (EXTENTP (extent))
3348 next = extent_next (decode_extent (extent, DE_MUST_BE_ATTACHED)); 3346 next = extent_next (decode_extent (extent, DE_MUST_BE_ATTACHED));
3349 else 3347 else
3350 next = extent_first (decode_buffer_or_string (extent)); 3348 next = extent_first (decode_buffer_or_string (extent));
3351 3349
3352 if (!next) 3350 if (!next)
3353 return Qnil; 3351 return Qnil;
3354 XSETEXTENT (val, next); 3352 return wrap_extent (next);
3355 return val;
3356 } 3353 }
3357 3354
3358 DEFUN ("previous-extent", Fprevious_extent, 1, 1, 0, /* 3355 DEFUN ("previous-extent", Fprevious_extent, 1, 1, 0, /*
3359 Find last extent before EXTENT. 3356 Find last extent before EXTENT.
3360 If EXTENT is a buffer return the last extent in the buffer; likewise 3357 If EXTENT is a buffer return the last extent in the buffer; likewise
3361 for strings. 3358 for strings.
3362 This function is analogous to `next-extent'. 3359 This function is analogous to `next-extent'.
3363 */ 3360 */
3364 (extent)) 3361 (extent))
3365 { 3362 {
3366 Lisp_Object val;
3367 EXTENT prev; 3363 EXTENT prev;
3368 3364
3369 if (EXTENTP (extent)) 3365 if (EXTENTP (extent))
3370 prev = extent_previous (decode_extent (extent, DE_MUST_BE_ATTACHED)); 3366 prev = extent_previous (decode_extent (extent, DE_MUST_BE_ATTACHED));
3371 else 3367 else
3372 prev = extent_last (decode_buffer_or_string (extent)); 3368 prev = extent_last (decode_buffer_or_string (extent));
3373 3369
3374 if (!prev) 3370 if (!prev)
3375 return Qnil; 3371 return Qnil;
3376 XSETEXTENT (val, prev); 3372 return wrap_extent (prev);
3377 return val;
3378 } 3373 }
3379 3374
3380 #ifdef DEBUG_XEMACS 3375 #ifdef DEBUG_XEMACS
3381 3376
3382 DEFUN ("next-e-extent", Fnext_e_extent, 1, 1, 0, /* 3377 DEFUN ("next-e-extent", Fnext_e_extent, 1, 1, 0, /*
3384 If EXTENT is a buffer return the first extent in the buffer; likewise 3379 If EXTENT is a buffer return the first extent in the buffer; likewise
3385 for strings. 3380 for strings.
3386 */ 3381 */
3387 (extent)) 3382 (extent))
3388 { 3383 {
3389 Lisp_Object val;
3390 EXTENT next; 3384 EXTENT next;
3391 3385
3392 if (EXTENTP (extent)) 3386 if (EXTENTP (extent))
3393 next = extent_e_next (decode_extent (extent, DE_MUST_BE_ATTACHED)); 3387 next = extent_e_next (decode_extent (extent, DE_MUST_BE_ATTACHED));
3394 else 3388 else
3395 next = extent_e_first (decode_buffer_or_string (extent)); 3389 next = extent_e_first (decode_buffer_or_string (extent));
3396 3390
3397 if (!next) 3391 if (!next)
3398 return Qnil; 3392 return Qnil;
3399 XSETEXTENT (val, next); 3393 return wrap_extent (next);
3400 return val;
3401 } 3394 }
3402 3395
3403 DEFUN ("previous-e-extent", Fprevious_e_extent, 1, 1, 0, /* 3396 DEFUN ("previous-e-extent", Fprevious_e_extent, 1, 1, 0, /*
3404 Find last extent before EXTENT using the "e" order. 3397 Find last extent before EXTENT using the "e" order.
3405 If EXTENT is a buffer return the last extent in the buffer; likewise 3398 If EXTENT is a buffer return the last extent in the buffer; likewise
3406 for strings. 3399 for strings.
3407 This function is analogous to `next-e-extent'. 3400 This function is analogous to `next-e-extent'.
3408 */ 3401 */
3409 (extent)) 3402 (extent))
3410 { 3403 {
3411 Lisp_Object val;
3412 EXTENT prev; 3404 EXTENT prev;
3413 3405
3414 if (EXTENTP (extent)) 3406 if (EXTENTP (extent))
3415 prev = extent_e_previous (decode_extent (extent, DE_MUST_BE_ATTACHED)); 3407 prev = extent_e_previous (decode_extent (extent, DE_MUST_BE_ATTACHED));
3416 else 3408 else
3417 prev = extent_e_last (decode_buffer_or_string (extent)); 3409 prev = extent_e_last (decode_buffer_or_string (extent));
3418 3410
3419 if (!prev) 3411 if (!prev)
3420 return Qnil; 3412 return Qnil;
3421 XSETEXTENT (val, prev); 3413 return wrap_extent (prev);
3422 return val;
3423 } 3414 }
3424 3415
3425 #endif 3416 #endif
3426 3417
3427 DEFUN ("next-extent-change", Fnext_extent_change, 1, 2, 0, /* 3418 DEFUN ("next-extent-change", Fnext_extent_change, 1, 2, 0, /*
3529 { 3520 {
3530 EXTENT e = decode_extent (extent, 0); 3521 EXTENT e = decode_extent (extent, 0);
3531 Lisp_Object cur_parent = extent_parent (e); 3522 Lisp_Object cur_parent = extent_parent (e);
3532 Lisp_Object rest; 3523 Lisp_Object rest;
3533 3524
3534 XSETEXTENT (extent, e); 3525 extent = wrap_extent (e);
3535 if (!NILP (parent)) 3526 if (!NILP (parent))
3536 CHECK_LIVE_EXTENT (parent); 3527 CHECK_LIVE_EXTENT (parent);
3537 if (EQ (parent, cur_parent)) 3528 if (EQ (parent, cur_parent))
3538 return Qnil; 3529 return Qnil;
3539 for (rest = parent; !NILP (rest); rest = extent_parent (XEXTENT (rest))) 3530 for (rest = parent; !NILP (rest); rest = extent_parent (XEXTENT (rest)))
3598 3589
3599 if (extent_detached_p (extent)) 3590 if (extent_detached_p (extent))
3600 { 3591 {
3601 if (extent_duplicable_p (extent)) 3592 if (extent_duplicable_p (extent))
3602 { 3593 {
3603 Lisp_Object extent_obj; 3594 Lisp_Object extent_obj = wrap_extent (extent);
3604 XSETEXTENT (extent_obj, extent); 3595
3605 record_extent (extent_obj, 1); 3596 record_extent (extent_obj, 1);
3606 } 3597 }
3607 } 3598 }
3608 else 3599 else
3609 extent_detach (extent); 3600 extent_detach (extent);
3679 struct extent_auxiliary *data = 3670 struct extent_auxiliary *data =
3680 alloc_lcrecord_type (struct extent_auxiliary, 3671 alloc_lcrecord_type (struct extent_auxiliary,
3681 &lrecord_extent_auxiliary); 3672 &lrecord_extent_auxiliary);
3682 3673
3683 copy_lcrecord (data, XEXTENT_AUXILIARY (XCAR (original->plist))); 3674 copy_lcrecord (data, XEXTENT_AUXILIARY (XCAR (original->plist)));
3684 XSETEXTENT_AUXILIARY (XCAR (e->plist), data); 3675 XCAR (e->plist) = wrap_extent_auxiliary (data);
3685 } 3676 }
3686 3677
3687 { 3678 {
3688 /* we may have just added another child to the parent extent. */ 3679 /* we may have just added another child to the parent extent. */
3689 Lisp_Object parent = extent_parent (e); 3680 Lisp_Object parent = extent_parent (e);
3690 if (!NILP (parent)) 3681 if (!NILP (parent))
3691 { 3682 {
3692 Lisp_Object extent; 3683 Lisp_Object extent = wrap_extent (e);
3693 XSETEXTENT (extent, e); 3684
3694 add_extent_to_children_list (XEXTENT (parent), extent); 3685 add_extent_to_children_list (XEXTENT (parent), extent);
3695 } 3686 }
3696 } 3687 }
3697 3688
3698 return e; 3689 return e;
3711 if (!NILP (children)) 3702 if (!NILP (children))
3712 { 3703 {
3713 LIST_LOOP_DELETING (rest, nextrest, XWEAK_LIST_LIST (children)) 3704 LIST_LOOP_DELETING (rest, nextrest, XWEAK_LIST_LIST (children))
3714 Fset_extent_parent (XCAR (rest), Qnil); 3705 Fset_extent_parent (XCAR (rest), Qnil);
3715 } 3706 }
3716 XSETEXTENT (extent_obj, extent); 3707 extent_obj = wrap_extent (extent);
3717 Fset_extent_parent (extent_obj, Qnil); 3708 Fset_extent_parent (extent_obj, Qnil);
3718 /* mark the extent as destroyed */ 3709 /* mark the extent as destroyed */
3719 extent_object (extent) = Qt; 3710 extent_object (extent) = Qt;
3720 } 3711 }
3721 3712
3737 obj = decode_buffer_or_string (buffer_or_string); 3728 obj = decode_buffer_or_string (buffer_or_string);
3738 if (NILP (from) && NILP (to)) 3729 if (NILP (from) && NILP (to))
3739 { 3730 {
3740 if (NILP (buffer_or_string)) 3731 if (NILP (buffer_or_string))
3741 obj = Qnil; 3732 obj = Qnil;
3742 XSETEXTENT (extent_obj, make_extent_detached (obj)); 3733 extent_obj = wrap_extent (make_extent_detached (obj));
3743 } 3734 }
3744 else 3735 else
3745 { 3736 {
3746 Bytebpos start, end; 3737 Bytebpos start, end;
3747 3738
3748 get_buffer_or_string_range_byte (obj, from, to, &start, &end, 3739 get_buffer_or_string_range_byte (obj, from, to, &start, &end,
3749 GB_ALLOW_PAST_ACCESSIBLE); 3740 GB_ALLOW_PAST_ACCESSIBLE);
3750 XSETEXTENT (extent_obj, make_extent_internal (obj, start, end)); 3741 extent_obj = wrap_extent (make_extent_internal (obj, start, end));
3751 } 3742 }
3752 return extent_obj; 3743 return extent_obj;
3753 } 3744 }
3754 3745
3755 DEFUN ("copy-extent", Fcopy_extent, 1, 2, 0, /* 3746 DEFUN ("copy-extent", Fcopy_extent, 1, 2, 0, /*
3763 if (NILP (buffer_or_string)) 3754 if (NILP (buffer_or_string))
3764 buffer_or_string = extent_object (ext); 3755 buffer_or_string = extent_object (ext);
3765 else 3756 else
3766 buffer_or_string = decode_buffer_or_string (buffer_or_string); 3757 buffer_or_string = decode_buffer_or_string (buffer_or_string);
3767 3758
3768 XSETEXTENT (extent, copy_extent (ext, -1, -1, buffer_or_string)); 3759 return wrap_extent (copy_extent (ext, -1, -1, buffer_or_string));
3769 return extent;
3770 } 3760 }
3771 3761
3772 DEFUN ("delete-extent", Fdelete_extent, 1, 1, 0, /* 3762 DEFUN ("delete-extent", Fdelete_extent, 1, 1, 0, /*
3773 Remove EXTENT from its buffer and destroy it. 3763 Remove EXTENT from its buffer and destroy it.
3774 This does not modify the buffer's text, only its display properties. 3764 This does not modify the buffer's text, only its display properties.
3941 static int 3931 static int
3942 slow_map_extents_function (EXTENT extent, void *arg) 3932 slow_map_extents_function (EXTENT extent, void *arg)
3943 { 3933 {
3944 /* This function can GC */ 3934 /* This function can GC */
3945 struct slow_map_extents_arg *closure = (struct slow_map_extents_arg *) arg; 3935 struct slow_map_extents_arg *closure = (struct slow_map_extents_arg *) arg;
3946 Lisp_Object extent_obj; 3936 Lisp_Object extent_obj = wrap_extent (extent);
3947 3937
3948 XSETEXTENT (extent_obj, extent);
3949 3938
3950 /* make sure this extent qualifies according to the PROPERTY 3939 /* make sure this extent qualifies according to the PROPERTY
3951 and VALUE args */ 3940 and VALUE args */
3952 3941
3953 if (!NILP (closure->property)) 3942 if (!NILP (closure->property))
4135 { 4124 {
4136 if (start < closure->prev_end) 4125 if (start < closure->prev_end)
4137 return 0; 4126 return 0;
4138 /* corner case: prev_end can be -1 if there is no prev */ 4127 /* corner case: prev_end can be -1 if there is no prev */
4139 } 4128 }
4140 XSETEXTENT (extent_obj, extent); 4129 extent_obj = wrap_extent (extent);
4141 4130
4142 /* make sure this extent qualifies according to the PROPERTY 4131 /* make sure this extent qualifies according to the PROPERTY
4143 and VALUE args */ 4132 and VALUE args */
4144 4133
4145 if (!NILP (closure->property)) 4134 if (!NILP (closure->property))
4282 4271
4283 /* If closure->prop is non-nil, then the extent is only acceptable 4272 /* If closure->prop is non-nil, then the extent is only acceptable
4284 if it has a non-nil value for that property. */ 4273 if it has a non-nil value for that property. */
4285 if (!NILP (closure->prop)) 4274 if (!NILP (closure->prop))
4286 { 4275 {
4287 Lisp_Object extent; 4276 Lisp_Object extent = wrap_extent (e);
4288 XSETEXTENT (extent, e); 4277
4289 if (NILP (Fextent_property (extent, closure->prop, Qnil))) 4278 if (NILP (Fextent_property (extent, closure->prop, Qnil)))
4290 return 0; 4279 return 0;
4291 } 4280 }
4292 4281
4293 if (!closure->all_extents) 4282 if (!closure->all_extents)
4309 closure->best_end)) 4298 closure->best_end))
4310 goto accept; 4299 goto accept;
4311 else 4300 else
4312 return 0; 4301 return 0;
4313 accept: 4302 accept:
4314 XSETEXTENT (closure->best_match, e); 4303 closure->best_match = wrap_extent (e);
4315 closure->best_start = extent_start (e); 4304 closure->best_start = extent_start (e);
4316 closure->best_end = extent_end (e); 4305 closure->best_end = extent_end (e);
4317 } 4306 }
4318 else 4307 else
4319 { 4308 {
4320 Lisp_Object extent; 4309 Lisp_Object extent = wrap_extent (e);
4321 4310
4322 XSETEXTENT (extent, e);
4323 closure->best_match = Fcons (extent, closure->best_match); 4311 closure->best_match = Fcons (extent, closure->best_match);
4324 } 4312 }
4325 4313
4326 return 0; 4314 return 0;
4327 } 4315 }
4716 ? extent_after_change_functions (extent) 4704 ? extent_after_change_functions (extent)
4717 : extent_before_change_functions (extent)); 4705 : extent_before_change_functions (extent));
4718 if (NILP (hook)) 4706 if (NILP (hook))
4719 return 0; 4707 return 0;
4720 4708
4721 XSETEXTENT (exobj, extent); 4709 exobj = wrap_extent (extent);
4722 XSETINT (startobj, closure->start); 4710 startobj = make_int (closure->start);
4723 XSETINT (endobj, closure->end); 4711 endobj = make_int (closure->end);
4724 4712
4725 /* Now that we are sure to call elisp, set up an unwind-protect so 4713 /* Now that we are sure to call elisp, set up an unwind-protect so
4726 inside_change_hook gets restored in case we throw. Also record 4714 inside_change_hook gets restored in case we throw. Also record
4727 the current buffer, in case we change it. Do the recording only 4715 the current buffer, in case we change it. Do the recording only
4728 once. 4716 once.
5528 e = XEXTENT (extent); 5516 e = XEXTENT (extent);
5529 if (!EXTENT_LIVE_P (e)) 5517 if (!EXTENT_LIVE_P (e))
5530 return cons3 (Qdestroyed, Qt, Qnil); 5518 return cons3 (Qdestroyed, Qt, Qnil);
5531 5519
5532 anc = extent_ancestor (e); 5520 anc = extent_ancestor (e);
5533 XSETEXTENT (anc_obj, anc); 5521 anc_obj = wrap_extent (anc);
5534 5522
5535 /* For efficiency, use the ancestor for all properties except detached */ 5523 /* For efficiency, use the ancestor for all properties except detached */
5536 5524
5537 result = extent_plist_slot (anc); 5525 result = extent_plist_slot (anc);
5538 5526
5642 (extent, highlight_p)) 5630 (extent, highlight_p))
5643 { 5631 {
5644 if (NILP (extent)) 5632 if (NILP (extent))
5645 highlight_p = Qnil; 5633 highlight_p = Qnil;
5646 else 5634 else
5647 XSETEXTENT (extent, decode_extent (extent, DE_MUST_BE_ATTACHED)); 5635 extent = wrap_extent (decode_extent (extent, DE_MUST_BE_ATTACHED));
5648 do_highlight (extent, !NILP (highlight_p)); 5636 do_highlight (extent, !NILP (highlight_p));
5649 return Qnil; 5637 return Qnil;
5650 } 5638 }
5651 5639
5652 DEFUN ("highlight-extent", Fhighlight_extent, 1, 2, 0, /* 5640 DEFUN ("highlight-extent", Fhighlight_extent, 1, 2, 0, /*
5677 Lisp_Object prop) 5665 Lisp_Object prop)
5678 { 5666 {
5679 /* This function can GC */ 5667 /* This function can GC */
5680 Lisp_Object extent; 5668 Lisp_Object extent;
5681 Lisp_Object copy_fn; 5669 Lisp_Object copy_fn;
5682 XSETEXTENT (extent, e); 5670 extent = wrap_extent (e);
5683 copy_fn = Fextent_property (extent, prop, Qnil); 5671 copy_fn = Fextent_property (extent, prop, Qnil);
5684 if (!NILP (copy_fn)) 5672 if (!NILP (copy_fn))
5685 { 5673 {
5686 Lisp_Object flag; 5674 Lisp_Object flag;
5687 struct gcpro gcpro1, gcpro2, gcpro3; 5675 struct gcpro gcpro1, gcpro2, gcpro3;
5733 static Lisp_Object 5721 static Lisp_Object
5734 insert_extent (EXTENT extent, Bytebpos new_start, Bytebpos new_end, 5722 insert_extent (EXTENT extent, Bytebpos new_start, Bytebpos new_end,
5735 Lisp_Object object, int run_hooks) 5723 Lisp_Object object, int run_hooks)
5736 { 5724 {
5737 /* This function can GC */ 5725 /* This function can GC */
5738 Lisp_Object tmp;
5739
5740 if (!EQ (extent_object (extent), object)) 5726 if (!EQ (extent_object (extent), object))
5741 goto copy_it; 5727 goto copy_it;
5742 5728
5743 if (extent_detached_p (extent)) 5729 if (extent_detached_p (extent))
5744 { 5730 {
5763 if (exstart != new_start || exend != new_end) 5749 if (exstart != new_start || exend != new_end)
5764 update_extent (extent, new_start, new_end); 5750 update_extent (extent, new_start, new_end);
5765 } 5751 }
5766 } 5752 }
5767 5753
5768 XSETEXTENT (tmp, extent); 5754 return wrap_extent (extent);
5769 return tmp;
5770 5755
5771 copy_it: 5756 copy_it:
5772 if (run_hooks && 5757 if (run_hooks &&
5773 !run_extent_paste_function (extent, new_start, new_end, object)) 5758 !run_extent_paste_function (extent, new_start, new_end, object))
5774 /* The paste-function said don't attach a copy of the extent here. */ 5759 /* The paste-function said don't attach a copy of the extent here. */
5775 return Qnil; 5760 return Qnil;
5776 else 5761 else
5777 { 5762 return wrap_extent (copy_extent (extent, new_start, new_end, object));
5778 XSETEXTENT (tmp, copy_extent (extent, new_start, new_end, object));
5779 return tmp;
5780 }
5781 } 5763 }
5782 5764
5783 DEFUN ("insert-extent", Finsert_extent, 1, 5, 0, /* 5765 DEFUN ("insert-extent", Finsert_extent, 1, 5, 0, /*
5784 Insert EXTENT from START to END in BUFFER-OR-STRING. 5766 Insert EXTENT from START to END in BUFFER-OR-STRING.
5785 BUFFER-OR-STRING defaults to the current buffer if omitted. 5767 BUFFER-OR-STRING defaults to the current buffer if omitted.
5926 splice_in_string_extents (Lisp_Object string, struct buffer *buf, 5908 splice_in_string_extents (Lisp_Object string, struct buffer *buf,
5927 Bytebpos opoint, Bytecount length, Bytecount pos) 5909 Bytebpos opoint, Bytecount length, Bytecount pos)
5928 { 5910 {
5929 struct splice_in_string_extents_arg closure; 5911 struct splice_in_string_extents_arg closure;
5930 struct gcpro gcpro1, gcpro2; 5912 struct gcpro gcpro1, gcpro2;
5931 Lisp_Object buffer; 5913 Lisp_Object buffer = wrap_buffer (buf);
5932 5914
5933 buffer = wrap_buffer (buf);
5934 closure.opoint = opoint; 5915 closure.opoint = opoint;
5935 closure.pos = pos; 5916 closure.pos = pos;
5936 closure.length = length; 5917 closure.length = length;
5937 closure.buffer = buffer; 5918 closure.buffer = buffer;
5938 GCPRO2 (buffer, string); 5919 GCPRO2 (buffer, string);
6176 Bytebpos start = closure->start; 6157 Bytebpos start = closure->start;
6177 Bytebpos end = closure->end; 6158 Bytebpos end = closure->end;
6178 Lisp_Object extent, e_val; 6159 Lisp_Object extent, e_val;
6179 int is_eq; 6160 int is_eq;
6180 6161
6181 XSETEXTENT (extent, e); 6162 extent = wrap_extent (e);
6182 6163
6183 /* Note: in some cases when the property itself is 'start-open 6164 /* Note: in some cases when the property itself is 'start-open
6184 or 'end-closed, the checks to set the openness may do a bit 6165 or 'end-closed, the checks to set the openness may do a bit
6185 of extra work; but it won't hurt because we then fix up the 6166 of extra work; but it won't hurt because we then fix up the
6186 openness later on in put_text_prop_openness_mapper(). */ 6167 openness later on in put_text_prop_openness_mapper(). */
6333 { 6314 {
6334 struct put_text_prop_arg *closure = (struct put_text_prop_arg *) arg; 6315 struct put_text_prop_arg *closure = (struct put_text_prop_arg *) arg;
6335 Bytebpos e_start, e_end; 6316 Bytebpos e_start, e_end;
6336 Bytebpos start = closure->start; 6317 Bytebpos start = closure->start;
6337 Bytebpos end = closure->end; 6318 Bytebpos end = closure->end;
6338 Lisp_Object extent; 6319 Lisp_Object extent = wrap_extent (e);
6339 XSETEXTENT (extent, e); 6320
6340 e_start = extent_endpoint_bytebpos (e, 0); 6321 e_start = extent_endpoint_bytebpos (e, 0);
6341 e_end = extent_endpoint_bytebpos (e, 1); 6322 e_end = extent_endpoint_bytebpos (e, 1);
6342 6323
6343 if (NILP (Fextent_property (extent, Qtext_prop, Qnil))) 6324 if (NILP (Fextent_property (extent, Qtext_prop, Qnil)))
6344 { 6325 {
6406 /* If we made it through the loop without reusing an extent 6387 /* If we made it through the loop without reusing an extent
6407 (and we want there to be one) make it now. 6388 (and we want there to be one) make it now.
6408 */ 6389 */
6409 if (!NILP (value) && NILP (closure.the_extent)) 6390 if (!NILP (value) && NILP (closure.the_extent))
6410 { 6391 {
6411 Lisp_Object extent; 6392 Lisp_Object extent = wrap_extent (make_extent_internal (object, start, end));
6412 6393
6413 XSETEXTENT (extent, make_extent_internal (object, start, end));
6414 closure.changed_p = 1; 6394 closure.changed_p = 1;
6415 Fset_extent_property (extent, Qtext_prop, prop); 6395 Fset_extent_property (extent, Qtext_prop, prop);
6416 Fset_extent_property (extent, prop, value); 6396 Fset_extent_property (extent, prop, value);
6417 if (duplicable_p) 6397 if (duplicable_p)
6418 { 6398 {