From: Christopher Dimech <dimech@gmx.com>
To: moasenwood@zoho.eu
Cc: help-gnu-emacs@gnu.org
Subject: Re: global-set-key with function taking arguments
Date: Sun, 1 Nov 2020 15:08:33 +0100 [thread overview]
Message-ID: <trinity-037a48b4-ef6f-44a9-a1cf-677577897c4d-1604239713759@3c-app-mailcom-bs11> (raw)
In-Reply-To: <87361txkor.fsf@zoho.eu>
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
description.
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" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> 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
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
next prev parent reply other threads:[~2020-11-01 14:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-01 9:53 global-set-key with function taking arguments jai-bholeki via Users list for the GNU Emacs text editor
2020-11-01 10:57 ` William Xu
2020-11-01 11:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-01 11:47 ` Christopher Dimech
2020-11-01 12:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-01 12:28 ` Christopher Dimech
2020-11-01 12:57 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-01 13:19 ` Christopher Dimech
2020-11-01 13:37 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-01 14:08 ` Christopher Dimech [this message]
2020-11-01 14:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-01 23:38 ` Corwin Brust
2020-11-01 13:05 ` William Xu
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=trinity-037a48b4-ef6f-44a9-a1cf-677577897c4d-1604239713759@3c-app-mailcom-bs11 \
--to=dimech@gmx.com \
--cc=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).