all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Phil Sainty <psainty@orcon.net.nz>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: Round-tripping key definitions
Date: Mon, 15 Nov 2021 16:10:10 -0500	[thread overview]
Message-ID: <jwv8rxp2l3o.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87o86lzv6a.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 15 Nov 2021 09:21:01 +0100")

> -(define-key global-map "\t" 'indent-for-tab-command)
> +(define-key global-map [TAB] 'indent-for-tab-command)
> +(define-key global-map [?\C-i] nil)
> +(define-key global-map [tab] nil)
> +(define-key function-key-map [?\C-i] [TAB])
> +(define-key function-key-map [tab] [TAB])

Sadly, I think this will introduce a fair bit of trouble because code
which currently does

    (define-key map "\t" ...)

expects this binding to apply to both `tab` and tty's TAB key.

We could try and fix it by having `tab` first fallback to `?\t` and only
then to `TAB`, but that currently can't be done with `function-key-map`
because `function-key-map` is not applied to its output.

We could do it via ad-hoc code (like we currently have for the
`drag-mouse-1` fallback to `mouse-1`) or we could introduce a new keymap
like `function-key-map` but that's applied repeatedly until it doesn't
apply any more (or until a binding is found).

Or maybe we could do

    (define-key function-key-map [tab] #'some-new-tab-remap)

and then make sure `some-new-tab-remap` can get enough info to figure
out whether this `tab` should be remapped to `TAB` or to `?\C-i`.

I remember wanting such a repeatedly applied keymap a few times in the
past, and similarly getting enough info for a function to be able to
decide whether to do would be useful in other cases as well.


        Stefan




  reply	other threads:[~2021-11-15 21:10 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-13  4:58 Round-tripping key definitions Lars Ingebrigtsen
2021-11-13 14:43 ` Stefan Monnier
2021-11-13 14:50   ` Lars Ingebrigtsen
2021-11-13 15:23     ` Stefan Monnier
2021-11-14  0:33       ` Phil Sainty
2021-11-14 14:27         ` Stefan Monnier
2021-11-14 15:07           ` Andreas Schwab
2021-11-14 17:56             ` Stefan Monnier
2021-11-14 18:03           ` Lars Ingebrigtsen
2021-11-14 18:37             ` Stefan Monnier
2021-11-14 18:51               ` Lars Ingebrigtsen
2021-11-14 22:27                 ` Stefan Monnier
2021-11-15  5:48                   ` Lars Ingebrigtsen
2021-11-15  7:31                     ` Lars Ingebrigtsen
2021-11-15  8:21                       ` Lars Ingebrigtsen
2021-11-15 21:10                         ` Stefan Monnier [this message]
2021-11-16  7:41                           ` Lars Ingebrigtsen
2021-11-17  8:01                             ` Lars Ingebrigtsen
2021-11-16  4:06           ` Richard Stallman
2021-11-17 20:38             ` Stefan Monnier
2021-11-18  2:25               ` Po Lu
2021-11-18  2:48                 ` Stefan Monnier
2021-11-18  2:58                   ` Po Lu
2021-11-18 11:16                   ` Stefan Kangas
2021-11-18 12:31                     ` Po Lu
2021-11-19  4:44                 ` Richard Stallman
2021-11-18  9:08               ` Lars Ingebrigtsen
2021-11-14  0:39       ` Lars Ingebrigtsen
2021-11-14 14:09         ` Stefan Monnier
2021-11-15  4:53   ` Richard Stallman

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv8rxp2l3o.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=psainty@orcon.net.nz \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.