unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences
       [not found] ` <20221114161917.7FC8AC00AB5@vcs2.savannah.gnu.org>
@ 2022-11-15  3:40   ` Stefan Kangas
  2022-11-15  8:28     ` Robert Pluim
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2022-11-15  3:40 UTC (permalink / raw)
  To: Robert Pluim, emacs-devel

Robert Pluim <rpluim@gmail.com> writes:

> branch: emacs-28
> commit 56026242e462e8834337f118baaa9c49e2411f7d
> Author: Robert Pluim <rpluim@gmail.com>
> Commit: Robert Pluim <rpluim@gmail.com>
>
>     Explain how to bind keys to non-ASCII sequences
>
>     * doc/emacs/custom.texi (Init Rebinding): Explain how to use `kbd'
>     when binding keys to non-ASCII sequences.
> ---
>  doc/emacs/custom.texi | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
> index 2bc1d3820d..65970ce412 100644
> --- a/doc/emacs/custom.texi
> +++ b/doc/emacs/custom.texi
> @@ -1868,6 +1868,22 @@ characters.  For example, here's how to bind @kbd{C-x M-l} to
>
>  @example
>  (global-set-key "\C-x\M-l" 'make-symbolic-link)
> +@end example
> +
> +  Similarly, a key sequence can be bound to a Lisp string or a vector
> +instead of a command.  A vector is only required if the intended
> +result contains non-@acronym{ASCII} characters, and @code{kbd} can
> +again be used to create that vector.  For example, to bind @kbd{C-c h}
> +to the string @samp{hello}:
> +
> +@example
> +(global-set-key (kbd "C-c h") "hello")
> +@end example
> +
> +  But to bind it to the string @samp{olá} instead:
> +
> +@example
> +(global-set-key (kbd "C-c h") (kbd "olá"))
>  @end example
>
>    To bind a key sequence including @key{TAB}, @key{RET}, @key{ESC}, or

This section has changed quite a bit on master, including using
`keymap-global-set' instead.  Unfortunately, I'm not sure what if
anything needs adding to the text already on master.  Could you please
look into it, or even help merge it?

Thanks in advance.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences
  2022-11-15  3:40   ` emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences Stefan Kangas
@ 2022-11-15  8:28     ` Robert Pluim
  2022-11-15  9:09       ` Stefan Kangas
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2022-11-15  8:28 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: emacs-devel

>>>>> On Mon, 14 Nov 2022 19:40:35 -0800, Stefan Kangas <stefankangas@gmail.com> said:

    Stefan> This section has changed quite a bit on master, including using
    Stefan> `keymap-global-set' instead.  Unfortunately, I'm not sure what if
    Stefan> anything needs adding to the text already on master.  Could you please
    Stefan> look into it, or even help merge it?

Well this has opened a can of worms:

Item the first:

    (keymap-global-set "C-c h" "h") => [104]

    (keymap-global-set "C-c h" "hello") => 

    Debugger entered--Lisp error: (error "\"hello\" is not a valid key definition; see `key-va...")
      signal(error ("\"hello\" is not a valid key definition; see `key-va..."))
      error("%S is not a valid key definition; see `key-valid-p..." "hello")
      keymap--check("hello")
      keymap-set((keymap #^[nil nil keymap 
      keymap-global-set("C-c h" "hello")

    (keymap-global-set "C-c h" (kbd "hello")) => same

    (keymap-global-set "C-c h" "h e l l o") => [104 101 108 108 111]

    But:

    (keymap-global-set "C-c h" (kbd "olá"))  => [111 108 225]

I think itʼs a bug (and a regression from `global-set-key') to require
that what weʼre binding a key to satifies `key-valid-p' (or we need to
change the output of (kbd "hello") 😺)

(I know that binding keys to strings is not common amongst people who
know how to write their own commands, but plenty of people just want
to insert commonly used strings)

Item the second:

Higher up in that texi file is the following text:

    @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}):

    @example
    (keymap-global-set "C-z" 'shell)
    @end example

which talks about `kbd' but then never uses it (since
`keymap-global-set' doesnʼt need it).

Item the third:

But wait, maybe the documentation about `kbd' has been moved, so I
look for discussion about non-ASCII, since thatʼs where itʼs useful,
and find the following (in @node Init Non-ASCII):

      To bind non-@acronym{ASCII} keys, you must use a vector (@pxref{Init
    Rebinding}).  The string syntax cannot be used, since the
    non-@acronym{ASCII} characters will be interpreted as meta keys.  For
    instance:

    @example
    (global-set-key [?@var{char}] 'some-function)
    @end example

    @noindent
    Type @kbd{C-q}, followed by the key you want to bind, to insert @var{char}.

where rather than telling people to write vectors by hand, we could
explain how to use `kbd'.

Robert
-- 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences
  2022-11-15  8:28     ` Robert Pluim
@ 2022-11-15  9:09       ` Stefan Kangas
  2022-11-15  9:14         ` Robert Pluim
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2022-11-15  9:09 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel, Lars Ingebrigtsen

Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Mon, 14 Nov 2022 19:40:35 -0800, Stefan Kangas <stefankangas@gmail.com> said:
>
>     Stefan> This section has changed quite a bit on master, including using
>     Stefan> `keymap-global-set' instead.  Unfortunately, I'm not sure what if
>     Stefan> anything needs adding to the text already on master.  Could you please
>     Stefan> look into it, or even help merge it?
>
> Well this has opened a can of worms:

Indeed.  I guess there are several issues to discuss or resolve here.

Meanwhile, in the interest of being able to merge the emacs-28 branch at
all, is it okay if we just skip the changes you made while we work on a
new patch for master?

I'm also copying in Lars.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences
  2022-11-15  9:09       ` Stefan Kangas
@ 2022-11-15  9:14         ` Robert Pluim
  2022-11-16  7:44           ` Stefan Kangas
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2022-11-15  9:14 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: emacs-devel, Lars Ingebrigtsen

>>>>> On Tue, 15 Nov 2022 01:09:56 -0800, Stefan Kangas <stefankangas@gmail.com> said:

    Stefan> Robert Pluim <rpluim@gmail.com> writes:
    >>>>>>> On Mon, 14 Nov 2022 19:40:35 -0800, Stefan Kangas <stefankangas@gmail.com> said:
    >> 
    Stefan> This section has changed quite a bit on master, including using
    Stefan> `keymap-global-set' instead.  Unfortunately, I'm not sure what if
    Stefan> anything needs adding to the text already on master.  Could you please
    Stefan> look into it, or even help merge it?
    >> 
    >> Well this has opened a can of worms:

    Stefan> Indeed.  I guess there are several issues to discuss or resolve here.

    Stefan> Meanwhile, in the interest of being able to merge the emacs-28 branch at
    Stefan> all, is it okay if we just skip the changes you made while we work on a
    Stefan> new patch for master?

Yes, thatʼs probably best. Perhaps I should now stop making my doc
changes on emacs-28 first 😀

Once we resolve this I can redo the patch for master.

Robert
-- 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences
  2022-11-15  9:14         ` Robert Pluim
@ 2022-11-16  7:44           ` Stefan Kangas
  2022-11-16  8:50             ` Robert Pluim
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2022-11-16  7:44 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel, Lars Ingebrigtsen

Robert Pluim <rpluim@gmail.com> writes:

>     Stefan> Meanwhile, in the interest of being able to merge the emacs-28 branch at
>     Stefan> all, is it okay if we just skip the changes you made while we work on a
>     Stefan> new patch for master?
>
> Yes, thatʼs probably best. Perhaps I should now stop making my doc
> changes on emacs-28 first 😀

Thanks, done.

> Once we resolve this I can redo the patch for master.

Sounds like a plan.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences
  2022-11-16  7:44           ` Stefan Kangas
@ 2022-11-16  8:50             ` Robert Pluim
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Pluim @ 2022-11-16  8:50 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: emacs-devel, Lars Ingebrigtsen

>>>>> On Tue, 15 Nov 2022 23:44:23 -0800, Stefan Kangas <stefankangas@gmail.com> said:


    >> Once we resolve this I can redo the patch for master.

    Stefan> Sounds like a plan.

Iʼve opened bug#59305 so we can discuss solutions to the
`keymap-global-set' issue.

Robert
-- 



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-16  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <166844275725.4187.2343107623845911514@vcs2.savannah.gnu.org>
     [not found] ` <20221114161917.7FC8AC00AB5@vcs2.savannah.gnu.org>
2022-11-15  3:40   ` emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences Stefan Kangas
2022-11-15  8:28     ` Robert Pluim
2022-11-15  9:09       ` Stefan Kangas
2022-11-15  9:14         ` Robert Pluim
2022-11-16  7:44           ` Stefan Kangas
2022-11-16  8:50             ` Robert Pluim

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