all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-devel@gnu.org
Subject: Re: Buffer menu fix
Date: Mon, 05 Sep 2005 18:18:18 -0400	[thread overview]
Message-ID: <87wtlvrwet.fsf@stupidchicken.com> (raw)
In-Reply-To: <umzmr44tm.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 05 Sep 2005 23:50:29 +0300")

Eli Zaretskii <eliz@gnu.org> 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	other threads:[~2005-09-05 22:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-04 19:16 Buffer menu fix Chong Yidong
2005-09-05  3:32 ` Eli Zaretskii
2005-09-05 12:31   ` Chong Yidong
2005-09-05 20:50     ` Eli Zaretskii
2005-09-05 22:18       ` Chong Yidong [this message]
2005-09-05 23:16         ` Chong Yidong
2005-09-06  4:39         ` Eli Zaretskii
2005-09-06  8:09           ` Thien-Thi Nguyen
2005-09-06 19:49           ` Chong Yidong
2005-09-06 23:01             ` Kim F. Storm
2005-09-07  0:08               ` Chong Yidong
2005-09-07 12:07               ` Stefan Monnier
2005-09-07 13:04                 ` Kim F. Storm
2005-09-08  6:02                   ` Chong Yidong
2005-09-07 23:55               ` Chong Yidong
2005-09-05  7:14 ` Richard M. Stallman
2005-09-05 23:58 ` Nick Roberts
2005-09-06  0:23   ` Chong Yidong
2005-09-06  1:16     ` Nick Roberts
2005-09-06  3:30       ` asdf
2005-09-06  4:15         ` Nick Roberts
2005-09-06 19:17           ` Chong Yidong
2005-09-06 11:22     ` Richard M. Stallman
2005-09-06 19:16       ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2005-09-06  9:55 Tomas Zerolo
2005-09-06 21:41 ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wtlvrwet.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.