widget.el 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ;;; widget.el --- a library of user interface components
  2. ;;
  3. ;; Copyright (C) 1996-1997, 2001-2017 Free Software Foundation, Inc.
  4. ;;
  5. ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
  6. ;; Keywords: help, extensions, faces, hypermedia
  7. ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
  8. ;; Package: emacs
  9. ;; This file is part of GNU Emacs.
  10. ;; GNU Emacs is free software: you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation, either version 3 of the License, or
  13. ;; (at your option) any later version.
  14. ;; GNU Emacs is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;; GNU General Public License for more details.
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  20. ;;; Commentary:
  21. ;;
  22. ;; The widget library is partially documented in the `widget' Info
  23. ;; file.
  24. ;;
  25. ;; This file only contains the code needed to define new widget types.
  26. ;; Everything else is autoloaded from `wid-edit.el'.
  27. ;;; Code:
  28. ;; Doing this is unnecessary in Emacs 20. Kept as dummy in case
  29. ;; external libraries call it. We save a kb or two of purespace by
  30. ;; dummying-out such definitions generally.
  31. (defmacro define-widget-keywords (&rest _keys)
  32. ;; ;; Don't use backquote, since that makes trouble trying to
  33. ;; ;; re-bootstrap from just the .el files.
  34. ;; (list 'eval-and-compile
  35. ;; (list 'let (list (list 'keywords (list 'quote keys)))
  36. ;; (list 'while 'keywords
  37. ;; (list 'or (list 'boundp (list 'car 'keywords))
  38. ;; (list 'set (list 'car 'keywords) (list 'car 'keywords)))
  39. ;; (list 'setq 'keywords (list 'cdr 'keywords)))))
  40. )
  41. ;;(define-widget-keywords :documentation-indent
  42. ;; :complete-function :complete :button-overlay
  43. ;; :field-overlay
  44. ;; :documentation-shown :button-prefix
  45. ;; :button-suffix :mouse-down-action :glyph-up :glyph-down :glyph-inactive
  46. ;; :prompt-internal :prompt-history :prompt-match
  47. ;; :prompt-value :deactivate :active
  48. ;; :inactive :activate :sibling-args :delete-button-args
  49. ;; :insert-button-args :append-button-args :button-args
  50. ;; :tag-glyph :off-glyph :on-glyph :valid-regexp
  51. ;; :secret :sample-face :sample-face-get :case-fold
  52. ;; :create :convert-widget :format :value-create :offset :extra-offset
  53. ;; :tag :doc :from :to :args :value :action
  54. ;; :value-set :value-delete :match :parent :delete :menu-tag-get
  55. ;; :value-get :choice :void :menu-tag :on :off :on-type :off-type
  56. ;; :notify :entry-format :button :children :buttons :insert-before
  57. ;; :delete-at :format-handler :widget :value-pos :value-to-internal
  58. ;; :indent :size :value-to-external :validate :error :directory
  59. ;; :must-match :type-error :value-inline :inline :match-inline :greedy
  60. ;; :button-face-get :button-face :value-face :keymap :entry-from
  61. ;; :entry-to :help-echo :documentation-property :tab-order)
  62. (defun define-widget (name class doc &rest args)
  63. "Define a new widget type named NAME from CLASS.
  64. NAME and CLASS should both be symbols, CLASS should be one of the
  65. existing widget types, or nil to create the widget from scratch.
  66. After the new widget has been defined, the following two calls will
  67. create identical widgets:
  68. * (widget-create NAME)
  69. * (apply #\\='widget-create CLASS ARGS)
  70. The third argument DOC is a documentation string for the widget."
  71. (declare (doc-string 3))
  72. ;;
  73. (unless (or (null doc) (stringp doc))
  74. (error "widget documentation must be nil or a string."))
  75. (put name 'widget-type (cons class args))
  76. (put name 'widget-documentation (purecopy doc))
  77. name)
  78. ;; This is used by external widget code (in W3, at least).
  79. (define-obsolete-function-alias 'widget-plist-member #'plist-member "26.1")
  80. ;;; The End.
  81. (provide 'widget)
  82. ;;; widget.el ends here