help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very customizable menus


From: David Kastrup
Subject: Re: Very customizable menus
Date: 01 Feb 2003 19:22:59 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

dbrown69@yahoo.com (David L. Brown) writes:

> So, I figured out the following fairly easily:
> 
> (defvar my-alist '(("key1" . "value1") ("key2" . "value2") ...)))
> 
> (defun my-function (key)
>   ; do stuff with my-alist to get the value that goes with key and do
> something
> )
> 
> (add-submenu nil '("DoFunc"))
> 
> But now I'm trying to figure out the following
> 
> (defun regenerate-menu ()
>   (dolist (item my-alist)
>      ; grab the key and value from item and do something akin to
>      ; (add-submenu '("DoFunc")
>      ;              '("Keys" [key1  (my-function key1)]
>      ;                       [key2  (my-function key2)]
>      ;                        etc ...                 ]))
>   )
> )
> 
> Is this possible?  Any assistance would be greatly appreciated

Replace '("Keys" ...
with `("Keys" ,(mapcar (lambda (elt) `[,(car elt) (my-function ,(car
                elt))]) my-alist))

A least I think this is what you are aiming for: your above code
snippet implies that you want to regenerate the menu for every item
in the alist which would be awkward, so you probably want to just
drop the dolist. 
                

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

[Prev in Thread] Current Thread [Next in Thread]