unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ryan Johnson <ryanjohn@ece.cmu.edu>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org, Kenichi Handa <handa@m17n.org>
Subject: Re: Best way to intercept terminal escape sequences?
Date: Thu, 02 Sep 2010 14:33:36 +0200	[thread overview]
Message-ID: <4C7F99A0.4090502@ece.cmu.edu> (raw)
In-Reply-To: <jwvpqww8m5z.fsf-monnier+emacs@gnu.org>

  On 9/2/2010 12:53 PM, Stefan Monnier wrote:
>> As mentioned, read-event did not do obey keyboard-coding-system in
>> earlier Emacsen, so any affected package is more likely to be fixed than
>> broken by making a change that reverts to this previous behavior.
> Handa, could you take a look at the feasibility of moving the
> decode_keyboard_code to a later stage such that read-event still returns
> raw bytes for ttys?
>
> There is a tension here, because raw events in GUIs are already decoded,
> whereas raw events in ttys are just bytes.  You "fixed it" by decoding
> tty input in directly in tty_read_avail_input, so that read-event now
> always returns decoded input, but that in turns means that read-event
> doesn't return raw events any more.  The decoding is desirable for
> read-key-sequence (and maybe also for read-char, tho I don't care much
> about this case since read-key is generally a better replacement) but
> not for read-event, since access to raw events is important for things
> like xt-mouse.el.
By the way, I noticed while working on something else [1] that read-key 
cannot actually replace all uses of read-event because the latter 
supports timeouts while the former does not. Would it be possible to add 
a timeout to read-key as a third (optional) parameter? I don't know 
whether read-key-delay would provide workarounds to some timeout uses, 
but it seems brittle.

>> If you have enabled keyboard character set decoding using
>> `set-keyboard-coding-system', decoding is done after the translations
>> listed above.  See Terminal I/O Encoding.  However, in future Emacs
>> versions, character set decoding may be done at an earlier stage.
> This doc is out of date, indeed.

It would be really nice to have, somewhere in the emacs docs, a diagram 
showing what processing happens to keyboard input, starting from raw 
bytes and UI events, and tracing them (or their translations) through 
coding systems, input methods, command loop, various keymaps, etc. and 
showing where in that process the different read-* functions intercept 
that data (and where the various unread-*-events reinsert things). A 
similar diagram for reading and writing files would probably also be useful.

This would not only make it easier to figure out how to interface new 
code with emacs, it would probably expose gaps in the API which make 
existing code unnecessarily complex and certain features impossible 
(mouse.el and xt-mouse.el suffer from both of those latter problems).

Unfortunately, even after spending so long on this problem I don't think 
I know enough to generate that diagram...

Ryan

[1] http://www.ece.cmu.edu/~ryanjohn/sticky-control.el




  reply	other threads:[~2010-09-02 12:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100827142724.E1DD712F@hazard.ece.cmu.edu>
2010-08-27 14:44 ` Best way to intercept terminal escape sequences? Ryan Johnson
2010-08-27 15:40   ` Eli Zaretskii
2010-08-27 18:04     ` Ryan Johnson
2010-08-27 20:38       ` Eli Zaretskii
2010-08-27 23:54     ` Stefan Monnier
2010-08-28  7:54       ` Ryan Johnson
2010-08-28 14:47         ` Stefan Monnier
2010-08-28 20:34           ` Ryan Johnson
2010-08-31 23:12           ` Ryan Johnson
2010-09-02 10:53             ` Stefan Monnier
2010-09-02 12:33               ` Ryan Johnson [this message]
2010-09-04 13:01                 ` Improve input handling documentation (was Re: Best way to intercept terminal escape sequences?) Štěpán Němec
     [not found]               ` <jwvy6bfdp23.fsf-monnier+emacs@gnu.org>
2010-09-07  0:32                 ` Best way to intercept terminal escape sequences? Kenichi Handa
2010-09-08  9:05                   ` Stefan Monnier
     [not found] <20100827112348.5023B3D5@osgood.ece.cmu.edu>
2010-08-27 13:56 ` Ryan Johnson
2010-08-27 14:17   ` David Kastrup
2010-08-26 15:58 Ryan Johnson
2010-08-26 23:03 ` Stefan Monnier
2010-08-27  9:28   ` Ryan Johnson
2010-08-27 10:36     ` David Kastrup
2010-08-27 23:50       ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2010-08-26 13:22 Ryan Johnson

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=4C7F99A0.4090502@ece.cmu.edu \
    --to=ryanjohn@ece.cmu.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=handa@m17n.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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).