[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: single-key-description no good for Japanese and Chinese chars

From: Drew Adams
Subject: RE: single-key-description no good for Japanese and Chinese chars
Date: Sun, 24 Sep 2006 18:56:28 -0700

    > Also, if self-insert-command is not necessarily intended to
    > "Insert the character you type", as the doc string says,
    > then maybe that could be explained a bit more somewhere?

    It does exactly what the docstring say.  What you don't seem to
    understand is that a char can be bound to self-insert-command
    via a keymap binding that doesn't mention that char.

I assume you mean mapped (via a key binding and perhaps some other stuff
such as input methods), not bound. Characters are not bound directly to
commands, are they?

And the point is? I guess you're saying that the doc and doc string already
clearly cover everything, including the cases of keys and their chars (e.g.
multi-byte) that Kenichi called "invalid" keys because you can't simply call
`self-insert-command' to insert the characters. That is, you can't just set
`last-command-char' and then call `self-insert-command'.

To me the behavior of `self-insert-command' with multibyte chars is not so
clear. There might be some sense in which `self-insert-command' "inserts the
character you type" for such keys also, but I don't understand that. I
thought that some more explanation of such cases might help. I know you've
indicated previously that the doc isn't really needed anyway, that the
source code alone is sufficient, but I think it might be helpful to clarify
things here regarding insertion of multi-byte characters and

Again, I admit that this is still not clear to me, so perhaps I'm seeing a
special case where there is none. It's always hard to tell, when things are
not clear to you, whether things need to be clarified for others too, or
it's just you who doesn't get it. Given the discussion so far, you guys can
tell better than I which case this is.

    Basically, it's often easy to find the reverse mapping of a
    keymap (i.e. the inverse function, if you think of the keymap
    as a function from keys to commands), but it's not always
    that easy.  There are many special cases.

I am not trying to find keys from commands or commands from keys. I'm
starting with keys and the commands they are bound to.

    > I see now. How can I test for (all of) these cases? How can I
    > test a key to see if it is one "that can be turned (more or
    > less trivially) into" a char?

    I'd ask a different question: why do you start from a keymap and use
    map-keymap on it, rather than start with `charset-list' and generate the
    complete set of valid chars from it?

I'll still ask the question I asked - but I think maybe I got the answer:
`char-valid-p' (also, `generic-char-p', for a related test). But thanks for
the tip about `charset-list'; it's good to know.

BTW, the doc on `char-valid-p' doesn't speak of keys or events at all, but
it seems to work with an event argument. On Jason's advice, I tried it using
the event arg to the function that `map-keymap' takes as arg, and it works
fine. I would never have guessed from the `char-valid-p' doc that a
key/event arg would work that way, but I guess it does because the event is
just a character code. Again, this too might come from my fuzziness on the
relations between keys and characters, but, again, I suspect that the doc
might be fruitfully enhanced a bit to make this clear to others also.

To answer your question: I'm starting from keymaps because the application
is not just to insert characters. Inserting (chars associated with) keys
bound to `self-insert-command' is just a side line of the application, which
is executing commands bound to keys by completing against the key name
and/or command name. I start from keymaps because this app is about
completing keys.

It might also be worthwhile to come up with a different, related application
that focuses on inserting characters, using a similar approach
(character-name completion). I haven't tried that. I'm just playing with
completing keys, for now, and keys bound to `self-insert-command' are an
interesting special case of that. Anyway, if I knew how to do the character
completion operation for multibyte chars (see my previous mail), then I'd
probably start by plugging that into my key-completion app (at the `ignore'
placeholder for the generic-char case).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]