diff options
| author | Jimmy Aguilar Mena | 2019-10-25 01:52:16 +0200 |
|---|---|---|
| committer | Jimmy Aguilar Mena | 2019-10-29 14:34:00 +0100 |
| commit | 8ae2a3a46b9c4cd2126f3c6504c619892ffff6ce (patch) | |
| tree | f7dcea902071d9c88d6b563e112edbbad9fb82be | |
| parent | 0956a65e6f46a04f8fb2bce6e909ff6a10a1c016 (diff) | |
| download | emacs-8ae2a3a46b9c4cd2126f3c6504c619892ffff6ce.tar.gz emacs-8ae2a3a46b9c4cd2126f3c6504c619892ffff6ce.zip | |
Fix inherited :extend attribute in faces.
* src/xfaces.c (merge_face_vectors) : Add extra parameter ATTR_FILTER
with the same functionality than in merge_named_face. Update all
occurrences.
(merge_named_face): Remove condition to avoid call
`merge_face_vectors`.
| -rw-r--r-- | src/xfaces.c | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index 5a741ae8cc6..e4d19440bc9 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -2052,23 +2052,48 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid) | |||
| 2052 | be 0 when called from other places. If window W is non-NULL, use W | 2052 | be 0 when called from other places. If window W is non-NULL, use W |
| 2053 | to interpret face specifications. */ | 2053 | to interpret face specifications. */ |
| 2054 | static void | 2054 | static void |
| 2055 | merge_face_vectors (struct window *w, | 2055 | merge_face_vectors (struct window *w, struct frame *f, |
| 2056 | struct frame *f, Lisp_Object *from, Lisp_Object *to, | 2056 | const Lisp_Object *from, Lisp_Object *to, |
| 2057 | struct named_merge_point *named_merge_points) | 2057 | struct named_merge_point *named_merge_points, |
| 2058 | enum lface_attribute_index attr_filter) | ||
| 2058 | { | 2059 | { |
| 2059 | int i; | 2060 | int i; |
| 2060 | Lisp_Object font = Qnil; | 2061 | Lisp_Object font = Qnil; |
| 2061 | 2062 | ||
| 2063 | eassert (attr_filter < LFACE_VECTOR_SIZE); | ||
| 2064 | |||
| 2065 | /* When FROM sets attr_filter to nil explicitly we don't merge it. */ | ||
| 2066 | if (attr_filter > 0 && NILP(from[attr_filter])) | ||
| 2067 | return; | ||
| 2068 | |||
| 2062 | /* If FROM inherits from some other faces, merge their attributes into | 2069 | /* If FROM inherits from some other faces, merge their attributes into |
| 2063 | TO before merging FROM's direct attributes. Note that an :inherit | 2070 | TO before merging FROM's direct attributes. Note that an :inherit |
| 2064 | attribute of `unspecified' is the same as one of nil; we never | 2071 | attribute of `unspecified' is the same as one of nil; we never |
| 2065 | merge :inherit attributes, so nil is more correct, but lots of | 2072 | merge :inherit attributes, so nil is more correct, but lots of |
| 2066 | other code uses `unspecified' as a generic value for face attributes. */ | 2073 | other code uses `unspecified' as a generic value for face |
| 2067 | if (!UNSPECIFIEDP (from[LFACE_INHERIT_INDEX]) | 2074 | attributes. */ |
| 2068 | && !NILP (from[LFACE_INHERIT_INDEX])) | 2075 | if (!NILP (from[LFACE_INHERIT_INDEX]) |
| 2069 | merge_face_ref (w, f, from[LFACE_INHERIT_INDEX], | 2076 | && !UNSPECIFIEDP (from[LFACE_INHERIT_INDEX])) |
| 2070 | to, false, named_merge_points, | 2077 | { |
| 2071 | 0); | 2078 | if (attr_filter == 0 /* No Filter */ |
| 2079 | || !UNSPECIFIEDP (from[attr_filter])) /* FROM specifies filter */ | ||
| 2080 | merge_face_ref (w, f, from[LFACE_INHERIT_INDEX], | ||
| 2081 | to, false, named_merge_points, 0); | ||
| 2082 | else if (UNSPECIFIEDP (from[attr_filter])) /* FROM don't specify filter */ | ||
| 2083 | { | ||
| 2084 | Lisp_Object tmp[LFACE_VECTOR_SIZE]; | ||
| 2085 | memcpy (tmp, to, LFACE_VECTOR_SIZE * sizeof *tmp); | ||
| 2086 | |||
| 2087 | merge_face_ref (w, f, from[LFACE_INHERIT_INDEX], | ||
| 2088 | tmp, false, named_merge_points, 0); | ||
| 2089 | |||
| 2090 | if (NILP (tmp[attr_filter]) | ||
| 2091 | || UNSPECIFIEDP (tmp[attr_filter])) | ||
| 2092 | return; | ||
| 2093 | |||
| 2094 | memcpy (to, tmp, LFACE_VECTOR_SIZE * sizeof *to); | ||
| 2095 | } | ||
| 2096 | } | ||
| 2072 | 2097 | ||
| 2073 | if (FONT_SPEC_P (from[LFACE_FONT_INDEX])) | 2098 | if (FONT_SPEC_P (from[LFACE_FONT_INDEX])) |
| 2074 | { | 2099 | { |
| @@ -2092,8 +2117,8 @@ merge_face_vectors (struct window *w, | |||
| 2092 | to[i] = from[i]; | 2117 | to[i] = from[i]; |
| 2093 | if (i >= LFACE_FAMILY_INDEX && i <=LFACE_SLANT_INDEX) | 2118 | if (i >= LFACE_FAMILY_INDEX && i <=LFACE_SLANT_INDEX) |
| 2094 | font_clear_prop (to, | 2119 | font_clear_prop (to, |
| 2095 | (i == LFACE_FAMILY_INDEX ? FONT_FAMILY_INDEX | 2120 | (i == LFACE_FAMILY_INDEX ? FONT_FAMILY_INDEX |
| 2096 | : i == LFACE_FOUNDRY_INDEX ? FONT_FOUNDRY_INDEX | 2121 | : i == LFACE_FOUNDRY_INDEX ? FONT_FOUNDRY_INDEX |
| 2097 | : i == LFACE_SWIDTH_INDEX ? FONT_WIDTH_INDEX | 2122 | : i == LFACE_SWIDTH_INDEX ? FONT_WIDTH_INDEX |
| 2098 | : i == LFACE_HEIGHT_INDEX ? FONT_SIZE_INDEX | 2123 | : i == LFACE_HEIGHT_INDEX ? FONT_SIZE_INDEX |
| 2099 | : i == LFACE_WEIGHT_INDEX ? FONT_WEIGHT_INDEX | 2124 | : i == LFACE_WEIGHT_INDEX ? FONT_WEIGHT_INDEX |
| @@ -2140,19 +2165,15 @@ merge_named_face (struct window *w, | |||
| 2140 | struct named_merge_point named_merge_point; | 2165 | struct named_merge_point named_merge_point; |
| 2141 | 2166 | ||
| 2142 | if (push_named_merge_point (&named_merge_point, | 2167 | if (push_named_merge_point (&named_merge_point, |
| 2143 | face_name, NAMED_MERGE_POINT_NORMAL, | 2168 | face_name, NAMED_MERGE_POINT_NORMAL, |
| 2144 | &named_merge_points)) | 2169 | &named_merge_points)) |
| 2145 | { | 2170 | { |
| 2146 | Lisp_Object from[LFACE_VECTOR_SIZE]; | 2171 | Lisp_Object from[LFACE_VECTOR_SIZE]; |
| 2147 | bool ok = get_lface_attributes (w, f, face_name, from, false, | 2172 | bool ok = get_lface_attributes (w, f, face_name, from, false, |
| 2148 | named_merge_points); | 2173 | named_merge_points); |
| 2149 | 2174 | ||
| 2150 | eassert (attr_filter < LFACE_VECTOR_SIZE); | 2175 | if (ok && (attr_filter == 0 || !NILP(from[attr_filter]))) |
| 2151 | 2176 | merge_face_vectors (w, f, from, to, named_merge_points, attr_filter); | |
| 2152 | if (ok && (attr_filter == 0 | ||
| 2153 | || (!NILP (from[attr_filter]) | ||
| 2154 | && !UNSPECIFIEDP (from[attr_filter])))) | ||
| 2155 | merge_face_vectors (w, f, from, to, named_merge_points); | ||
| 2156 | 2177 | ||
| 2157 | return ok; | 2178 | return ok; |
| 2158 | } | 2179 | } |
| @@ -3851,7 +3872,7 @@ Default face attributes override any local face attributes. */) | |||
| 3851 | /* Ensure that the face vector is fully specified by merging | 3872 | /* Ensure that the face vector is fully specified by merging |
| 3852 | the previously-cached vector. */ | 3873 | the previously-cached vector. */ |
| 3853 | memcpy (attrs, oldface->lface, sizeof attrs); | 3874 | memcpy (attrs, oldface->lface, sizeof attrs); |
| 3854 | merge_face_vectors (NULL, f, lvec, attrs, 0); | 3875 | merge_face_vectors (NULL, f, lvec, attrs, 0, 0); |
| 3855 | vcopy (local_lface, 0, attrs, LFACE_VECTOR_SIZE); | 3876 | vcopy (local_lface, 0, attrs, LFACE_VECTOR_SIZE); |
| 3856 | newface = realize_face (c, lvec, DEFAULT_FACE_ID); | 3877 | newface = realize_face (c, lvec, DEFAULT_FACE_ID); |
| 3857 | 3878 | ||
| @@ -4607,7 +4628,7 @@ lookup_named_face (struct window *w, struct frame *f, | |||
| 4607 | return -1; | 4628 | return -1; |
| 4608 | 4629 | ||
| 4609 | memcpy (attrs, default_face->lface, sizeof attrs); | 4630 | memcpy (attrs, default_face->lface, sizeof attrs); |
| 4610 | merge_face_vectors (w, f, symbol_attrs, attrs, 0); | 4631 | merge_face_vectors (w, f, symbol_attrs, attrs, 0, 0); |
| 4611 | 4632 | ||
| 4612 | return lookup_face (f, attrs); | 4633 | return lookup_face (f, attrs); |
| 4613 | } | 4634 | } |
| @@ -4776,7 +4797,7 @@ lookup_derived_face (struct window *w, | |||
| 4776 | 4797 | ||
| 4777 | default_face = FACE_FROM_ID (f, face_id); | 4798 | default_face = FACE_FROM_ID (f, face_id); |
| 4778 | memcpy (attrs, default_face->lface, sizeof attrs); | 4799 | memcpy (attrs, default_face->lface, sizeof attrs); |
| 4779 | merge_face_vectors (w, f, symbol_attrs, attrs, 0); | 4800 | merge_face_vectors (w, f, symbol_attrs, attrs, 0, 0); |
| 4780 | return lookup_face (f, attrs); | 4801 | return lookup_face (f, attrs); |
| 4781 | } | 4802 | } |
| 4782 | 4803 | ||
| @@ -4874,7 +4895,7 @@ gui_supports_face_attributes_p (struct frame *f, | |||
| 4874 | 4895 | ||
| 4875 | memcpy (merged_attrs, def_attrs, sizeof merged_attrs); | 4896 | memcpy (merged_attrs, def_attrs, sizeof merged_attrs); |
| 4876 | 4897 | ||
| 4877 | merge_face_vectors (NULL, f, attrs, merged_attrs, 0); | 4898 | merge_face_vectors (NULL, f, attrs, merged_attrs, 0, 0); |
| 4878 | 4899 | ||
| 4879 | face_id = lookup_face (f, merged_attrs); | 4900 | face_id = lookup_face (f, merged_attrs); |
| 4880 | face = FACE_FROM_ID_OR_NULL (f, face_id); | 4901 | face = FACE_FROM_ID_OR_NULL (f, face_id); |
| @@ -5519,7 +5540,7 @@ realize_named_face (struct frame *f, Lisp_Object symbol, int id) | |||
| 5519 | 5540 | ||
| 5520 | /* Merge SYMBOL's face with the default face. */ | 5541 | /* Merge SYMBOL's face with the default face. */ |
| 5521 | get_lface_attributes_no_remap (f, symbol, symbol_attrs, true); | 5542 | get_lface_attributes_no_remap (f, symbol, symbol_attrs, true); |
| 5522 | merge_face_vectors (NULL, f, symbol_attrs, attrs, 0); | 5543 | merge_face_vectors (NULL, f, symbol_attrs, attrs, 0, 0); |
| 5523 | 5544 | ||
| 5524 | /* Realize the face. */ | 5545 | /* Realize the face. */ |
| 5525 | realize_face (c, attrs, id); | 5546 | realize_face (c, attrs, id); |
| @@ -6386,7 +6407,7 @@ merge_faces (struct window *w, Lisp_Object face_name, int face_id, | |||
| 6386 | if (!face) | 6407 | if (!face) |
| 6387 | return base_face_id; | 6408 | return base_face_id; |
| 6388 | 6409 | ||
| 6389 | merge_face_vectors (w, f, face->lface, attrs, 0); | 6410 | merge_face_vectors (w, f, face->lface, attrs, 0, 0); |
| 6390 | } | 6411 | } |
| 6391 | 6412 | ||
| 6392 | /* Look up a realized face with the given face attributes, | 6413 | /* Look up a realized face with the given face attributes, |