changeset 81429:fb627c8fac18

(custom-split-regexp-maybe): Simplify. (custom-buffer-create-internal): Simplify message. (custom-variable-tag): Reduce height to normal. (custom-variable-value-create, custom-face-value-create) (custom-visibility): New widget. (custom-visibility): New face. (custom-group-value-create): Call widget-add-documentation-string-button, using `custom-visibility'.
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 14 Jun 2007 23:08:20 +0000
parents fd3f2f0bf986
children cade0e5b26d6
files lisp/cus-edit.el
diffstat 1 files changed, 39 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/cus-edit.el	Thu Jun 14 23:07:05 2007 +0000
+++ b/lisp/cus-edit.el	Thu Jun 14 23:08:20 2007 +0000
@@ -501,17 +501,12 @@
 
 (defun custom-split-regexp-maybe (regexp)
   "If REGEXP is a string, split it to a list at `\\|'.
-You can get the original back with from the result with:
+You can get the original back from the result with:
   (mapconcat 'identity result \"\\|\")
 
 IF REGEXP is not a string, return it unchanged."
   (if (stringp regexp)
-      (let ((start 0)
-	    all)
-	(while (string-match "\\\\|" regexp start)
-	  (setq all (cons (substring regexp start (match-beginning 0)) all)
-		start (match-end 0)))
-	(nreverse (cons (substring regexp start) all)))
+      (split-string regexp "\\\\|")
     regexp))
 
 (defun custom-variable-prompt ()
@@ -1559,18 +1554,15 @@
 				 "Square brackets indicate")))
 	(if init-file-user
 	    (widget-insert "
-Use the setting's State button to set it or save changes in it.
-Saving a change normally works by editing your Emacs init file.")
-	    (widget-insert "
-\nSince you started Emacs with `-q', which inhibits use of the
-Emacs init file, you cannot save settings into the Emacs init file."))
-	(widget-insert "\nSee ")
+Use the Save or Set buttons to set apply your changes.
+Saving a change normally works by editing your Emacs ")
+	  (widget-insert "
+\nSince you started Emacs with `-q', you cannot save settings into
+the Emacs "))
 	(widget-create 'custom-manual
-		       :tag "Custom file"
+		       :tag "init file"
 		       "(emacs)Saving Customizations")
-	(widget-insert
-	 " for information on how to save in a different file.\n
-See ")
+	(widget-insert ".\nSee ")
 	(widget-create 'custom-manual
 		       :tag "Help"
 		       :help-echo "Read the online help."
@@ -2439,13 +2431,13 @@
 (defface custom-variable-tag
   `((((class color)
       (background dark))
-     (:foreground "light blue" :weight bold :height 1.2 :inherit variable-pitch))
+     (:foreground "light blue" :weight bold :inherit variable-pitch))
     (((min-colors 88) (class color)
       (background light))
-     (:foreground "blue1" :weight bold :height 1.2 :inherit variable-pitch))
+     (:foreground "blue1" :weight bold :inherit variable-pitch))
     (((class color)
       (background light))
-     (:foreground "blue" :weight bold :height 1.2 :inherit variable-pitch))
+     (:foreground "blue" :weight bold :inherit variable-pitch))
     (t (:weight bold)))
   "Face used for unpushable variable tags."
   :group 'custom-faces)
@@ -2636,15 +2628,11 @@
 		    widget 'custom-magic nil)))
 	(widget-put widget :custom-magic magic)
 	(push magic buttons))
-      ;; ### NOTE: this is ugly!!!! I need to update the :buttons property
-      ;; before the call to `widget-default-format-handler'. Otherwise, I
-      ;; loose my current `buttons'. This function shouldn't be called like
-      ;; 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)
+      (widget-add-documentation-string-button
+       widget :visibility-widget 'custom-visibility)
 
       ;; The comment field
       (unless (eq state 'hidden)
@@ -2984,6 +2972,21 @@
     ;; This call will possibly make the comment invisible
     (custom-redraw widget)))
 
+;;; The `custom-visibility' Widget
+
+(define-widget 'custom-visibility 'visibility
+  "Show or hide a documentation string."
+  :button-face 'custom-visibility
+  :pressed-face 'custom-visibility
+  :mouse-face 'highlight
+  :pressed-face 'highlight)
+
+(defface custom-visibility
+  '((t :height 0.8 :inherit link))
+  "Face for the `custom-visibility' widget."
+  :version "23.1"
+  :group 'custom-faces)
+
 ;;; The `custom-face-edit' Widget.
 
 (define-widget 'custom-face-edit 'checklist
@@ -3355,7 +3358,9 @@
 	   ;; Update buttons.
 	   (widget-put widget :buttons buttons)
 	   ;; Insert documentation.
-	   (widget-default-format-handler widget ?h)
+	   (widget-add-documentation-string-button
+	    widget :visibility-widget 'custom-visibility)
+
 	   ;; The comment field
 	   (unless (eq state 'hidden)
 	     (let* ((comment (get symbol 'face-comment))
@@ -3927,7 +3932,9 @@
 	   ;; Insert documentation.
 	   (if (and (eq custom-buffer-style 'links) (> level 1))
 	       (widget-put widget :documentation-indent 0))
-	   (widget-default-format-handler widget ?h))
+	   (widget-add-documentation-string-button
+	    widget :visibility-widget 'custom-visibility))
+
 	  ;; Nested style.
 	  (t				;Visible.
 	   ;; Add parent groups references above the group.
@@ -3935,7 +3942,7 @@
 		    ;;; was made to display a group.
 	       (when (eq level 1)
 		 (if (custom-add-parent-links widget
-					      "Go to parent group:")
+					      "Parent group:")
 		     (insert "\n"))))
 	   ;; Create level indicator.
 	   (insert-char ?\  (* custom-buffer-indent (1- level)))
@@ -3971,7 +3978,9 @@
 	   ;; Update buttons.
 	   (widget-put widget :buttons buttons)
 	   ;; Insert documentation.
-	   (widget-default-format-handler widget ?h)
+	   (widget-add-documentation-string-button
+	    widget :visibility-widget 'custom-visibility)
+
 	   ;; Parent groups.
 	   (if nil  ;;; This should test that the buffer
 		    ;;; was not made to display a group.