Index: src/xfaces.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/xfaces.c,v retrieving revision 1.266 diff -u -r1.266 xfaces.c --- src/xfaces.c 17 Nov 2002 23:51:19 -0000 1.266 +++ src/xfaces.c 17 Dec 2002 04:31:36 -0000 @@ -422,6 +422,13 @@ Lisp_Object Vtty_defined_color_alist; +/* If non-nil, a function called to perturb faces before final realization. + It is passed a lisp-vector containing all the attributes of the + fully-specified face, and can change any that it wishes. */ + +Lisp_Object Vrealize_face_filter; + + /* Counter for calls to clear_face_cache. If this counter reaches CLEAR_FONT_TABLE_COUNT, and a frame has more than CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */ @@ -6691,6 +6698,21 @@ realize_face (cache, attrs, c, base_face free_realized_face (cache->f, former_face); } + if (! NILP (Vrealize_face_filter)) + { + /* Call a user-defined function to perturb the face attributes + before realization. */ + Lisp_Object lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), + Qunspecified); + bcopy (attrs, XVECTOR (lface)->contents, + LFACE_VECTOR_SIZE * (sizeof *attrs)); + + safe_call1 (Vrealize_face_filter, lface); + + bcopy (XVECTOR (lface)->contents, attrs, + LFACE_VECTOR_SIZE * (sizeof *attrs)); + } + if (FRAME_WINDOW_P (cache->f)) face = realize_x_face (cache, attrs, c, base_face); else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)) @@ -7670,6 +7692,13 @@ Each element is a regular expression that matches names of fonts to ignore. */); Vface_ignored_fonts = Qnil; + + DEFVAR_LISP ("realize-face-filter", &Vrealize_face_filter, + doc: /* If non-nil, a function called to perturb faces before final realization. +It is passed a lisp-vector containing all the attributes of the +fully-specified face, and can change any that it wishes. */); + Vrealize_face_filter = Qnil; + #ifdef HAVE_WINDOW_SYSTEM defsubr (&Sbitmap_spec_p);