help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: global-set-key with function taking arguments


From: Christopher Dimech
Subject: Re: global-set-key with function taking arguments
Date: Sun, 1 Nov 2020 14:19:22 +0100

> 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.

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'.



> Sent: Sunday, November 01, 2020 at 1:57 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" 
> <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: global-set-key with function taking arguments
>
> Christopher Dimech wrote:
>
> >> ... you mean `describe-function'?
> >
> > No. I mean describe-key. If you try describe-key for a key binding
> > you are not going to get useful documentation with an
> > anonymous function.
>
> Ah, that's what you mean. No, you are right, and I agree!
>
> > But I might be mistaken. May one include documentation string for
> > lambda ()?
>
> You can! But it doesn't work the same way. C-h f lambda RET
>
>   (lambda ARGS [DOCSTRING] [INTERACTIVE] BODY)
>
>   DOCSTRING is an optional documentation string.
>   If present, it should describe how to call the function.
>   But documentation strings are usually not useful in nameless functions.
>
> IMO proper functions (defuns) should be used with keys, not lambdas.
> Except for perhaps very simple or temporary solutions.
>
> Because functions are up in the sky - heaven, almost. And keys are by
> all means a way, one way, a good way, but not the _only_ way, to
> reach them. Functions shouldn't be imprisoned down there, at the same
> level as mere keys...
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



reply via email to

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