for the text property PROP. */
static int
-text_property_eq (prop, pos1, pos2)
+char_property_eq (prop, pos1, pos2)
Lisp_Object prop;
Lisp_Object pos1, pos2;
{
Lisp_Object pval1, pval2;
- pval1 = Fget_text_property (pos1, prop, Qnil);
- pval2 = Fget_text_property (pos2, prop, Qnil);
+ pval1 = Fget_char_property (pos1, prop, Qnil);
+ pval2 = Fget_char_property (pos2, prop, Qnil);
return EQ (pval1, pval2);
}
-/* Return the direction from which the text-property PROP would be
+/* Return the direction from which the char-property PROP would be
inherited by any new text inserted at POS: 1 if it would be
inherited from the char after POS, -1 if it would be inherited from
the char before POS, and 0 if from neither. */
static int
-text_property_stickiness (prop, pos)
+char_property_stickiness (prop, pos)
Lisp_Object prop;
Lisp_Object pos;
{
Lisp_Object prev_pos, rear_non_sticky;
prev_pos = make_number (XINT (pos) - 1);
- rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil);
+ rear_non_sticky = Fget_char_property (prev_pos, Qrear_nonsticky, Qnil);
if (EQ (rear_non_sticky, Qnil)
|| (CONSP (rear_non_sticky)
- && !Fmemq (prop, rear_non_sticky)))
+ && NILP (Fmemq (prop, rear_non_sticky))))
/* PROP is not rear-non-sticky, and since this takes precedence over
any front-stickiness, PROP is inherited from before. */
return -1;
}
/* Consider following character. */
- front_sticky = Fget_text_property (pos, Qfront_sticky, Qnil);
+ front_sticky = Fget_char_property (pos, Qfront_sticky, Qnil);
if (EQ (front_sticky, Qt)
|| (CONSP (front_sticky)
- && Fmemq (prop, front_sticky)))
+ && !NILP (Fmemq (prop, front_sticky))))
/* PROP is inherited from after. */
return 1;
/* First see if POS is actually *at* a boundary. */
Lisp_Object after_field, before_field;
- after_field = Fget_text_property (pos, Qfield, Qnil);
- before_field = Fget_text_property (make_number (XINT (pos) - 1),
+ after_field = Fget_char_property (pos, Qfield, Qnil);
+ before_field = Fget_char_property (make_number (XINT (pos) - 1),
Qfield, Qnil);
if (! EQ (after_field, before_field))
/* We are at a boundary, see which direction is inclusive. */
{
- int stickiness = text_property_stickiness (Qfield, pos);
+ int stickiness = char_property_stickiness (Qfield, pos);
if (stickiness > 0)
at_field_start = 1;
at_field_end = 1;
else
/* STICKINESS == 0 means that any inserted text will get a
- `field' text-property of nil, so check to see if that
+ `field' char-property of nil, so check to see if that
matches either of the adjacent characters (this being a
kind of "stickiness by default"). */
{
/* Find the previous field boundary. */
{
Lisp_Object prev;
- prev = Fprevious_single_property_change (pos, Qfield, Qnil, Qnil);
+ prev =
+ Fprevious_single_char_property_change (pos, Qfield, Qnil, Qnil);
*beg = NILP (prev) ? BEGV : XFASTINT (prev);
}
}
/* Find the next field boundary. */
{
Lisp_Object next;
- next = Fnext_single_property_change (pos, Qfield, Qnil, Qnil);
+ next = Fnext_single_char_property_change (pos, Qfield, Qnil, Qnil);
*end = NILP (next) ? ZV : XFASTINT (next);
}
}
If OLD-POS is at the boundary of two fields, then the allowable\n\
positions for NEW-POS depends on the value of the optional argument\n\
ESCAPE-FROM-EDGE: If ESCAPE-FROM-EDGE is nil, then NEW-POS is\n\
-constrained to the field that has the same `field' text-property\n\
+constrained to the field that has the same `field' char-property\n\
as any new characters inserted at OLD-POS, whereas if ESCAPE-FROM-EDGE\n\
is non-nil, NEW-POS is constrained to the union of the two adjacent\n\
fields.\n\
if (NILP (Vinhibit_field_text_motion)
&& !EQ (new_pos, old_pos)
- && !text_property_eq (Qfield, new_pos, old_pos))
+ && !char_property_eq (Qfield, new_pos, old_pos))
/* NEW_POS is not within the same field as OLD_POS; try to
move NEW_POS so that it is. */
{
\f
DEFUN ("following-char", Ffollowing_char, Sfollowing_char, 0, 0, 0,
"Return the character following point, as a number.\n\
-At the end of the buffer or accessible region, return 0.\n\
-If `enable-multibyte-characters' is nil or point is not\n\
- at character boundary, multibyte form is ignored,\n\
- and only one byte following point is returned as a character.")
+At the end of the buffer or accessible region, return 0.")
()
{
Lisp_Object temp;
DEFUN ("preceding-char", Fprevious_char, Sprevious_char, 0, 0, 0,
"Return the character preceding point, as a number.\n\
-At the beginning of the buffer or accessible region, return 0.\n\
-If `enable-multibyte-characters' is nil or point is not\n\
- at character boundary, multi-byte form is ignored,\n\
- and only one byte preceding point is returned as a character.")
+At the beginning of the buffer or accessible region, return 0.")
()
{
Lisp_Object temp;
#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER)
int maybe_byte_combining = COMBINING_NO;
int last_changed;
+ int multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
validate_region (&start, &end);
CHECK_NUMBER (fromchar, 2);
CHECK_NUMBER (tochar, 3);
- if (! NILP (current_buffer->enable_multibyte_characters))
+ if (multibyte_p)
{
len = CHAR_STRING (XFASTINT (fromchar), fromstr);
if (CHAR_STRING (XFASTINT (tochar), tostr) != len)
stop = end_byte;
}
p = BYTE_POS_ADDR (pos_byte);
- INC_POS (pos_byte_next);
+ if (multibyte_p)
+ INC_POS (pos_byte_next);
+ else
+ ++pos_byte_next;
if (pos_byte_next - pos_byte == len
&& p[0] == fromstr[0]
&& (len == 1
{
#ifdef HAVE_MENUS
if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
- && NILP (use_dialog_box))
+ && use_dialog_box)
return Fmessage_box (nargs, args);
#endif
return Fmessage (nargs, args);
}
else if (SYMBOLP (args[n]))
{
- XSETSTRING (args[n], XSYMBOL (args[n])->name);
+ /* Use a temp var to avoid problems when ENABLE_CHECKING
+ is turned on. */
+ struct Lisp_String *t = XSYMBOL (args[n])->name;
+ XSETSTRING (args[n], t);
if (STRING_MULTIBYTE (args[n]) && ! multibyte)
{
multibyte = 1;
&& !CHAR_HEAD_P (*((unsigned char *) p)))
maybe_combine_byte = 1;
this_nchars = strlen (p);
- p += this_nchars;
+ if (multibyte)
+ p += str_to_multibyte (p, buf + total - p, this_nchars);
+ else
+ p += this_nchars;
nchars += this_nchars;
}
}
new_len = make_number (info[n].end - info[n].start);
props = text_property_list (args[n], make_number (0), len, Qnil);
extend_property_ranges (props, len, new_len);
+ /* If successive arguments have properites, be sure that
+ the value of `composition' property be the copy. */
+ if (n > 1 && info[n - 1].end)
+ make_composition_value_copy (props);
add_text_properties_from_list (val, props,
make_number (info[n].start));
}
int start1_byte, start2_byte, len1_byte, len2_byte;
int gap, len1, len_mid, len2;
unsigned char *start1_addr, *start2_addr, *temp;
- int combined_before_bytes_1, combined_after_bytes_1;
- int combined_before_bytes_2, combined_after_bytes_2;
struct gcpro gcpro1, gcpro2;
INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2;
len1_byte = CHAR_TO_BYTE (end1) - start1_byte;
len2_byte = CHAR_TO_BYTE (end2) - start2_byte;
+#ifdef BYTE_COMBINING_DEBUG
if (end1 == start2)
{
- combined_before_bytes_2
- = count_combining_before (BYTE_POS_ADDR (start2_byte),
- len2_byte, start1, start1_byte);
- combined_before_bytes_1
- = count_combining_before (BYTE_POS_ADDR (start1_byte),
- len1_byte, end2, start2_byte + len2_byte);
- combined_after_bytes_1
- = count_combining_after (BYTE_POS_ADDR (start1_byte),
- len1_byte, end2, start2_byte + len2_byte);
- combined_after_bytes_2 = 0;
+ if (count_combining_before (BYTE_POS_ADDR (start2_byte),
+ len2_byte, start1, start1_byte)
+ || count_combining_before (BYTE_POS_ADDR (start1_byte),
+ len1_byte, end2, start2_byte + len2_byte)
+ || count_combining_after (BYTE_POS_ADDR (start1_byte),
+ len1_byte, end2, start2_byte + len2_byte))
+ abort ();
}
else
{
- combined_before_bytes_2
- = count_combining_before (BYTE_POS_ADDR (start2_byte),
- len2_byte, start1, start1_byte);
- combined_before_bytes_1
- = count_combining_before (BYTE_POS_ADDR (start1_byte),
- len1_byte, start2, start2_byte);
- combined_after_bytes_2
- = count_combining_after (BYTE_POS_ADDR (start2_byte),
- len2_byte, end1, start1_byte + len1_byte);
- combined_after_bytes_1
- = count_combining_after (BYTE_POS_ADDR (start1_byte),
- len1_byte, end2, start2_byte + len2_byte);
+ if (count_combining_before (BYTE_POS_ADDR (start2_byte),
+ len2_byte, start1, start1_byte)
+ || count_combining_before (BYTE_POS_ADDR (start1_byte),
+ len1_byte, start2, start2_byte)
+ || count_combining_after (BYTE_POS_ADDR (start2_byte),
+ len2_byte, end1, start1_byte + len1_byte)
+ || count_combining_after (BYTE_POS_ADDR (start1_byte),
+ len1_byte, end2, start2_byte + len2_byte))
+ abort ();
}
+#endif
- /* If any combining is going to happen, do this the stupid way,
- because replace handles combining properly. */
- if (combined_before_bytes_1 || combined_before_bytes_2
- || combined_after_bytes_1 || combined_after_bytes_2)
- {
- Lisp_Object text1, text2;
-
- text1 = text2 = Qnil;
- GCPRO2 (text1, text2);
-
- text1 = make_buffer_string_both (start1, start1_byte,
- end1, start1_byte + len1_byte, 1);
- text2 = make_buffer_string_both (start2, start2_byte,
- end2, start2_byte + len2_byte, 1);
-
- transpose_markers (start1, end1, start2, end2,
- start1_byte, start1_byte + len1_byte,
- start2_byte, start2_byte + len2_byte);
-
- replace_range (start2, end2, text1, 1, 0, 0);
- replace_range (start1, end1, text2, 1, 0, 0);
-
- UNGCPRO;
- return Qnil;
- }
-
/* Hmmm... how about checking to see if the gap is large
enough to use as the temporary storage? That would avoid an
allocation... interesting. Later, don't fool with it now. */