comparison lisp/wid-edit.el @ 43295:ce2590f06ba0

2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk> * facemenu.el (describe-text-done): New function. (describe-text-mode-map): New variable. (describe-text-mode-hook): New option. (describe-text-mode): New function. (describe-text-widget): New function. (describe-text-sexp): New function. (describe-text-properties): New function. (describe-text-category): New command. (describe-text-at): New command. (facemenu-menu): Replace `list-text-properties-at' with `describe-text-at' in the menu. * wid-edit.el (widgetp): New function. * wid-edit.el (widget-keymap, widget-insert, widget-setup): Autoloaded. * emacs-lisp/pp.el (pp-to-string): Autoloaded. * wid-browse.el: Removed version and x-url keywords.
author Per Abrahamsen <abraham@dina.kvl.dk>
date Thu, 14 Feb 2002 16:47:11 +0000
parents 0cfd64a10789
children 683707b691b8
comparison
equal deleted inserted replaced
43294:849846dd9b9a 43295:ce2590f06ba0
1 ;;; wid-edit.el --- Functions for creating and using widgets -*-byte-compile-dynamic: t;-*- 1 ;;; wid-edit.el --- Functions for creating and using widgets -*-byte-compile-dynamic: t;-*-
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 ;; Keywords: extensions 7 ;; Keywords: extensions
8 8
466 466
467 (defsubst widget-type (widget) 467 (defsubst widget-type (widget)
468 "Return the type of WIDGET, a symbol." 468 "Return the type of WIDGET, a symbol."
469 (car widget)) 469 (car widget))
470 470
471 ;;;###autoload
472 (defun widgetp (widget)
473 "Return non-nil iff WIDGET is a widget."
474 (if (symbolp widget)
475 (get widget 'widget-type)
476 (and (consp widget)
477 (get (widget-type widget) 'widget-type))))
478
471 (defun widget-get-indirect (widget property) 479 (defun widget-get-indirect (widget property)
472 "In WIDGET, get the value of PROPERTY. 480 "In WIDGET, get the value of PROPERTY.
473 If the value is a symbol, return its binding. 481 If the value is a symbol, return its binding.
474 Otherwise, just return the value." 482 Otherwise, just return the value."
475 (let ((value (widget-get widget property))) 483 (let ((value (widget-get widget property)))
745 :value-to-internal 753 :value-to-internal
746 (widget-get widget :value)))) 754 (widget-get widget :value))))
747 ;; Return the newly create widget. 755 ;; Return the newly create widget.
748 widget)) 756 widget))
749 757
758 ;;;###autoload
750 (defun widget-insert (&rest args) 759 (defun widget-insert (&rest args)
751 "Call `insert' with ARGS even if surrounding text is read only." 760 "Call `insert' with ARGS even if surrounding text is read only."
752 (let ((inhibit-read-only t) 761 (let ((inhibit-read-only t)
753 (inhibit-modification-hooks t)) 762 (inhibit-modification-hooks t))
754 (apply 'insert args))) 763 (apply 'insert args)))
799 (delete-overlay field)) 808 (delete-overlay field))
800 (mapc 'widget-leave-text (widget-get widget :children)))) 809 (mapc 'widget-leave-text (widget-get widget :children))))
801 810
802 ;;; Keymap and Commands. 811 ;;; Keymap and Commands.
803 812
813 ;;;###autoload
804 (defvar widget-keymap 814 (defvar widget-keymap
805 (let ((map (make-sparse-keymap))) 815 (let ((map (make-sparse-keymap)))
806 (define-key map "\t" 'widget-forward) 816 (define-key map "\t" 'widget-forward)
807 (define-key map [(shift tab)] 'widget-backward) 817 (define-key map [(shift tab)] 'widget-backward)
808 (define-key map [backtab] 'widget-backward) 818 (define-key map [backtab] 'widget-backward)
1081 (defun widget-at (&optional pos) 1091 (defun widget-at (&optional pos)
1082 "The button or field at POS (default, point)." 1092 "The button or field at POS (default, point)."
1083 (or (get-char-property (or pos (point)) 'button) 1093 (or (get-char-property (or pos (point)) 'button)
1084 (widget-field-at pos))) 1094 (widget-field-at pos)))
1085 1095
1096 ;;;###autoload
1086 (defun widget-setup () 1097 (defun widget-setup ()
1087 "Setup current buffer so editing string widgets works." 1098 "Setup current buffer so editing string widgets works."
1088 (let ((inhibit-read-only t) 1099 (let ((inhibit-read-only t)
1089 (inhibit-modification-hooks t) 1100 (inhibit-modification-hooks t)
1090 field) 1101 field)