Mercurial > emacs
changeset 21428:28157e58238a
(default, widget-default-default-get): Define it.
(group, widget-group-default-get): Define it.
(menu-choice, widget-choice-default-get): Define it.
(widget-default-get): New function.
(widget-choice-action): Call it.
(widget-editable-list-entry-create): Call it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 08 Apr 1998 07:26:54 +0000 |
parents | b5a5ac474741 |
children | 3552d6fbbddc |
files | lisp/wid-edit.el |
diffstat | 1 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/wid-edit.el Wed Apr 08 07:25:05 1998 +0000 +++ b/lisp/wid-edit.el Wed Apr 08 07:26:54 1998 +0000 @@ -470,6 +470,11 @@ :value-set (widget-apply widget :value-to-internal value))) +(defun widget-default-get (widget) + "Extract the defaylt value of WIDGET." + (or (widget-get widget :value) + (widget-apply widget :default-get))) + (defun widget-match-inline (widget vals) ;; In WIDGET, match the start of VALS. (cond ((widget-get widget :inline) @@ -1334,6 +1339,7 @@ :delete 'widget-default-delete :value-set 'widget-default-value-set :value-inline 'widget-default-value-inline + :default-get 'widget-default-default-get :menu-tag-get 'widget-default-menu-tag-get :validate (lambda (widget) nil) :active 'widget-default-active @@ -1530,6 +1536,10 @@ (widget-value widget) (list (widget-value widget)))) +(defun widget-default-default-get (widget) + ;; Get `:value'. + (widget-get widget :value)) + (defun widget-default-menu-tag-get (widget) ;; Use tag or value for menus. (or (widget-get widget :menu-tag) @@ -1903,6 +1913,7 @@ :value-delete 'widget-children-value-delete :value-get 'widget-choice-value-get :value-inline 'widget-choice-value-inline + :default-get 'widget-choice-default-get :mouse-down-action 'widget-choice-mouse-down-action :action 'widget-choice-action :error "Make a choice" @@ -1947,6 +1958,10 @@ ;; Get value of the child widget. (widget-apply (car (widget-get widget :children)) :value-inline)) +(defun widget-choice-default-get (widget) + ;; Get default for the first choice. + (widget-default-get (car (widget-get widget :args)))) + (defcustom widget-choice-toggle nil "If non-nil, a binary choice will just toggle between the values. Otherwise, the user will explicitly have to choose between the values @@ -2023,9 +2038,9 @@ (when this-explicit (widget-put widget :explicit-choice current) (widget-put widget :explicit-choice-value (widget-get widget :value))) - (widget-value-set widget - (widget-apply current :value-to-external - (widget-get current :value))) + (let ((value (widget-default-get current))) + (widget-value-set widget + (widget-apply current :value-to-external value))) (widget-setup) (widget-apply widget :notify widget event))) (run-hook-with-args 'widget-edit-functions widget)) @@ -2635,7 +2650,8 @@ (if conv (setq child (widget-create-child-value widget type value)) - (setq child (widget-create-child widget type)))) + (setq child (widget-create-child-value + widget type (widget-default-get type))))) (t (error "Unknown escape `%c'" escape))))) (widget-put widget @@ -2661,6 +2677,7 @@ :value-create 'widget-group-value-create :value-delete 'widget-children-value-delete :value-get 'widget-editable-list-value-get + :default-get 'widget-group-default-get :validate 'widget-children-validate :match 'widget-group-match :match-inline 'widget-group-match-inline) @@ -2687,6 +2704,10 @@ children)) (widget-put widget :children (nreverse children)))) +(defun widget-group-default-get (widget) + ;; Get the default of the components. + (mapcar 'widget-default-get (widget-get widget :args))) + (defun widget-group-match (widget values) ;; Match if the components match. (and (listp values)