From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: Re: global-set-key with function taking arguments Date: Sun, 1 Nov 2020 15:08:33 +0100 Message-ID: References: <87r1pdxqey.fsf@zoho.eu> <87lfflxo76.fsf@zoho.eu> <87h7q9xmim.fsf@zoho.eu> <87361txkor.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19331"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: moasenwood@zoho.eu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 01 15:13:00 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZE6N-0004up-8K for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 01 Nov 2020 15:12:59 +0100 Original-Received: from localhost ([::1]:37034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZE6M-0006FR-3k for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 01 Nov 2020 09:12:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZE2B-0004Vn-7j for help-gnu-emacs@gnu.org; Sun, 01 Nov 2020 09:08:39 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]:50457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZE28-0006CM-SA for help-gnu-emacs@gnu.org; Sun, 01 Nov 2020 09:08:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1604239713; bh=mFu8L8Y/HcDGls5n/0DUpPqpKszAMSWkcisOSVce4mM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=lC5hEPpsyHWbDEX+Nw6VQUyWdvS1YSmCZ/+i/WLosQVAeaW4tyy+ZbrbAwUHAS3uW HC0xaiNZ1sZ26kWX3RQiphL949D8rGvkQ6x/WbJmbpyFtzGYYpccs7GHXDa4QzXxlw c2yhOJLaY9w724gfaJCI8d/NGiB45KUZHgt3ZEUU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs11.server.lan [172.19.170.179]) (via HTTP); Sun, 1 Nov 2020 15:08:33 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87361txkor.fsf@zoho.eu> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:MNyMjkj6gEoXV+DSkTTXTK1HuRWvRmPvz4vNvcMPawijYe2UOmybGxAIwNhG6lPLnjBA/ I+r6XEGB5KHHlmRr/Sbalf/go93VuedjCXmAaXJjZldd35OKfa63NwQxaOhuXzpvn7ojS1yiwCWq D+dS9Y7dfTEsNT+by6gAoak9w6YzK/sm0wwKs7bPkN2xx2zK1JoEcJUBTpjf3Sb5SkN7N35i+INL Bs371bkM14FkmTdhzq9fDryiYEWM4kyRXL9dox2jWGHW8KziNXiD3H8sBcJn4EszSXzH8zJxYtHS vc= X-UI-Out-Filterresults: notjunk:1;V03:K0:eVW+ZuSQTXM=:NfRHmNxWNH6yKw7Dqdqq5V XpTbGjRxvbhzp7YYhrvShfBCXiqLpcwl6vQy7q9bi5JO6wqC451G6EPAQVt8xkUG/aZkvkiCm UYqCEOwkkLhqp2+a3RCGERe5SaRA8a3Enh7KNvNkRMNMLSmUD+lLzIRGqvJ6jQDLtI6Zctk8f hfWhFQ0bo6jGaZfmIi0mNOK6mthyfJFBmY6EpQoMEWQ0CdWQo3uJOY9OZFtiYErqftbt6yJDn T3dWqaHxlxbDEvBMPAJmxxl+YqZPuhCy5Ye/KYyiswtCVnFg9JBXocHtErtgVk1G1SpZmg25o P4OFu0lD1JKLhYF2mIfYfrxW/qIOjrG2WrRwj8YbVge0tr8/TbP+s4WEFSZhMbioxUoJEKExX XV/K4sbeJicyrM6vjCT/w/5yN+0ZOq4mJ/nIbtnsnmqz89zJHDJ48BcxxUS0VVfowpr+uZe1N 9DMvKlhm4k6JuuNERuB3Jj+NPyzWNzee8haI9FR9ajAI3SB0Bm3lmojNQFh+KrrgFRTJTIwsE GKYu0Gy5nfbI7eRiEZso+bgGhOhG46MHediBz/PVpTHflaHWVI1Hi7R2Lv+/kJZLKpzzZhUjH f89/9BJSJ+3gs= Received-SPF: pass client-ip=212.227.17.21; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/01 07:28:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124864 Archived-At: 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" > 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 > > >