comparison lisp/cus-edit.el @ 73795:4064a5037466

(custom-mode-map): Move defvar above code using it. (custom-mode-link-map): New variable. (custom-group-link, custom-manual): Use follow-link.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 06 Nov 2006 22:05:23 +0000
parents 13cf25f8b198
children 2e5ad09135ff
comparison
equal deleted inserted replaced
73794:f2f9784a8ff5 73795:4064a5037466
463 "Mac specific features." 463 "Mac specific features."
464 :link '(custom-manual "(emacs)Mac OS") 464 :link '(custom-manual "(emacs)Mac OS")
465 :group 'environment 465 :group 'environment
466 :version "22.1" 466 :version "22.1"
467 :prefix "mac-") 467 :prefix "mac-")
468
469 ;;; Custom mode keymaps
470
471 (defvar custom-mode-map
472 ;; This keymap should be dense, but a dense keymap would prevent inheriting
473 ;; "\r" bindings from the parent map.
474 ;; Actually, this misfeature of dense keymaps was fixed on 2001-11-26.
475 (let ((map (make-keymap)))
476 (set-keymap-parent map widget-keymap)
477 (define-key map [remap self-insert-command] 'Custom-no-edit)
478 (define-key map "\^m" 'Custom-newline)
479 (define-key map " " 'scroll-up)
480 (define-key map "\177" 'scroll-down)
481 (define-key map "\C-c\C-c" 'Custom-set)
482 (define-key map "\C-x\C-s" 'Custom-save)
483 (define-key map "q" 'Custom-buffer-done)
484 (define-key map "u" 'Custom-goto-parent)
485 (define-key map "n" 'widget-forward)
486 (define-key map "p" 'widget-backward)
487 map)
488 "Keymap for `custom-mode'.")
489
490 (defvar custom-mode-link-map
491 (let ((map (make-keymap)))
492 (set-keymap-parent map custom-mode-map)
493 (define-key map [down-mouse-2] nil)
494 (define-key map [down-mouse-1] 'mouse-drag-region)
495 (define-key map [mouse-2] 'widget-move-and-invoke)
496 map)
497 "Local keymap for links in `custom-mode'.")
498
468 499
469 ;;; Utilities. 500 ;;; Utilities.
470 501
471 (defun custom-split-regexp-maybe (regexp) 502 (defun custom-split-regexp-maybe (regexp)
472 "If REGEXP is a string, split it to a list at `\\|'. 503 "If REGEXP is a string, split it to a list at `\\|'.
1779 ;;; The `custom-manual' Widget. 1810 ;;; The `custom-manual' Widget.
1780 1811
1781 (define-widget 'custom-manual 'info-link 1812 (define-widget 'custom-manual 'info-link
1782 "Link to the manual entry for this customization option." 1813 "Link to the manual entry for this customization option."
1783 :help-echo "Read the manual entry for this option." 1814 :help-echo "Read the manual entry for this option."
1815 :keymap custom-mode-link-map
1816 :follow-link 'mouse-face
1784 :button-face 'custom-link 1817 :button-face 'custom-link
1785 :mouse-face 'highlight 1818 :mouse-face 'highlight
1786 :pressed-face 'highlight 1819 :pressed-face 'highlight
1787 :tag "Manual") 1820 :tag "Manual")
1788 1821
3671 "Show parent in other window when activated." 3704 "Show parent in other window when activated."
3672 :button-face 'custom-link 3705 :button-face 'custom-link
3673 :mouse-face 'highlight 3706 :mouse-face 'highlight
3674 :pressed-face 'highlight 3707 :pressed-face 'highlight
3675 :help-echo "Create customization buffer for this group." 3708 :help-echo "Create customization buffer for this group."
3709 :keymap custom-mode-link-map
3710 :follow-link 'mouse-face
3676 :action 'custom-group-link-action) 3711 :action 'custom-group-link-action)
3677 3712
3678 (defun custom-group-link-action (widget &rest ignore) 3713 (defun custom-group-link-action (widget &rest ignore)
3679 (customize-group (widget-value widget))) 3714 (customize-group (widget-value widget)))
3680 3715
4449 (let ((menu (custom-menu-create ',symbol))) 4484 (let ((menu (custom-menu-create ',symbol)))
4450 (if (consp menu) (cdr menu) menu))))) 4485 (if (consp menu) (cdr menu) menu)))))
4451 4486
4452 ;;; The Custom Mode. 4487 ;;; The Custom Mode.
4453 4488
4454 (defvar custom-mode-map
4455 ;; This keymap should be dense, but a dense keymap would prevent inheriting
4456 ;; "\r" bindings from the parent map.
4457 ;; Actually, this misfeature of dense keymaps was fixed on 2001-11-26.
4458 (let ((map (make-keymap)))
4459 (set-keymap-parent map widget-keymap)
4460 (define-key map [remap self-insert-command] 'Custom-no-edit)
4461 (define-key map "\^m" 'Custom-newline)
4462 (define-key map " " 'scroll-up)
4463 (define-key map "\177" 'scroll-down)
4464 (define-key map "\C-c\C-c" 'Custom-set)
4465 (define-key map "\C-x\C-s" 'Custom-save)
4466 (define-key map "q" 'Custom-buffer-done)
4467 (define-key map "u" 'Custom-goto-parent)
4468 (define-key map "n" 'widget-forward)
4469 (define-key map "p" 'widget-backward)
4470 map)
4471 "Keymap for `custom-mode'.")
4472
4473 (defun Custom-no-edit (pos &optional event) 4489 (defun Custom-no-edit (pos &optional event)
4474 "Invoke button at POS, or refuse to allow editing of Custom buffer." 4490 "Invoke button at POS, or refuse to allow editing of Custom buffer."
4475 (interactive "@d") 4491 (interactive "@d")
4476 (error "You can't edit this part of the Custom buffer")) 4492 (error "You can't edit this part of the Custom buffer"))
4477 4493