comparison lisp/cus-edit.el @ 68343:05dbd20a248e

(custom-buffer-create-internal): Use widget type `custom-manual' instead of `info-link' and don't set properties `button-face' and `mouse-face' explicitly. (custom-browse-group-tag, custom-browse-variable-tag) (custom-browse-face-tag): Inherit from widget class `custom-group-link' instead of `push-button'. (custom-button-unraised): Inherit from `underline' face. (custom-link): Inherit from `link' face. Fix doc and group. (custom-add-parent-links, custom-group-value-create): Don't set properties `button-face' and `mouse-face' explicitly for `custom-group-link' widget. (custom-group-link): Add properties `button-face' and `mouse-face' to widget definition. (custom-field-keymap): New variable. Put `custom-field-keymap' to editable-field's :keymap property. (custom-mode): Fix docstring: substitute keybindings for `widget-forward' and `widget-backward' from `widget-keymap', `widget-complete' from `custom-field-keymap', replace old `Custom-move-and-invoke' with `widget-move-and-invoke'. Untabify.
author Juri Linkov <juri@jurta.org>
date Mon, 23 Jan 2006 01:21:24 +0000
parents 125d04254c22
children 5020a0c4a1aa 5b7d410e31f9
comparison
equal deleted inserted replaced
68342:e3989d3241d5 68343:05dbd20a248e
1468 Saving a change normally works by editing your Emacs init file. 1468 Saving a change normally works by editing your Emacs init file.
1469 See " 1469 See "
1470 (if custom-raised-buttons 1470 (if custom-raised-buttons
1471 "`Raised' text indicates" 1471 "`Raised' text indicates"
1472 "Square brackets indicate"))) 1472 "Square brackets indicate")))
1473 (widget-create 'info-link 1473 (widget-create 'custom-manual
1474 :tag "Custom file" 1474 :tag "Custom file"
1475 :button-face 'custom-link
1476 :mouse-face 'highlight
1477 "(emacs)Saving Customizations") 1475 "(emacs)Saving Customizations")
1478 (widget-insert 1476 (widget-insert
1479 " for information on how to save in a different file.\n 1477 " for information on how to save in a different file.\n
1480 See ") 1478 See ")
1481 (widget-create 'info-link 1479 (widget-create 'custom-manual
1482 :tag "Help" 1480 :tag "Help"
1483 :button-face 'custom-link
1484 :mouse-face 'highlight
1485 :help-echo "Read the online help." 1481 :help-echo "Read the online help."
1486 "(emacs)Easy Customization") 1482 "(emacs)Easy Customization")
1487 (widget-insert " for more information.\n\n") 1483 (widget-insert " for more information.\n\n")
1488 (widget-insert "Operate on all settings in this buffer that \ 1484 (widget-insert "Operate on all settings in this buffer that \
1489 are not marked HIDDEN:\n ")) 1485 are not marked HIDDEN:\n "))
1495 :action (lambda (widget &optional event) 1491 :action (lambda (widget &optional event)
1496 (Custom-set))) 1492 (Custom-set)))
1497 (if (not custom-buffer-verbose-help) 1493 (if (not custom-buffer-verbose-help)
1498 (progn 1494 (progn
1499 (widget-insert " ") 1495 (widget-insert " ")
1500 (widget-create 'info-link 1496 (widget-create 'custom-manual
1501 :tag "Help" 1497 :tag "Help"
1502 :button-face 'custom-link
1503 :mouse-face 'highlight
1504 :help-echo "Read the online help." 1498 :help-echo "Read the online help."
1505 "(emacs)Easy Customization"))) 1499 "(emacs)Easy Customization")))
1506 (when (or custom-file user-init-file) 1500 (when (or custom-file user-init-file)
1507 (widget-insert " ") 1501 (widget-insert " ")
1508 (widget-create 'push-button 1502 (widget-create 'push-button
1646 1640
1647 (defun custom-browse-visibility-action (widget &rest ignore) 1641 (defun custom-browse-visibility-action (widget &rest ignore)
1648 (let ((custom-buffer-style 'tree)) 1642 (let ((custom-buffer-style 'tree))
1649 (custom-toggle-parent widget))) 1643 (custom-toggle-parent widget)))
1650 1644
1651 (define-widget 'custom-browse-group-tag 'push-button 1645 (define-widget 'custom-browse-group-tag 'custom-group-link
1652 "Show parent in other window when activated." 1646 "Show parent in other window when activated."
1653 :tag "Group" 1647 :tag "Group"
1654 :tag-glyph "folder" 1648 :tag-glyph "folder"
1655 :action 'custom-browse-group-tag-action) 1649 :action 'custom-browse-group-tag-action)
1656 1650
1657 (defun custom-browse-group-tag-action (widget &rest ignore) 1651 (defun custom-browse-group-tag-action (widget &rest ignore)
1658 (let ((parent (widget-get widget :parent))) 1652 (let ((parent (widget-get widget :parent)))
1659 (customize-group-other-window (widget-value parent)))) 1653 (customize-group-other-window (widget-value parent))))
1660 1654
1661 (define-widget 'custom-browse-variable-tag 'push-button 1655 (define-widget 'custom-browse-variable-tag 'custom-group-link
1662 "Show parent in other window when activated." 1656 "Show parent in other window when activated."
1663 :tag "Option" 1657 :tag "Option"
1664 :tag-glyph "option" 1658 :tag-glyph "option"
1665 :action 'custom-browse-variable-tag-action) 1659 :action 'custom-browse-variable-tag-action)
1666 1660
1667 (defun custom-browse-variable-tag-action (widget &rest ignore) 1661 (defun custom-browse-variable-tag-action (widget &rest ignore)
1668 (let ((parent (widget-get widget :parent))) 1662 (let ((parent (widget-get widget :parent)))
1669 (customize-variable-other-window (widget-value parent)))) 1663 (customize-variable-other-window (widget-value parent))))
1670 1664
1671 (define-widget 'custom-browse-face-tag 'push-button 1665 (define-widget 'custom-browse-face-tag 'custom-group-link
1672 "Show parent in other window when activated." 1666 "Show parent in other window when activated."
1673 :tag "Face" 1667 :tag "Face"
1674 :tag-glyph "face" 1668 :tag-glyph "face"
1675 :action 'custom-browse-face-tag-action) 1669 :action 'custom-browse-face-tag-action)
1676 1670
2008 "Mouse face for custom buffer buttons if `custom-raised-buttons' is non-nil." 2002 "Mouse face for custom buffer buttons if `custom-raised-buttons' is non-nil."
2009 :version "22.1" 2003 :version "22.1"
2010 :group 'custom-faces) 2004 :group 'custom-faces)
2011 2005
2012 (defface custom-button-unraised 2006 (defface custom-button-unraised
2013 '((((min-colors 88) 2007 '((t :inherit underline))
2014 (class color) (background light)) :foreground "blue1" :underline t)
2015 (((class color) (background light)) :foreground "blue" :underline t)
2016 (((min-colors 88)
2017 (class color) (background dark)) :foreground "cyan1" :underline t)
2018 (((class color) (background dark)) :foreground "cyan" :underline t)
2019 (t :underline t))
2020 "Face for custom buffer buttons if `custom-raised-buttons' is nil." 2008 "Face for custom buffer buttons if `custom-raised-buttons' is nil."
2021 :version "22.1" 2009 :version "22.1"
2022 :group 'custom-faces) 2010 :group 'custom-faces)
2023 2011
2024 (setq custom-button 2012 (setq custom-button
2069 :group 'custom-faces) 2057 :group 'custom-faces)
2070 ;; backward-compatibility alias 2058 ;; backward-compatibility alias
2071 (put 'custom-state-face 'face-alias 'custom-state) 2059 (put 'custom-state-face 'face-alias 'custom-state)
2072 2060
2073 (defface custom-link 2061 (defface custom-link
2074 '((((min-colors 88) 2062 '((t :inherit link))
2075 (class color) (background light)) :foreground "blue1" :underline t) 2063 "Face for links in customization buffers."
2076 (((class color) (background light)) :foreground "blue" :underline t) 2064 :version "22.1"
2077 (((min-colors 88) 2065 :group 'custom-faces)
2078 (class color) (background dark)) :foreground "cyan1" :underline t)
2079 (((class color) (background dark)) :foreground "cyan" :underline t)
2080 (t :underline t))
2081 "Face for Info links in customization buffers."
2082 :group 'info)
2083 2066
2084 (define-widget 'custom 'default 2067 (define-widget 'custom 'default
2085 "Customize a user option." 2068 "Customize a user option."
2086 :format "%v" 2069 :format "%v"
2087 :convert-widget 'custom-convert-widget 2070 :convert-widget 'custom-convert-widget
2244 (mapatoms (lambda (symbol) 2227 (mapatoms (lambda (symbol)
2245 (when (member (list name type) (get symbol 'custom-group)) 2228 (when (member (list name type) (get symbol 'custom-group))
2246 (insert " ") 2229 (insert " ")
2247 (push (widget-create-child-and-convert 2230 (push (widget-create-child-and-convert
2248 widget 'custom-group-link 2231 widget 'custom-group-link
2249 :button-face 'custom-link
2250 :mouse-face 'highlight
2251 :tag (custom-unlispify-tag-name symbol) 2232 :tag (custom-unlispify-tag-name symbol)
2252 symbol) 2233 symbol)
2253 buttons) 2234 buttons)
2254 (setq parents (cons symbol parents))))) 2235 (setq parents (cons symbol parents)))))
2255 (and (null (get name 'custom-links)) ;No links of its own. 2236 (and (null (get name 'custom-links)) ;No links of its own.
3605 3586
3606 ;;; The `custom-group-link' Widget. 3587 ;;; The `custom-group-link' Widget.
3607 3588
3608 (define-widget 'custom-group-link 'link 3589 (define-widget 'custom-group-link 'link
3609 "Show parent in other window when activated." 3590 "Show parent in other window when activated."
3591 :button-face 'custom-link
3592 :mouse-face 'highlight
3610 :help-echo "Create customization buffer for this group." 3593 :help-echo "Create customization buffer for this group."
3611 :action 'custom-group-link-action) 3594 :action 'custom-group-link-action)
3612 3595
3613 (defun custom-group-link-action (widget &rest ignore) 3596 (defun custom-group-link-action (widget &rest ignore)
3614 (customize-group (widget-value widget))) 3597 (customize-group (widget-value widget)))
3803 (insert " group: ") 3786 (insert " group: ")
3804 ;; Create link/visibility indicator. 3787 ;; Create link/visibility indicator.
3805 (if (eq custom-buffer-style 'links) 3788 (if (eq custom-buffer-style 'links)
3806 (push (widget-create-child-and-convert 3789 (push (widget-create-child-and-convert
3807 widget 'custom-group-link 3790 widget 'custom-group-link
3808 :button-face 'custom-link
3809 :mouse-face 'highlight
3810 :tag "Go to Group" 3791 :tag "Go to Group"
3811 symbol) 3792 symbol)
3812 buttons) 3793 buttons)
3813 (push (widget-create-child-and-convert 3794 (push (widget-create-child-and-convert
3814 widget 'custom-group-visibility 3795 widget 'custom-group-visibility
4398 ["Undo Edits" Custom-reset-current t] 4379 ["Undo Edits" Custom-reset-current t]
4399 ["Reset to Saved" Custom-reset-saved t] 4380 ["Reset to Saved" Custom-reset-saved t]
4400 ["Erase Customization" Custom-reset-standard t] 4381 ["Erase Customization" Custom-reset-standard t]
4401 ["Info" (info "(emacs)Easy Customization") t])) 4382 ["Info" (info "(emacs)Easy Customization") t]))
4402 4383
4384 (defvar custom-field-keymap
4385 (let ((map (copy-keymap widget-field-keymap)))
4386 (define-key map "\C-c\C-c" 'Custom-set)
4387 (define-key map "\C-x\C-s" 'Custom-save)
4388 map)
4389 "Keymap used inside editable fields in customization buffers.")
4390
4391 (widget-put (get 'editable-field 'widget-type) :keymap custom-field-keymap)
4392
4403 (defun Custom-goto-parent () 4393 (defun Custom-goto-parent ()
4404 "Go to the parent group listed at the top of this buffer. 4394 "Go to the parent group listed at the top of this buffer.
4405 If several parents are listed, go to the first of them." 4395 If several parents are listed, go to the first of them."
4406 (interactive) 4396 (interactive)
4407 (save-excursion 4397 (save-excursion
4423 (defun custom-mode () 4413 (defun custom-mode ()
4424 "Major mode for editing customization buffers. 4414 "Major mode for editing customization buffers.
4425 4415
4426 The following commands are available: 4416 The following commands are available:
4427 4417
4428 Move to next button or editable field. \\[widget-forward] 4418 \\<widget-keymap>\
4429 Move to previous button or editable field. \\[widget-backward] 4419 Move to next button, link or editable field. \\[widget-forward]
4430 \\<widget-field-keymap>\ 4420 Move to previous button, link or editable field. \\[widget-backward]
4421 \\<custom-field-keymap>\
4431 Complete content of editable text field. \\[widget-complete] 4422 Complete content of editable text field. \\[widget-complete]
4432 \\<custom-mode-map>\ 4423 \\<custom-mode-map>\
4433 Invoke button under the mouse pointer. \\[Custom-move-and-invoke] 4424 Invoke button under the mouse pointer. \\[widget-move-and-invoke]
4434 Invoke button under point. \\[widget-button-press] 4425 Invoke button under point. \\[widget-button-press]
4435 Set all options from current text. \\[Custom-set] 4426 Set all options from current text. \\[Custom-set]
4436 Make values in current text permanent. \\[Custom-save] 4427 Make values in current text permanent. \\[Custom-save]
4437 Make text match actual option values. \\[Custom-reset-current] 4428 Make text match actual option values. \\[Custom-reset-current]
4438 Reset options to permanent settings. \\[Custom-reset-saved] 4429 Reset options to permanent settings. \\[Custom-reset-saved]
4439 Erase customizations; set options 4430 Erase customizations; set options
4440 and buffer text to the standard values. \\[Custom-reset-standard] 4431 and buffer text to the standard values. \\[Custom-reset-standard]
4441 4432
4442 Entry to this mode calls the value of `custom-mode-hook' 4433 Entry to this mode calls the value of `custom-mode-hook'
4443 if that value is non-nil." 4434 if that value is non-nil."