unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Panagiotis Koutsourakis <kutsurak@slartibartfast.net>
To: 60859@debbugs.gnu.org
Subject: bug#60859: [PATCH] Remove reference to the kbd function from documentation
Date: Tue, 17 Jan 2023 16:20:38 +0200	[thread overview]
Message-ID: <87edrt6y4p.fsf@panoramix.zarniwoop.org> (raw)
In-Reply-To: <83cz7e4dve.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 16 Jan 2023 18:56:37 +0200")

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

On Mon, Jan 16 2023, Eli Zaretskii wrote:
>
> I prefer to keep the description of 'kbd' in the manual.  We can (and
> probably should) reword the text if we are going to the
> 'keymap-global-set' alternative, and we should probably describe the
> latter first.

Here's a second attempt. I added a brief example using `global-set-key'
and `kbd'. I also added a link to the relevant section in the elisp
reference manual and some findex directives.

Best regards,
Panos.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Reword-user-documentation-on-binding-keys-in-lisp.patch --]
[-- Type: text/x-patch, Size: 2348 bytes --]

From 5f338f0c7cad1898825c9b1b17ae92c08224c5f8 Mon Sep 17 00:00:00 2001
From: Panagiotis Koutsourakis <kutsurak@slartibartfast.net>
Date: Tue, 17 Jan 2023 15:42:35 +0200
Subject: [PATCH] ; Reword user documentation on binding keys in lisp

---
 doc/emacs/custom.texi | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index 91df15a21d7..5abe92ed43c 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1887,13 +1887,11 @@ 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)
@@ -1920,6 +1918,24 @@ 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
+Please note that these functions do not accept a simple string to
+specify the binding but need a key sequence. The easiest way to
+produce one is to use the function @code{kbd}.  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


  reply	other threads:[~2023-01-17 14:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 11:15 bug#60859: [PATCH] Remove reference to the kbd function from documentation Panagiotis Koutsourakis
2023-01-16 14:47 ` Eli Zaretskii
2023-01-16 16:17   ` Panagiotis Koutsourakis
2023-01-16 16:56     ` Eli Zaretskii
2023-01-17 14:20       ` Panagiotis Koutsourakis [this message]
2023-01-17 14:56         ` Robert Pluim
2023-01-17 16:09           ` Panagiotis Koutsourakis
2023-01-17 17:16             ` Robert Pluim
2023-01-17 17:32             ` Eli Zaretskii
2023-01-17 19:40               ` Panagiotis Koutsourakis
2023-01-21  7:52                 ` Eli Zaretskii

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=87edrt6y4p.fsf@panoramix.zarniwoop.org \
    --to=kutsurak@slartibartfast.net \
    --cc=60859@debbugs.gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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