X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/97a1bc6376397911333f1decc764379fce397728..d95ebe75a0471e700cfddecb68329f9970c128c4:/src/textprop.c diff --git a/src/textprop.c b/src/textprop.c index 4f13aefb1b..e2f9c53173 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -1,6 +1,6 @@ /* Interface code for dealing with text properties. - Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, + 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -16,8 +16,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ #include #include "lisp.h" @@ -637,30 +637,13 @@ get_char_property_and_overlay (position, prop, object, overlay) } if (BUFFERP (object)) { - int posn = XINT (position); int noverlays; - Lisp_Object *overlay_vec, tem; - int len; + Lisp_Object *overlay_vec; struct buffer *obuf = current_buffer; set_buffer_temp (XBUFFER (object)); - /* First try with room for 40 overlays. */ - len = 40; - overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); - - noverlays = overlays_at (posn, 0, &overlay_vec, &len, - NULL, NULL, 0); - - /* If there are more than 40, - make enough space for all, and try again. */ - if (noverlays > len) - { - len = noverlays; - overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); - noverlays = overlays_at (posn, 0, &overlay_vec, &len, - NULL, NULL, 0); - } + GET_OVERLAYS_AT (XINT (position), overlay_vec, noverlays, NULL, 0); noverlays = sort_overlays (overlay_vec, noverlays, w); set_buffer_temp (obuf); @@ -668,7 +651,7 @@ get_char_property_and_overlay (position, prop, object, overlay) /* Now check the overlays in order of decreasing priority. */ while (--noverlays >= 0) { - tem = Foverlay_get (overlay_vec[noverlays], prop); + Lisp_Object tem = Foverlay_get (overlay_vec[noverlays], prop); if (!NILP (tem)) { if (overlay) @@ -736,7 +719,7 @@ it finds a change in some text property, or the beginning or end of an overlay, and returns the position of that. If none is found, the function returns (point-max). -If the optional third argument LIMIT is non-nil, don't search +If the optional second argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT. */) (position, limit) Lisp_Object position, limit; @@ -746,7 +729,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */) temp = Fnext_overlay_change (position); if (! NILP (limit)) { - CHECK_NUMBER (limit); + CHECK_NUMBER_COERCE_MARKER (limit); if (XINT (limit) < XINT (temp)) temp = limit; } @@ -761,7 +744,7 @@ finds a change in some text property, or the beginning or end of an overlay, and returns the position of that. If none is found, the function returns (point-max). -If the optional third argument LIMIT is non-nil, don't search +If the optional second argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT. */) (position, limit) Lisp_Object position, limit; @@ -771,7 +754,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */) temp = Fprevious_overlay_change (position); if (! NILP (limit)) { - CHECK_NUMBER (limit); + CHECK_NUMBER_COERCE_MARKER (limit); if (XINT (limit) > XINT (temp)) temp = limit; } @@ -804,7 +787,10 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */) if (NILP (limit)) position = make_number (SCHARS (object)); else - position = limit; + { + CHECK_NUMBER (limit); + position = limit; + } } } else @@ -821,6 +807,8 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */) Fset_buffer (object); } + CHECK_NUMBER_COERCE_MARKER (position); + initial_value = Fget_char_property (position, prop, object); if (NILP (limit)) @@ -873,7 +861,10 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT. */) if (NILP (limit)) position = make_number (SCHARS (object)); else - position = limit; + { + CHECK_NUMBER (limit); + position = limit; + } } } else @@ -889,6 +880,8 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT. */) Fset_buffer (object); } + CHECK_NUMBER_COERCE_MARKER (position); + if (NILP (limit)) XSETFASTINT (limit, BUF_BEGV (current_buffer)); else @@ -1323,8 +1316,8 @@ the designated part of OBJECT. */) properties PROPERTIES. OBJECT is the buffer or string containing the text. OBJECT nil means use the current buffer. SIGNAL_AFTER_CHANGE_P nil means don't signal after changes. Value - is non-nil if properties were replaced; it is nil if there weren't - any properties to replace. */ + is nil if the function _detected_ that it did not replace any + properties, non-nil otherwise. */ Lisp_Object set_text_properties (start, end, properties, object, signal_after_change_p) @@ -1348,7 +1341,7 @@ set_text_properties (start, end, properties, object, signal_after_change_p) && XFASTINT (end) == SCHARS (object)) { if (! STRING_INTERVALS (object)) - return Qt; + return Qnil; STRING_SET_INTERVALS (object, NULL_INTERVAL); return Qt; @@ -1609,10 +1602,12 @@ Return t if any property was actually removed, nil otherwise. */) } } - if (BUFFERP (object)) - modify_region (XBUFFER (object), XINT (start), XINT (end)); - - /* We are at the beginning of an interval, with len to scan */ + /* We are at the beginning of an interval, with len to scan. + The flag `modified' records if changes have been made. + When object is a buffer, we must call modify_region before changes are + made and signal_after_change when we are done. + We call modify_region before calling remove_properties iff modified == 0, + and we call signal_after_change before returning iff modified != 0. */ for (;;) { if (i == 0) @@ -1621,10 +1616,20 @@ Return t if any property was actually removed, nil otherwise. */) if (LENGTH (i) >= len) { if (! interval_has_some_properties_list (properties, i)) - return modified ? Qt : Qnil; + if (modified) + { + if (BUFFERP (object)) + signal_after_change (XINT (start), XINT (end) - XINT (start), + XINT (end) - XINT (start)); + return Qt; + } + else + return Qnil; if (LENGTH (i) == len) { + if (!modified && BUFFERP (object)) + modify_region (XBUFFER (object), XINT (start), XINT (end)); remove_properties (Qnil, properties, i, object); if (BUFFERP (object)) signal_after_change (XINT (start), XINT (end) - XINT (start), @@ -1636,6 +1641,8 @@ Return t if any property was actually removed, nil otherwise. */) unchanged = i; i = split_interval_left (i, len); copy_properties (unchanged, i); + if (!modified && BUFFERP (object)) + modify_region (XBUFFER (object), XINT (start), XINT (end)); remove_properties (Qnil, properties, i, object); if (BUFFERP (object)) signal_after_change (XINT (start), XINT (end) - XINT (start), @@ -1643,8 +1650,14 @@ Return t if any property was actually removed, nil otherwise. */) return Qt; } + if (interval_has_some_properties_list (properties, i)) + { + if (!modified && BUFFERP (object)) + modify_region (XBUFFER (object), XINT (start), XINT (end)); + remove_properties (Qnil, properties, i, object); + modified = 1; + } len -= LENGTH (i); - modified += remove_properties (Qnil, properties, i, object); i = next_interval (i); } } @@ -2250,7 +2263,9 @@ If a character in a buffer has PROPERTY, new text inserted adjacent to the character doesn't inherit PROPERTY if NONSTICKINESS is non-nil, inherits it if NONSTICKINESS is nil. The front-sticky and rear-nonsticky properties of the character overrides NONSTICKINESS. */); - Vtext_property_default_nonsticky = Qnil; + /* Text property `syntax-table' should be nonsticky by default. */ + Vtext_property_default_nonsticky + = Fcons (Fcons (intern ("syntax-table"), Qt), Qnil); staticpro (&interval_insert_behind_hooks); staticpro (&interval_insert_in_front_hooks);