From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Robert J. Chassell" Newsgroups: gmane.emacs.devel Subject: Re: new *Help* argument highlighting Date: Mon, 10 May 2004 12:18:09 -0400 (EDT) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <20040510013534.F994.LEKTU@mi.madritel.es> <20040510020140.F99A.LEKTU@mi.madritel.es> Reply-To: bob@rattlesnake.com NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1084214800 28449 80.91.224.253 (10 May 2004 18:46:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 10 May 2004 18:46:40 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon May 10 20:46:29 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BNFnJ-0006jW-00 for ; Mon, 10 May 2004 20:46:29 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BNFnI-0008Dr-00 for ; Mon, 10 May 2004 20:46:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BNFcI-0006CL-RA for emacs-devel@quimby.gnus.org; Mon, 10 May 2004 14:35:06 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BNFLp-0002cF-6e for emacs-devel@gnu.org; Mon, 10 May 2004 14:18:05 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BNFJj-0002M8-US for emacs-devel@gnu.org; Mon, 10 May 2004 14:16:33 -0400 Original-Received: from [140.186.114.245] (helo=rattlesnake.com) by monty-python.gnu.org with esmtp (Exim 4.33) id 1BNDh6-0003I0-NV for emacs-devel@gnu.org; Mon, 10 May 2004 12:32:12 -0400 Original-Received: by rattlesnake.com via sendmail from stdin id (Debian Smail3.2.0.115) Mon, 10 May 2004 12:18:09 -0400 (EDT) Original-To: emacs-devel@gnu.org In-reply-to: (message from Stefan Monnier on 09 May 2004 20:25:13 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:23069 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23069 But playing with font size is pretty safe ... No, it is not. Bold sometimes causes problems... Yes, you are right. But the word `sometimes' is not accurate. Bold *always* causes a problem when I change font size to 10x20. In a mode line, `m' becomes unreadable. (That font size is best for the display I mostly use. Everything looks fine in the default font.) Back in December 2002, Miles Bader fixed the problem by providing a patch to emacs/src/xfaces.c and an Emacs Lisp file to load. The patch works fine. I have been incorporating it with the current xfaces.c source ever since. Because I do not understand it, I have held back from committing Miles' change. First, will someone who understands the patch review it? Or should I commit the merged version of xfaces.c and see whether it breaks others people's installations? Here is the patch itself. As I said, the patch works fine with the current CVS. 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 18 Dec 2002 05:26:34 -0000 @@ -422,6 +422,13 @@ Lisp_Object Vtty_defined_color_alist; +/* A list of functions to perturb faces before final realization. + They are passed a lisp-vector containing all the attributes of the + fully-specified face, and can change any that they wish. */ + +Lisp_Object Vrealize_face_filter_functions; + + /* 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. */ @@ -481,7 +488,7 @@ static unsigned char *xstrlwr P_ ((unsigned char *)); static void signal_error P_ ((char *, Lisp_Object)); static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); -static void load_face_font P_ ((struct frame *, struct face *, int)); +static void load_face_font P_ ((struct frame *, struct face *, Lisp_Object *, int)); static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); static void free_face_colors P_ ((struct frame *, struct face *)); static int face_color_gray_p P_ ((struct frame *, char *)); @@ -502,10 +509,10 @@ static int cmp_font_names P_ ((const void *, const void *)); static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int, struct face *, int)); -static struct face *realize_x_face P_ ((struct face_cache *, - Lisp_Object *, int, struct face *)); -static struct face *realize_tty_face P_ ((struct face_cache *, - Lisp_Object *, int)); +static void realize_x_face P_ ((struct face *, struct face_cache *, + Lisp_Object *, int, struct face *)); +static void realize_tty_face P_ ((struct face *, struct face_cache *, + Lisp_Object *, int)); static int realize_basic_faces P_ ((struct frame *)); static int realize_default_face P_ ((struct frame *)); static void realize_named_face P_ ((struct frame *, Lisp_Object, int)); @@ -1245,14 +1252,15 @@ #ifdef HAVE_WINDOW_SYSTEM -/* Load font of face FACE which is used on frame F to display - character C. The name of the font to load is determined by lface - and fontset of FACE. */ +/* Load font of face FACE with attributes ATTRS which is used on frame F to + display character C. The name of the font to load is determined by + lface and fontset of FACE. */ static void -load_face_font (f, face, c) +load_face_font (f, face, attrs, c) struct frame *f; struct face *face; + Lisp_Object *attrs; int c; { struct font_info *font_info = NULL; @@ -1262,7 +1270,7 @@ face->font_info_id = -1; face->font = NULL; - font_name = choose_face_font (f, face->lface, face->fontset, c, + font_name = choose_face_font (f, attrs, face->fontset, c, &needs_overstrike); if (!font_name) return; @@ -6678,6 +6686,11 @@ int former_face_id; { struct face *face; + /* The set of attributes this face is know by to the user, as opposed to + the set actually used to render the face. They're usually the same + as, but may be different if some attribute is changed by + realize-face-filter. */ + Lisp_Object *orig_attrs = attrs; /* LFACE must be fully specified. */ xassert (cache != NULL); @@ -6691,41 +6704,70 @@ free_realized_face (cache->f, former_face); } + if (CONSP (Vrealize_face_filter_functions)) + { + /* Call these user-defined functions to perturb the face attributes + before realization. */ + Lisp_Object filters, cycle_check; + Lisp_Object lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), + Qunspecified); + + bcopy (attrs, XVECTOR (lface)->contents, + LFACE_VECTOR_SIZE * (sizeof *attrs)); + + cycle_check = Qnil; + for (filters = Vrealize_face_filter_functions; + CONSP (filters); + filters = XCDR (filters)) + { + safe_call1 (XCAR (filters), lface); + cycle_check = CYCLE_CHECK (cycle_check, filters, 50); + if (NILP (cycle_check)) + break; /* cycle detected */ + } + + attrs = XVECTOR (lface)->contents; + } + + /* Allocate a new realized face. */ + face = make_realized_face (orig_attrs); + + /* Fill it in. */ if (FRAME_WINDOW_P (cache->f)) - face = realize_x_face (cache, attrs, c, base_face); + realize_x_face (face, cache, attrs, c, base_face); else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)) - face = realize_tty_face (cache, attrs, c); + realize_tty_face (face, cache, attrs, c); else abort (); /* Insert the new face. */ - cache_face (cache, face, lface_hash (attrs)); + cache_face (cache, face, lface_hash (orig_attrs)); #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (cache->f) && face->font == NULL) - load_face_font (cache->f, face, c); + load_face_font (cache->f, face, attrs, c); #endif /* HAVE_WINDOW_SYSTEM */ return face; } -/* Realize the fully-specified face with attributes ATTRS in face - cache CACHE for character C. Do it for X frame CACHE->f. If C is - a multibyte character, BASE_FACE is a face that has the same - attributes. Otherwise, BASE_FACE is ignored. If the new face - doesn't share font with the default face, a fontname is allocated - from the heap and set in `font_name' of the new face, but it is not - yet loaded here. Value is a pointer to the newly created realized - face. */ +/* Realize into FACE the fully-specified face with attributes ATTRS in face + cache CACHE for character C. Do it for X frame CACHE->f. If C is a + multibyte character, BASE_FACE is a face that has the same attributes. + Otherwise, BASE_FACE is ignored. If the new face doesn't share font + with the default face, a fontname is allocated from the heap and set in + `font_name' of the new face, but it is not yet loaded here. Value is a + pointer to the newly created realized face. */ -static struct face * -realize_x_face (cache, attrs, c, base_face) +static void +realize_x_face (face, cache, attrs, c, base_face) + struct face *face; struct face_cache *cache; Lisp_Object *attrs; int c; struct face *base_face; { #ifdef HAVE_WINDOW_SYSTEM - struct face *face, *default_face; + struct face *default_face; struct frame *f; Lisp_Object stipple, overline, strike_through, box; @@ -6733,9 +6775,6 @@ xassert (SINGLE_BYTE_CHAR_P (c) || base_face); - /* Allocate a new realized face. */ - face = make_realized_face (attrs); - f = cache->f; /* If C is a multibyte character, we share all face attirbutes with @@ -6751,7 +6790,7 @@ /* to force realize_face to load font */ face->font = NULL; - return face; + return; } /* Now we are realizing a face for ASCII (and unibyte) characters. */ @@ -6921,7 +6960,6 @@ face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h); xassert (FACE_SUITABLE_FOR_CHAR_P (face, c)); - return face; #endif /* HAVE_WINDOW_SYSTEM */ } @@ -7012,17 +7050,16 @@ } -/* Realize the fully-specified face with attributes ATTRS in face - cache CACHE for character C. Do it for TTY frame CACHE->f. Value is a - pointer to the newly created realized face. */ +/* Realize into FACE the fully-specified face with attributes ATTRS in face + cache CACHE for character C. Do it for TTY frame CACHE->f. */ -static struct face * -realize_tty_face (cache, attrs, c) +static void +realize_tty_face (face, cache, attrs, c) + struct face *face; struct face_cache *cache; Lisp_Object *attrs; int c; { - struct face *face; int weight, slant; int face_colors_defaulted = 0; struct frame *f = cache->f; @@ -7030,8 +7067,6 @@ /* Frame must be a termcap frame. */ xassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)); - /* Allocate a new realized face. */ - face = make_realized_face (attrs); face->font_name = FRAME_MSDOS_P (cache->f) ? "ms-dos" : "tty"; /* Map face attributes to TTY appearances. We map slant to @@ -7068,8 +7103,6 @@ && face->background == FACE_TTY_DEFAULT_FG_COLOR && face->foreground == FACE_TTY_DEFAULT_BG_COLOR) face->tty_bold_p = 0; - - return face; } @@ -7670,6 +7703,14 @@ Each element is a regular expression that matches names of fonts to ignore. */); Vface_ignored_fonts = Qnil; + + DEFVAR_LISP ("realize-face-filter-functions", + &Vrealize_face_filter_functions, + doc:/* A list of functions to perturb faces before final realization. +They are passed a lisp-vector containing all the attributes of the +fully-specified face, and can change any that they wish. */); + Vrealize_face_filter_functions = Qnil; + #ifdef HAVE_WINDOW_SYSTEM defsubr (&Sbitmap_spec_p); -- Robert J. Chassell Rattlesnake Enterprises As I slowly update it, bob@rattlesnake.com I rewrite a "What's New" segment for http://www.rattlesnake.com