annotate lisp/wid-browse.el @ 74152:5a2066ffc645

(gnus-agent-expire-unagentized-dirs, gnus-agent-regenerate-group): Fix space/tab mixup in messages.
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 24 Nov 2006 10:46:43 +0000
parents 3bd95f4f2941
children b2e5081b9320 c5406394f567
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 32905
diff changeset
1 ;;; wid-browse.el --- functions for browsing widgets
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
2 ;;
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64762
diff changeset
3 ;; Copyright (C) 1997, 2002, 2003, 2004, 2005,
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64762
diff changeset
4 ;; 2006 Free Software Foundation, Inc.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
5 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
7 ;; Keywords: extensions
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
8
17799
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
9 ;; This file is part of GNU Emacs.
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
10
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
14 ;; any later version.
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
15
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
19 ;; GNU General Public License for more details.
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
20
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
21 ;; You should have received a copy of the GNU General Public License
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62747
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62747
diff changeset
24 ;; Boston, MA 02110-1301, USA.
17799
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17550
diff changeset
25
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
26 ;;; Commentary:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
27 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
28 ;; Widget browser. See `widget.el'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
29
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
30 ;;; Code:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
31
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
32 (require 'easymenu)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
33 (require 'custom)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
34 (require 'wid-edit)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
35 (eval-when-compile (require 'cl))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
36
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
37 (defgroup widget-browse nil
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
38 "Customization support for browsing widgets."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
39 :group 'widgets)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
40
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
41 ;;; The Mode.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
42
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
43 (defvar widget-browse-mode-map nil
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
44 "Keymap for `widget-browse-mode'.")
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46836
diff changeset
45
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
46 (unless widget-browse-mode-map
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
47 (setq widget-browse-mode-map (make-sparse-keymap))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
48 (set-keymap-parent widget-browse-mode-map widget-keymap)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
49 (define-key widget-browse-mode-map "q" 'bury-buffer))
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
50
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46836
diff changeset
51 (easy-menu-define widget-browse-mode-customize-menu
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
52 widget-browse-mode-map
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
53 "Menu used in widget browser buffers."
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
54 (customize-menu-create 'widgets))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
55
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46836
diff changeset
56 (easy-menu-define widget-browse-mode-menu
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
57 widget-browse-mode-map
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
58 "Menu used in widget browser buffers."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
59 '("Widget"
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
60 ["Browse" widget-browse t]
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
61 ["Browse At" widget-browse-at t]))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
62
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
63 (defcustom widget-browse-mode-hook nil
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
64 "Hook called when entering widget-browse-mode."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
65 :type 'hook
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
66 :group 'widget-browse)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
67
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
68 (defun widget-browse-mode ()
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
69 "Major mode for widget browser buffers.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
70
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
71 The following commands are available:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
72
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
73 \\[widget-forward] Move to next button or editable field.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
74 \\[widget-backward] Move to previous button or editable field.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
75 \\[widget-button-click] Activate button under the mouse pointer.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
76 \\[widget-button-press] Activate button under point.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
77
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
78 Entry to this mode calls the value of `widget-browse-mode-hook'
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
79 if that value is non-nil."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
80 (kill-all-local-variables)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
81 (setq major-mode 'widget-browse-mode
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
82 mode-name "Widget")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
83 (use-local-map widget-browse-mode-map)
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
84 (easy-menu-add widget-browse-mode-customize-menu)
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
85 (easy-menu-add widget-browse-mode-menu)
62747
05708d980e7a (widget-browse-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
86 (run-mode-hooks 'widget-browse-mode-hook))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
87
32905
c197a16ba190 (widget-browse-mode): Add `special' mode-class property.
Dave Love <fx@gnu.org>
parents: 18244
diff changeset
88 (put 'widget-browse-mode 'mode-class 'special)
c197a16ba190 (widget-browse-mode): Add `special' mode-class property.
Dave Love <fx@gnu.org>
parents: 18244
diff changeset
89
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
90 ;;; Commands.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
91
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
92 ;;;###autoload
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
93 (defun widget-browse-at (pos)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
94 "Browse the widget under point."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
95 (interactive "d")
18090
2983683a278b Synched with 1.9905
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17799
diff changeset
96 (let* ((field (get-char-property pos 'field))
2983683a278b Synched with 1.9905
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17799
diff changeset
97 (button (get-char-property pos 'button))
2983683a278b Synched with 1.9905
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17799
diff changeset
98 (doc (get-char-property pos 'widget-doc))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
99 (text (cond (field "This is an editable text area.")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
100 (button "This is an active area.")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
101 (doc "This is documentation text.")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
102 (t "This is unidentified text.")))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
103 (widget (or field button doc)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
104 (when widget
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
105 (widget-browse widget))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
106 (message text)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
107
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
108 (defvar widget-browse-history nil)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
109
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
110 ;;;###autoload
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
111 (defun widget-browse (widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
112 "Create a widget browser for WIDGET."
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46836
diff changeset
113 (interactive (list (completing-read "Widget: "
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
114 obarray
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
115 (lambda (symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
116 (get symbol 'widget-type))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
117 t nil 'widget-browse-history)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
118 (if (stringp widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
119 (setq widget (intern widget)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
120 (unless (if (symbolp widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
121 (get widget 'widget-type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
122 (and (consp widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
123 (get (widget-type widget) 'widget-type)))
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 32905
diff changeset
124 (error "Not a widget"))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
125 ;; Create the buffer.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
126 (if (symbolp widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
127 (let ((buffer (format "*Browse %s Widget*" widget)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
128 (kill-buffer (get-buffer-create buffer))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
129 (switch-to-buffer (get-buffer-create buffer)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
130 (kill-buffer (get-buffer-create "*Browse Widget*"))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
131 (switch-to-buffer (get-buffer-create "*Browse Widget*")))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
132 (widget-browse-mode)
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46836
diff changeset
133
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
134 ;; Quick way to get out.
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
135 ;; (widget-create 'push-button
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
136 ;; :action (lambda (widget &optional event)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
137 ;; (bury-buffer))
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
138 ;; "Quit")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
139 ;; (widget-insert "\n")
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
140
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
141 ;; Top text indicating whether it is a class or object browser.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
142 (if (listp widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
143 (widget-insert "Widget object browser.\n\nClass: ")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
144 (widget-insert "Widget class browser.\n\n")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
145 (widget-create 'widget-browse
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
146 :format "%[%v%]\n%d"
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
147 :doc (get widget 'widget-documentation)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
148 widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
149 (unless (eq (preceding-char) ?\n)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
150 (widget-insert "\n"))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
151 (widget-insert "\nSuper: ")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
152 (setq widget (get widget 'widget-type)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
153
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
154 ;; Now show the attributes.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
155 (let ((name (car widget))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
156 (items (cdr widget))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
157 key value printer)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
158 (widget-create 'widget-browse
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
159 :format "%[%v%]"
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
160 name)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
161 (widget-insert "\n")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
162 (while items
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
163 (setq key (nth 0 items)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
164 value (nth 1 items)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
165 printer (or (get key 'widget-keyword-printer)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
166 'widget-browse-sexp)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
167 items (cdr (cdr items)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
168 (widget-insert "\n" (symbol-name key) "\n\t")
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
169 (funcall printer widget key value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
170 (widget-insert "\n")))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
171 (widget-setup)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
172 (goto-char (point-min)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
173
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
174 ;;;###autoload
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
175 (defun widget-browse-other-window (&optional widget)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
176 "Show widget browser for WIDGET in other window."
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
177 (interactive)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
178 (let ((window (selected-window)))
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
179 (switch-to-buffer-other-window "*Browse Widget*")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
180 (if widget
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
181 (widget-browse widget)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
182 (call-interactively 'widget-browse))
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
183 (select-window window)))
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
184
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17334
diff changeset
185
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
186 ;;; The `widget-browse' Widget.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
187
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
188 (define-widget 'widget-browse 'push-button
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
189 "Button for creating a widget browser.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
190 The :value of the widget shuld be the widget to be browsed."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
191 :format "%[[%v]%]"
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
192 :value-create 'widget-browse-value-create
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
193 :action 'widget-browse-action)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
194
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
195 (defun widget-browse-action (widget &optional event)
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46836
diff changeset
196 ;; Create widget browser for WIDGET's :value.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
197 (widget-browse (widget-get widget :value)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
198
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
199 (defun widget-browse-value-create (widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
200 ;; Insert type name.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
201 (let ((value (widget-get widget :value)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
202 (cond ((symbolp value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
203 (insert (symbol-name value)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
204 ((consp value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
205 (insert (symbol-name (widget-type value))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
206 (t
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
207 (insert "strange")))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
208
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
209 ;;; Keyword Printer Functions.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
210
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
211 (defun widget-browse-widget (widget key value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
212 "Insert description of WIDGET's KEY VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
213 VALUE is assumed to be a widget."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
214 (widget-create 'widget-browse value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
215
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
216 (defun widget-browse-widgets (widget key value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
217 "Insert description of WIDGET's KEY VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
218 VALUE is assumed to be a list of widgets."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
219 (while value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
220 (widget-create 'widget-browse
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
221 (car value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
222 (setq value (cdr value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
223 (when value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
224 (widget-insert " "))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
225
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
226 (defun widget-browse-sexp (widget key value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
227 "Insert description of WIDGET's KEY VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
228 Nothing is assumed about value."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
229 (let ((pp (condition-case signal
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
230 (pp-to-string value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
231 (error (prin1-to-string signal)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
232 (when (string-match "\n\\'" pp)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
233 (setq pp (substring pp 0 (1- (length pp)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
234 (if (cond ((string-match "\n" pp)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
235 nil)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
236 ((> (length pp) (- (window-width) (current-column)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
237 nil)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
238 (t t))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
239 (widget-insert pp)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
240 (widget-create 'push-button
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
241 :tag "show"
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
242 :action (lambda (widget &optional event)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
243 (with-output-to-temp-buffer
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
244 "*Pp Eval Output*"
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
245 (princ (widget-get widget :value))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
246 pp))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
247
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
248 (defun widget-browse-sexps (widget key value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
249 "Insert description of WIDGET's KEY VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
250 VALUE is assumed to be a list of widgets."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
251 (let ((target (current-column)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
252 (while value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
253 (widget-browse-sexp widget key (car value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
254 (setq value (cdr value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
255 (when value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
256 (widget-insert "\n" (make-string target ?\ ))))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
257
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
258 ;;; Keyword Printers.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
259
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
260 (put :parent 'widget-keyword-printer 'widget-browse-widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
261 (put :children 'widget-keyword-printer 'widget-browse-widgets)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
262 (put :buttons 'widget-keyword-printer 'widget-browse-widgets)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
263 (put :button 'widget-keyword-printer 'widget-browse-widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
264 (put :args 'widget-keyword-printer 'widget-browse-sexps)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
265
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
266 ;;; Widget Minor Mode.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
267
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
268 (defvar widget-minor-mode nil
46836
cd975daf6365 * xt-mouse.el (xterm-mouse-mode): Make it a global mode.
John Paul Wallington <jpw@pobox.com>
parents: 43295
diff changeset
269 "If non-nil, we are in Widget Minor Mode.")
cd975daf6365 * xt-mouse.el (xterm-mouse-mode): Make it a global mode.
John Paul Wallington <jpw@pobox.com>
parents: 43295
diff changeset
270 (make-variable-buffer-local 'widget-minor-mode)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
271
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
272 (defvar widget-minor-mode-map nil
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
273 "Keymap used in Widget Minor Mode.")
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
274
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
275 (unless widget-minor-mode-map
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
276 (setq widget-minor-mode-map (make-sparse-keymap))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
277 (set-keymap-parent widget-minor-mode-map widget-keymap))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
278
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
279 ;;;###autoload
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
280 (defun widget-minor-mode (&optional arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
281 "Togle minor mode for traversing widgets.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
282 With arg, turn widget mode on if and only if arg is positive."
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
283 (interactive "P")
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
284 (cond ((null arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
285 (setq widget-minor-mode (not widget-minor-mode)))
18244
909a0f9169b8 Synched with 1.9914.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 18090
diff changeset
286 ((<= arg 0)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
287 (setq widget-minor-mode nil))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
288 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
289 (setq widget-minor-mode t)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
290 (force-mode-line-update))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
291
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
292 (add-to-list 'minor-mode-alist '(widget-minor-mode " Widget"))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
293
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46836
diff changeset
294 (add-to-list 'minor-mode-map-alist
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
295 (cons 'widget-minor-mode widget-minor-mode-map))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17415
diff changeset
296
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
297 ;;; The End:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
298
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
299 (provide 'wid-browse)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
300
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49597
diff changeset
301 ;;; arch-tag: d5ffb18f-8984-4735-8502-edf70456db21
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 32905
diff changeset
302 ;;; wid-browse.el ends here