From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David PONCE Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.devel Subject: Re: Inherited face appears as a function in customize-face buffer Date: Mon, 4 Apr 2005 14:20:45 +0200 (CEST) Message-ID: <2658884.1112617245113.JavaMail.www@wwinf1302> Reply-To: david.ponce@wanadoo.fr NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1112630030 28600 80.91.229.2 (4 Apr 2005 15:53:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 4 Apr 2005 15:53:50 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Mon Apr 04 17:53:44 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DITrx-0002FW-79 for gebp-emacs-pretest-bug@gmane.org; Mon, 04 Apr 2005 17:52:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DITCa-00040j-OY for gebp-emacs-pretest-bug@gmane.org; Mon, 04 Apr 2005 11:09:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DISsG-0005AN-GA for emacs-pretest-bug@gnu.org; Mon, 04 Apr 2005 10:48:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DISsE-00059W-FQ for emacs-pretest-bug@gnu.org; Mon, 04 Apr 2005 10:48:19 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DISoR-0003Xj-II for emacs-pretest-bug@gnu.org; Mon, 04 Apr 2005 10:44:23 -0400 Original-Received: from [193.252.22.54] (helo=smtp13.wanadoo.fr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DIQb2-0001gf-Gr for emacs-pretest-bug@gnu.org; Mon, 04 Apr 2005 08:22:25 -0400 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1304.wanadoo.fr (SMTP Server) with ESMTP id 633DC7000087 for ; Mon, 4 Apr 2005 14:20:46 +0200 (CEST) Original-Received: from wwinf1302 (wwinf1302 [172.22.144.29]) by mwinf1304.wanadoo.fr (SMTP Server) with ESMTP id 34D417000084; Mon, 4 Apr 2005 14:20:45 +0200 (CEST) X-ME-UUID: 20050404122045216.34D417000084@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-pretest-bug@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: emacs-pretest-bug.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Errors-To: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.pretest.bugs:6760 gmane.emacs.devel:35537 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:35537 Hello, > It works well excepted that sometimes, when doing M-TAB completion, I > encounter this bug: >=20 > 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 "=C3=80=C3=81!‡" [lisp-complete-symbol facep] 2 nil nil]() > call-interactively(#[nil "=C3=80=C3=81!‡" [lisp-complete-symbol fa= cep] 2 nil nil]) > widget-default-complete(...) > widget-apply(... :complete) > widget-complete() > call-interactively(widget-complete) >=20 > 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? I think I finally found the cause of the above bug. It is due to a side effect of the field narrowing done in `widget-complete' and the call to `widget-field-end' (so to `get-char-property') done via the `before-change-functions' hook `widget-before-change'. I fixed that by temporarily removing field narrowing in `widget-field-end' before to call `get-char-property'. Here is a new complete patch that seems to work great now. WDYT? Sincerely, David 2005-04-04 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. =09(widget-face-value-create): Remove. =09* wid-edit.el (widget-field-end): Temporarily remove field =09narrowing before to call `get-char-property'. 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=094 Apr 2005 12:14:37 -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. Index: lisp/wid-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/wid-edit.el,v retrieving revision 1.136 diff -c -r1.136 wid-edit.el *** lisp/wid-edit.el=0929 Jan 2005 17:21:12 -0000=091.136 --- lisp/wid-edit.el=094 Apr 2005 12:14:44 -0000 *************** *** 1185,1193 **** ;; or if a special `boundary' field has been added after the widget ;; field. (if (overlayp overlay) ! =09(if (and (not (eq (get-char-property (overlay-end overlay) ! =09=09=09=09=09 'field ! =09=09=09=09=09 (widget-field-buffer widget)) =09=09=09 'boundary)) =09=09 (or widget-field-add-space =09=09 (null (widget-get widget :size)))) --- 1185,1201 ---- ;; or if a special `boundary' field has been added after the widget ;; field. (if (overlayp overlay) ! =09(if (and (not (eq (with-current-buffer ! =09=09=09 (widget-field-buffer widget) ! =09=09=09 (save-restriction ! =09=09=09 ;; `widget-narrow-to-field' can be ! =09=09=09 ;; active when this function is called ! =09=09=09 ;; from an change-functions hook. So ! =09=09=09 ;; temporarily remove field narrowing ! =09=09=09 ;; before to call `get-char-property'. ! =09=09=09 (widen) ! =09=09=09 (get-char-property (overlay-end overlay) ! =09=09=09=09=09=09 'field))) =09=09=09 'boundary)) =09=09 (or widget-field-add-space =09=09 (null (widget-get widget :size))))