comparison lisp/custom/wid-browse.el @ 124:9b50b4588a93 r20-1b15

Import from CVS: tag r20-1b15
author cvs
date Mon, 13 Aug 2007 09:26:39 +0200
parents cca96a509cfe
children 34a5b81f86ba
comparison
equal deleted inserted replaced
123:c77884c6318d 124:9b50b4588a93
2 ;; 2 ;;
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: extensions 6 ;; Keywords: extensions
7 ;; Version: 1.74 7 ;; Version: 1.84
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 9
10 ;;; Commentary: 10 ;;; Commentary:
11 ;; 11 ;;
12 ;; Widget browser. See `widget.el'. 12 ;; Widget browser. See `widget.el'.
27 (defvar widget-browse-mode-map nil 27 (defvar widget-browse-mode-map nil
28 "Keymap for `widget-browse-mode'.") 28 "Keymap for `widget-browse-mode'.")
29 29
30 (unless widget-browse-mode-map 30 (unless widget-browse-mode-map
31 (setq widget-browse-mode-map (make-sparse-keymap)) 31 (setq widget-browse-mode-map (make-sparse-keymap))
32 (set-keymap-parent widget-browse-mode-map widget-keymap)) 32 (set-keymap-parent widget-browse-mode-map widget-keymap)
33 (define-key widget-browse-mode-map "q" 'bury-buffer))
34
35 (easy-menu-define widget-browse-mode-customize-menu
36 widget-browse-mode-map
37 "Menu used in widget browser buffers."
38 (customize-menu-create 'widgets))
33 39
34 (easy-menu-define widget-browse-mode-menu 40 (easy-menu-define widget-browse-mode-menu
35 widget-browse-mode-map 41 widget-browse-mode-map
36 "Menu used in widget browser buffers." 42 "Menu used in widget browser buffers."
37 '("Widget" 43 '("Widget"
57 if that value is non-nil." 63 if that value is non-nil."
58 (kill-all-local-variables) 64 (kill-all-local-variables)
59 (setq major-mode 'widget-browse-mode 65 (setq major-mode 'widget-browse-mode
60 mode-name "Widget") 66 mode-name "Widget")
61 (use-local-map widget-browse-mode-map) 67 (use-local-map widget-browse-mode-map)
68 (easy-menu-add widget-browse-mode-customize-menu)
62 (easy-menu-add widget-browse-mode-menu) 69 (easy-menu-add widget-browse-mode-menu)
63 (run-hooks 'widget-browse-mode-hook)) 70 (run-hooks 'widget-browse-mode-hook))
64 71
65 ;;; Commands. 72 ;;; Commands.
66 73
80 (widget-browse widget)) 87 (widget-browse widget))
81 (message text))) 88 (message text)))
82 89
83 (defvar widget-browse-history nil) 90 (defvar widget-browse-history nil)
84 91
92 ;;;###autoload
85 (defun widget-browse (widget) 93 (defun widget-browse (widget)
86 "Create a widget browser for WIDGET." 94 "Create a widget browser for WIDGET."
87 (interactive (list (completing-read "Widget: " 95 (interactive (list (completing-read "Widget: "
88 obarray 96 obarray
89 (lambda (symbol) 97 (lambda (symbol)
104 (kill-buffer (get-buffer-create "*Browse Widget*")) 112 (kill-buffer (get-buffer-create "*Browse Widget*"))
105 (switch-to-buffer (get-buffer-create "*Browse Widget*"))) 113 (switch-to-buffer (get-buffer-create "*Browse Widget*")))
106 (widget-browse-mode) 114 (widget-browse-mode)
107 115
108 ;; Quick way to get out. 116 ;; Quick way to get out.
109 (widget-create 'push-button 117 ;; (widget-create 'push-button
110 :action (lambda (widget &optional event) 118 ;; :action (lambda (widget &optional event)
111 (bury-buffer)) 119 ;; (bury-buffer))
112 "Quit") 120 ;; "Quit")
113 (widget-insert "\n") 121 ;; (widget-insert "\n")
114 122
115 ;; Top text indicating whether it is a class or object browser. 123 ;; Top text indicating whether it is a class or object browser.
116 (if (listp widget) 124 (if (listp widget)
117 (widget-insert "Widget object browser.\n\nClass: ") 125 (widget-insert "Widget object browser.\n\nClass: ")
118 (widget-insert "Widget class browser.\n\n") 126 (widget-insert "Widget class browser.\n\n")
143 (funcall printer widget key value) 151 (funcall printer widget key value)
144 (widget-insert "\n"))) 152 (widget-insert "\n")))
145 (widget-setup) 153 (widget-setup)
146 (goto-char (point-min))) 154 (goto-char (point-min)))
147 155
156 ;;;###autoload
157 (defun widget-browse-other-window (&optional widget)
158 "Show widget browser for WIDGET in other window."
159 (interactive)
160 (let ((window (selected-window)))
161 (switch-to-buffer-other-window "*Browse Widget*")
162 (if widget
163 (widget-browse widget)
164 (call-interactively 'widget-browse))
165 (select-window window)))
166
167
148 ;;; The `widget-browse' Widget. 168 ;;; The `widget-browse' Widget.
149 169
150 (define-widget 'widget-browse 'push-button 170 (define-widget 'widget-browse 'push-button
151 "Button for creating a widget browser. 171 "Button for creating a widget browser.
152 The :value of the widget shuld be the widget to be browsed." 172 The :value of the widget shuld be the widget to be browsed."