emacs-devel
[Top][All Lists]
Advanced

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

Re: Buffer menu fix


From: Chong Yidong
Subject: Re: Buffer menu fix
Date: Mon, 05 Sep 2005 18:18:18 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> > So may I suggest to define a real function, with a real doc string,
>> > and then bind those clicks to that function?
>> 
>> I can't see a clean way to do that, without putting in 8 function
>> definitions that vary from each other by only a couple characters.
>> Yuck.
>
> Perhaps you could use a lambda expression or a macro inside a single
> function.  Lisp is an interpreted language, as I'm sure you know.

The code in question goes like this:

(defun Buffer-menu-make-sort-button (column ...)
  ...
  (propertize ...
    'keymap (let ((map (make-sparse-keymap))
                  (fun `(lambda ()
                          (interactive)
                          (Buffer-menu-sort ,column))))
              (define-key map [header-line mouse-1] fun)
              ...))

When you bind a function to a key, you can't specify any additional
arguments to pass to that function.  So you have to define one
function for each of the possible values of `column' in the code.

The only way I can think of to get around this is to bind to a single
function that tries to re-construct the value of `column' based on
where the mouse was clicked.  But that seems like a strange thing to
do -- you're throwing away information that you had (i.e., the value
of `column'), only to do a lot of work find out what it was later on.

I'm not sure which approach is cleaner.




reply via email to

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