unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Robert J. Chassell" <bob@rattlesnake.com>
Subject: Re: new *Help* argument highlighting
Date: Mon, 10 May 2004 12:18:09 -0400 (EDT)	[thread overview]
Message-ID: <m1BNDTl-000UNSC@rattlesnake.com> (raw)
In-Reply-To: <jwvwu3l6sn8.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on 09 May 2004 20:25:13 -0400)

    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

  parent reply	other threads:[~2004-05-10 16:18 UTC|newest]

Thread overview: 173+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-07  5:32 new *Help* argument highlighting Miles Bader
2004-05-07  8:39 ` Juanma Barranquero
2004-05-08 22:22   ` Juri Linkov
2004-05-08 23:32     ` Juanma Barranquero
2004-05-08 23:47       ` Juri Linkov
2004-05-09  0:14         ` Juanma Barranquero
2004-05-08 23:49       ` Miles Bader
2004-05-09  0:09         ` Juanma Barranquero
2004-05-09 18:47     ` Richard Stallman
2004-05-09 22:25       ` Miles Bader
2004-05-09 22:54         ` Juanma Barranquero
2004-05-09 23:10           ` Stefan Monnier
2004-05-09 23:48             ` Juanma Barranquero
2004-05-10  0:00               ` Stefan Monnier
2004-05-10  0:11                 ` Juanma Barranquero
2004-05-10  0:25                   ` Stefan Monnier
2004-05-10  0:53                     ` Juanma Barranquero
2004-05-10  1:32                       ` Miles Bader
2004-05-10  7:24                         ` Juanma Barranquero
2004-05-10  2:42                       ` Stefan Monnier
2004-05-10  7:37                         ` Juanma Barranquero
2004-05-10 12:45                           ` Thien-Thi Nguyen
2004-05-10 13:01                             ` Juanma Barranquero
2004-05-10 16:18                     ` Robert J. Chassell [this message]
2004-05-10 19:06                       ` Stefan Monnier
2004-05-10 21:54                         ` Robert J. Chassell
2004-05-11 15:57                           ` Juri Linkov
2004-05-11 20:58                             ` Miles Bader
2004-05-11 21:51                               ` Juri Linkov
2004-05-11 22:58                                 ` Miles Bader
2004-05-11 22:08                             ` Robert J. Chassell
2004-05-11  0:07                         ` Juri Linkov
2004-05-11  2:30                           ` Stefan Monnier
2004-05-11 15:28                             ` Juri Linkov
2004-05-11 17:44                               ` Stefan Monnier
2004-05-10 17:54         ` Richard Stallman
2004-05-10 21:10           ` Juanma Barranquero
2004-05-10 21:28             ` David Kastrup
2004-05-10 21:41               ` Juanma Barranquero
2004-05-10 21:59                 ` Stefan Monnier
2004-05-10 22:12                   ` Juanma Barranquero
2004-05-10 21:47               ` Juanma Barranquero
2004-05-10 21:57                 ` David Kastrup
2004-05-10 22:10                   ` Juanma Barranquero
2004-05-10 22:26                     ` Miles Bader
2004-05-11  8:11                       ` Juanma Barranquero
2004-05-12  7:51                         ` Richard Stallman
2004-05-12  8:15                           ` Miles Bader
2004-05-12  8:58                             ` Juanma Barranquero
2004-05-12  9:25                               ` Miles Bader
2004-05-12  9:32                                 ` Juanma Barranquero
2004-05-13 15:45                                   ` Richard Stallman
2004-05-13 17:33                                     ` David Kastrup
2004-05-13 15:45                               ` Richard Stallman
2004-06-11 10:53                                 ` Bug tracking (was: new *Help* argument highlighting) Juanma Barranquero
2004-06-11 11:20                                   ` Bug tracking Lars Hansen
2004-06-11 11:33                                     ` Juanma Barranquero
2004-06-11 11:39                                   ` Bug tracking (was: new *Help* argument highlighting) Kim F. Storm
2004-06-11 12:40                                     ` Bug tracking Juanma Barranquero
2004-06-11 14:21                                     ` Bug tracking (was: new *Help* argument highlighting) Miles Bader
2004-06-11 15:11                                       ` Kim F. Storm
2004-06-11 22:29                                         ` Miles Bader
2004-06-12  9:45                                       ` Richard Stallman
2004-06-12  1:50                                   ` Richard Stallman
2004-06-12  2:12                                     ` Juanma Barranquero
2004-06-12  8:15                                       ` Lars Hansen
2004-06-13  0:01                                       ` Richard Stallman
2004-06-13  0:20                                         ` Juanma Barranquero
2004-06-12  8:37                                     ` Bug tracking Juri Linkov
2004-06-12  9:38                                       ` Lars Hansen
2004-06-12 15:28                                         ` Juri Linkov
2004-06-14 13:52                                           ` Kim F. Storm
2004-06-14 15:09                                             ` Juri Linkov
2004-06-14 15:38                                               ` Juanma Barranquero
2004-06-14 16:32                                                 ` Juri Linkov
2004-06-13  0:01                                         ` Richard Stallman
2004-06-13  0:05                                           ` Juanma Barranquero
2004-06-13 11:55                                           ` Kai Grossjohann
2004-06-13 14:34                                             ` Juanma Barranquero
2004-06-13 16:04                                               ` Juri Linkov
2004-06-14 18:50                                             ` Richard Stallman
2004-06-14 21:41                                               ` Juanma Barranquero
2004-06-14 23:09                                                 ` Kim F. Storm
2004-06-14 23:33                                                   ` Miles Bader
2004-06-15  8:11                                                     ` Kim F. Storm
2004-06-16 16:57                                                 ` Richard Stallman
2004-06-13 22:26                                           ` Kim F. Storm
2004-06-13 23:52                                             ` Miles Bader
2004-06-12 12:47                                       ` Juanma Barranquero
2004-06-12 15:38                                         ` Juri Linkov
2004-06-12 22:09                                           ` Juanma Barranquero
2004-06-12 23:06                                             ` Miles Bader
2004-06-13  0:08                                               ` Juanma Barranquero
2004-06-13  0:50                                                 ` Miles Bader
2004-06-13  1:07                                                   ` Juanma Barranquero
2004-06-13 16:00                                                     ` Juri Linkov
2004-06-13 22:52                                                       ` Juanma Barranquero
2004-06-13 23:56                                                         ` Miles Bader
2004-06-14  7:20                                                           ` Juanma Barranquero
2004-06-14  7:31                                                             ` Juanma Barranquero
2004-06-14 16:40                                                             ` Thien-Thi Nguyen
2004-06-14 21:36                                                               ` Juanma Barranquero
2004-06-15  1:36                                                                 ` Thien-Thi Nguyen
2004-06-15 13:58                                                                   ` Juanma Barranquero
2004-06-13 21:49                                         ` Richard Stallman
2004-06-13 23:03                                           ` Juanma Barranquero
2004-06-13  0:01                                       ` Richard Stallman
2004-06-12 18:26                                   ` Bug tracking (was: new *Help* argument highlighting) Karl Fogel
2004-06-12 20:03                                     ` Karl Fogel
2004-06-13  2:39                                       ` Miles Bader
2004-06-12 21:01                                         ` Karl Fogel
2004-06-13  3:34                                           ` Miles Bader
2004-06-12 21:52                                             ` Karl Fogel
2004-06-13 11:31                                             ` Bug tracking Juanma Barranquero
2004-06-13 13:28                                               ` Miles Bader
2004-06-13 14:38                                                 ` Juanma Barranquero
2004-06-13 12:19                                             ` Bug tracking (was: new *Help* argument highlighting) Jason Rumney
2004-06-13  9:06                                         ` David Kastrup
2004-06-13 14:26                                         ` Robert J. Chassell
2004-06-13 14:36                                           ` Karl Fogel
2004-06-13 23:29                                             ` Robert J. Chassell
2004-06-13 14:29                                         ` Bug tracking Oliver Scholz
2004-06-14 18:50                                           ` Richard Stallman
2004-06-14 21:17                                             ` Tak Ota
2004-06-16 16:57                                               ` Richard Stallman
2004-06-16 17:59                                                 ` Tak Ota
2004-06-14 18:50                                     ` Bug tracking (was: new *Help* argument highlighting) Richard Stallman
2004-06-14 20:19                                       ` Karl Fogel
2004-06-16 16:58                                         ` Richard Stallman
2004-05-12 10:47                             ` new *Help* argument highlighting Kenichi Handa
2004-05-12 11:10                               ` Juanma Barranquero
2004-05-12 11:25                                 ` Kenichi Handa
2004-05-12 11:47                                   ` Juanma Barranquero
2004-05-12 13:01                                     ` Kenichi Handa
2004-05-12 13:15                                       ` Juanma Barranquero
2004-05-12 14:06                                         ` Miles Bader
2004-05-12 13:09                                           ` Kim F. Storm
2004-05-12 22:18                                             ` Miles Bader
2004-05-17  1:14                                               ` Kenichi Handa
2004-05-17  2:30                                                 ` Miles Bader
2004-05-18 12:54                                                   ` Kenichi Handa
2004-05-17 14:46                                               ` Kim F. Storm
2004-05-17 22:23                                                 ` Miles Bader
2004-05-12 23:28                                           ` fill docstring (Re: new *Help* argument highlighting) Kenichi Handa
2004-05-17  1:16                                         ` new *Help* argument highlighting Kenichi Handa
2004-05-17  7:02                                           ` Juanma Barranquero
2004-05-17  7:16                                             ` Kenichi Handa
2004-05-12 12:53                                   ` Juanma Barranquero
2004-05-12 13:22                                     ` Kenichi Handa
2004-05-12 13:43                                       ` Juanma Barranquero
2004-05-11  9:02                       ` Juanma Barranquero
2004-05-10 23:42                 ` Kenichi Handa
2004-05-11  8:14                   ` Juanma Barranquero
2004-05-11 12:23             ` Richard Stallman
2004-05-11 13:56               ` Juanma Barranquero
2004-05-11 14:36                 ` David Kastrup
2004-05-11 14:53                   ` Juanma Barranquero
2004-05-12 19:40                 ` Richard Stallman
2004-05-12 20:12                   ` Stefan Monnier
2004-05-13  1:18                     ` Miles Bader
2004-05-13  1:30                     ` Juanma Barranquero
2004-05-13  1:41                       ` Stefan Monnier
2004-05-13  7:04                         ` Juanma Barranquero
2004-05-13 14:21                           ` Stefan Monnier
2004-05-13 21:25                             ` Juanma Barranquero
2004-05-13  1:25                   ` Juanma Barranquero
2004-05-14  9:20                     ` Richard Stallman
2004-05-11 16:51             ` Kevin Rodgers
2004-05-11 18:30               ` Juanma Barranquero
2004-05-12  0:04               ` Juanma Barranquero
2004-05-12 18:29                 ` Romain Francoise
2004-05-13  1:31                   ` Juanma Barranquero
2004-05-13  6:55                     ` Romain Francoise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1BNDTl-000UNSC@rattlesnake.com \
    --to=bob@rattlesnake.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).