comparison lisp/cus-edit.el @ 68021:271ab3aed790

* cus-edit.el (custom-reset-menu, Custom-mode-menu) (custom-variable-menu, custom-face-menu, custom-group-menu): Undo last change. (Custom-reset-current, Custom-reset-saved) (Custom-reset-standard): Fix y-or-n-p messages.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 04 Jan 2006 17:23:23 +0000
parents d8acae190ef7
children c7ec296cf313
comparison
equal deleted inserted replaced
68020:d8acae190ef7 68021:271ab3aed790
766 children) 766 children)
767 (custom-save-all)) 767 (custom-save-all))
768 (message "Aborted"))) 768 (message "Aborted")))
769 769
770 (defvar custom-reset-menu 770 (defvar custom-reset-menu
771 '(("Show current settings" . Custom-reset-current) 771 '(("Reset to current settings" . Custom-reset-current)
772 ("Show saved settings" . Custom-reset-saved) 772 ("Reset to saved settings" . Custom-reset-saved)
773 ("Erase Customization (use standard values)" . Custom-reset-standard)) 773 ("Erase Customization (use standard values)" . Custom-reset-standard))
774 "Alist of actions for the `Reset' button. 774 "Alist of actions for the `Reset' button.
775 The key is a string containing the name of the action, the value is a 775 The key is a string containing the name of the action, the value is a
776 Lisp function taking the widget as an element which will be called 776 Lisp function taking the widget as an element which will be called
777 when the action is chosen.") 777 when the action is chosen.")
786 (funcall answer)))) 786 (funcall answer))))
787 787
788 (defun Custom-reset-current (&rest ignore) 788 (defun Custom-reset-current (&rest ignore)
789 "Reset all modified group members to their current value." 789 "Reset all modified group members to their current value."
790 (interactive) 790 (interactive)
791 (if (y-or-n-p "Update buffer text to show all current settings? ") 791 (if (y-or-n-p "Reset buffer to show current settings? ")
792 (let ((children custom-options)) 792 (let ((children custom-options))
793 (mapc (lambda (widget) 793 (mapc (lambda (widget)
794 (if (memq (widget-get widget :custom-state) 794 (if (memq (widget-get widget :custom-state)
795 '(modified changed)) 795 '(modified changed))
796 (widget-apply widget :custom-reset-current))) 796 (widget-apply widget :custom-reset-current)))
798 (message "Aborted"))) 798 (message "Aborted")))
799 799
800 (defun Custom-reset-saved (&rest ignore) 800 (defun Custom-reset-saved (&rest ignore)
801 "Reset all modified or set group members to their saved value." 801 "Reset all modified or set group members to their saved value."
802 (interactive) 802 (interactive)
803 (if (y-or-n-p "Update buffer text to show all saved settings? ") 803 (if (y-or-n-p "Reset all settings to saved values? ")
804 (let ((children custom-options)) 804 (let ((children custom-options))
805 (mapc (lambda (widget) 805 (mapc (lambda (widget)
806 (if (memq (widget-get widget :custom-state) 806 (if (memq (widget-get widget :custom-state)
807 '(modified set changed rogue)) 807 '(modified set changed rogue))
808 (widget-apply widget :custom-reset-saved))) 808 (widget-apply widget :custom-reset-saved)))
817 (interactive) 817 (interactive)
818 (let ((children custom-options)) 818 (let ((children custom-options))
819 (if (or (and (= 1 (length children)) 819 (if (or (and (= 1 (length children))
820 (memq (widget-type (car children)) 820 (memq (widget-type (car children))
821 '(custom-variable custom-face))) 821 '(custom-variable custom-face)))
822 (yes-or-no-p "Really erase all customizations in this buffer? ")) 822 (yes-or-no-p "Erase all customizations in this buffer? "))
823 (mapc (lambda (widget) 823 (mapc (lambda (widget)
824 (and (if (widget-get widget :custom-standard-value) 824 (and (if (widget-get widget :custom-standard-value)
825 (widget-apply widget :custom-standard-value) 825 (widget-apply widget :custom-standard-value)
826 t) 826 t)
827 (memq (widget-get widget :custom-state) 827 (memq (widget-get widget :custom-state)
1480 :mouse-down-action (lambda (&rest junk) t) 1480 :mouse-down-action (lambda (&rest junk) t)
1481 :action (lambda (widget &optional event) 1481 :action (lambda (widget &optional event)
1482 (custom-reset event)))) 1482 (custom-reset event))))
1483 (widget-insert "\n ") 1483 (widget-insert "\n ")
1484 (widget-create 'push-button 1484 (widget-create 'push-button
1485 :tag "Show Current Settings" 1485 :tag "Reset to Current"
1486 :help-echo "\ 1486 :help-echo "\
1487 Reset all edited text in this buffer to reflect current values." 1487 Reset all edited text in this buffer to reflect current values."
1488 :action 'Custom-reset-current) 1488 :action 'Custom-reset-current)
1489 (widget-insert " ") 1489 (widget-insert " ")
1490 (widget-create 'push-button 1490 (widget-create 'push-button
1491 :tag "Show Saved Settings" 1491 :tag "Reset to Saved"
1492 :help-echo "\ 1492 :help-echo "\
1493 Reset all settings in this buffer to their saved values." 1493 Reset all settings in this buffer to their saved values."
1494 :action 'Custom-reset-saved) 1494 :action 'Custom-reset-saved)
1495 (widget-insert " ") 1495 (widget-insert " ")
1496 (when (or custom-file user-init-file) 1496 (when (or custom-file user-init-file)
1497 (widget-create 'push-button 1497 (widget-create 'push-button
1498 :tag "Erase Customization" 1498 :tag "Erase Customization"
1499 :help-echo "\ 1499 :help-echo "\
1500 Un-customize all settings in this buffer--save them with standard values." 1500 Un-customize all settings in this buffer and save them with standard values."
1501 :action 'Custom-reset-standard))) 1501 :action 'Custom-reset-standard)))
1502 (widget-insert "\n ") 1502 (widget-insert "\n ")
1503 (widget-create 'push-button 1503 (widget-create 'push-button
1504 :tag "Set for Current Session" 1504 :tag "Set for Current Session"
1505 :help-echo "\ 1505 :help-echo "\
2225 (mapatoms (lambda (symbol) 2225 (mapatoms (lambda (symbol)
2226 (when (member (list name type) (get symbol 'custom-group)) 2226 (when (member (list name type) (get symbol 'custom-group))
2227 (insert " ") 2227 (insert " ")
2228 (push (widget-create-child-and-convert 2228 (push (widget-create-child-and-convert
2229 widget 'custom-group-link 2229 widget 'custom-group-link
2230 :button-face 'custom-link
2231 :mouse-face 'highlight
2230 :tag (custom-unlispify-tag-name symbol) 2232 :tag (custom-unlispify-tag-name symbol)
2231 symbol) 2233 symbol)
2232 buttons) 2234 buttons)
2233 (setq parents (cons symbol parents))))) 2235 (setq parents (cons symbol parents)))))
2234 (and (null (get name 'custom-links)) ;No links of its own. 2236 (and (null (get name 'custom-links)) ;No links of its own.
2619 2621
2620 (defun custom-variable-standard-value (widget) 2622 (defun custom-variable-standard-value (widget)
2621 (get (widget-value widget) 'standard-value)) 2623 (get (widget-value widget) 'standard-value))
2622 2624
2623 (defvar custom-variable-menu 2625 (defvar custom-variable-menu
2624 `(("Show current value" custom-redraw 2626 `(("Add comment" custom-comment-show custom-comment-invisible-p)
2625 (lambda (widget)
2626 (and (default-boundp (widget-value widget))
2627 (memq (widget-get widget :custom-state) '(modified changed)))))
2628 ("Show saved value" custom-variable-reset-saved
2629 (lambda (widget)
2630 (and (or (get (widget-value widget) 'saved-value)
2631 (get (widget-value widget) 'saved-variable-comment))
2632 (memq (widget-get widget :custom-state)
2633 '(modified set changed rogue)))))
2634 ("Show backup value" custom-variable-reset-backup
2635 (lambda (widget)
2636 (get (widget-value widget) 'backup-value)))
2637 ("---" ignore ignore)
2638 ("Add comment" custom-comment-show custom-comment-invisible-p)
2639 ("Show value widget" custom-variable-edit 2627 ("Show value widget" custom-variable-edit
2640 (lambda (widget) 2628 (lambda (widget)
2641 (eq (widget-get widget :custom-form) 'lisp))) 2629 (eq (widget-get widget :custom-form) 'lisp)))
2642 ("Show Lisp expression" custom-variable-edit-lisp 2630 ("Show Lisp expression" custom-variable-edit-lisp
2643 (lambda (widget) 2631 (lambda (widget)
2644 (eq (widget-get widget :custom-form) 'edit))) 2632 (eq (widget-get widget :custom-form) 'edit)))
2633 ("---" ignore ignore)
2634 ("Reset to current value" custom-redraw
2635 (lambda (widget)
2636 (and (default-boundp (widget-value widget))
2637 (memq (widget-get widget :custom-state) '(modified changed)))))
2638 ("Reset to saved value" custom-variable-reset-saved
2639 (lambda (widget)
2640 (and (or (get (widget-value widget) 'saved-value)
2641 (get (widget-value widget) 'saved-variable-comment))
2642 (memq (widget-get widget :custom-state)
2643 '(modified set changed rogue)))))
2644 ("Reset to backup value" custom-variable-reset-backup
2645 (lambda (widget)
2646 (get (widget-value widget) 'backup-value)))
2645 ("---" ignore ignore) 2647 ("---" ignore ignore)
2646 ,@(when (or custom-file user-init-file) 2648 ,@(when (or custom-file user-init-file)
2647 '(("Erase customization" custom-variable-reset-standard 2649 '(("Erase customization" custom-variable-reset-standard
2648 (lambda (widget) 2650 (lambda (widget)
2649 (and (get (widget-value widget) 'standard-value) 2651 (and (get (widget-value widget) 'standard-value)
3292 (push edit children) 3294 (push edit children)
3293 (widget-put widget :children children)) 3295 (widget-put widget :children children))
3294 (message "Creating face editor...done")))))) 3296 (message "Creating face editor...done"))))))
3295 3297
3296 (defvar custom-face-menu 3298 (defvar custom-face-menu
3297 `(("Show saved face" custom-face-reset-saved 3299 `(("Add comment" custom-comment-show custom-comment-invisible-p)
3298 (lambda (widget)
3299 (or (get (widget-value widget) 'saved-face)
3300 (get (widget-value widget) 'saved-face-comment))))
3301 ("---" ignore ignore)
3302 ("Add comment" custom-comment-show custom-comment-invisible-p)
3303 ("Show all attributes" custom-face-edit-all 3300 ("Show all attributes" custom-face-edit-all
3304 (lambda (widget) 3301 (lambda (widget)
3305 (not (eq (widget-get widget :custom-form) 'all)))) 3302 (not (eq (widget-get widget :custom-form) 'all))))
3306 ("Show current attributes" custom-face-edit-selected 3303 ("Show current attributes" custom-face-edit-selected
3307 (lambda (widget) 3304 (lambda (widget)
3308 (not (eq (widget-get widget :custom-form) 'selected)))) 3305 (not (eq (widget-get widget :custom-form) 'selected))))
3309 ("Show Lisp expression" custom-face-edit-lisp 3306 ("Show Lisp expression" custom-face-edit-lisp
3310 (lambda (widget) 3307 (lambda (widget)
3311 (not (eq (widget-get widget :custom-form) 'lisp)))) 3308 (not (eq (widget-get widget :custom-form) 'lisp))))
3312 ("---" ignore ignore) 3309 ("---" ignore ignore)
3310 ("Reset to saved face" custom-face-reset-saved
3311 (lambda (widget)
3312 (or (get (widget-value widget) 'saved-face)
3313 (get (widget-value widget) 'saved-face-comment))))
3313 ,@(when (or custom-file user-init-file) 3314 ,@(when (or custom-file user-init-file)
3314 '(("Erase customization" custom-face-reset-standard 3315 '(("Erase customization" custom-face-reset-standard
3315 (lambda (widget) 3316 (lambda (widget)
3316 (get (widget-value widget) 'face-defface-spec))))) 3317 (get (widget-value widget) 'face-defface-spec)))))
3317 ("Set for current session" custom-face-set) 3318 ("Set for current session" custom-face-set)
3773 (insert " group: ") 3774 (insert " group: ")
3774 ;; Create link/visibility indicator. 3775 ;; Create link/visibility indicator.
3775 (if (eq custom-buffer-style 'links) 3776 (if (eq custom-buffer-style 'links)
3776 (push (widget-create-child-and-convert 3777 (push (widget-create-child-and-convert
3777 widget 'custom-group-link 3778 widget 'custom-group-link
3779 :button-face 'custom-link
3780 :mouse-face 'highlight
3778 :tag "Go to Group" 3781 :tag "Go to Group"
3779 symbol) 3782 symbol)
3780 buttons) 3783 buttons)
3781 (push (widget-create-child-and-convert 3784 (push (widget-create-child-and-convert
3782 widget 'custom-group-visibility 3785 widget 'custom-group-visibility
3888 (insert "\\- " (widget-get widget :tag) " group end ") 3891 (insert "\\- " (widget-get widget :tag) " group end ")
3889 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level))) 3892 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level)))
3890 (insert "/\n"))))) 3893 (insert "/\n")))))
3891 3894
3892 (defvar custom-group-menu 3895 (defvar custom-group-menu
3893 `(("Show current settings" custom-group-reset-current 3896 `(("Reset to current settings" custom-group-reset-current
3894 (lambda (widget) 3897 (lambda (widget)
3895 (memq (widget-get widget :custom-state) '(modified)))) 3898 (memq (widget-get widget :custom-state) '(modified))))
3896 ("Show saved settings" custom-group-reset-saved 3899 ("Reset to saved settings" custom-group-reset-saved
3897 (lambda (widget) 3900 (lambda (widget)
3898 (memq (widget-get widget :custom-state) '(modified set)))) 3901 (memq (widget-get widget :custom-state) '(modified set))))
3899 ,@(when (or custom-file user-init-file) 3902 ,@(when (or custom-file user-init-file)
3900 '(("Show standard settings" custom-group-reset-standard 3903 '(("Reset to standard settings" custom-group-reset-standard
3901 (lambda (widget) 3904 (lambda (widget)
3902 (memq (widget-get widget :custom-state) '(modified set saved)))))) 3905 (memq (widget-get widget :custom-state) '(modified set saved))))))
3903 ("---" ignore ignore) 3906 ("---" ignore ignore)
3904 ("Set for current session" custom-group-set 3907 ("Set for current session" custom-group-set
3905 (lambda (widget) 3908 (lambda (widget)
4362 "Menu used in customization buffers." 4365 "Menu used in customization buffers."
4363 `("Custom" 4366 `("Custom"
4364 ,(customize-menu-create 'customize) 4367 ,(customize-menu-create 'customize)
4365 ["Set" Custom-set t] 4368 ["Set" Custom-set t]
4366 ["Save" Custom-save t] 4369 ["Save" Custom-save t]
4367 ["Show current settings" Custom-reset-current t] 4370 ["Reset to current settings" Custom-reset-current t]
4368 ["Show saved settings" Custom-reset-saved t] 4371 ["Reset to saved settings" Custom-reset-saved t]
4369 ["Erase customizations" Custom-reset-standard t] 4372 ["Erase customizations" Custom-reset-standard t]
4370 ["Info" (info "(emacs)Easy Customization") t])) 4373 ["Info" (info "(emacs)Easy Customization") t]))
4371 4374
4372 (defun Custom-goto-parent () 4375 (defun Custom-goto-parent ()
4373 "Go to the parent group listed at the top of this buffer. 4376 "Go to the parent group listed at the top of this buffer.