mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
wid-edit.el fixes
This commit is contained in:
parent
94ae29e4c2
commit
4c2f559e16
3 changed files with 54 additions and 11 deletions
|
|
@ -27,6 +27,24 @@
|
||||||
* startup.el (normal-top-level): Reset standard-value property of
|
* startup.el (normal-top-level): Reset standard-value property of
|
||||||
`user-full-name' here.
|
`user-full-name' here.
|
||||||
|
|
||||||
|
2002-10-02 Per Abrahamsen <abraham@dina.kvl.dk>
|
||||||
|
|
||||||
|
* wid-edit.el (widget-default-get): Change to return external
|
||||||
|
value.
|
||||||
|
(widget-choice-action): Update caller.
|
||||||
|
(widget-editable-list-entry-create): Update caller.
|
||||||
|
|
||||||
|
* wid-edit.el (widget-types-copy): New function.
|
||||||
|
(default): Added :copy keyword.
|
||||||
|
(menu-choice): Ditto.
|
||||||
|
(checklist): Ditto.
|
||||||
|
(radio-button-choice): Ditto.
|
||||||
|
(editable-list): Ditto.
|
||||||
|
(group): Ditto.
|
||||||
|
(widget-copy): New function.
|
||||||
|
(widget-create-child): Use it.
|
||||||
|
(widget-create-child-value): Use it.
|
||||||
|
|
||||||
2002-10-01 Bill Wohler <wohler@newt.com>
|
2002-10-01 Bill Wohler <wohler@newt.com>
|
||||||
|
|
||||||
* mail/mh-comp.el, mail/mh-e.el, mail/mh-funcs.el,
|
* mail/mh-comp.el, mail/mh-e.el, mail/mh-funcs.el,
|
||||||
|
|
|
||||||
|
|
@ -508,9 +508,10 @@ Otherwise, just return the value."
|
||||||
:value-to-internal value)))
|
:value-to-internal value)))
|
||||||
|
|
||||||
(defun widget-default-get (widget)
|
(defun widget-default-get (widget)
|
||||||
"Extract the default value of WIDGET."
|
"Extract the default external value of WIDGET."
|
||||||
(or (widget-get widget :value)
|
(widget-apply widget :value-to-external
|
||||||
(widget-apply widget :default-get)))
|
(or (widget-get widget :value)
|
||||||
|
(widget-apply widget :default-get))))
|
||||||
|
|
||||||
(defun widget-match-inline (widget vals)
|
(defun widget-match-inline (widget vals)
|
||||||
"In WIDGET, match the start of VALS."
|
"In WIDGET, match the start of VALS."
|
||||||
|
|
@ -688,7 +689,7 @@ The child is converted, using the keyword arguments ARGS."
|
||||||
|
|
||||||
(defun widget-create-child (parent type)
|
(defun widget-create-child (parent type)
|
||||||
"Create widget of TYPE."
|
"Create widget of TYPE."
|
||||||
(let ((widget (copy-sequence type)))
|
(let ((widget (widget-copy type)))
|
||||||
(widget-put widget :parent parent)
|
(widget-put widget :parent parent)
|
||||||
(unless (widget-get widget :indent)
|
(unless (widget-get widget :indent)
|
||||||
(widget-put widget :indent (+ (or (widget-get parent :indent) 0)
|
(widget-put widget :indent (+ (or (widget-get parent :indent) 0)
|
||||||
|
|
@ -699,7 +700,7 @@ The child is converted, using the keyword arguments ARGS."
|
||||||
|
|
||||||
(defun widget-create-child-value (parent type value)
|
(defun widget-create-child-value (parent type value)
|
||||||
"Create widget of TYPE with value VALUE."
|
"Create widget of TYPE with value VALUE."
|
||||||
(let ((widget (copy-sequence type)))
|
(let ((widget (widget-copy type)))
|
||||||
(widget-put widget :value (widget-apply widget :value-to-internal value))
|
(widget-put widget :value (widget-apply widget :value-to-internal value))
|
||||||
(widget-put widget :parent parent)
|
(widget-put widget :parent parent)
|
||||||
(unless (widget-get widget :indent)
|
(unless (widget-get widget :indent)
|
||||||
|
|
@ -714,6 +715,10 @@ The child is converted, using the keyword arguments ARGS."
|
||||||
"Delete WIDGET."
|
"Delete WIDGET."
|
||||||
(widget-apply widget :delete))
|
(widget-apply widget :delete))
|
||||||
|
|
||||||
|
(defun widget-copy (widget)
|
||||||
|
"Make a deep copy of WIDGET."
|
||||||
|
(widget-apply (copy-sequence widget) :copy))
|
||||||
|
|
||||||
(defun widget-convert (type &rest args)
|
(defun widget-convert (type &rest args)
|
||||||
"Convert TYPE to a widget without inserting it in the buffer.
|
"Convert TYPE to a widget without inserting it in the buffer.
|
||||||
The optional ARGS are additional keyword arguments."
|
The optional ARGS are additional keyword arguments."
|
||||||
|
|
@ -1271,6 +1276,11 @@ Optional EVENT is the event that triggered the action."
|
||||||
found (widget-apply child :validate)))
|
found (widget-apply child :validate)))
|
||||||
found))
|
found))
|
||||||
|
|
||||||
|
(defun widget-types-copy (widget)
|
||||||
|
"Copy :args as widget types in WIDGET."
|
||||||
|
(widget-put widget :args (mapcar 'widget-copy (widget-get widget :args)))
|
||||||
|
widget)
|
||||||
|
|
||||||
;; Made defsubst to speed up face editor creation.
|
;; Made defsubst to speed up face editor creation.
|
||||||
(defsubst widget-types-convert-widget (widget)
|
(defsubst widget-types-convert-widget (widget)
|
||||||
"Convert :args as widget types in WIDGET."
|
"Convert :args as widget types in WIDGET."
|
||||||
|
|
@ -1308,6 +1318,7 @@ Optional EVENT is the event that triggered the action."
|
||||||
:button-face-get 'widget-default-button-face-get
|
:button-face-get 'widget-default-button-face-get
|
||||||
:sample-face-get 'widget-default-sample-face-get
|
:sample-face-get 'widget-default-sample-face-get
|
||||||
:delete 'widget-default-delete
|
:delete 'widget-default-delete
|
||||||
|
:copy 'identity
|
||||||
:value-set 'widget-default-value-set
|
:value-set 'widget-default-value-set
|
||||||
:value-inline 'widget-default-value-inline
|
:value-inline 'widget-default-value-inline
|
||||||
:default-get 'widget-default-default-get
|
:default-get 'widget-default-default-get
|
||||||
|
|
@ -1853,6 +1864,7 @@ the earlier input."
|
||||||
(define-widget 'menu-choice 'default
|
(define-widget 'menu-choice 'default
|
||||||
"A menu of options."
|
"A menu of options."
|
||||||
:convert-widget 'widget-types-convert-widget
|
:convert-widget 'widget-types-convert-widget
|
||||||
|
:copy 'widget-types-copy
|
||||||
:format "%[%t%]: %v"
|
:format "%[%t%]: %v"
|
||||||
:case-fold t
|
:case-fold t
|
||||||
:tag "choice"
|
:tag "choice"
|
||||||
|
|
@ -1982,9 +1994,7 @@ when he invoked the menu."
|
||||||
(when this-explicit
|
(when this-explicit
|
||||||
(widget-put widget :explicit-choice current)
|
(widget-put widget :explicit-choice current)
|
||||||
(widget-put widget :explicit-choice-value (widget-get widget :value)))
|
(widget-put widget :explicit-choice-value (widget-get widget :value)))
|
||||||
(widget-value-set
|
(widget-value-set widget (widget-default-get current))
|
||||||
widget (widget-apply current
|
|
||||||
:value-to-external (widget-default-get current)))
|
|
||||||
(widget-setup)
|
(widget-setup)
|
||||||
(widget-apply widget :notify widget event)))
|
(widget-apply widget :notify widget event)))
|
||||||
(run-hook-with-args 'widget-edit-functions widget))
|
(run-hook-with-args 'widget-edit-functions widget))
|
||||||
|
|
@ -2091,6 +2101,7 @@ when he invoked the menu."
|
||||||
(define-widget 'checklist 'default
|
(define-widget 'checklist 'default
|
||||||
"A multiple choice widget."
|
"A multiple choice widget."
|
||||||
:convert-widget 'widget-types-convert-widget
|
:convert-widget 'widget-types-convert-widget
|
||||||
|
:copy 'widget-types-copy
|
||||||
:format "%v"
|
:format "%v"
|
||||||
:offset 4
|
:offset 4
|
||||||
:entry-format "%b %v"
|
:entry-format "%b %v"
|
||||||
|
|
@ -2268,6 +2279,7 @@ Return an alist of (TYPE MATCH)."
|
||||||
(define-widget 'radio-button-choice 'default
|
(define-widget 'radio-button-choice 'default
|
||||||
"Select one of multiple options."
|
"Select one of multiple options."
|
||||||
:convert-widget 'widget-types-convert-widget
|
:convert-widget 'widget-types-convert-widget
|
||||||
|
:copy 'widget-types-copy
|
||||||
:offset 4
|
:offset 4
|
||||||
:format "%v"
|
:format "%v"
|
||||||
:entry-format "%b %v"
|
:entry-format "%b %v"
|
||||||
|
|
@ -2456,6 +2468,7 @@ Return an alist of (TYPE MATCH)."
|
||||||
(define-widget 'editable-list 'default
|
(define-widget 'editable-list 'default
|
||||||
"A variable list of widgets of the same type."
|
"A variable list of widgets of the same type."
|
||||||
:convert-widget 'widget-types-convert-widget
|
:convert-widget 'widget-types-convert-widget
|
||||||
|
:copy 'widget-types-copy
|
||||||
:offset 12
|
:offset 12
|
||||||
:format "%v%i\n"
|
:format "%v%i\n"
|
||||||
:format-handler 'widget-editable-list-format-handler
|
:format-handler 'widget-editable-list-format-handler
|
||||||
|
|
@ -2607,9 +2620,7 @@ Return an alist of (TYPE MATCH)."
|
||||||
(setq child (widget-create-child-value
|
(setq child (widget-create-child-value
|
||||||
widget type value))
|
widget type value))
|
||||||
(setq child (widget-create-child-value
|
(setq child (widget-create-child-value
|
||||||
widget type
|
widget type (widget-default-get type)))))
|
||||||
(widget-apply type :value-to-external
|
|
||||||
(widget-default-get type))))))
|
|
||||||
(t
|
(t
|
||||||
(error "Unknown escape `%c'" escape)))))
|
(error "Unknown escape `%c'" escape)))))
|
||||||
(widget-put widget
|
(widget-put widget
|
||||||
|
|
@ -2631,6 +2642,7 @@ Return an alist of (TYPE MATCH)."
|
||||||
(define-widget 'group 'default
|
(define-widget 'group 'default
|
||||||
"A widget which groups other widgets inside."
|
"A widget which groups other widgets inside."
|
||||||
:convert-widget 'widget-types-convert-widget
|
:convert-widget 'widget-types-convert-widget
|
||||||
|
:copy 'widget-types-copy
|
||||||
:format "%v"
|
:format "%v"
|
||||||
:value-create 'widget-group-value-create
|
:value-create 'widget-group-value-create
|
||||||
:value-delete 'widget-children-value-delete
|
:value-delete 'widget-children-value-delete
|
||||||
|
|
|
||||||
|
|
@ -1536,6 +1536,19 @@ Convert @code{:args} as widget types in @var{widget}.
|
||||||
Initialize @code{:value} from @code{:args} in @var{widget}.
|
Initialize @code{:value} from @code{:args} in @var{widget}.
|
||||||
@end defun
|
@end defun
|
||||||
|
|
||||||
|
@vindex copy@r{ keyword}
|
||||||
|
@item :copy
|
||||||
|
Function to deep copy a widget type. It takes a shallow copy of the
|
||||||
|
widget type as an argument (made by @code{copy-sequence}), and returns a
|
||||||
|
deep copy. The purpose of this is to avoid having different instances
|
||||||
|
of combined widgets share nested attributes.
|
||||||
|
|
||||||
|
The following predefined functions can be used here:
|
||||||
|
|
||||||
|
@defun widget-types-copy widget
|
||||||
|
Copy @code{:args} as widget types in @var{widget}.
|
||||||
|
@end defun
|
||||||
|
|
||||||
@vindex value-to-internal@r{ keyword}
|
@vindex value-to-internal@r{ keyword}
|
||||||
@item :value-to-internal
|
@item :value-to-internal
|
||||||
Function to convert the value to the internal format. The function
|
Function to convert the value to the internal format. The function
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue