comparison lisp/wid-edit.el @ 18364:01666331d10f

Synched with 1.9930.
author Per Abrahamsen <abraham@dina.kvl.dk>
date Sat, 21 Jun 1997 12:48:00 +0000
parents eecbc06aed1c
children ceb9388fe67f
comparison
equal deleted inserted replaced
18363:31e4a16368c9 18364:01666331d10f
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: extensions 6 ;; Keywords: extensions
7 ;; Version: 1.9924 7 ;; Version: 1.9929
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
436 ((setq tmp (car widget)) 436 ((setq tmp (car widget))
437 (setq widget (get tmp 'widget-type))) 437 (setq widget (get tmp 'widget-type)))
438 (t 438 (t
439 (setq missing nil)))) 439 (setq missing nil))))
440 value)) 440 value))
441
442 (defun widget-get-indirect (widget property)
443 "In WIDGET, get the value of PROPERTY.
444 If the value is a symbol, return its binding.
445 Otherwise, just return the value."
446 (let ((value (widget-get widget property)))
447 (if (symbolp value)
448 (symbol-value value)
449 value)))
441 450
442 (defun widget-member (widget property) 451 (defun widget-member (widget property)
443 "Non-nil iff there is a definition in WIDGET for PROPERTY." 452 "Non-nil iff there is a definition in WIDGET for PROPERTY."
444 (cond ((widget-plist-member (cdr widget) property) 453 (cond ((widget-plist-member (cdr widget) property)
445 t) 454 t)
664 673
665 (defcustom widget-button-suffix "" 674 (defcustom widget-button-suffix ""
666 "String used as suffix for buttons." 675 "String used as suffix for buttons."
667 :type 'string 676 :type 'string
668 :group 'widget-button) 677 :group 'widget-button)
669
670 (defun widget-button-insert-indirect (widget key)
671 "Insert value of WIDGET's KEY property."
672 (let ((val (widget-get widget key)))
673 (while (and val (symbolp val))
674 (setq val (symbol-value val)))
675 (when val
676 (insert val))))
677 678
678 ;;; Creating Widgets. 679 ;;; Creating Widgets.
679 680
680 ;;;###autoload 681 ;;;###autoload
681 (defun widget-create (type &rest args) 682 (defun widget-create (type &rest args)
1183 (when found 1184 (when found
1184 (debug "Overlapping fields")) 1185 (debug "Overlapping fields"))
1185 (setq found field)))) 1186 (setq found field))))
1186 found)) 1187 found))
1187 1188
1188 ;; This is how, for example, a variable changes its state to "set"
1189 ;; when it is being edited.
1190 (defun widget-before-change (from &rest ignore) 1189 (defun widget-before-change (from &rest ignore)
1190 ;; This is how, for example, a variable changes its state to `modified'.
1191 ;; when it is being edited.
1191 (condition-case nil 1192 (condition-case nil
1192 (let ((field (widget-field-find from))) 1193 (let ((field (widget-field-find from)))
1193 (widget-apply field :notify field)) 1194 (widget-apply field :notify field))
1194 (error (debug "After Change")))) 1195 (error (debug "Before Change"))))
1195 1196
1196 (defun widget-after-change (from to old) 1197 (defun widget-after-change (from to old)
1197 ;; Adjust field size and text properties. 1198 ;; Adjust field size and text properties.
1198 (condition-case nil 1199 (condition-case nil
1199 (let ((field (widget-field-find from)) 1200 (let ((field (widget-field-find from))
1234 (while (< begin end) 1235 (while (< begin end)
1235 (let ((old (char-after begin))) 1236 (let ((old (char-after begin)))
1236 (unless (eq old secret) 1237 (unless (eq old secret)
1237 (subst-char-in-region begin (1+ begin) old secret) 1238 (subst-char-in-region begin (1+ begin) old secret)
1238 (put-text-property begin (1+ begin) 'secret old)) 1239 (put-text-property begin (1+ begin) 'secret old))
1239 (setq begin (1+ begin))))))))) 1240 (setq begin (1+ begin)))))))
1241 (widget-apply field :notify field)))
1240 (error (debug "After Change")))) 1242 (error (debug "After Change"))))
1241 1243
1242 ;;; Widget Functions 1244 ;;; Widget Functions
1243 ;; 1245 ;;
1244 ;; These functions are used in the definition of multiple widgets. 1246 ;; These functions are used in the definition of multiple widgets.
1335 (replace-match "" t t) 1337 (replace-match "" t t)
1336 (cond ((eq escape ?%) 1338 (cond ((eq escape ?%)
1337 (insert "%")) 1339 (insert "%"))
1338 ((eq escape ?\[) 1340 ((eq escape ?\[)
1339 (setq button-begin (point)) 1341 (setq button-begin (point))
1340 (widget-button-insert-indirect widget :button-prefix)) 1342 (insert (widget-get-indirect widget :button-prefix)))
1341 ((eq escape ?\]) 1343 ((eq escape ?\])
1342 (widget-button-insert-indirect widget :button-suffix) 1344 (insert (widget-get-indirect widget :button-suffix))
1343 (setq button-end (point))) 1345 (setq button-end (point)))
1344 ((eq escape ?\{) 1346 ((eq escape ?\{)
1345 (setq sample-begin (point))) 1347 (setq sample-begin (point)))
1346 ((eq escape ?\}) 1348 ((eq escape ?\})
1347 (setq sample-end (point))) 1349 (setq sample-end (point)))
1647 1649
1648 (defun widget-info-link-action (widget &optional event) 1650 (defun widget-info-link-action (widget &optional event)
1649 "Open the info node specified by WIDGET." 1651 "Open the info node specified by WIDGET."
1650 (Info-goto-node (widget-value widget))) 1652 (Info-goto-node (widget-value widget)))
1651 1653
1652 ;;; The `group-link' Widget.
1653
1654 (define-widget 'group-link 'link
1655 "A link to a customization group."
1656 :create 'widget-group-link-create
1657 :action 'widget-group-link-action)
1658
1659 (defun widget-group-link-create (widget)
1660 (let ((state (widget-get (widget-get widget :parent) :custom-state)))
1661 (if (eq state 'hidden)
1662 (widget-default-create widget))))
1663
1664 (defun widget-group-link-action (widget &optional event)
1665 "Open the info node specified by WIDGET."
1666 (customize-group (widget-value widget)))
1667
1668 ;;; The `url-link' Widget. 1654 ;;; The `url-link' Widget.
1669 1655
1670 (define-widget 'url-link 'link 1656 (define-widget 'url-link 'link
1671 "A link to an www page." 1657 "A link to an www page."
1672 :action 'widget-url-link-action) 1658 :action 'widget-url-link-action)
2633 (setq off "")) 2619 (setq off ""))
2634 (if (widget-value widget) 2620 (if (widget-value widget)
2635 (widget-glyph-insert widget on "down" "down-pushed") 2621 (widget-glyph-insert widget on "down" "down-pushed")
2636 (widget-glyph-insert widget off "right" "right-pushed")))) 2622 (widget-glyph-insert widget off "right" "right-pushed"))))
2637 2623
2638 (define-widget 'group-visibility 'item
2639 "An indicator and manipulator for hidden group contents."
2640 :format "%[%v%]"
2641 :create 'widget-group-visibility-create
2642 :button-prefix ""
2643 :button-suffix ""
2644 :on "Hide"
2645 :off "Show"
2646 :value-create 'widget-visibility-value-create
2647 :action 'widget-toggle-action
2648 :match (lambda (widget value) t))
2649
2650 (defun widget-group-visibility-create (widget)
2651 (let ((visible (widget-value widget)))
2652 (if visible
2653 (insert "--------")))
2654 (widget-default-create widget))
2655
2656 ;;; The `documentation-link' Widget. 2624 ;;; The `documentation-link' Widget.
2657 ;; 2625 ;;
2658 ;; This is a helper widget for `documentation-string'. 2626 ;; This is a helper widget for `documentation-string'.
2659 2627
2660 (define-widget 'documentation-link 'link 2628 (define-widget 'documentation-link 'link