diff options
| author | Eli Zaretskii | 2016-07-08 22:34:34 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-07-08 22:34:34 +0300 |
| commit | d8a9c450cf4c575d21297885d6823920aec0482f (patch) | |
| tree | 35d2299a4dd5779e6c5afe2ed849c4942480c902 /src/textprop.c | |
| parent | d0c0b71d889ff223d2e5073b733f4047d541343b (diff) | |
| download | emacs-d8a9c450cf4c575d21297885d6823920aec0482f.tar.gz emacs-d8a9c450cf4c575d21297885d6823920aec0482f.zip | |
Yet another fix for copying properties by 'format'
* src/textprop.c (extend_property_ranges): Accept an additional
argument OLD_END, and only extend the end of a property range if
its original end is at OLD_END; all the other ranges are left
intact. (Bug#23897)
* src/editfns.c (styled_format): Pass the original length of the
string to 'extend_property_ranges'.
* src/intervals.h (extend_property_ranges): Adjust prototype.
* test/src/editfns-tests.el (format-properties): Add tests for
bug#23897.
Diffstat (limited to 'src/textprop.c')
| -rw-r--r-- | src/textprop.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/textprop.c b/src/textprop.c index aabd5671e76..7af8c698736 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -2043,18 +2043,19 @@ add_text_properties_from_list (Lisp_Object object, Lisp_Object list, Lisp_Object | |||
| 2043 | end-points to NEW_END. */ | 2043 | end-points to NEW_END. */ |
| 2044 | 2044 | ||
| 2045 | Lisp_Object | 2045 | Lisp_Object |
| 2046 | extend_property_ranges (Lisp_Object list, Lisp_Object new_end) | 2046 | extend_property_ranges (Lisp_Object list, Lisp_Object old_end, Lisp_Object new_end) |
| 2047 | { | 2047 | { |
| 2048 | Lisp_Object prev = Qnil, head = list; | 2048 | Lisp_Object prev = Qnil, head = list; |
| 2049 | ptrdiff_t max = XINT (new_end); | 2049 | ptrdiff_t max = XINT (new_end); |
| 2050 | 2050 | ||
| 2051 | for (; CONSP (list); prev = list, list = XCDR (list)) | 2051 | for (; CONSP (list); prev = list, list = XCDR (list)) |
| 2052 | { | 2052 | { |
| 2053 | Lisp_Object item, beg, end; | 2053 | Lisp_Object item, beg; |
| 2054 | ptrdiff_t end; | ||
| 2054 | 2055 | ||
| 2055 | item = XCAR (list); | 2056 | item = XCAR (list); |
| 2056 | beg = XCAR (item); | 2057 | beg = XCAR (item); |
| 2057 | end = XCAR (XCDR (item)); | 2058 | end = XINT (XCAR (XCDR (item))); |
| 2058 | 2059 | ||
| 2059 | if (XINT (beg) >= max) | 2060 | if (XINT (beg) >= max) |
| 2060 | { | 2061 | { |
| @@ -2065,12 +2066,14 @@ extend_property_ranges (Lisp_Object list, Lisp_Object new_end) | |||
| 2065 | else | 2066 | else |
| 2066 | XSETCDR (prev, XCDR (list)); | 2067 | XSETCDR (prev, XCDR (list)); |
| 2067 | } | 2068 | } |
| 2068 | else if (XINT (end) != max) | 2069 | else if ((end == XINT (old_end) && end != max) |
| 2070 | || end > max) | ||
| 2069 | { | 2071 | { |
| 2070 | /* Either the end-point is past the end of the new string, | 2072 | /* Either the end-point is past the end of the new string, |
| 2071 | and we need to discard the properties past the new end, | 2073 | and we need to discard the properties past the new end, |
| 2072 | or the caller is extending the property range, and we | 2074 | or the caller is extending the property range, and we |
| 2073 | should update the end-point to reflect that. */ | 2075 | should update all end-points that are on the old end of |
| 2076 | the range to reflect that. */ | ||
| 2074 | XSETCAR (XCDR (item), new_end); | 2077 | XSETCAR (XCDR (item), new_end); |
| 2075 | } | 2078 | } |
| 2076 | } | 2079 | } |