Re: User parameter collection and assignment
Heime <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <px5wULlZZE4Pt0ExURpUYHjJ5ChuXOOPrJKkxoohPpWFMh-3UMszmp5UvOiZREfEVlkrvttvutDB1xYNLvupB2ZvSr7LxQR3QC9mGp2IV-s=@protonmail.com> |
On Monday, August 3rd, 2026 at 12:48 PM, [email protected] <[email protected]> wrote: > Heime <[email protected]> writes: > > > Have made this generic function for users to fill an alist > > of parameters. > > > > Then I made the command galaxiakos-frame-config to call the generic > > function and try to populate the global variable I want - for instance > > galaxiakos-frame-prms. > > > > Here are four enumerated expressions based on your > expressions that could do what you appear to want. It > assumes that the ‘value’ which is assigned to the named > parameter is always a number. If that is not true, then you > would need to add conditional code that would check ‘value’ > to decide what to do with (convert it to a number or leave > it unchanged, and so on). > > ;;; 1. > (defun galaxiakos-alist-config (params) > "Query the user for named parameter/value pairs, PARAMS. > Return these pairs as an association list." > (interactive > (list > (let ((name "-") > (value nil) > (result nil)) > (while (not (string-empty-p name)) > (setq name > (read-string "Parameter Name (leave empty to finish): ")) > (unless (string-empty-p name) > (setq value > (string-to-number > (read-string (format "Value for %s: " name)))) > (push (cons (intern name) value) result))) > result))) > params) > > ;;; 2. > (defvar galaxiakos-frame-prms nil > "An association list of parameter/value pairs.") > > ;;; 3. > (defun galaxiakos-frame-config () > "Set the value of ‘galaxiakos-frame-prms’ to an association list of > parameter/value pairs that are provided by the user." > (interactive) > (setq galaxiakos-frame-prms > (call-interactively 'galaxiakos-alist-config))) > > ;;; 4. > (make-frame galaxiakos-frame-prms) I wonder whether I can define a defcustom and be able to allow the user to customise the alist with differnt value types.