diff options
| author | Kim F. Storm | 2005-04-28 13:14:06 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-04-28 13:14:06 +0000 |
| commit | d1bf13b33d0fdae7d66a5d5d0c37a66546c8f53a (patch) | |
| tree | e1702f53ffe34068de14afaf387cdca46a988cd7 | |
| parent | 0b606bb230f7db6392fa7d9dc4fe4aefcf7f460b (diff) | |
| download | emacs-d1bf13b33d0fdae7d66a5d5d0c37a66546c8f53a.tar.gz emacs-d1bf13b33d0fdae7d66a5d5d0c37a66546c8f53a.zip | |
(resolve_face_name): Add arg SIGNAL_P. Calls changed.
Fix cyclic alias check. If alias loop is detected, signal
circular-list error if SIGNAL_P, and return Qdefault if !SIGNAL_P.
| -rw-r--r-- | src/xfaces.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index 5c865be3000..0b0b2f97533 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -333,6 +333,8 @@ extern Lisp_Object Qmode_line; | |||
| 333 | 333 | ||
| 334 | Lisp_Object Qface_alias; | 334 | Lisp_Object Qface_alias; |
| 335 | 335 | ||
| 336 | extern Lisp_Object Qcircular_list; | ||
| 337 | |||
| 336 | /* Default stipple pattern used on monochrome displays. This stipple | 338 | /* Default stipple pattern used on monochrome displays. This stipple |
| 337 | pattern is used on monochrome displays instead of shades of gray | 339 | pattern is used on monochrome displays instead of shades of gray |
| 338 | for a face background color. See `set-face-stipple' for possible | 340 | for a face background color. See `set-face-stipple' for possible |
| @@ -468,7 +470,7 @@ struct named_merge_point; | |||
| 468 | 470 | ||
| 469 | static void map_tty_color P_ ((struct frame *, struct face *, | 471 | static void map_tty_color P_ ((struct frame *, struct face *, |
| 470 | enum lface_attribute_index, int *)); | 472 | enum lface_attribute_index, int *)); |
| 471 | static Lisp_Object resolve_face_name P_ ((Lisp_Object)); | 473 | static Lisp_Object resolve_face_name P_ ((Lisp_Object, int)); |
| 472 | static int may_use_scalable_font_p P_ ((const char *)); | 474 | static int may_use_scalable_font_p P_ ((const char *)); |
| 473 | static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); | 475 | static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); |
| 474 | static int better_font_p P_ ((int *, struct font_name *, struct font_name *, | 476 | static int better_font_p P_ ((int *, struct font_name *, struct font_name *, |
| @@ -3203,27 +3205,47 @@ push_named_merge_point (struct named_merge_point *new_named_merge_point, | |||
| 3203 | 3205 | ||
| 3204 | 3206 | ||
| 3205 | /* Resolve face name FACE_NAME. If FACE_NAME is a string, intern it | 3207 | /* Resolve face name FACE_NAME. If FACE_NAME is a string, intern it |
| 3206 | to make it a symvol. If FACE_NAME is an alias for another face, | 3208 | to make it a symbol. If FACE_NAME is an alias for another face, |
| 3207 | return that face's name. */ | 3209 | return that face's name. |
| 3210 | |||
| 3211 | Return default face in case of errors. */ | ||
| 3208 | 3212 | ||
| 3209 | static Lisp_Object | 3213 | static Lisp_Object |
| 3210 | resolve_face_name (face_name) | 3214 | resolve_face_name (face_name, signal_p) |
| 3211 | Lisp_Object face_name; | 3215 | Lisp_Object face_name; |
| 3216 | int signal_p; | ||
| 3212 | { | 3217 | { |
| 3213 | Lisp_Object aliased; | 3218 | Lisp_Object orig_face; |
| 3214 | int alias_loop_max = 10; | 3219 | Lisp_Object tortoise, hare; |
| 3215 | 3220 | ||
| 3216 | if (STRINGP (face_name)) | 3221 | if (STRINGP (face_name)) |
| 3217 | face_name = intern (SDATA (face_name)); | 3222 | face_name = intern (SDATA (face_name)); |
| 3218 | 3223 | ||
| 3219 | while (SYMBOLP (face_name)) | 3224 | if (NILP (face_name) || !SYMBOLP (face_name)) |
| 3225 | return face_name; | ||
| 3226 | |||
| 3227 | orig_face = face_name; | ||
| 3228 | tortoise = hare = face_name; | ||
| 3229 | |||
| 3230 | while (1) | ||
| 3220 | { | 3231 | { |
| 3221 | aliased = Fget (face_name, Qface_alias); | 3232 | face_name = hare; |
| 3222 | if (NILP (aliased)) | 3233 | hare = Fget (hare, Qface_alias); |
| 3234 | if (NILP (hare) || !SYMBOLP (hare)) | ||
| 3223 | break; | 3235 | break; |
| 3224 | if (--alias_loop_max == 0) | 3236 | |
| 3237 | face_name = hare; | ||
| 3238 | hare = Fget (hare, Qface_alias); | ||
| 3239 | if (NILP (hare) || !SYMBOLP (hare)) | ||
| 3225 | break; | 3240 | break; |
| 3226 | face_name = aliased; | 3241 | |
| 3242 | tortoise = Fget (tortoise, Qface_alias); | ||
| 3243 | if (EQ (hare, tortoise)) | ||
| 3244 | { | ||
| 3245 | if (signal_p) | ||
| 3246 | Fsignal (Qcircular_list, Fcons (orig_face, Qnil)); | ||
| 3247 | return Qdefault; | ||
| 3248 | } | ||
| 3227 | } | 3249 | } |
| 3228 | 3250 | ||
| 3229 | return face_name; | 3251 | return face_name; |
| @@ -3247,7 +3269,7 @@ lface_from_face_name (f, face_name, signal_p) | |||
| 3247 | { | 3269 | { |
| 3248 | Lisp_Object lface; | 3270 | Lisp_Object lface; |
| 3249 | 3271 | ||
| 3250 | face_name = resolve_face_name (face_name); | 3272 | face_name = resolve_face_name (face_name, signal_p); |
| 3251 | 3273 | ||
| 3252 | if (f) | 3274 | if (f) |
| 3253 | lface = assq_no_quit (face_name, f->face_alist); | 3275 | lface = assq_no_quit (face_name, f->face_alist); |
| @@ -3982,7 +4004,7 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 3982 | CHECK_SYMBOL (face); | 4004 | CHECK_SYMBOL (face); |
| 3983 | CHECK_SYMBOL (attr); | 4005 | CHECK_SYMBOL (attr); |
| 3984 | 4006 | ||
| 3985 | face = resolve_face_name (face); | 4007 | face = resolve_face_name (face, 1); |
| 3986 | 4008 | ||
| 3987 | /* If FRAME is 0, change face on all frames, and change the | 4009 | /* If FRAME is 0, change face on all frames, and change the |
| 3988 | default for new frames. */ | 4010 | default for new frames. */ |