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

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

Re: From menu button, how run more than one command?


From: Kevin Rodgers
Subject: Re: From menu button, how run more than one command?
Date: Wed, 01 Mar 2006 11:51:17 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Mathias Dahl wrote:
> Luckily for you I struggled too with menus last week. Would something
> like this work for you?
>
> (defvar my-menu (make-sparse-keymap))
>
> (define-key my-menu [rmx1]
>    `(menu-item "Find file on c:/"
>                ,(lambda ()
>                   (interactive)
>                   (abc "c:/"))))
>
> (define-key my-menu [rmx2]
>    `(menu-item "Find file on h:/"
>                ,(lambda ()
>                   (interactive)
>                   (abc "h:/"))))
>
> (defun abc (path)
>    (cd path)
>    (call-interactively 'find-file))
>
> ;; Test it
>
> (popup-menu my-menu)

(lambda ...) is a self-evaluating form, so the backquote/comma syntax is
completely extraneous and can be replaced with a simple quote:
'(menu-item ...)

--
Kevin Rodgers





reply via email to

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