From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David PONCE Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: Re: Inherited face appears as a function in customize-face buffer Date: Fri, 1 Apr 2005 10:40:21 +0200 (CEST) Message-ID: <4655671.1112344821006.JavaMail.www@wwinf1304.me-wanadoo.net> Reply-To: david.ponce@wanadoo.fr NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1112345486 13443 80.91.229.2 (1 Apr 2005 08:51:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 1 Apr 2005 08:51:26 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 01 10:51:22 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DHHqz-0006zF-9V for ged-emacs-devel@m.gmane.org; Fri, 01 Apr 2005 10:50:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DHI6I-00049d-6R for ged-emacs-devel@m.gmane.org; Fri, 01 Apr 2005 04:05:59 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DHHxT-0000iq-R3 for emacs-devel@gnu.org; Fri, 01 Apr 2005 03:56:52 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DHHxL-0000gO-KE for emacs-devel@gnu.org; Fri, 01 Apr 2005 03:56:44 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DHHxI-0000ej-Ex for emacs-devel@gnu.org; Fri, 01 Apr 2005 03:56:41 -0500 Original-Received: from [193.252.22.54] (helo=smtp13.wanadoo.fr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DHHhX-0000n1-PH for emacs-devel@gnu.org; Fri, 01 Apr 2005 03:40:24 -0500 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1304.wanadoo.fr (SMTP Server) with ESMTP id 0E9847000085 for ; Fri, 1 Apr 2005 10:40:21 +0200 (CEST) Original-Received: from wwinf1304.me-wanadoo.net (wwinf1304.me-wanadoo.net [172.22.144.31]) by mwinf1304.wanadoo.fr (SMTP Server) with ESMTP id 03D8C7000081; Fri, 1 Apr 2005 10:40:21 +0200 (CEST) X-ME-UUID: 20050401084021158.03D8C7000081@mwinf1304.wanadoo.fr Original-To: rms@gnu.org X-Originating-IP: [205.167.7.18] X-WUM-FROM: |~| X-WUM-TO: |~| X-WUM-CC: |~||~| X-WUM-REPLYTO: |~| 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:35465 gmane.emacs.pretest.bugs:6711 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:35465 [CC'd this msg again to the devel ML for help] Hello, > I made the following patch which seems to work better. WDYT? >=20 > You changed the code quite a bit, so I can't quickly see what the > user-level behavior is. Would you please describe what has changed > at that level? I redid the patch more simpler. Mainly the face widget now inherits its behavior from the symbol widget and include the sample display in the :format specification. The sample display is now updated as you type the face name in the input field (it is inspired of the behavior of the color widget). It works well excepted that sometimes, when doing M-TAB completion, I encounter this bug: Debugger entered--Lisp error: (args-out-of-range 1094 1094) get-char-property(1094 field #) widget-field-end(...) widget-field-find(1229) widget-before-change(1229 1234) lisp-complete-symbol(facep) #[nil "=C0=C1!‡" [lisp-complete-symbol facep] 2 nil nil]() call-interactively(#[nil "=C0=C1!‡" [lisp-complete-symbol facep] 2 n= il nil]) widget-default-complete(...) widget-apply(... :complete) widget-complete() call-interactively(widget-complete) I am not sure it is due to my change nor have any idea on what could cause it. Maybe a guru of the custom/widget internals could help? Thanks! David=20 2005-04-01 David Ponce =09* cus-edit.el (face): Derive from symbol widget. Display sample =09of the current face on the fly. =09(widget-face-sample-face-get, widget-face-notify): New functions. Index: lisp/cus-edit.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/emacs/emacs/lisp/cus-edit.el,v retrieving revision 1.216 diff -c -r1.216 cus-edit.el *** lisp/cus-edit.el=0927 Feb 2005 21:37:03 -0000=091.216 --- lisp/cus-edit.el=0931 Mar 2005 10:35:30 -0000 *************** *** 3296,3360 **** (defvar widget-face-prompt-value-history nil "History of input to `widget-face-prompt-value'.") =20 ! (define-widget 'face 'restricted-sexp ! "A Lisp face name." :complete-function (lambda () =09=09 (interactive) =09=09 (lisp-complete-symbol 'facep)) - :prompt-value 'widget-field-prompt-value - :prompt-internal 'widget-symbol-prompt-internal :prompt-match 'facep :prompt-history 'widget-face-prompt-value-history - :value-create 'widget-face-value-create - :action 'widget-field-action - :match-alternatives '(facep) :validate (lambda (widget) =09 (unless (facep (widget-value widget)) ! =09=09(widget-put widget :error (format "Invalid face: %S" ! =09=09=09=09=09=09 (widget-value widget))) ! =09=09widget)) ! :value 'ignore ! :tag "Function") !=20 !=20 ! ;;; There is a bug here: the sample doesn't get redisplayed ! ;;; in the new font when you specify one. Does anyone know how to ! ;;; make that work? -- rms. !=20 ! (defun widget-face-value-create (widget) ! "Create an editable face name field." ! (let ((buttons (widget-get widget :buttons)) ! =09(symbol (widget-get widget :value))) ! ;; Sample. ! (push (widget-create-child-and-convert widget 'item ! =09=09=09=09=09 :format "(%{%t%})" ! =09=09=09=09=09 :sample-face symbol ! =09=09=09=09=09 :tag "sample") ! =09 buttons) ! (insert " ") ! ;; Update buttons. ! (widget-put widget :buttons buttons)) !=20 ! (let ((size (widget-get widget :size)) ! =09(value (widget-get widget :value)) ! =09(from (point)) ! =09;; This is changed to a real overlay in `widget-setup'. We ! =09;; need the end points to behave differently until ! =09;; `widget-setup' is called. ! =09(overlay (cons (make-marker) (make-marker)))) ! (widget-put widget :field-overlay overlay) ! (insert value) ! (and size ! =09 (< (length value) size) ! =09 (insert-char ?\ (- size (length value)))) ! (unless (memq widget widget-field-list) ! (setq widget-field-new (cons widget widget-field-new))) ! (move-marker (cdr overlay) (point)) ! (set-marker-insertion-type (cdr overlay) nil) ! (when (null size) ! (insert ?\n)) ! (move-marker (car overlay) from) ! (set-marker-insertion-type (car overlay) t))) =20 =20 ;;; The `hook' Widget. --- 3296,3332 ---- (defvar widget-face-prompt-value-history nil "History of input to `widget-face-prompt-value'.") =20 ! (define-widget 'face 'symbol ! "A Lisp face name (with sample)." ! :format "%t: (%{sample%}) %v" ! :tag "Face" ! :value 'default ! :sample-face-get 'widget-face-sample-face-get ! :notify 'widget-face-notify ! :match (lambda (widget value) (facep value)) :complete-function (lambda () =09=09 (interactive) =09=09 (lisp-complete-symbol 'facep)) :prompt-match 'facep :prompt-history 'widget-face-prompt-value-history :validate (lambda (widget) =09 (unless (facep (widget-value widget)) ! =09=09(widget-put widget ! =09=09=09 :error (format "Invalid face: %S" ! =09=09=09=09=09 (widget-value widget))) ! =09=09widget))) !=20 ! (defun widget-face-sample-face-get (widget) ! (let ((value (widget-value widget))) ! (if (facep value) ! =09value ! 'default))) !=20 ! (defun widget-face-notify (widget child &optional event) ! "Update the sample, and notify the parent." ! (overlay-put (widget-get widget :sample-overlay) ! =09 'face (widget-apply widget :sample-face-get)) ! (widget-default-notify widget child event)) =20 =20 ;;; The `hook' Widget.