wid-edit.el 117 KB
Newer Older
1
;;; wid-edit.el --- Functions for creating and using widgets -*-byte-compile-dynamic: t;-*-
Per Abrahamsen's avatar
Per Abrahamsen committed
2
;;
3
;; Copyright (C) 1996,97,1999,2000,01,02,2003, 2004, 2005  Free Software Foundation, Inc.
Per Abrahamsen's avatar
Per Abrahamsen committed
4 5
;;
;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6
;; Maintainer: FSF
Per Abrahamsen's avatar
Per Abrahamsen committed
7 8
;; Keywords: extensions

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
;;; Wishlist items (from widget.texi):

;; * The `menu-choice' tag should be prettier, something like the
;;   abbreviated menus in Open Look.

;; * Finish `:tab-order'.

;; * Make indentation work with glyphs and proportional fonts.

;; * Add commands to show overview of object and class hierarchies to
;;   the browser.

;; * Find a way to disable mouse highlight for inactive widgets.

;; * Find a way to make glyphs look inactive.

;; * Add `key-binding' widget.

;; * Add `widget' widget for editing widget specifications.

;; * Find clean way to implement variable length list.  See
;;   `TeX-printer-list' for an explanation.

;; * `C-h' in `widget-prompt-value' should give type specific help.

;; * A mailto widget. [This should work OK as a url-link if with
;;   browse-url-browser-function' set up appropriately.]

Per Abrahamsen's avatar
Per Abrahamsen committed
54 55 56 57 58 59 60
;;; Commentary:
;;
;; See `widget.el'.

;;; Code:

;;; Compatibility.
61

62 63
(defun widget-event-point (event)
  "Character position of the end of event if that exists, or nil."
64
  (posn-point (event-end event)))
65

66 67 68 69 70 71
(defun widget-button-release-event-p (event)
  "Non-nil if EVENT is a mouse-button-release event object."
  (and (eventp event)
       (memq (event-basic-type event) '(mouse-1 mouse-2 mouse-3))
       (or (memq 'click (event-modifiers event))
	   (memq  'drag (event-modifiers event)))))
Per Abrahamsen's avatar
Per Abrahamsen committed
72 73 74 75 76 77

;;; Customization.

(defgroup widgets nil
  "Customization support for the Widget Library."
  :link '(custom-manual "(widget)Top")
Per Abrahamsen's avatar
Per Abrahamsen committed
78
  :link '(emacs-library-link :tag "Lisp File" "widget.el")
Per Abrahamsen's avatar
Per Abrahamsen committed
79 80 81 82
  :prefix "widget-"
  :group 'extensions
  :group 'hypermedia)

Per Abrahamsen's avatar
Per Abrahamsen committed
83 84 85 86
(defgroup widget-documentation nil
  "Options controling the display of documentation strings."
  :group 'widgets)

Per Abrahamsen's avatar
Per Abrahamsen committed
87 88 89 90 91
(defgroup widget-faces nil
  "Faces used by the widget library."
  :group 'widgets
  :group 'faces)

92
(defvar widget-documentation-face 'widget-documentation-face
93
  "Face used for documentation strings in widgets.
94 95
This exists as a variable so it can be set locally in certain buffers.")

Per Abrahamsen's avatar
Per Abrahamsen committed
96 97 98 99 100 101 102 103 104 105 106
(defface widget-documentation-face '((((class color)
				       (background dark))
				      (:foreground "lime green"))
				     (((class color)
				       (background light))
				      (:foreground "dark green"))
				     (t nil))
  "Face used for documentation text."
  :group 'widget-documentation
  :group 'widget-faces)

107
(defvar widget-button-face 'widget-button-face
108
  "Face used for buttons in widgets.
109 110
This exists as a variable so it can be set locally in certain buffers.")

111
(defface widget-button-face '((t (:weight bold)))
Per Abrahamsen's avatar
Per Abrahamsen committed
112
  "Face used for widget buttons."
Per Abrahamsen's avatar
Per Abrahamsen committed
113
  :group 'widget-faces)
Per Abrahamsen's avatar
Per Abrahamsen committed
114 115 116 117

(defcustom widget-mouse-face 'highlight
  "Face used for widget buttons when the mouse is above them."
  :type 'face
Per Abrahamsen's avatar
Per Abrahamsen committed
118
  :group 'widget-faces)
Per Abrahamsen's avatar
Per Abrahamsen committed
119

120 121 122 123
;; TTY gets special definitions here and in the next defface, because
;; the gray colors defined for other displays cause black text on a black
;; background, at least on light-background TTYs.
(defface widget-field-face '((((type tty))
124 125
			      :background "yellow3"
			      :foreground "black")
126
			     (((class grayscale color)
Per Abrahamsen's avatar
Per Abrahamsen committed
127
			       (background light))
128
			      :background "gray85")
Per Abrahamsen's avatar
Per Abrahamsen committed
129 130
			     (((class grayscale color)
			       (background dark))
131
			      :background "dim gray")
132
			     (t
133
			      :slant italic))
Per Abrahamsen's avatar
Per Abrahamsen committed
134
  "Face used for editable fields."
Per Abrahamsen's avatar
Per Abrahamsen committed
135
  :group 'widget-faces)
Per Abrahamsen's avatar
Per Abrahamsen committed
136

137
(defface widget-single-line-field-face '((((type tty))
138 139
					  :background "green3"
					  :foreground "black")
140
					 (((class grayscale color)
Per Abrahamsen's avatar
Per Abrahamsen committed
141
					   (background light))
142
					  :background "gray85")
Per Abrahamsen's avatar
Per Abrahamsen committed
143 144
					 (((class grayscale color)
					   (background dark))
145
					  :background "dim gray")
146
					 (t
147
					  :slant italic))
Per Abrahamsen's avatar
Per Abrahamsen committed
148 149 150
  "Face used for editable fields spanning only a single line."
  :group 'widget-faces)

151 152 153 154 155 156 157 158 159 160 161
;;; This causes display-table to be loaded, and not usefully.
;;;(defvar widget-single-line-display-table
;;;  (let ((table (make-display-table)))
;;;    (aset table 9  "^I")
;;;    (aset table 10 "^J")
;;;    table)
;;;  "Display table used for single-line editable fields.")

;;;(when (fboundp 'set-face-display-table)
;;;  (set-face-display-table 'widget-single-line-field-face
;;;			  widget-single-line-display-table))
Per Abrahamsen's avatar
Per Abrahamsen committed
162

Per Abrahamsen's avatar
Per Abrahamsen committed
163 164 165 166 167
;;; Utility functions.
;;
;; These are not really widget specific.

(defun widget-princ-to-string (object)
168 169 170 171 172
  "Return string representation of OBJECT, any Lisp object.
No quoting characters are used; no delimiters are printed around
the contents of strings."
  (with-output-to-string
      (princ object)))
Per Abrahamsen's avatar
Per Abrahamsen committed
173 174 175 176 177 178

(defun widget-clear-undo ()
  "Clear all undo information."
  (buffer-disable-undo (current-buffer))
  (buffer-enable-undo))

Per Abrahamsen's avatar
Per Abrahamsen committed
179 180 181 182 183 184
(defcustom widget-menu-max-size 40
  "Largest number of items allowed in a popup-menu.
Larger menus are read through the minibuffer."
  :group 'widgets
  :type 'integer)

185 186 187 188 189 190 191
(defcustom widget-menu-max-shortcuts 40
  "Largest number of items for which it works to choose one with a character.
For a larger number of items, the minibuffer is used."
  :group 'widgets
  :type 'integer)

(defcustom widget-menu-minibuffer-flag nil
192 193 194 195 196 197
  "*Control how to ask for a choice from the keyboard.
Non-nil means use the minibuffer;
nil means read a single character."
  :group 'widgets
  :type 'boolean)

Per Abrahamsen's avatar
Per Abrahamsen committed
198 199 200 201
(defun widget-choose (title items &optional event)
  "Choose an item from a list.

First argument TITLE is the name of the list.
202
Second argument ITEMS is a list whose members are either
Per Abrahamsen's avatar
Per Abrahamsen committed
203 204
 (NAME . VALUE), to indicate selectable items, or just strings to
 indicate unselectable items.
Per Abrahamsen's avatar
Per Abrahamsen committed
205 206 207 208 209 210 211 212
Optional third argument EVENT is an input event.

The user is asked to choose between each NAME from the items alist,
and the VALUE of the chosen element will be returned.  If EVENT is a
mouse event, and the number of elements in items is less than
`widget-menu-max-size', a popup menu will be used, otherwise the
minibuffer."
  (cond ((and (< (length items) widget-menu-max-size)
213
	      event (display-popup-menus-p))
214
	 ;; Mouse click.
Per Abrahamsen's avatar
Per Abrahamsen committed
215 216
	 (x-popup-menu event
		       (list title (cons "" items))))
217 218
	((or widget-menu-minibuffer-flag
	     (> (length items) widget-menu-max-shortcuts))
219
	 ;; Read the choice of name from the minibuffer.
220
	 (setq items (widget-remove-if 'stringp items))
Per Abrahamsen's avatar
Per Abrahamsen committed
221 222 223 224 225
	 (let ((val (completing-read (concat title ": ") items nil t)))
	   (if (stringp val)
	       (let ((try (try-completion val items)))
		 (when (stringp try)
		   (setq val try))
226
		 (cdr (assoc val items))))))
227 228 229
	(t
	 ;; Construct a menu of the choices
	 ;; and then use it for prompting for a single character.
230 231 232
	 (let* ((overriding-terminal-local-map (make-sparse-keymap))
		(next-digit ?0)
		map choice some-choice-enabled value)
233 234 235
	   ;; Define SPC as a prefix char to get to this menu.
	   (define-key overriding-terminal-local-map " "
	     (setq map (make-sparse-keymap title)))
236
	   (with-current-buffer (get-buffer-create " widget-choose")
237 238 239 240 241 242 243 244
	     (erase-buffer)
	     (insert "Available choices:\n\n")
	     (while items
	       (setq choice (car items) items (cdr items))
	       (if (consp choice)
		   (let* ((name (car choice))
			 (function (cdr choice)))
		     (insert (format "%c = %s\n" next-digit name))
245 246
		     (define-key map (vector next-digit) function)
		     (setq some-choice-enabled t)))
247 248 249 250
	       ;; Allocate digits to disabled alternatives
	       ;; so that the digit of a given alternative never varies.
	       (setq next-digit (1+ next-digit)))
	     (insert "\nC-g = Quit"))
251 252
	   (or some-choice-enabled
	       (error "None of the choices is currently meaningful"))
253
	   (define-key map [?\C-g] 'keyboard-quit)
254
	   (define-key map [t] 'keyboard-quit)
255 256
	   (define-key map [?\M-\C-v] 'scroll-other-window)
	   (define-key map [?\M--] 'negative-argument)
257 258 259
	   (setcdr map (nreverse (cdr map)))
	   ;; Read a char with the menu, and return the result
	   ;; that corresponds to it.
260
	   (save-window-excursion
261
	     (let ((buf (get-buffer " widget-choose")))
262
	       (fit-window-to-buffer (display-buffer buf))
263 264 265 266 267 268 269
	       (let ((cursor-in-echo-area t)
		     keys
		     (char 0)
		     (arg 1))
		 (while (not (or (and (>= char ?0) (< char next-digit))
				 (eq value 'keyboard-quit)))
		   ;; Unread a SPC to lead to our new menu.
270
		   (setq unread-command-events (cons ?\  unread-command-events))
271
		   (setq keys (read-key-sequence title))
272 273
		   (setq value
			 (lookup-key overriding-terminal-local-map keys t)
274 275
			 char (string-to-char (substring keys 1)))
		   (cond ((eq value 'scroll-other-window)
276 277
			  (let ((minibuffer-scroll-window
				 (get-buffer-window buf)))
278
			    (if (> 0 arg)
279 280
				(scroll-other-window-down
				 (window-height minibuffer-scroll-window))
281 282 283 284 285 286
			      (scroll-other-window))
			    (setq arg 1)))
			 ((eq value 'negative-argument)
			  (setq arg -1))
			 (t
			  (setq arg 1)))))))
287 288 289
	   (when (eq value 'keyboard-quit)
	     (error "Canceled"))
	   value))))
Per Abrahamsen's avatar
Per Abrahamsen committed
290

291 292 293 294 295 296 297 298
(defun widget-remove-if (predictate list)
  (let (result (tail list))
    (while tail
      (or (funcall predictate (car tail))
	  (setq result (cons (car tail) result)))
      (setq tail (cdr tail)))
    (nreverse result)))

Per Abrahamsen's avatar
Per Abrahamsen committed
299
;;; Widget text specifications.
300
;;
301
;; These functions are for specifying text properties.
Per Abrahamsen's avatar
Per Abrahamsen committed
302

303 304
;; We can set it to nil now that get_local_map uses get_pos_property.
(defconst widget-field-add-space nil
Per Abrahamsen's avatar
Per Abrahamsen committed
305 306
  "Non-nil means add extra space at the end of editable text fields.
If you don't add the space, it will become impossible to edit a zero
307
size field.")
Per Abrahamsen's avatar
Per Abrahamsen committed
308

309
(defvar widget-field-use-before-change t
Per Abrahamsen's avatar
Per Abrahamsen committed
310
  "Non-nil means use `before-change-functions' to track editable fields.
311
This enables the use of undo, but doesn't work on Emacs 19.34 and earlier.
Per Abrahamsen's avatar
Per Abrahamsen committed
312
Using before hooks also means that the :notify function can't know the
313
new value.")
Per Abrahamsen's avatar
Per Abrahamsen committed
314

Per Abrahamsen's avatar
Per Abrahamsen committed
315
(defun widget-specify-field (widget from to)
Per Abrahamsen's avatar
Per Abrahamsen committed
316
  "Specify editable button for WIDGET between FROM and TO."
Per Abrahamsen's avatar
Per Abrahamsen committed
317 318 319 320 321
  ;; Terminating space is not part of the field, but necessary in
  ;; order for local-map to work.  Remove next sexp if local-map works
  ;; at the end of the overlay.
  (save-excursion
    (goto-char to)
Per Abrahamsen's avatar
Per Abrahamsen committed
322 323 324 325
    (cond ((null (widget-get widget :size))
	   (forward-char 1))
	  (widget-field-add-space
	   (insert-and-inherit " ")))
Per Abrahamsen's avatar
Per Abrahamsen committed
326
    (setq to (point)))
Miles Bader's avatar
Miles Bader committed
327 328 329
  (let ((keymap (widget-get widget :keymap))
	(face (or (widget-get widget :value-face) 'widget-field-face))
	(help-echo (widget-get widget :help-echo))
330
	(follow-link (widget-get widget :follow-link))
Miles Bader's avatar
Miles Bader committed
331 332
	(rear-sticky
	 (or (not widget-field-add-space) (widget-get widget :size))))
333
    (if (functionp help-echo)
334
      (setq help-echo 'widget-mouse-help))
Miles Bader's avatar
Miles Bader committed
335 336 337 338 339 340 341 342
    (when (= (char-before to) ?\n)
      ;; When the last character in the field is a newline, we want to
      ;; give it a `field' char-property of `boundary', which helps the
      ;; C-n/C-p act more naturally when entering/leaving the field.  We
     ;; do this by making a small secondary overlay to contain just that
      ;; one character.
      (let ((overlay (make-overlay (1- to) to nil t nil)))
	(overlay-put overlay 'field 'boundary)
343 344
        ;; We need the real field for tabbing.
	(overlay-put overlay 'real-field widget)
345 346 347
	;; Use `local-map' here, not `keymap', so that normal editing
	;; works in the field when, say, Custom uses `suppress-keymap'.
	(overlay-put overlay 'local-map keymap)
Miles Bader's avatar
Miles Bader committed
348
	(overlay-put overlay 'face face)
349
	(overlay-put overlay 'follow-link follow-link)
Miles Bader's avatar
Miles Bader committed
350 351 352 353 354 355 356
	(overlay-put overlay 'help-echo help-echo))
      (setq to (1- to))
      (setq rear-sticky t))
    (let ((overlay (make-overlay from to nil nil rear-sticky)))
      (widget-put widget :field-overlay overlay)
      ;;(overlay-put overlay 'detachable nil)
      (overlay-put overlay 'field widget)
357
      (overlay-put overlay 'local-map keymap)
Miles Bader's avatar
Miles Bader committed
358
      (overlay-put overlay 'face face)
359
      (overlay-put overlay 'follow-link follow-link)
Miles Bader's avatar
Miles Bader committed
360
      (overlay-put overlay 'help-echo help-echo)))
361 362 363 364 365 366 367 368 369
  (widget-specify-secret widget))

(defun widget-specify-secret (field)
  "Replace text in FIELD with value of `:secret', if non-nil."
  (let ((secret (widget-get field :secret))
	(size (widget-get field :size)))
    (when secret
      (let ((begin (widget-field-start field))
	    (end (widget-field-end field)))
370
	(when size
371 372 373 374 375 376 377 378 379
	  (while (and (> end begin)
		      (eq (char-after (1- end)) ?\ ))
	    (setq end (1- end))))
	(while (< begin end)
	  (let ((old (char-after begin)))
	    (unless (eq old secret)
	      (subst-char-in-region begin (1+ begin) old secret)
	      (put-text-property begin (1+ begin) 'secret old))
	    (setq begin (1+ begin))))))))
Per Abrahamsen's avatar
Per Abrahamsen committed
380 381

(defun widget-specify-button (widget from to)
Per Abrahamsen's avatar
Per Abrahamsen committed
382
  "Specify button for WIDGET between FROM and TO."
383
  (let ((overlay (make-overlay from to nil t nil))
384
	(follow-link (widget-get widget :follow-link))
385
	(help-echo (widget-get widget :help-echo)))
Per Abrahamsen's avatar
Per Abrahamsen committed
386
    (widget-put widget :button-overlay overlay)
387 388
    (if (functionp help-echo)
      (setq help-echo 'widget-mouse-help))
Per Abrahamsen's avatar
Per Abrahamsen committed
389
    (overlay-put overlay 'button widget)
390
    (overlay-put overlay 'keymap (widget-get widget :keymap))
391
    (overlay-put overlay 'evaporate t)
392 393
    ;; We want to avoid the face with image buttons.
    (unless (widget-get widget :suppress-face)
394 395 396 397 398
      (overlay-put overlay 'face (widget-apply widget :button-face-get))
      ; Text terminals cannot change mouse pointer shape, so use mouse
      ; face instead.
      (or (display-graphic-p)
	  (overlay-put overlay 'mouse-face widget-mouse-face)))
399
    (overlay-put overlay 'pointer 'hand)
400
    (overlay-put overlay 'follow-link follow-link)
401 402 403 404 405 406 407 408 409 410
    (overlay-put overlay 'help-echo help-echo)))

(defun widget-mouse-help (window overlay point)
  "Help-echo callback for widgets whose :help-echo is a function."
  (with-current-buffer (overlay-buffer overlay)
    (let* ((widget (widget-at (overlay-start overlay)))
	   (help-echo (if widget (widget-get widget :help-echo))))
      (if (functionp help-echo)
	  (funcall help-echo widget)
	help-echo))))
Per Abrahamsen's avatar
Per Abrahamsen committed
411 412

(defun widget-specify-sample (widget from to)
413
  "Specify sample for WIDGET between FROM and TO."
414 415
  (let ((overlay (make-overlay from to nil t nil)))
    (overlay-put overlay 'face (widget-apply widget :sample-face-get))
416
    (overlay-put overlay 'evaporate t)
Per Abrahamsen's avatar
Per Abrahamsen committed
417 418
    (widget-put widget :sample-overlay overlay)))

Per Abrahamsen's avatar
Per Abrahamsen committed
419
(defun widget-specify-doc (widget from to)
420
  "Specify documentation for WIDGET between FROM and TO."
Per Abrahamsen's avatar
Per Abrahamsen committed
421 422 423
  (let ((overlay (make-overlay from to nil t nil)))
    (overlay-put overlay 'widget-doc widget)
    (overlay-put overlay 'face widget-documentation-face)
424
    (overlay-put overlay 'evaporate t)
Per Abrahamsen's avatar
Per Abrahamsen committed
425
    (widget-put widget :doc-overlay overlay)))
Per Abrahamsen's avatar
Per Abrahamsen committed
426 427

(defmacro widget-specify-insert (&rest form)
428 429 430
  "Execute FORM without inheriting any text properties."
  `(save-restriction
    (let ((inhibit-read-only t)
431 432 433 434
	  (inhibit-modification-hooks t))
      (narrow-to-region (point) (point))
      (prog1 (progn ,@form)
	(goto-char (point-max))))))
Per Abrahamsen's avatar
Per Abrahamsen committed
435 436 437 438 439 440

(defface widget-inactive-face '((((class grayscale color)
				  (background dark))
				 (:foreground "light gray"))
				(((class grayscale color)
				  (background light))
Per Abrahamsen's avatar
Per Abrahamsen committed
441
				 (:foreground "dim gray"))
442
				(t
443
				 (:slant italic)))
Per Abrahamsen's avatar
Per Abrahamsen committed
444
  "Face used for inactive widgets."
Per Abrahamsen's avatar
Per Abrahamsen committed
445
  :group 'widget-faces)
Per Abrahamsen's avatar
Per Abrahamsen committed
446 447 448 449 450 451

(defun widget-specify-inactive (widget from to)
  "Make WIDGET inactive for user modifications."
  (unless (widget-get widget :inactive)
    (let ((overlay (make-overlay from to nil t nil)))
      (overlay-put overlay 'face 'widget-inactive-face)
Per Abrahamsen's avatar
Per Abrahamsen committed
452 453
      ;; This is disabled, as it makes the mouse cursor change shape.
      ;; (overlay-put overlay 'mouse-face 'widget-inactive-face)
Per Abrahamsen's avatar
Per Abrahamsen committed
454 455
      (overlay-put overlay 'evaporate t)
      (overlay-put overlay 'priority 100)
456
      (overlay-put overlay 'modification-hooks '(widget-overlay-inactive))
Per Abrahamsen's avatar
Per Abrahamsen committed
457 458 459 460 461
      (widget-put widget :inactive overlay))))

(defun widget-overlay-inactive (&rest junk)
  "Ignoring the arguments, signal an error."
  (unless inhibit-read-only
462
    (error "The widget here is not active")))
Per Abrahamsen's avatar
Per Abrahamsen committed
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477


(defun widget-specify-active (widget)
  "Make WIDGET active for user modifications."
  (let ((inactive (widget-get widget :inactive)))
    (when inactive
      (delete-overlay inactive)
      (widget-put widget :inactive nil))))

;;; Widget Properties.

(defsubst widget-type (widget)
  "Return the type of WIDGET, a symbol."
  (car widget))

478 479 480 481 482 483
;;;###autoload
(defun widgetp (widget)
  "Return non-nil iff WIDGET is a widget."
  (if (symbolp widget)
      (get widget 'widget-type)
    (and (consp widget)
484 485
	 (symbolp (car widget))
	 (get (car widget) 'widget-type))))
486

Per Abrahamsen's avatar
Per Abrahamsen committed
487 488
(defun widget-get-indirect (widget property)
  "In WIDGET, get the value of PROPERTY.
489
If the value is a symbol, return its binding.
Per Abrahamsen's avatar
Per Abrahamsen committed
490 491 492 493 494 495
Otherwise, just return the value."
  (let ((value (widget-get widget property)))
    (if (symbolp value)
	(symbol-value value)
      value)))

Per Abrahamsen's avatar
Per Abrahamsen committed
496 497
(defun widget-member (widget property)
  "Non-nil iff there is a definition in WIDGET for PROPERTY."
498
  (cond ((plist-member (cdr widget) property)
Per Abrahamsen's avatar
Per Abrahamsen committed
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
	 t)
	((car widget)
	 (widget-member (get (car widget) 'widget-type) property))
	(t nil)))

(defun widget-value (widget)
  "Extract the current value of WIDGET."
  (widget-apply widget
		:value-to-external (widget-apply widget :value-get)))

(defun widget-value-set (widget value)
  "Set the current value of WIDGET to VALUE."
  (widget-apply widget
		:value-set (widget-apply widget
					 :value-to-internal value)))

515
(defun widget-default-get (widget)
Per Abrahamsen's avatar
Per Abrahamsen committed
516
  "Extract the default external value of WIDGET."
517
  (widget-apply widget :value-to-external
Per Abrahamsen's avatar
Per Abrahamsen committed
518 519
		(or (widget-get widget :value)
		    (widget-apply widget :default-get))))
520

Per Abrahamsen's avatar
Per Abrahamsen committed
521
(defun widget-match-inline (widget vals)
522
  "In WIDGET, match the start of VALS."
Per Abrahamsen's avatar
Per Abrahamsen committed
523 524
  (cond ((widget-get widget :inline)
	 (widget-apply widget :match-inline vals))
525
	((and (listp vals)
Per Abrahamsen's avatar
Per Abrahamsen committed
526 527 528 529 530 531
	      (widget-apply widget :match (car vals)))
	 (cons (list (car vals)) (cdr vals)))
	(t nil)))

(defun widget-apply-action (widget &optional event)
  "Apply :action in WIDGET in response to EVENT."
Per Abrahamsen's avatar
Per Abrahamsen committed
532 533 534
  (if (widget-apply widget :active)
      (widget-apply widget :action event)
    (error "Attempt to perform action on inactive widget")))
Per Abrahamsen's avatar
Per Abrahamsen committed
535

Per Abrahamsen's avatar
Per Abrahamsen committed
536 537 538 539 540 541 542 543 544 545 546 547 548 549
;;; Helper functions.
;;
;; These are widget specific.

;;;###autoload
(defun widget-prompt-value (widget prompt &optional value unbound)
  "Prompt for a value matching WIDGET, using PROMPT.
The current value is assumed to be VALUE, unless UNBOUND is non-nil."
  (unless (listp widget)
    (setq widget (list widget)))
  (setq prompt (format "[%s] %s" (widget-type widget) prompt))
  (setq widget (widget-convert widget))
  (let ((answer (widget-apply widget :prompt-value prompt value unbound)))
    (unless (widget-apply widget :match answer)
550
      (error "Value does not match %S type" (car widget)))
Per Abrahamsen's avatar
Per Abrahamsen committed
551 552 553 554 555
    answer))

(defun widget-get-sibling (widget)
  "Get the item WIDGET is assumed to toggle.
This is only meaningful for radio buttons or checkboxes in a list."
556
  (let* ((children (widget-get (widget-get widget :parent) :children))
Per Abrahamsen's avatar
Per Abrahamsen committed
557 558 559 560 561 562 563 564 565
	 child)
    (catch 'child
      (while children
	(setq child (car children)
	      children (cdr children))
	(when (eq (widget-get child :button) widget)
	  (throw 'child child)))
      nil)))

Per Abrahamsen's avatar
Per Abrahamsen committed
566 567 568 569 570 571 572 573 574 575 576
(defun widget-map-buttons (function &optional buffer maparg)
  "Map FUNCTION over the buttons in BUFFER.
FUNCTION is called with the arguments WIDGET and MAPARG.

If FUNCTION returns non-nil, the walk is cancelled.

The arguments MAPARG, and BUFFER default to nil and (current-buffer),
respectively."
  (let ((cur (point-min))
	(widget nil)
	(overlays (if buffer
577
		      (with-current-buffer buffer (overlay-lists))
Per Abrahamsen's avatar
Per Abrahamsen committed
578 579 580 581 582 583 584
		    (overlay-lists))))
    (setq overlays (append (car overlays) (cdr overlays)))
    (while (setq cur (pop overlays))
      (setq widget (overlay-get cur 'button))
      (if (and widget (funcall function widget maparg))
	  (setq overlays nil)))))

585
;;; Images.
Per Abrahamsen's avatar
Per Abrahamsen committed
586

587 588 589
(defcustom widget-image-directory (file-name-as-directory
				   (expand-file-name "custom" data-directory))
  "Where widget button images are located.
Per Abrahamsen's avatar
Per Abrahamsen committed
590
If this variable is nil, widget will try to locate the directory
Per Abrahamsen's avatar
Per Abrahamsen committed
591
automatically."
Per Abrahamsen's avatar
Per Abrahamsen committed
592 593 594
  :group 'widgets
  :type 'directory)

595 596 597
(defcustom widget-image-enable t
  "If non nil, use image buttons in widgets when available."
  :version "21.1"
Per Abrahamsen's avatar
Per Abrahamsen committed
598 599 600
  :group 'widgets
  :type 'boolean)

Per Abrahamsen's avatar
Per Abrahamsen committed
601 602 603 604 605 606 607 608 609 610
(defcustom widget-image-conversion
  '((xpm ".xpm") (gif ".gif") (png ".png") (jpeg ".jpg" ".jpeg")
    (xbm ".xbm"))
  "Conversion alist from image formats to file name suffixes."
  :group 'widgets
  :type '(repeat (cons :format "%v"
		       (symbol :tag "Image Format" unknown)
		       (repeat :tag "Suffixes"
			       (string :format "%v")))))

611 612 613
(defun widget-image-find (image)
  "Create a graphical button from IMAGE.
IMAGE should either already be an image, or be a file name sans
Per Abrahamsen's avatar
Per Abrahamsen committed
614
extension (xpm, xbm, gif, jpg, or png) located in
615 616 617
`widget-image-directory' or otherwise where `find-image' will find it."
  (cond ((not (and image widget-image-enable (display-graphic-p)))
	 ;; We don't want or can't use images.
Per Abrahamsen's avatar
Per Abrahamsen committed
618
	 nil)
619 620 621
	((and (consp image)
	      (eq 'image (car image)))
	 ;; Already an image spec.  Use it.
Per Abrahamsen's avatar
Per Abrahamsen committed
622
	 image)
Per Abrahamsen's avatar
Per Abrahamsen committed
623 624
	((stringp image)
	 ;; A string.  Look it up in relevant directories.
625 626 627 628 629 630 631
	 (let* ((load-path (cons widget-image-directory load-path))
		specs)
	   (dolist (elt widget-image-conversion)
	     (dolist (ext (cdr elt))
	       (push (list :type (car elt) :file (concat image ext)) specs)))
	   (setq specs (nreverse specs))
	   (find-image specs)))
Per Abrahamsen's avatar
Per Abrahamsen committed
632
	(t
Per Abrahamsen's avatar
Per Abrahamsen committed
633
	 ;; Oh well.
Per Abrahamsen's avatar
Per Abrahamsen committed
634 635
	 nil)))

636 637 638 639 640 641
(defvar widget-button-pressed-face 'widget-button-pressed-face
  "Face used for pressed buttons in widgets.
This exists as a variable so it can be set locally in certain
buffers.")

(defun widget-image-insert (widget tag image &optional down inactive)
Per Abrahamsen's avatar
Per Abrahamsen committed
642
  "In WIDGET, insert the text TAG or, if supported, IMAGE.
643 644 645 646 647 648 649 650 651 652 653 654
IMAGE should either be an image or an image file name sans extension
\(xpm, xbm, gif, jpg, or png) located in `widget-image-directory'.

Optional arguments DOWN and INACTIVE are used instead of IMAGE when the
button is pressed or inactive, respectively.  These are currently ignored."
  (if (and (display-graphic-p)
	   (setq image (widget-image-find image)))
      (progn (widget-put widget :suppress-face t)
	     (insert-image image
			   (propertize
			    tag 'mouse-face widget-button-pressed-face)))
    (insert tag)))
Per Abrahamsen's avatar
Per Abrahamsen committed
655

Per Abrahamsen's avatar
Per Abrahamsen committed
656 657 658 659 660 661 662 663 664
;;; Buttons.

(defgroup widget-button nil
  "The look of various kinds of buttons."
  :group 'widgets)

(defcustom widget-button-prefix ""
  "String used as prefix for buttons."
  :type 'string
Per Abrahamsen's avatar
Per Abrahamsen committed
665
  :group 'widget-button)
Per Abrahamsen's avatar
Per Abrahamsen committed
666 667 668 669

(defcustom widget-button-suffix ""
  "String used as suffix for buttons."
  :type 'string
Per Abrahamsen's avatar
Per Abrahamsen committed
670
  :group 'widget-button)
Per Abrahamsen's avatar
Per Abrahamsen committed
671

Per Abrahamsen's avatar
Per Abrahamsen committed
672 673 674 675
;;; Creating Widgets.

;;;###autoload
(defun widget-create (type &rest args)
676
  "Create widget of TYPE.
Per Abrahamsen's avatar
Per Abrahamsen committed
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
The optional ARGS are additional keyword arguments."
  (let ((widget (apply 'widget-convert type args)))
    (widget-apply widget :create)
    widget))

(defun widget-create-child-and-convert (parent type &rest args)
  "As part of the widget PARENT, create a child widget TYPE.
The child is converted, using the keyword arguments ARGS."
  (let ((widget (apply 'widget-convert type args)))
    (widget-put widget :parent parent)
    (unless (widget-get widget :indent)
      (widget-put widget :indent (+ (or (widget-get parent :indent) 0)
				    (or (widget-get widget :extra-offset) 0)
				    (widget-get parent :offset))))
    (widget-apply widget :create)
    widget))

(defun widget-create-child (parent type)
  "Create widget of TYPE."
Per Abrahamsen's avatar
Per Abrahamsen committed
696
  (let ((widget (widget-copy type)))
Per Abrahamsen's avatar
Per Abrahamsen committed
697 698 699 700 701 702 703 704 705 706
    (widget-put widget :parent parent)
    (unless (widget-get widget :indent)
      (widget-put widget :indent (+ (or (widget-get parent :indent) 0)
				    (or (widget-get widget :extra-offset) 0)
				    (widget-get parent :offset))))
    (widget-apply widget :create)
    widget))

(defun widget-create-child-value (parent type value)
  "Create widget of TYPE with value VALUE."
Per Abrahamsen's avatar
Per Abrahamsen committed
707
  (let ((widget (widget-copy type)))
Per Abrahamsen's avatar
Per Abrahamsen committed
708 709 710 711 712 713 714 715 716 717 718 719 720 721
    (widget-put widget :value (widget-apply widget :value-to-internal value))
    (widget-put widget :parent parent)
    (unless (widget-get widget :indent)
      (widget-put widget :indent (+ (or (widget-get parent :indent) 0)
				    (or (widget-get widget :extra-offset) 0)
				    (widget-get parent :offset))))
    (widget-apply widget :create)
    widget))

;;;###autoload
(defun widget-delete (widget)
  "Delete WIDGET."
  (widget-apply widget :delete))

Per Abrahamsen's avatar
Per Abrahamsen committed
722 723 724 725
(defun widget-copy (widget)
  "Make a deep copy of WIDGET."
  (widget-apply (copy-sequence widget) :copy))

Per Abrahamsen's avatar
Per Abrahamsen committed
726
(defun widget-convert (type &rest args)
727
  "Convert TYPE to a widget without inserting it in the buffer.
Per Abrahamsen's avatar
Per Abrahamsen committed
728 729
The optional ARGS are additional keyword arguments."
  ;; Don't touch the type.
730
  (let* ((widget (if (symbolp type)
Per Abrahamsen's avatar
Per Abrahamsen committed
731
		     (list type)
732
		   (copy-sequence type)))
Per Abrahamsen's avatar
Per Abrahamsen committed
733
	 (current widget)
734
	 done
Per Abrahamsen's avatar
Per Abrahamsen committed
735 736 737
	 (keys args))
    ;; First set the :args keyword.
    (while (cdr current)		;Look in the type.
738 739 740 741 742 743 744 745 746 747
      (if (and (keywordp (cadr current))
	       ;; If the last element is a keyword,
	       ;; it is still the :args element,
	       ;; even though it is a keyword.
	       (cddr current))
	  (if (eq (cadr current) :args)
	      ;; If :args is explicitly specified, obey it.
	      (setq current nil)
	    ;; Some other irrelevant keyword.
	    (setq current (cdr (cdr current))))
748 749
	(setcdr current (list :args (cdr current)))
	(setq current nil)))
750 751 752 753 754 755 756 757 758 759
    (while (and args (not done))	;Look in ARGS.
      (cond ((eq (car args) :args)
	     ;; Handle explicit specification of :args.
	     (setq args (cadr args)
		   done t))
	    ((keywordp (car args))
	     (setq args (cddr args)))
	    (t (setq done t))))
    (when done
      (widget-put widget :args args))
Per Abrahamsen's avatar
Per Abrahamsen committed
760 761 762 763 764 765 766 767
    ;; Then Convert the widget.
    (setq type widget)
    (while type
      (let ((convert-widget (plist-get (cdr type) :convert-widget)))
	(if convert-widget
	    (setq widget (funcall convert-widget widget))))
      (setq type (get (car type) 'widget-type)))
    ;; Finally set the keyword args.
768
    (while keys
Per Abrahamsen's avatar
Per Abrahamsen committed
769
      (let ((next (nth 0 keys)))
770 771
	(if (keywordp next)
	    (progn
Per Abrahamsen's avatar
Per Abrahamsen committed
772 773 774 775 776
	      (widget-put widget next (nth 1 keys))
	      (setq keys (nthcdr 2 keys)))
	  (setq keys nil))))
    ;; Convert the :value to internal format.
    (if (widget-member widget :value)
777 778 779 780
	(widget-put widget
		    :value (widget-apply widget
					 :value-to-internal
					 (widget-get widget :value))))
Per Abrahamsen's avatar
Per Abrahamsen committed
781 782 783
    ;; Return the newly create widget.
    widget))

784
;;;###autoload
Per Abrahamsen's avatar
Per Abrahamsen committed
785
(defun widget-insert (&rest args)
786
  "Call `insert' with ARGS even if surrounding text is read only."
Per Abrahamsen's avatar
Per Abrahamsen committed
787
  (let ((inhibit-read-only t)
788
	(inhibit-modification-hooks t))
Per Abrahamsen's avatar
Per Abrahamsen committed
789
    (apply 'insert args)))
Per Abrahamsen's avatar
Per Abrahamsen committed
790

Per Abrahamsen's avatar
Per Abrahamsen committed
791 792 793
(defun widget-convert-text (type from to
				 &optional button-from button-to
				 &rest args)
Per Abrahamsen's avatar
Per Abrahamsen committed
794
  "Return a widget of type TYPE with endpoint FROM TO.
Per Abrahamsen's avatar
Per Abrahamsen committed
795
Optional ARGS are extra keyword arguments for TYPE.
Per Abrahamsen's avatar
Per Abrahamsen committed
796 797
and TO will be used as the widgets end points. If optional arguments
BUTTON-FROM and BUTTON-TO are given, these will be used as the widgets
Per Abrahamsen's avatar
Per Abrahamsen committed
798 799 800
button end points.
Optional ARGS are extra keyword arguments for TYPE."
  (let ((widget (apply 'widget-convert type :delete 'widget-leave-text args))
Per Abrahamsen's avatar
Per Abrahamsen committed
801
	(from (copy-marker from))
802
	(to (copy-marker to)))
Per Abrahamsen's avatar
Per Abrahamsen committed
803 804 805 806 807 808 809 810
    (set-marker-insertion-type from t)
    (set-marker-insertion-type to nil)
    (widget-put widget :from from)
    (widget-put widget :to to)
    (when button-from
      (widget-specify-button widget button-from button-to))
    widget))

Per Abrahamsen's avatar
Per Abrahamsen committed
811
(defun widget-convert-button (type from to &rest args)
Per Abrahamsen's avatar
Per Abrahamsen committed
812
  "Return a widget of type TYPE with endpoint FROM TO.
Per Abrahamsen's avatar
Per Abrahamsen committed
813
Optional ARGS are extra keyword arguments for TYPE.
Per Abrahamsen's avatar
Per Abrahamsen committed
814 815 816
No text will be inserted to the buffer, instead the text between FROM
and TO will be used as the widgets end points, as well as the widgets
button end points."
Per Abrahamsen's avatar
Per Abrahamsen committed
817 818 819 820
  (apply 'widget-convert-text type from to from to args))

(defun widget-leave-text (widget)
  "Remove markers and overlays from WIDGET and its children."
821
  (let ((button (widget-get widget :button-overlay))
Per Abrahamsen's avatar
Per Abrahamsen committed
822
	(sample (widget-get widget :sample-overlay))
Per Abrahamsen's avatar
Per Abrahamsen committed
823
	(doc (widget-get widget :doc-overlay))
824 825 826
	(field (widget-get widget :field-overlay)))
    (set-marker (widget-get widget :from) nil)
    (set-marker (widget-get widget :to) nil)
Per Abrahamsen's avatar
Per Abrahamsen committed
827 828
    (when button
      (delete-overlay button))
Per Abrahamsen's avatar
Per Abrahamsen committed
829 830
    (when sample
      (delete-overlay sample))
Per Abrahamsen's avatar
Per Abrahamsen committed
831 832
    (when doc
      (delete-overlay doc))
Per Abrahamsen's avatar
Per Abrahamsen committed
833 834
    (when field
      (delete-overlay field))
835
    (mapc 'widget-leave-text (widget-get widget :children))))
Per Abrahamsen's avatar
Per Abrahamsen committed
836

Per Abrahamsen's avatar
Per Abrahamsen committed
837 838
;;; Keymap and Commands.

839
;;;###autoload
840 841 842 843 844 845 846 847
(defvar widget-keymap
  (let ((map (make-sparse-keymap)))
    (define-key map "\t" 'widget-forward)
    (define-key map [(shift tab)] 'widget-backward)
    (define-key map [backtab] 'widget-backward)
    (define-key map [down-mouse-2] 'widget-button-click)
    (define-key map "\C-m" 'widget-button-press)
    map)
Per Abrahamsen's avatar
Per Abrahamsen committed
848 849 850 851
  "Keymap containing useful binding for buffers containing widgets.
Recommended as a parent keymap for modes using widgets.")

(defvar widget-global-map global-map
Dave Love's avatar
Don't  
Dave Love committed
852
  "Keymap used for events a widget does not handle itself.")
Per Abrahamsen's avatar
Per Abrahamsen committed
853 854
(make-variable-buffer-local 'widget-global-map)

855 856 857 858 859
(defvar widget-field-keymap
  (let ((map (copy-keymap widget-keymap)))
    (define-key map "\C-k" 'widget-kill-line)
    (define-key map "\M-\t" 'widget-complete)
    (define-key map "\C-m" 'widget-field-activate)
860
    ;; Since the widget code uses a `field' property to identify fields,
861
    ;; ordinary beginning-of-line does the right thing.
862
    ;;  (define-key map "\C-a" 'widget-beginning-of-line)
863
    (define-key map "\C-e" 'widget-end-of-line)
864
    map)
Per Abrahamsen's avatar
Per Abrahamsen committed
865 866
  "Keymap used inside an editable field.")

867 868
(defvar widget-text-keymap
  (let ((map (copy-keymap widget-keymap)))
869
    ;; Since the widget code uses a `field' property to identify fields,
870
    ;; ordinary beginning-of-line does the right thing.
871
    ;;  (define-key map "\C-a" 'widget-beginning-of-line)
872
    (define-key map "\C-e" 'widget-end-of-line)
873
    map)
Per Abrahamsen's avatar
Per Abrahamsen committed
874 875 876
  "Keymap used inside a text field.")

(defun widget-field-activate (pos &optional event)
Dave Love's avatar
Dave Love committed
877
  "Invoke the editable field at point."
Per Abrahamsen's avatar
Per Abrahamsen committed
878
  (interactive "@d")
Miles Bader's avatar
Miles Bader committed
879
  (let ((field (widget-field-at pos)))
Per Abrahamsen's avatar
Per Abrahamsen committed
880 881 882 883 884
    (if field
	(widget-apply-action field event)
      (call-interactively
       (lookup-key widget-global-map (this-command-keys))))))

885
(defface widget-button-pressed-face
886 887 888
  '((((min-colors 88) (class color))
     (:foreground "red1"))
    (((class color))
Per Abrahamsen's avatar
Per Abrahamsen committed
889 890
     (:foreground "red"))
    (t
891
     (:weight bold :underline t)))
Per Abrahamsen's avatar
Per Abrahamsen committed
892
  "Face used for pressed buttons."
Per Abrahamsen's avatar
Per Abrahamsen committed
893
  :group 'widget-faces)
Per Abrahamsen's avatar
Per Abrahamsen committed
894

Per Abrahamsen's avatar
Per Abrahamsen committed
895
(defun widget-button-click (event)
896
  "Invoke the button that the mouse is pointing at."
897
  (interactive "e")
898
  (if (widget-event-point event)
899
      (let* ((pos (widget-event-point event))
900
	     (start (event-start event))
901
	     (button (get-char-property
902 903
		      pos 'button (and (windowp (posn-window start))
				       (window-buffer (posn-window start))))))
904 905 906 907
	(if button
	    ;; Mouse click on a widget button.  Do the following
	    ;; in a save-excursion so that the click on the button
	    ;; doesn't change point.
908
	    (save-selected-window
909
	      (select-window (posn-window (event-start event)))
910
	      (save-excursion
911
		(goto-char (posn-point (event-start event)))
912 913 914 915
		(let* ((overlay (widget-get button :button-overlay))
		       (face (overlay-get overlay 'face))
		       (mouse-face (overlay-get overlay 'mouse-face)))
		  (unwind-protect
916 917 918 919
		      ;; Read events, including mouse-movement events
		      ;; until we receive a release event.  Highlight/
		      ;; unhighlight the button the mouse was initially
		      ;; on when we move over it.
920 921 922 923 924 925 926 927
		      (save-excursion
			(when face	; avoid changing around image
			  (overlay-put overlay
				       'face widget-button-pressed-face)
			  (overlay-put overlay
				       'mouse-face widget-button-pressed-face))
			(unless (widget-apply button :mouse-down-action event)
			  (let ((track-mouse t))
928 929 930 931 932 933 934 935 936 937 938 939 940 941
			    (while (not (widget-button-release-event-p event))
			      (setq event (read-event)
				    pos (widget-event-point event))
			      (if (and pos
				       (eq (get-char-property pos 'button)
					   button))
				  (when face
				    (overlay-put overlay
						 'face
						 widget-button-pressed-face)
				    (overlay-put overlay
						 'mouse-face
						 widget-button-pressed-face))
				(overlay-put overlay 'face face)
942
				(overlay-put overlay 'mouse-face mouse-face)))))
943

944 945 946 947 948
			;; When mouse is released over the button, run
			;; its action function.
			(when (and pos
				   (eq (get-char-property pos 'button) button))
			  (widget-apply-action button event)))
949 950 951
		    (overlay-put overlay 'face face)
		    (overlay-put overlay 'mouse-face mouse-face))))

952 953 954 955 956
	      (unless (pos-visible-in-window-p (widget-event-point event))
		(mouse-set-point event)
		(beginning-of-line)
		(recenter))
	      )
957 958 959 960 961 962

	    (let ((up t) command)
	      ;; Mouse click not on a widget button.  Find the global
	      ;; command to run, and check whether it is bound to an
	      ;; up event.
	      (mouse-set-point event)
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
	      (if (memq (event-basic-type event) '(mouse-1 down-mouse-1))
		  (cond ((setq command	;down event
			       (lookup-key widget-global-map [down-mouse-1]))
			 (setq up nil))
			((setq command	;up event
			       (lookup-key widget-global-map [mouse-1]))))
		(cond ((setq command	;down event
			     (lookup-key widget-global-map [down-mouse-2]))
		       (setq up nil))
		      ((setq command	;up event
			     (lookup-key widget-global-map [mouse-2])))))
	      (when up
		;; Don't execute up events twice.
		(while (not (widget-button-release-event-p event))
		  (setq event (read-event))))
	      (when command
		(call-interactively command)))))
    (message "You clicked somewhere weird.")))
Per Abrahamsen's avatar
Per Abrahamsen committed
981

Per Abrahamsen's avatar
Per Abrahamsen committed
982
(defun widget-button-press (pos &optional event)
Per Abrahamsen's avatar
Per Abrahamsen committed
983
  "Invoke button at POS."
Per Abrahamsen's avatar
Per Abrahamsen committed
984
  (interactive "@d")
Per Abrahamsen's avatar
Per Abrahamsen committed
985
  (let ((button (get-char-property pos 'button)))
Per Abrahamsen's avatar
Per Abrahamsen committed
986 987 988 989 990 991
    (if button
	(widget-apply-action button event)
      (let ((command (lookup-key widget-global-map (this-command-keys))))
	(when (commandp command)
	  (call-interactively command))))))

Per Abrahamsen's avatar
Per Abrahamsen committed
992 993 994
(defun widget-tabable-a