From: Anders Lindgren <andlind@gmail.com>
To: yurivkhan@gmail.com
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: input-decode-map: Silently ignore certain sequences
Date: Sun, 16 Dec 2018 13:20:28 +0100 [thread overview]
Message-ID: <CABr8ebaKsyDGh2X9hpY59v7c=BRRLrtBDxotjQ0Q-YyMPFmRfA@mail.gmail.com> (raw)
In-Reply-To: <CAP_d_8Wy1DeeHSxpj2zaLvaRro+3ep+F7pZ7a3AfVw+tb3JugQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3032 bytes --]
Hi!
I found myself in a similar situation with an experimental package I've
been working on, mode-line-keyboard [1]. In this package I need to ignore
event, like key down, all together. My solution is to bind functions to
input-event-map that calls `read-key` recursively, as I found that
returning nil breaks a key sequence. I just realised that I haven't tried
[] so I might need to revisit this.
Anyway, I found the key map handing in Emacs really confusing. To help me
out I put together a companion package, keymap-logger [2], that logs most
things that is passed to and transformed by the various keymaps like
input-key-map and key-translation-map. Maybe it can help you to gain some
insight of what is going on.
-- Anders
[1]: https://github.com/Lindydancer/mode-line-keyboard
[2]: https://github.com/Lindydancer/keymap-logger
On Thu, Dec 13, 2018 at 8:11 PM Yuri Khan <yurivkhan@gmail.com> wrote:
> Hello emacs-devel,
>
> I am trying to implement an input-decode-map for the Kitty terminal
> emulator [1], specifically, for its full keyboard mode extension [2].
> This would solve one of the two major deficiences of Emacs in a
> terminal emulator, namely, the inability to distinguish many
> keystrokes. (The other one, lack of full color, is also solved by
> Kitty, with the right terminfo modifications.)
>
> In the full keyboard mode, the terminal passes to the application
> *all* keystrokes, in a very machine-friendly format. That is, for
> events other than character input (i.e. normal characters, shifted
> characters, Enter, Tab, and Backspace), it sends an escape sequence
> containing a key code, a modifier bit mask, and whether the key was
> pressed, released, or autorepeated.
>
> This is a bit too much for an application such as Emacs; in
> particular, it is not interested in key release events, or events
> regarding modifier keys.
>
> To give an example, Kitty sends the sequence “ESC _ K p A B b ESC \”
> for the event “Left Alt pressed”.
>
> I can get Emacs to ignore this sequence by doing this:
>
> (define-key input-decode-map "\e_KpABb\e\\" [])
>
> However, input decoding is accompanied by echoing the current key
> sequence prefix, and when the sequence is complete, Emacs clears the
> echo area. With key release events, this happens *a lot*. This is
> suboptimal because sometimes Emacs asks a question in the echo area
> and waits for a key.
>
> For example, when the user presses C-x C-c, (kill-emacs) may ask
> whether to save files. Then the release event for C-c comes, and the
> echo area is cleared.
>
> Is there a way to turn off echoing for prefixes of sequences matched
> against input-decode-map, so that echoing still works for “manual” key
> sequences but not sequences sent by the terminal?
>
> If not, would such an option be considered useful?
>
>
> [1]: https://sw.kovidgoyal.net/kitty/
> [2]:
> https://sw.kovidgoyal.net/kitty/protocol-extensions.html#keyboard-handling
>
>
[-- Attachment #2: Type: text/html, Size: 3894 bytes --]
next prev parent reply other threads:[~2018-12-16 12:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-13 19:10 input-decode-map: Silently ignore certain sequences Yuri Khan
2018-12-13 22:43 ` Stefan Monnier
2018-12-15 8:18 ` Yuri Khan
2018-12-16 12:20 ` Anders Lindgren [this message]
2018-12-16 14:35 ` Yuri Khan
2018-12-17 3:24 ` Stefan Monnier
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='CABr8ebaKsyDGh2X9hpY59v7c=BRRLrtBDxotjQ0Q-YyMPFmRfA@mail.gmail.com' \
--to=andlind@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=yurivkhan@gmail.com \
/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).