[Top][All Lists]

[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 15:08:33 +0100

My only complaint was that you would not get a description when
using in a key binding.  But now I know that one can put a

I usually use them when I write by own improved versions of Built-In
Functions.  Then use a keybinding with the original call using 'lambda'.

Using key bindings makes it easy to see how my new function behaves
when compared with the Built-In version.

> Sent: Sunday, November 01, 2020 at 2:37 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" 
> <>
> To:
> Subject: Re: global-set-key with function taking arguments
> 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
> it?!
> 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]