tmp = Fassq (sym, Vtext_property_default_nonsticky);
use_left = (lpresent
&& ! (TMEM (sym, lrear)
- || CONSP (tmp) && ! NILP (XCDR (tmp))));
+ || (CONSP (tmp) && ! NILP (XCDR (tmp)))));
use_right = (TMEM (sym, rfront)
|| (CONSP (tmp) && NILP (XCDR (tmp))));
if (use_left && use_right)
tree = BUF_INTERVALS (buffer);
- /* If the new text has no properties, it becomes part of whatever
- interval it was inserted into. */
+ /* If the new text has no properties, then with inheritance it
+ becomes part of whatever interval it was inserted into.
+ To prevent inheritance, we must clear out the properties
+ of the newly inserted text. */
if (NULL_INTERVAL_P (source))
{
Lisp_Object buf;
- if (!inherit && ! NULL_INTERVAL_P (tree))
+ if (!inherit && !NULL_INTERVAL_P (tree) && length > 0)
{
- int saved_inhibit_modification_hooks = inhibit_modification_hooks;
XSETBUFFER (buf, buffer);
- inhibit_modification_hooks = 1;
- Fset_text_properties (make_number (position),
- make_number (position + length),
- Qnil, buf);
- inhibit_modification_hooks = saved_inhibit_modification_hooks;
+ set_text_properties_1 (make_number (position),
+ make_number (position + length),
+ Qnil, buf, 0);
}
if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer)))
BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer));
or end of the buffer, so don't bother checking in that case. */
&& charpos != BEGV && charpos != ZV)
{
- Lisp_Object intangible_propval;
+ Lisp_Object intangible_propval, invisible_propval;
Lisp_Object pos;
+ int invis_p;
XSETINT (pos, charpos);
if (backwards)
{
- intangible_propval = Fget_char_property (make_number (charpos),
- Qintangible, Qnil);
+ /* If the preceding char is both invisible and intangible,
+ start backing up from just before that one. */
+
+ intangible_propval
+ = Fget_char_property (make_number (charpos - 1),
+ Qintangible, Qnil);
+ invisible_propval
+ = Fget_char_property (make_number (charpos - 1), Qinvisible, Qnil);
+ invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval);
+
+ if (! NILP (intangible_propval) && invis_p)
+ XSETINT (pos, --charpos);
/* If following char is intangible,
skip back over all chars with matching intangible property. */
+
+ intangible_propval = Fget_char_property (pos, Qintangible, Qnil);
+
if (! NILP (intangible_propval))
- while (XINT (pos) > BUF_BEGV (buffer)
- && EQ (Fget_char_property (make_number (XINT (pos) - 1),
- Qintangible, Qnil),
- intangible_propval))
- pos = Fprevious_char_property_change (pos, Qnil);
+ {
+ while (XINT (pos) > BUF_BEGV (buffer)
+ && EQ (Fget_char_property (make_number (XINT (pos) - 1),
+ Qintangible, Qnil),
+ intangible_propval))
+ pos = Fprevious_char_property_change (pos, Qnil);
+ }
}
else
{
+ /* If preceding char is intangible,
+ skip forward over all chars with matching intangible property. */
+
intangible_propval = Fget_char_property (make_number (charpos - 1),
Qintangible, Qnil);
- /* If following char is intangible,
- skip forward over all chars with matching intangible property. */
if (! NILP (intangible_propval))
- while (XINT (pos) < BUF_ZV (buffer)
- && EQ (Fget_char_property (pos, Qintangible, Qnil),
- intangible_propval))
- pos = Fnext_char_property_change (pos, Qnil);
+ {
+ while (XINT (pos) < BUF_ZV (buffer)
+ && EQ (Fget_char_property (pos, Qintangible, Qnil),
+ intangible_propval))
+ pos = Fnext_char_property_change (pos, Qnil);
+ /* Is the last one invisible as well as intangible? */
+
+ invisible_propval
+ = Fget_char_property (make_number (XINT (pos) - 1),
+ Qinvisible, Qnil);
+ invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval);
+
+ /* If so, advance one character more:
+ don't stop after an invisible, intangible character. */
+
+ if (invis_p && XINT (pos) < BUF_ZV (buffer))
+ XSETINT (pos, XINT (pos) + 1);
+ }
}
charpos = XINT (pos);