From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yoni Rabkin Katzenell Newsgroups: gmane.emacs.devel Subject: Re: describe-face should show an example of text in the face. Date: Mon, 16 Oct 2006 22:01:53 +0200 Message-ID: <874pu4rpvy.fsf@actcom.com> References: <87wt70y82j.fsf@actcom.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1161029022 26495 80.91.229.2 (16 Oct 2006 20:03:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Oct 2006 20:03:42 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 16 22:03:38 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GZYgE-0006f8-K5 for ged-emacs-devel@m.gmane.org; Mon, 16 Oct 2006 22:03:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GZYgE-0000xq-1Y for ged-emacs-devel@m.gmane.org; Mon, 16 Oct 2006 16:03:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GZYdt-0005xl-OQ for emacs-devel@gnu.org; Mon, 16 Oct 2006 16:00:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GZYdq-0005rW-Du for emacs-devel@gnu.org; Mon, 16 Oct 2006 16:00:56 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GZYdp-0005ps-A1 for emacs-devel@gnu.org; Mon, 16 Oct 2006 16:00:53 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GZYn0-00058R-1c for emacs-devel@gnu.org; Mon, 16 Oct 2006 16:10:22 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GZYdS-000626-52 for emacs-devel@gnu.org; Mon, 16 Oct 2006 22:00:30 +0200 Original-Received: from line134-129.adsl.actcom.co.il ([192.115.134.129]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Oct 2006 22:00:30 +0200 Original-Received: from yoni-r by line134-129.adsl.actcom.co.il with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Oct 2006 22:00:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 82 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: line134-129.adsl.actcom.co.il X-Ethics: Use GNU User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:t9ssVcavtAqmZSHeFS40nrn7V78= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:60799 Archived-At: --=-=-= "Drew Adams" writes: > > Good idea. How about showing two samples: foreground and background? > > Like in `list-colors-display'? If that is not what you mean then I am > misunderstanding you. > > Yes, that's what I was thinking. > > But I was mistakenly thinking of colors, not faces. Please ignore my > suggestion. Your reply got me thinking. The following patch does exactly the same, except that it renders the "sample" text to look just like the "sample" text in the `customize' buffer. So that both are visually consistent examples. The following screenshot shows how `describe-face' looks with the attached patch, as compared with the `customize' buffer: http://yrk.nfshost.com/images/faces-sample.png --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=describe_face.patch Index: faces.el =================================================================== RCS file: /sources/emacs/emacs/lisp/faces.el,v retrieving revision 1.354 diff -u -r1.354 faces.el --- faces.el 14 Sep 2006 23:54:44 -0000 1.354 +++ faces.el 16 Oct 2006 19:52:28 -0000 @@ -32,6 +32,9 @@ ;; Warning suppression -- can't require x-win in batch: (autoload 'xw-defined-colors "x-win")) +(defvar faces-sample-overlay nil + "Overlay for showing an example of a face.") + (defvar help-xref-stack-item) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1253,6 +1256,17 @@ (setq faces (cdr faces))))))) +(defun faces-sample-overlay (face) + "Insert sample text with FACE. + +If FACE is not a face or nil, use the default face." + (let ((f (if (facep face) face 'default)) + (start (+ (point) 2))) ;; +1 to skip leading space + (insert " (sample)") + (setq faces-sample-overlay (make-overlay start (1- (point)))) + (overlay-put faces-sample-overlay 'face f))) + + (defun describe-face (face &optional frame) "Display the properties of face FACE on FRAME. Interactively, FACE defaults to the faces of the character after point @@ -1293,6 +1307,7 @@ (insert " undefined face.\n") (let ((customize-label "customize this face") file-name) + (faces-sample-overlay f) (princ (concat " (" customize-label ")\n")) (insert "Documentation: " (or (face-documentation f) --=-=-= -- "Cut your own wood and it will warm you twice" --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--