From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Visual cleanup for customize buffers Date: Sun, 05 Feb 2006 01:07:50 +0100 Message-ID: References: <200601142305.k0EN5Nl22098@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1139109800 11987 80.91.229.2 (5 Feb 2006 03:23:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 5 Feb 2006 03:23:20 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 05 04:23:13 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 1F5aUa-0003uE-CV for ged-emacs-devel@m.gmane.org; Sun, 05 Feb 2006 04:23:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F5aXo-00021h-5T for ged-emacs-devel@m.gmane.org; Sat, 04 Feb 2006 22:26:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F5YBq-0006AT-9V for emacs-devel@gnu.org; Sat, 04 Feb 2006 19:55:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F5Y7Y-0005BS-I4 for emacs-devel@gnu.org; Sat, 04 Feb 2006 19:51:17 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F5XVj-0006cZ-RZ for emacs-devel@gnu.org; Sat, 04 Feb 2006 19:12:12 -0500 Original-Received: from [195.41.46.236] (helo=pfepb.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1F5XUw-0004Qa-UX; Sat, 04 Feb 2006 19:11:23 -0500 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepb.post.tele.dk (Postfix) with SMTP id BE263A507E4; Sun, 5 Feb 2006 01:08:42 +0100 (CET) Original-To: Luc Teirlinck In-Reply-To: <200601142305.k0EN5Nl22098@raven.dms.auburn.edu> (Luc Teirlinck's message of "Sat, 14 Jan 2006 17:05:23 -0600 (CST)") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:50025 Archived-At: I have worked a little more on this to address the bugs that Luc reported, as well as the concerns about omitting show/hide buttons. A new patch is included at the end of this mail. I really think that the new look of this is quite good -- much better than the old look IMVHO! It uses a "familiar" icon to indicate a choice field. Please try it out and tell me what you think. Luc Teirlinck writes: > This is not the type of change that should be attempted shortly (one > can always hope) before a release and maybe even never. It might look > small and harmless at first view but it definitely is not. YMMV, but I think the new patch is quite harmless. > However, I believe that the following bug is definitely real and not > due to some bad application of patches (I guessed this bug would occur > from reading the code). Evaluate: > > (defcustom long-var > "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" > "Great doc." > :group 'help-at-pt > :type 'string) > > Do `M-x customize-group RET help-at-pt'. > > With or without Kim's patch this option starts out hidden. Without > Kim's patch, if I unhide it, I can hide it again, as I clearly should > be able to do. With Kim's patch, there is no button to hide it. I fixed this [trivial]. I also fixed other problems reported by Luc with that page. > > 1. The criteria Custom uses are heuristic and occasionally may show > very long values that the user _definitely_ may want to hide. > > 2. There would be the continuous danger of the two conditions getting > out of sync at any moment whatsoever, leading to very annoying bugs. These concerns a valid, so I added a new custom-reduce-show-hide-buttons option (default nil) for user who want to do this. If this is still controversial, we can omit that part of the patch entirely! Here are the patches: Index: cus-edit.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/cus-edit.el,v retrieving revision 1.281 diff -c -r1.281 cus-edit.el *** cus-edit.el 26 Jan 2006 18:00:29 -0000 1.281 --- cus-edit.el 4 Feb 2006 23:57:27 -0000 *************** *** 1422,1427 **** --- 1422,1434 ---- :type 'boolean :group 'custom-buffer) + (defcustom custom-reduce-show-hide-buttons nil + "If non-nil, only display show/hide buttons for complex values. + This also means that you cannot hide non-complex values from actions + initiated by the buttons which operate on the whole customize buffer." + :type 'boolean + :group 'custom-buffer) + (defun Custom-buffer-done (&rest ignore) "Exit current Custom buffer according to `custom-buffer-done-kill'." (interactive) *************** *** 2514,2527 **** tag) buttons) (insert " ") ! (push (widget-create-child-and-convert ! widget 'visibility ! :help-echo "Hide the value of this option." ! :on "Hide Value" ! :off "Show Value" ! :action 'custom-toggle-parent ! t) ! buttons) (push (widget-create-child-and-convert widget type :format value-format --- 2521,2537 ---- tag) buttons) (insert " ") ! (unless (and custom-reduce-show-hide-buttons ! (atom value) ! (custom-show type value)) ! (push (widget-create-child-and-convert ! widget 'visibility ! :help-echo "Hide the value of this option." ! :on "Hide Value" ! :off "Show Value" ! :action 'custom-toggle-parent ! t) ! buttons)) (push (widget-create-child-and-convert widget type :format value-format *************** *** 2541,2547 **** ;; this anyway. The doc string widget should be added like the others. ;; --dv (widget-put widget :buttons buttons) ! (insert "\n") ;; Insert documentation. (widget-default-format-handler widget ?h) --- 2551,2558 ---- ;; this anyway. The doc string widget should be added like the others. ;; --dv (widget-put widget :buttons buttons) ! (unless (eq (preceding-char) ?\n) ! (insert "\n")) ;; Insert documentation. (widget-default-format-handler widget ?h) *************** *** 2876,2882 **** (define-widget 'custom-face-edit 'checklist "Edit face attributes." ! :format "%t: %v" :tag "Attributes" :extra-offset 13 :button-args '(:help-echo "Control whether this attribute has any effect.") --- 2887,2893 ---- (define-widget 'custom-face-edit 'checklist "Edit face attributes." ! :format "%t:\n %v" :tag "Attributes" :extra-offset 13 :button-args '(:help-echo "Control whether this attribute has any effect.") *************** *** 3122,3145 **** (define-widget 'custom-face-selected 'group "Edit the attributes of the selected display in a face specification." ! :args '((choice :inline t (group :tag "With Defaults" :inline t ! (group (const :tag "" default) ! (custom-face-edit :tag " Default\n Attributes")) ! (repeat :format "" ! :inline t ! (group custom-display-unselected sexp)) ! (group (sexp :format "") ! (custom-face-edit :tag " Overriding\n Attributes")) ! (repeat :format "" ! :inline t ! sexp)) ! (group :tag "No Defaults" :inline t (repeat :format "" :inline t (group custom-display-unselected sexp)) (group (sexp :format "") ! (custom-face-edit :tag "\n Attributes")) (repeat :format "" :inline t sexp))))) --- 3133,3156 ---- (define-widget 'custom-face-selected 'group "Edit the attributes of the selected display in a face specification." ! :args '((choice :tag "Attributes" :inline t (group :tag "With Defaults" :inline t ! (group (const :tag "" :format "%t" default) ! (custom-face-edit :tag "With Defaults")) (repeat :format "" :inline t (group custom-display-unselected sexp)) (group (sexp :format "") ! (custom-face-edit :tag "Overriding Attributes")) ! (repeat :format "" ! :inline t ! sexp)) ! (group :tag "No Defaults" :inline t ! (group (sexp :format "") ! (custom-face-edit :tag "No Defaults")) ! (repeat :format "" ! :inline t ! (group custom-display-unselected sexp)) (repeat :format "" :inline t sexp))))) *************** *** 3287,3300 **** (cond ((and (eq form 'selected) (widget-apply custom-face-selected :match spec)) ! (when indent (insert-char ?\ indent)) 'custom-face-selected) ((and (not (eq form 'lisp)) (widget-apply custom-face-all :match spec)) 'custom-face-all) (t ! (when indent (insert-char ?\ indent)) 'sexp)) :value spec)) (custom-face-state-set widget) --- 3298,3312 ---- (cond ((and (eq form 'selected) (widget-apply custom-face-selected :match spec)) ! (when indent (insert-char ?\s indent)) 'custom-face-selected) ((and (not (eq form 'lisp)) (widget-apply custom-face-all :match spec)) + (when indent (insert-char ?\s indent)) 'custom-face-all) (t ! (when indent (insert-char ?\s indent)) 'sexp)) :value spec)) (custom-face-state-set widget) Index: wid-edit.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/wid-edit.el,v retrieving revision 1.162 diff -c -r1.162 wid-edit.el *** wid-edit.el 26 Jan 2006 17:59:01 -0000 1.162 --- wid-edit.el 5 Feb 2006 00:05:51 -0000 *************** *** 403,409 **** ;; We want to avoid the face with image buttons. (unless (widget-get widget :suppress-face) (overlay-put overlay 'face (widget-apply widget :button-face-get)) ! (overlay-put overlay 'mouse-face (widget-apply widget :mouse-face-get))) (overlay-put overlay 'pointer 'hand) (overlay-put overlay 'follow-link follow-link) --- 403,409 ---- ;; We want to avoid the face with image buttons. (unless (widget-get widget :suppress-face) (overlay-put overlay 'face (widget-apply widget :button-face-get)) ! (overlay-put overlay 'mouse-face (widget-apply widget :mouse-face-get))) (overlay-put overlay 'pointer 'hand) (overlay-put overlay 'follow-link follow-link) *************** *** 1421,1426 **** --- 1421,1428 ---- (call-interactively (or (widget-get widget :complete-function) widget-complete-field))) + (defvar widget-choice-menu-image nil) + (defun widget-default-create (widget) "Create WIDGET at point in the current buffer." (widget-specify-insert *************** *** 1428,1434 **** button-begin button-end sample-begin sample-end doc-begin doc-end ! value-pos) (insert (widget-get widget :format)) (goto-char from) ;; Parse escapes in format. --- 1430,1436 ---- button-begin button-end sample-begin sample-end doc-begin doc-end ! value-pos value-choice-button) (insert (widget-get widget :format)) (goto-char from) ;; Parse escapes in format. *************** *** 1441,1448 **** (setq button-begin (point)) (insert (widget-get-indirect widget :button-prefix))) ((eq escape ?\]) ! (insert (widget-get-indirect widget :button-suffix)) ! (setq button-end (point))) ((eq escape ?\{) (setq sample-begin (point))) ((eq escape ?\}) --- 1443,1476 ---- (setq button-begin (point)) (insert (widget-get-indirect widget :button-prefix))) ((eq escape ?\]) ! (save-excursion ! (setq button-end (point)) ! (when value-choice-button ! (goto-char button-begin) ! (when (re-search-forward "[:\n]" button-end t) ! (setq button-end (1- (point)))) ! (goto-char button-end) ! (when (eq (preceding-char) ?\n) ! (backward-char 1)) ! (insert " ") ! (if (display-graphic-p) ! (insert-image ! (or widget-choice-menu-image ! (setq widget-choice-menu-image ! (create-image "\377\176\176\074\074\030\030\377" ! 'xbm t :width 8 :height 8 ! :foreground ! (if (facep 'custom-button) ! (face-foreground 'custom-button) ! "black") ! :background ! (if (facep 'custom-button) ! (face-background 'custom-button) ! "lightgrey") ! :ascent 'center))) ">") ! (insert (propertize "?>" ))) ! (setq button-end (point))) ! (insert (widget-get-indirect widget :button-suffix)))) ((eq escape ?\{) (setq sample-begin (point))) ((eq escape ?\}) *************** *** 1474,1479 **** --- 1502,1510 ---- (if (and button-begin (not button-end)) (widget-apply widget :value-create) (setq value-pos (point)))) + ((eq escape ?V) + (widget-apply widget :value-create) + (setq value-choice-button t)) (t (widget-apply widget :format-handler escape))))) ;; Specify button, sample, and doc, and insert value. *************** *** 3565,3571 **** (define-widget 'choice 'menu-choice "A union of several sexp types." :tag "Choice" ! :format "%{%t%}: %[Value Menu%] %v" :button-prefix 'widget-push-button-prefix :button-suffix 'widget-push-button-suffix :prompt-value 'widget-choice-prompt-value) --- 3596,3602 ---- (define-widget 'choice 'menu-choice "A union of several sexp types." :tag "Choice" ! :format "%{%t%}: %[%V%]" :button-prefix 'widget-push-button-prefix :button-suffix 'widget-push-button-suffix :prompt-value 'widget-choice-prompt-value) *************** *** 3634,3640 **** :prompt-value 'widget-boolean-prompt-value :button-prefix 'widget-push-button-prefix :button-suffix 'widget-push-button-suffix ! :format "%{%t%}: %[Toggle%] %v\n" :on "on (non-nil)" :off "off (nil)") --- 3665,3671 ---- :prompt-value 'widget-boolean-prompt-value :button-prefix 'widget-push-button-prefix :button-suffix 'widget-push-button-suffix ! :format "%{%t%}: %v %[Toggle%]\n" :on "on (non-nil)" :off "off (nil)") -- Kim F. Storm http://www.cua.dk