Looking up information from an Active Directory, I want to populate a form. Generally that works fine with editable-fields, since all one has to do is to add the value, which Emacs has a function for ((widget-value-set)). However, for one element I will need to use a drop-down field to only choose one of potentially more options, but I appear to fail to understand how to add items to a menu-choice widget.
My constant helper for building forms is the Emacs widget library. However, even the programming example under 3 is not revealing this as the example simply hard-coded them.
My current mock-up for testing this outside the actual environment looks like the following:
(let ((sBuffer "*Test*") (lItems (list '(item :tag "Test 1" :value 1) '(item :tag "Test 2" :value 2)))) (switch-to-buffer sBuffer) (make-local-variable 'wADgroup) (let ((inhibit-read-only t)) (erase-buffer)) (remove-overlays) (setq wButton (widget-create 'push-button :notify (lambda (widget &rest ignore) (widget-put wADgroup :children lItems) ;;(widget-value-set wADgroup 1) (widget-setup)) "Click me!")) (widget-insert "\n\n") (setq wADgroup (widget-create 'menu-choice :tag "- AD group " :value 1 :notify (lambda (widget &rest ignore)))) (use-local-map widget-keymap) (widget-setup)) Pressing the button in the above shall add the items.
Is there a way to dynamically add items to an existing menu-choice widget in hindsight or does it need to be deleted and re-created? I tried to add a list for :children, but that did not seem to have an effect and I am not sure how to add "loose" arguments when using widget-create (for any ordinary list I would use (append), of course). Even if the widget would need to be re-created, I still fail to understand how to programmatically add the items.
I'm using Emacs 28.