[Top][All Lists]

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

Binding functions and parameters

From: Bruce Ashfield
Subject: Binding functions and parameters
Date: Tue, 28 Jan 2003 09:05:02 -0500
User-agent: Mutt/1.3.25i

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 ()
    (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 Ashfield         | "Thou shalt not follow the NULL pointer, for
address@hidden  |  chaos and madness await thee at its end."
address@hidden         |       - unknown

reply via email to

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