Simplify and speed up widget-get implementation

* lisp/wid-edit.el (widget-get): Simplify and speed up.
Ref: https://lists.gnu.org/r/emacs-devel/2025-03/msg00010.html
This commit is contained in:
David Ponce 2025-03-02 02:41:24 +01:00 committed by Stefan Kangas
parent 49e3ef3437
commit be8a7c9c88

View file

@ -633,16 +633,12 @@ The value can later be retrieved with `widget-get'."
"In WIDGET, get the value of PROPERTY.
The value could either be specified when the widget was created, or
later with `widget-put'."
(let (tmp)
(catch 'found
(while widget
(cond ((and (setq tmp (plist-member (cdr widget) property))
(consp tmp))
(throw 'found (cadr tmp)))
((setq tmp (widget-type widget))
(setq widget (get tmp 'widget-type)))
(t
(throw 'found nil)))))))
(let (value found)
(while (and widget (not found))
(if (setq found (plist-member (cdr widget) property))
(setq value (cadr found))
(setq widget (get (widget-type widget) 'widget-type))))
value))
(defun widget-get-indirect (widget property)
"In WIDGET, get the value of PROPERTY.