[Top][All Lists]

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

Re: global-set-key with function taking arguments

From: Emanuel Berg
Subject: Re: global-set-key with function taking arguments
Date: Sun, 01 Nov 2020 14:37:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Christopher Dimech wrote:

>> IMO proper functions (defuns) should be used with keys, not
>> lambdas. Except for perhaps very simple or temporary solutions.
> Agreed. For simple keybindings using a few lines of Emacs In-Built
> Commands, using Anonymous Function is sensible, rather than having
> to make a 'defun'. Anonymous Functions are especially when you see
> no reason why one would normally call it. Because you may also
> document the Anonymous Function, the 'lamdba' construct, Anonymous
> Functions become a pragmatic way of working.

Yes but ... if it is such a small function containing just a few
lines, chances are it is something basic to you and your way of using
Emacs, and if it is, chances are, further, that you will want it
again, but from a slightly different setting, e.g., another
major mode.

If and when that happens, to avoid duplicate code, turn the lambda
into a defun and call that from two places, rather than
killing/yanking the original lambda...

> Documentation for an Anonymous Function should have the same
> purpose as for a 'defun'. Conssequently, Documentation for an
> Anonymous Function should not lack much from documentation of
> a 'defun'.

They seem to have a different focus, namely how to call it.
This makes sense as, having no name, I mean, yeah, how do you call

Again, see the note here on lambda docstrings:

  C-h f lambda RET

underground experts united

reply via email to

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