all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Binding functions and parameters
@ 2003-01-28 14:05 Bruce Ashfield
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2003-01-28 14:05 UTC (permalink / raw)


Hi all,

I've been madly searching through the emacs lisp manuals and other
online resources, but I can't figure out how to do exactly what I
want. The answer may be that it isn't possible, but that's why I'm
posting :)

What I'd like to do is create a series of menu entries (or toolbar
buttons) that trigger different actions. It's no problem creating
the entries, it's the binding of the function I'd like them to call
that is causing the problem. I don't know how many entries I'll have
so I'm creating a single function that takes one argument. I'm 
triggering on the argument to figure out what to do.

I'd rather not go brute force and limit myself to "x" functions that
I bind, but would like to bind the function name an an argument.

Has anyone seen examples of this, I can't find it in any source or
online resources. I've included an example of what I'd like to do
that processes the open buffers. Any help is greatly appreciated,
since I'm not 100 % comfortable hacking in lisp.

(defun buffer-to-toolbar ()
  (interactive)
    (let (
         (i 0)
         (max (length (buffer-list)))
         (buffers (buffer-list))
        )
      ( while (< i max)
        (let (
                (buf (nth i buffers))
                (b-name (buffer-name (nth i buffers)))
              )         
            (print b-name)
            (define-key global-map (vector 'tool-bar i)
;; I need to figure out how to bind a function call + arguments ... 
;; I want to say "switch-to-buffer <blah> -----------------
;;                                                        |
;;                                                        v
                (list 'menu-item b-name 'switcher-test 
                   :image (create-image "~/openterm.xpm" 'xpm))             
             )             
         )
        (setq i (+ i 1))
     )
   )
)

Bruce


-- 
Bruce Ashfield         | "Thou shalt not follow the NULL pointer, for
ashfield@computer.org  |  chaos and madness await thee at its end."
bruce@zedd.org         |       - unknown

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Binding functions and parameters
       [not found] <mailman.1080.1043762793.21513.help-gnu-emacs@gnu.org>
@ 2003-01-28 14:56 ` Christopher J. White
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher J. White @ 2003-01-28 14:56 UTC (permalink / raw)


>>>>> "bruce" == Bruce Ashfield <bruce@zedd.org> writes:

bruce> What I'd like to do is create a series of menu entries (or toolbar
bruce> buttons) that trigger different actions. It's no problem creating
bruce> the entries, it's the binding of the function I'd like them to call
bruce> that is causing the problem. I don't know how many entries I'll have
bruce> so I'm creating a single function that takes one argument. I'm 
bruce> triggering on the argument to figure out what to do.

By way of example, here's a way to set a key...

(let ((msg "Hello"))
     (local-set-key [f12] `(lambda() (interactive) (message ,msg))))

The backquote says there are variables inside that need to 
be replaced (prefixed by ,), namely msg.  lambda makes it an
argumentless interactive function.

...cj

-- 
------------------------------------------------------------------------------
 Christopher J. White                                    chris@grierwhite.com
------------------------------------------------------------------------------ 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-28 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-28 14:05 Binding functions and parameters Bruce Ashfield
     [not found] <mailman.1080.1043762793.21513.help-gnu-emacs@gnu.org>
2003-01-28 14:56 ` Christopher J. White

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.