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

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

Getting functions into define-key...


From: Norman Walsh
Subject: Getting functions into define-key...
Date: Mon, 29 Sep 2003 08:59:17 -0400
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm guessing there must be some way to do this other than brute force.

I have an alist:

(defvar my-alist
  '(("choice1" . "opt1")
    ("choice2" . 35)
    ("choice3" . "opt3")))

I want to make a menu-bar menu that contains choice1, choice2, choice3.
If choice1 is selected, I want to evaluate (my-function "opt1"),
If choice2 is selected, I want to evaluate (my-function 35), etc.

I can see a brute-force solution:

(defun my-function-opt1 ()
  (interactive)
  (my-function "opt1"))

(define-key menu-bar-my-menu [my-choice1]
  '("choice1" . my-function-opt1))

But it seems to me that it should be possible to build the menu bar
from the alist. Alas, it's just beyond my elisp skills.

Clues, please?

                                        Be seeing you,
                                          norm

- -- 
Norman Walsh <address@hidden> | Design and programming are human
http://nwalsh.com/            | activities; forget that and all is
                              | lost.--B. Stroustrup
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQE/eCylOyltUcwYWjsRAuaLAKCE1rUhSBghvetIfOhSGMAgvrUjuACfR1MK
m4eG4w1CZC2jpPYB1kji4s0=
=pLtC
-----END PGP SIGNATURE-----


reply via email to

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