comparison src/textprop.c @ 48840:b6981c46191d

(text_read_only): New arg `propval'. (get_char_property_and_overlay): Remove unused var `next_overlay'. (verify_interval_modification): Use text_read_only's new arg.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 14 Dec 2002 00:11:38 +0000
parents 218b99308569
children 5856f0179746
comparison
equal deleted inserted replaced
48839:b4f252602421 48840:b6981c46191d
81 81
82 /* Signal a `text-read-only' error. This function makes it easier 82 /* Signal a `text-read-only' error. This function makes it easier
83 to capture that error in GDB by putting a breakpoint on it. */ 83 to capture that error in GDB by putting a breakpoint on it. */
84 84
85 static void 85 static void
86 text_read_only () 86 text_read_only (propval)
87 { 87 Lisp_Object propval;
88 Fsignal (Qtext_read_only, Qnil); 88 {
89 Fsignal (Qtext_read_only, STRINGP (propval) ? Fcons (propval, Qnil) : Qnil);
89 } 90 }
90 91
91 92
92 93
93 /* Extract the interval at the position pointed to by BEGIN from 94 /* Extract the interval at the position pointed to by BEGIN from
602 Lisp_Object prop; 603 Lisp_Object prop;
603 { 604 {
604 return textget (Ftext_properties_at (position, object), prop); 605 return textget (Ftext_properties_at (position, object), prop);
605 } 606 }
606 607
607 /* Return the value of POSITION's property PROP, in OBJECT. 608 /* Return the value of char's property PROP, in OBJECT at POSITION.
608 OBJECT is optional and defaults to the current buffer. 609 OBJECT is optional and defaults to the current buffer.
609 If OVERLAY is non-0, then in the case that the returned property is from 610 If OVERLAY is non-0, then in the case that the returned property is from
610 an overlay, the overlay found is returned in *OVERLAY, otherwise nil is 611 an overlay, the overlay found is returned in *OVERLAY, otherwise nil is
611 returned in *OVERLAY. 612 returned in *OVERLAY.
612 If POSITION is at the end of OBJECT, the value is nil. 613 If POSITION is at the end of OBJECT, the value is nil.
636 if (BUFFERP (object)) 637 if (BUFFERP (object))
637 { 638 {
638 int posn = XINT (position); 639 int posn = XINT (position);
639 int noverlays; 640 int noverlays;
640 Lisp_Object *overlay_vec, tem; 641 Lisp_Object *overlay_vec, tem;
641 int next_overlay;
642 int len; 642 int len;
643 struct buffer *obuf = current_buffer; 643 struct buffer *obuf = current_buffer;
644 644
645 set_buffer_temp (XBUFFER (object)); 645 set_buffer_temp (XBUFFER (object));
646 646
647 /* First try with room for 40 overlays. */ 647 /* First try with room for 40 overlays. */
648 len = 40; 648 len = 40;
649 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); 649 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
650 650
651 noverlays = overlays_at (posn, 0, &overlay_vec, &len, 651 noverlays = overlays_at (posn, 0, &overlay_vec, &len,
652 &next_overlay, NULL, 0); 652 NULL, NULL, 0);
653 653
654 /* If there are more than 40, 654 /* If there are more than 40,
655 make enough space for all, and try again. */ 655 make enough space for all, and try again. */
656 if (noverlays > len) 656 if (noverlays > len)
657 { 657 {
658 len = noverlays; 658 len = noverlays;
659 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); 659 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
660 noverlays = overlays_at (posn, 0, &overlay_vec, &len, 660 noverlays = overlays_at (posn, 0, &overlay_vec, &len,
661 &next_overlay, NULL, 0); 661 NULL, NULL, 0);
662 } 662 }
663 noverlays = sort_overlays (overlay_vec, noverlays, w); 663 noverlays = sort_overlays (overlay_vec, noverlays, w);
664 664
665 set_buffer_temp (obuf); 665 set_buffer_temp (obuf);
666 666
2049 2049
2050 tem = textget (i->plist, Qfront_sticky); 2050 tem = textget (i->plist, Qfront_sticky);
2051 if (TMEM (Qread_only, tem) 2051 if (TMEM (Qread_only, tem)
2052 || (NILP (Fplist_get (i->plist, Qread_only)) 2052 || (NILP (Fplist_get (i->plist, Qread_only))
2053 && TMEM (Qcategory, tem))) 2053 && TMEM (Qcategory, tem)))
2054 text_read_only (); 2054 text_read_only (after);
2055 } 2055 }
2056 } 2056 }
2057 2057
2058 if (! NULL_INTERVAL_P (prev)) 2058 if (! NULL_INTERVAL_P (prev))
2059 { 2059 {
2069 2069
2070 tem = textget (prev->plist, Qrear_nonsticky); 2070 tem = textget (prev->plist, Qrear_nonsticky);
2071 if (! TMEM (Qread_only, tem) 2071 if (! TMEM (Qread_only, tem)
2072 && (! NILP (Fplist_get (prev->plist,Qread_only)) 2072 && (! NILP (Fplist_get (prev->plist,Qread_only))
2073 || ! TMEM (Qcategory, tem))) 2073 || ! TMEM (Qcategory, tem)))
2074 text_read_only (); 2074 text_read_only (before);
2075 } 2075 }
2076 } 2076 }
2077 } 2077 }
2078 else if (! NULL_INTERVAL_P (i)) 2078 else if (! NULL_INTERVAL_P (i))
2079 { 2079 {
2088 2088
2089 tem = textget (i->plist, Qfront_sticky); 2089 tem = textget (i->plist, Qfront_sticky);
2090 if (TMEM (Qread_only, tem) 2090 if (TMEM (Qread_only, tem)
2091 || (NILP (Fplist_get (i->plist, Qread_only)) 2091 || (NILP (Fplist_get (i->plist, Qread_only))
2092 && TMEM (Qcategory, tem))) 2092 && TMEM (Qcategory, tem)))
2093 text_read_only (); 2093 text_read_only (after);
2094 2094
2095 tem = textget (prev->plist, Qrear_nonsticky); 2095 tem = textget (prev->plist, Qrear_nonsticky);
2096 if (! TMEM (Qread_only, tem) 2096 if (! TMEM (Qread_only, tem)
2097 && (! NILP (Fplist_get (prev->plist, Qread_only)) 2097 && (! NILP (Fplist_get (prev->plist, Qread_only))
2098 || ! TMEM (Qcategory, tem))) 2098 || ! TMEM (Qcategory, tem)))
2099 text_read_only (); 2099 text_read_only (after);
2100 } 2100 }
2101 } 2101 }
2102 } 2102 }
2103 2103
2104 /* Run both insert hooks (just once if they're the same). */ 2104 /* Run both insert hooks (just once if they're the same). */
2116 2116
2117 i = find_interval (intervals, start); 2117 i = find_interval (intervals, start);
2118 do 2118 do
2119 { 2119 {
2120 if (! INTERVAL_WRITABLE_P (i)) 2120 if (! INTERVAL_WRITABLE_P (i))
2121 text_read_only (); 2121 text_read_only (textget (i->plist, Qread_only));
2122 2122
2123 if (!inhibit_modification_hooks) 2123 if (!inhibit_modification_hooks)
2124 { 2124 {
2125 mod_hooks = textget (i->plist, Qmodification_hooks); 2125 mod_hooks = textget (i->plist, Qmodification_hooks);
2126 if (! NILP (mod_hooks) && ! EQ (mod_hooks, prev_mod_hooks)) 2126 if (! NILP (mod_hooks) && ! EQ (mod_hooks, prev_mod_hooks))