From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Panagiotis Koutsourakis Newsgroups: gmane.emacs.bugs Subject: bug#60859: [PATCH] Remove reference to the kbd function from documentation Date: Tue, 17 Jan 2023 21:40:28 +0200 Message-ID: <874jspj6fn.fsf@panoramix.zarniwoop.org> References: <87pmbeivcl.fsf@panoramix.zarniwoop.org> <83ilh64juj.fsf@gnu.org> <87o7qyo3nc.fsf@panoramix.zarniwoop.org> <83cz7e4dve.fsf@gnu.org> <87edrt6y4p.fsf@panoramix.zarniwoop.org> <875yd5ciqs.fsf@gmail.com> <87fsc9jg6p.fsf@panoramix.zarniwoop.org> <83lem12hjh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3489"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: rpluim@gmail.com, 60859@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 17 20:41:18 2023 Return-path: Envelope-to: geb-bug-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 1pHrpb-0000jX-Sr for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Jan 2023 20:41:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHrpR-00088X-L0; Tue, 17 Jan 2023 14:41:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHrpO-00088F-KU for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2023 14:41:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHrpO-0000wg-C8 for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2023 14:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHrpO-0001wX-8U for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2023 14:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Panagiotis Koutsourakis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Jan 2023 19:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60859 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60859-submit@debbugs.gnu.org id=B60859.16739844397433 (code B ref 60859); Tue, 17 Jan 2023 19:41:02 +0000 Original-Received: (at 60859) by debbugs.gnu.org; 17 Jan 2023 19:40:39 +0000 Original-Received: from localhost ([127.0.0.1]:38328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHrp1-0001vp-4n for submit@debbugs.gnu.org; Tue, 17 Jan 2023 14:40:39 -0500 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:48675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHroz-0001vb-LJ for 60859@debbugs.gnu.org; Tue, 17 Jan 2023 14:40:38 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 949985C00DC; Tue, 17 Jan 2023 14:40:32 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 17 Jan 2023 14:40:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= slartibartfast.net; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1673984432; x= 1674070832; bh=PJLygxqCC+0lXXkBnqrjYknDVyHUCagzxgVrxp0bLgw=; b=Q iFGRV1aleOAoTDC1GzHo42oaria0G4MFLWuiwPyMhdbAC7XgCYwYRZNQAuiYvMDp qjm8auYNH7BMZrWC96EgjUgG7BR/PAiR51HKl51ejVzyXlzv+xcG240o71tUn7t+ Wf6ztwC6fGBtHjv75gOkMQKCsc4bXaQAXGALUU0msO93HrBKXiF4iDoqwovTC6aa jvjGrUUytGTMb4JZ3OcHtGJ+nCdvcoqxbBVl030/4nAOYyNKSFCIjT2U6rmscIEO pvqGk/r2auiZMpEEoxqCu/gV0pBPabVZyUNrZrNQAB7fS/txmZ/kNzCAqXHvm0z3 WD/Z3ly/8DyzvK3aQhLkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1673984432; x=1674070832; bh=PJLygxqCC+0lXXkBnqrjYknDVyHU CagzxgVrxp0bLgw=; b=AoivzFpBN+ao9tjyFU0VrMKj1Pe3AAKRGwEsHvQoYXFl Jqwv5/S3lnyW0pfI/zUFB4JglHsc+Qjq0Zrk5yeQAKUQGyFiYcy3QhhKm3kohBJn BHQWFFIDp35HP5D7e8z+wWEamgmQKQZ0sRQHXfac7UFZgHKWFz7vp2wBs/91LmGQ 4qYG2yLHVrDgqyfQ2ZttIpCnLj6e1t4kZUz1sYEDC0GAIwXAV1tCPs3FTZiC5ren uA0HkTUiworY3lb6BUQVTCQiV0Cxnbf25XLw8aDpPSVkY979j2iI6IFd0BbOOScM aUkjl2xhKJxokCxww4WpLN3SrdKqcDeYKnW2QYIQ3g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddtiedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufgjfhffkfgfgggtsehmtderredtredtnecuhfhrohhmpefrrghn rghgihhothhishcumfhouhhtshhouhhrrghkihhsuceokhhuthhsuhhrrghksehslhgrrh htihgsrghrthhfrghsthdrnhgvtheqnecuggftrfgrthhtvghrnhepudetgeejuddtfeef gefgueeltdejudeiveehgffhveeftdejteevjedvteejledtnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhuthhsuhhrrghksehslhgrrhht ihgsrghrthhfrghsthdrnhgvth X-ME-Proxy: Feedback-ID: iaac9463b:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 17 Jan 2023 14:40:31 -0500 (EST) In-Reply-To: <83lem12hjh.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 17 Jan 2023 19:32:34 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253579 Archived-At: --=-=-= Content-Type: text/plain On Tue, Jan 17 2023, Eli Zaretskii wrote: > > There's no need to generalize so much. Let's handle this specific > issue, and then move on. > > For now, I don't want to remove references to 'kbd' from the manual, > because many people still use it. So please accept that as the > baseline, and let's find the best way to describe the new APIs as > well. Eli, I am not sure if you saw my earlier message with the second proposed patch taking into account your feedback from yesterday. Apologies for any confusion I caused. Robert raised some valid points in his reply about it: 1. it does not describe accurately the arguments accepted by the old API: lisp strings and vectors of input events are missing. I think that pointing the users to the reference manual is enough to remedy this. 2. The syntax accepted by the new API and 'kbd' is not explicit. This is, I believe, a more serious issue. I don't think that the previous versions of the manual had an explicit description of it at this point, but since we are re-examining the section anyway, we should write a few words. I adapted the description Robert wrote in his e-mail (thank you Robert!). I am attaching the patch with these changes. Panos. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Reword-user-documentation-on-binding-keys-in-lisp.patch >From a8d959fed720618c03993311110fa87cf52cf13f Mon Sep 17 00:00:00 2001 From: Panagiotis Koutsourakis Date: Tue, 17 Jan 2023 20:57:41 +0200 Subject: [PATCH] ; Reword user documentation on binding keys in lisp --- doc/emacs/custom.texi | 46 +++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 91df15a21d7..44c37d3ac83 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1887,22 +1887,29 @@ Init Rebinding you can specify them in your initialization file by writing Lisp code. @xref{Init File}, for a description of the initialization file. -@findex kbd - There are several ways to write a key binding using Lisp. The -simplest is to use the @code{kbd} function, which converts a textual -representation of a key sequence---similar to how we have written key -sequences in this manual---into a form that can be passed as an -argument to @code{keymap-global-set}. For example, here's how to bind -@kbd{C-z} to the @code{shell} command (@pxref{Interactive Shell}): +@findex keymap-global-set + The recommended way to write a key binding using Lisp is to use one +of the @code{keymap-global-set}, or @code{keymap-set} functions. For +example, here's how to bind @kbd{C-z} to the @code{shell} command in +the global keymap (@pxref{Interactive Shell}): @example (keymap-global-set "C-z" 'shell) @end example +@cindex key sequence syntax @noindent -The single-quote before the command name, @code{shell}, marks it as a -constant symbol rather than a variable. If you omit the quote, Emacs -would try to evaluate @code{shell} as a variable. This probably +The second argument that describes the key sequence, is a string +containing a series of characters separated by spaces with each +character corresponding to a key. Keys with modifiers can be +specified by prepending the modifier, such as @samp{C-} for Control, +or @samp{M-} for Meta. Special keys, such as @kbd{TAB} and @kbd{RET}, +can be specified within angle brackets as in @kbd{@key{TAB}} and +@kbd{@key{RET}}. + + The single-quote before the command name, @code{shell}, marks it as +a constant symbol rather than a variable. If you omit the quote, +Emacs would try to evaluate @code{shell} as a variable. This probably causes an error; it certainly isn't what you want. Here are some additional examples, including binding function keys @@ -1920,6 +1927,25 @@ Init Rebinding Language and coding systems may cause problems with key bindings for non-@acronym{ASCII} characters. @xref{Init Non-ASCII}. +@findex global-set-key +@findex define-key + Alternatively you can use the low level functions @code{define-key} +and @code{global-set-key}. For example to bind @kbd{C-z} to the +@code{shell} command as in the above example, use: + +@example +(global-set-key (kbd "C-z") 'shell) +@end example + +@findex kbd +@noindent +There are various ways to specify the key sequence but the simplest is +to use the function @code{kbd} as shown in the example above. +@code{kbd} takes a single string argument specifying a key sequence in +the syntax described earlier for @code{keymap-global-set}. For more +details about binding keys using Lisp @ref{Keymaps,,, elisp, The Emacs +Lisp Reference Manual}. + @findex keymap-set @findex keymap-unset As described in @ref{Local Keymaps}, major modes and minor modes can -- 2.39.0 --=-=-=--