aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Abrahamsen2002-10-03 13:46:25 +0000
committerPer Abrahamsen2002-10-03 13:46:25 +0000
commit4c2f559e1616ec431bc2be357adbe6bc70db2edb (patch)
treef2e28634d828ae18cc9dd2c8da3f4198f29583c0
parent94ae29e4c2fc672d2efe35f26ae49a95799a75a1 (diff)
downloademacs-4c2f559e1616ec431bc2be357adbe6bc70db2edb.tar.gz
emacs-4c2f559e1616ec431bc2be357adbe6bc70db2edb.zip
wid-edit.el fixes
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/wid-edit.el34
-rw-r--r--man/widget.texi13
3 files changed, 54 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ae0deed1294..4496b3111b6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -27,6 +27,24 @@
27 * startup.el (normal-top-level): Reset standard-value property of 27 * startup.el (normal-top-level): Reset standard-value property of
28 `user-full-name' here. 28 `user-full-name' here.
29 29
302002-10-02 Per Abrahamsen <abraham@dina.kvl.dk>
31
32 * wid-edit.el (widget-default-get): Change to return external
33 value.
34 (widget-choice-action): Update caller.
35 (widget-editable-list-entry-create): Update caller.
36
37 * wid-edit.el (widget-types-copy): New function.
38 (default): Added :copy keyword.
39 (menu-choice): Ditto.
40 (checklist): Ditto.
41 (radio-button-choice): Ditto.
42 (editable-list): Ditto.
43 (group): Ditto.
44 (widget-copy): New function.
45 (widget-create-child): Use it.
46 (widget-create-child-value): Use it.
47
302002-10-01 Bill Wohler <wohler@newt.com> 482002-10-01 Bill Wohler <wohler@newt.com>
31 49
32 * mail/mh-comp.el, mail/mh-e.el, mail/mh-funcs.el, 50 * mail/mh-comp.el, mail/mh-e.el, mail/mh-funcs.el,
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 65c2c6fb28b..b9139dc90e7 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -508,9 +508,10 @@ Otherwise, just return the value."
508 :value-to-internal value))) 508 :value-to-internal value)))
509 509
510(defun widget-default-get (widget) 510(defun widget-default-get (widget)
511 "Extract the default value of WIDGET." 511 "Extract the default external value of WIDGET."
512 (or (widget-get widget :value) 512 (widget-apply widget :value-to-external
513 (widget-apply widget :default-get))) 513 (or (widget-get widget :value)
514 (widget-apply widget :default-get))))
514 515
515(defun widget-match-inline (widget vals) 516(defun widget-match-inline (widget vals)
516 "In WIDGET, match the start of VALS." 517 "In WIDGET, match the start of VALS."
@@ -688,7 +689,7 @@ The child is converted, using the keyword arguments ARGS."
688 689
689(defun widget-create-child (parent type) 690(defun widget-create-child (parent type)
690 "Create widget of TYPE." 691 "Create widget of TYPE."
691 (let ((widget (copy-sequence type))) 692 (let ((widget (widget-copy type)))
692 (widget-put widget :parent parent) 693 (widget-put widget :parent parent)
693 (unless (widget-get widget :indent) 694 (unless (widget-get widget :indent)
694 (widget-put widget :indent (+ (or (widget-get parent :indent) 0) 695 (widget-put widget :indent (+ (or (widget-get parent :indent) 0)
@@ -699,7 +700,7 @@ The child is converted, using the keyword arguments ARGS."
699 700
700(defun widget-create-child-value (parent type value) 701(defun widget-create-child-value (parent type value)
701 "Create widget of TYPE with value VALUE." 702 "Create widget of TYPE with value VALUE."
702 (let ((widget (copy-sequence type))) 703 (let ((widget (widget-copy type)))
703 (widget-put widget :value (widget-apply widget :value-to-internal value)) 704 (widget-put widget :value (widget-apply widget :value-to-internal value))
704 (widget-put widget :parent parent) 705 (widget-put widget :parent parent)
705 (unless (widget-get widget :indent) 706 (unless (widget-get widget :indent)
@@ -714,6 +715,10 @@ The child is converted, using the keyword arguments ARGS."
714 "Delete WIDGET." 715 "Delete WIDGET."
715 (widget-apply widget :delete)) 716 (widget-apply widget :delete))
716 717
718(defun widget-copy (widget)
719 "Make a deep copy of WIDGET."
720 (widget-apply (copy-sequence widget) :copy))
721
717(defun widget-convert (type &rest args) 722(defun widget-convert (type &rest args)
718 "Convert TYPE to a widget without inserting it in the buffer. 723 "Convert TYPE to a widget without inserting it in the buffer.
719The optional ARGS are additional keyword arguments." 724The optional ARGS are additional keyword arguments."
@@ -1271,6 +1276,11 @@ Optional EVENT is the event that triggered the action."
1271 found (widget-apply child :validate))) 1276 found (widget-apply child :validate)))
1272 found)) 1277 found))
1273 1278
1279(defun widget-types-copy (widget)
1280 "Copy :args as widget types in WIDGET."
1281 (widget-put widget :args (mapcar 'widget-copy (widget-get widget :args)))
1282 widget)
1283
1274;; Made defsubst to speed up face editor creation. 1284;; Made defsubst to speed up face editor creation.
1275(defsubst widget-types-convert-widget (widget) 1285(defsubst widget-types-convert-widget (widget)
1276 "Convert :args as widget types in WIDGET." 1286 "Convert :args as widget types in WIDGET."
@@ -1308,6 +1318,7 @@ Optional EVENT is the event that triggered the action."
1308 :button-face-get 'widget-default-button-face-get 1318 :button-face-get 'widget-default-button-face-get
1309 :sample-face-get 'widget-default-sample-face-get 1319 :sample-face-get 'widget-default-sample-face-get
1310 :delete 'widget-default-delete 1320 :delete 'widget-default-delete
1321 :copy 'identity
1311 :value-set 'widget-default-value-set 1322 :value-set 'widget-default-value-set
1312 :value-inline 'widget-default-value-inline 1323 :value-inline 'widget-default-value-inline
1313 :default-get 'widget-default-default-get 1324 :default-get 'widget-default-default-get
@@ -1853,6 +1864,7 @@ the earlier input."
1853(define-widget 'menu-choice 'default 1864(define-widget 'menu-choice 'default
1854 "A menu of options." 1865 "A menu of options."
1855 :convert-widget 'widget-types-convert-widget 1866 :convert-widget 'widget-types-convert-widget
1867 :copy 'widget-types-copy
1856 :format "%[%t%]: %v" 1868 :format "%[%t%]: %v"
1857 :case-fold t 1869 :case-fold t
1858 :tag "choice" 1870 :tag "choice"
@@ -1982,9 +1994,7 @@ when he invoked the menu."
1982 (when this-explicit 1994 (when this-explicit
1983 (widget-put widget :explicit-choice current) 1995 (widget-put widget :explicit-choice current)
1984 (widget-put widget :explicit-choice-value (widget-get widget :value))) 1996 (widget-put widget :explicit-choice-value (widget-get widget :value)))
1985 (widget-value-set 1997 (widget-value-set widget (widget-default-get current))
1986 widget (widget-apply current
1987 :value-to-external (widget-default-get current)))
1988 (widget-setup) 1998 (widget-setup)
1989 (widget-apply widget :notify widget event))) 1999 (widget-apply widget :notify widget event)))
1990 (run-hook-with-args 'widget-edit-functions widget)) 2000 (run-hook-with-args 'widget-edit-functions widget))
@@ -2091,6 +2101,7 @@ when he invoked the menu."
2091(define-widget 'checklist 'default 2101(define-widget 'checklist 'default
2092 "A multiple choice widget." 2102 "A multiple choice widget."
2093 :convert-widget 'widget-types-convert-widget 2103 :convert-widget 'widget-types-convert-widget
2104 :copy 'widget-types-copy
2094 :format "%v" 2105 :format "%v"
2095 :offset 4 2106 :offset 4
2096 :entry-format "%b %v" 2107 :entry-format "%b %v"
@@ -2268,6 +2279,7 @@ Return an alist of (TYPE MATCH)."
2268(define-widget 'radio-button-choice 'default 2279(define-widget 'radio-button-choice 'default
2269 "Select one of multiple options." 2280 "Select one of multiple options."
2270 :convert-widget 'widget-types-convert-widget 2281 :convert-widget 'widget-types-convert-widget
2282 :copy 'widget-types-copy
2271 :offset 4 2283 :offset 4
2272 :format "%v" 2284 :format "%v"
2273 :entry-format "%b %v" 2285 :entry-format "%b %v"
@@ -2456,6 +2468,7 @@ Return an alist of (TYPE MATCH)."
2456(define-widget 'editable-list 'default 2468(define-widget 'editable-list 'default
2457 "A variable list of widgets of the same type." 2469 "A variable list of widgets of the same type."
2458 :convert-widget 'widget-types-convert-widget 2470 :convert-widget 'widget-types-convert-widget
2471 :copy 'widget-types-copy
2459 :offset 12 2472 :offset 12
2460 :format "%v%i\n" 2473 :format "%v%i\n"
2461 :format-handler 'widget-editable-list-format-handler 2474 :format-handler 'widget-editable-list-format-handler
@@ -2607,9 +2620,7 @@ Return an alist of (TYPE MATCH)."
2607 (setq child (widget-create-child-value 2620 (setq child (widget-create-child-value
2608 widget type value)) 2621 widget type value))
2609 (setq child (widget-create-child-value 2622 (setq child (widget-create-child-value
2610 widget type 2623 widget type (widget-default-get type)))))
2611 (widget-apply type :value-to-external
2612 (widget-default-get type))))))
2613 (t 2624 (t
2614 (error "Unknown escape `%c'" escape))))) 2625 (error "Unknown escape `%c'" escape)))))
2615 (widget-put widget 2626 (widget-put widget
@@ -2631,6 +2642,7 @@ Return an alist of (TYPE MATCH)."
2631(define-widget 'group 'default 2642(define-widget 'group 'default
2632 "A widget which groups other widgets inside." 2643 "A widget which groups other widgets inside."
2633 :convert-widget 'widget-types-convert-widget 2644 :convert-widget 'widget-types-convert-widget
2645 :copy 'widget-types-copy
2634 :format "%v" 2646 :format "%v"
2635 :value-create 'widget-group-value-create 2647 :value-create 'widget-group-value-create
2636 :value-delete 'widget-children-value-delete 2648 :value-delete 'widget-children-value-delete
diff --git a/man/widget.texi b/man/widget.texi
index 2efb57624b5..fdac3cdde64 100644
--- a/man/widget.texi
+++ b/man/widget.texi
@@ -1536,6 +1536,19 @@ Convert @code{:args} as widget types in @var{widget}.
1536Initialize @code{:value} from @code{:args} in @var{widget}. 1536Initialize @code{:value} from @code{:args} in @var{widget}.
1537@end defun 1537@end defun
1538 1538
1539@vindex copy@r{ keyword}
1540@item :copy
1541Function to deep copy a widget type. It takes a shallow copy of the
1542widget type as an argument (made by @code{copy-sequence}), and returns a
1543deep copy. The purpose of this is to avoid having different instances
1544of combined widgets share nested attributes.
1545
1546The following predefined functions can be used here:
1547
1548@defun widget-types-copy widget
1549Copy @code{:args} as widget types in @var{widget}.
1550@end defun
1551
1539@vindex value-to-internal@r{ keyword} 1552@vindex value-to-internal@r{ keyword}
1540@item :value-to-internal 1553@item :value-to-internal
1541Function to convert the value to the internal format. The function 1554Function to convert the value to the internal format. The function