From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Miles Bader Newsgroups: gmane.emacs.devel Subject: Re: Bold by moving pixels problem Date: 17 Dec 2002 14:00:09 +0900 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <20021120220834.GC29543@gnu.org> <200211210133.gAL1XiP23941@rum.cs.yale.edu> Reply-To: Miles Bader NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1040101481 29607 80.91.224.249 (17 Dec 2002 05:04:41 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 17 Dec 2002 05:04:41 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18O9uK-0007hN-00 for ; Tue, 17 Dec 2002 06:04:40 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18OA87-0002Mz-00 for ; Tue, 17 Dec 2002 06:18:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18O9ru-0001Jl-05 for emacs-devel@quimby.gnus.org; Tue, 17 Dec 2002 00:02:10 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18O9rS-0001HX-00 for emacs-devel@gnu.org; Tue, 17 Dec 2002 00:01:42 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18O9rP-0001Gg-00 for emacs-devel@gnu.org; Tue, 17 Dec 2002 00:01:41 -0500 Original-Received: from tyo202.gate.nec.co.jp ([202.32.8.202]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18O9qc-0000hE-00; Tue, 17 Dec 2002 00:00:50 -0500 Original-Received: from mailgate4.nec.co.jp ([10.7.69.193])gBH50DU24988; Tue, 17 Dec 2002 14:00:13 +0900 (JST) Original-Received: from mailsv4.nec.co.jp (mailgate51.nec.co.jp [10.7.69.196]) by mailgate4.nec.co.jp (8.11.6/3.7W-MAILGATE-NEC) with ESMTP id gBH50CT25198; Tue, 17 Dec 2002 14:00:12 +0900 (JST) Original-Received: from mcsss2.ucom.lsi.nec.co.jp ([10.30.114.133]) by mailsv4.nec.co.jp (8.11.6/3.7W-MAILSV4-NEC) with ESMTP id gBH50Bq13652; Tue, 17 Dec 2002 14:00:11 +0900 (JST) Original-Received: from mcspd15.ucom.lsi.nec.co.jp (mcspd15 [10.30.114.174]) id gBH50AB18122; Tue, 17 Dec 2002 14:00:10 +0900 (JST) Original-Received: by mcspd15.ucom.lsi.nec.co.jp (Postfix, from userid 31295) id D938B3701; Tue, 17 Dec 2002 14:00:09 +0900 (JST) Original-To: bob@rattlesnake.com System-Type: i686-pc-linux-gnu Blat: Foop In-Reply-To: Original-Lines: 63 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10190 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10190 --=-=-= I've attached a patch below that's implements the `final face realization filtering' function that bob wanted. This is just a first-cut, so I'd appreciate any comments people have. The basic interface is a variable, `realize-face-filter': realize-face-filter's value is nil 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. For instance the following will completely turn off bold fonts: (defun unboldify-lface (lface) (aset lface 4 'normal)) (setq realize-face-filter 'unboldify-lface) (clear-face-cache) It seems to work fine. If I instrument the filter function a bit, like: (defvar ubf-count 0) (defun unboldify-lface (lface) (setq ubf-count (1+ ubf-count)) (aset lface 4 'normal)) (setq realize-face-filter 'unboldify-lface) (clear-face-cache) `ubf-count' seems to continually incremented (if I keep checking in *scratch* it goes up 2 or 3 each time, but if I display a complicated new buffer, it can go up by 100). It doesn't seem noticably slow to me, but I have a reasonably fast cpu (1GHz). I guess I'll need to see exactly what it's getting called on, but this suggests that maybe more places should be checking the face cache (or that the face-cache checking should be moved into realize_face). [Gerd, are you listening...?] Also, perhaps `realize-face-filter' should be a list of functions instead, e.g., `realize-face-filter-functions', as there might be circumstances when two entities want to add a filter -- but maybe this is something that will only ever be changed by the end-user, who can make his own filter function do everything he wants. Any comments? Thanks, -Miles Patch: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=realize-face-filter-20021217.patch Content-Description: realize-face-filter-20021217.patch 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); --=-=-= -- [|nurgle|] ddt- demonic? so quake will have an evil kinda setting? one that will make every christian in the world foamm at the mouth? [iddt] nurg, that's the goal --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel --=-=-=--