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

Re: 24.5; w3m.el using lambda function in keybinding definition

On 2016-07-25 18:25, Katsumi Yamaoka wrote:
> In [emacs-w3m : No.12575]
> 	On Mon, 25 Jul 2016 01:49:10 -0400, Boruch Baum wrote:
> > That's the point I'm trying to make, and the problem that I'm
> > reporting - when the w3m.el source defines a key to a lambda function,
> > there is no way to remap **the_function** to another keybinding
> > because 'FUNCTION doesn't have a name - its a lambda function. So, a
> > user would have to copy the lambda funtion in its entirety.
> Oh, I only see it.  What you want to do is this, don't you?
> (define-key w3m-mode-map [remap oldfun] 'newfun)

Not really, but close. Here is what I am doing for now:

  (define-key w3m-mode-map (kbd "<down>") 'w3m-scroll-up-1)
  (define-key w3m-mode-map (kbd "<up>")
    '(lambda () (interactive) (scroll-down 1)))

> Even if `oldfun' is not a symbol, you can do it as follows:
> (dolist (key (where-is-internal
> 	      (lookup-key w3m-mode-map "K")
> 	      w3m-mode-map))
>   (define-key w3m-mode-map key 'your-favorite-command))

But why do you, as a developer, want to force a user to go through all
those unnecessary and non-standard steps and procedures, when the
usual user is accustomed to the simple and straightforward:

  (define-key KEYMAP KEY DEF)

> This will replace the command, that the "K" key is bound to, with
> `your-favorite-command' for all the keys in `w3m-mode-map'.
> > It should not be a lambda function.
> grep -r '(define-key.*(lambda'
> reports that many ELisp modules use it in the Emacs source. ;-)

Strange. When I perform that same command on /usr/share/emacs/*, there
are only three responses. Two are because your regexp is good not
perfect, and the third is the case I', reporting. When I perform the
same command on /usr/share/emacs24/*, I get no responses.

In any event, even were there other cases in the wide wide world of
emacs, that doesn't make the usage correct.

Not only is it unfriendly to users, but it's also anomalous for
developers and contributors. You have two parallel functions, one
defined (IMHO properly) as 'w3m-scroll-up-1' in one part of your
source code, and the other, which a developer would expect to be
called 'w3m-scroll-down-1', not defined at all, but implemented as a
lambda function in a second part of the source code.

There's also the issue that the lambda function is 'less developed'
than its parallel defined function.

CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0