[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Visual cleanup for customize buffers
From: |
Kim F. Storm |
Subject: |
Re: Visual cleanup for customize buffers |
Date: |
Sun, 05 Feb 2006 01:07:50 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
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 <address@hidden> 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 <address@hidden> http://www.cua.dk
- Re: Visual cleanup for customize buffers,
Kim F. Storm <=