[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 12:43:34 -0700

    >     I now think that single-key-description should signal an
    >     error for a generic character because it's not a key.

    > Would it be possible for someone to let me know if this
    > change gets made (or if the description returned for such
    > pseudo-keys gets changed)? I will then
    > adapt my code accordingly. Thx.

    If you are going to modify your code, you should do a check
    something like this before calling single-key-description:
      (map-keymap #'(lambda (event definition)
                  (if (and (integerp event) (generic-char-p event))
                      ;; do something reasonable for a
                      ;; generic character.

    Then, your code should be free from the change of

Thanks very much. I have this now - I just added a stub for the generic-char
case, for now. Please let me know if I misunderstood something.

(when (keymapp (cdr keys+map))          ; Avoid, e.g. `t'.
  (map-keymap (lambda (event binding)
                (cond ((and (or (commandp binding) (keymapp binding))
                            (or (not (eq 'self-insert-command  binding))
                                (char-valid-p event))) ; Insert normal char.
                       (push `((,(single-key-description event)
                                 ,(if (keymapp binding)
                                      "..." ; Prefix key
                                      (format "%S" binding)))) ; e.g.
                      ((and (integerp event)
                            (generic-char-p event)
                            (eq 'self-insert-command  binding)) ; Generic
                       (ignore))))      ; Placeholder for future use.
              (cdr keys+map)))

I'd like to know a way to insert a multibyte char - for example, replace
`ignore' here with a push of a pseudo-binding name of, say, "multibyte
char...", and then, when the user subsequently picks a completion candidate
for that pseudo-binding name, let him complete against the possible
characters for that character group to insert one. The character group
(generic char) name would appear as part of the completion candidate - for

 "Charset JISX0208.1978-20864 (Japanese)  =  multibyte char..."

(I might keep a table of the official generic character names, and use
lookup to provide a shorter name to use for the completion candidate - say
"Japanese JISX (7)" instead of the longer name "Character set JISX0208.1978
(Japanese): ISO-IR-42, 20864".)

If the user chose this completion candidate, then *Completions* would be
redisplayed with only the characters in that character group (20864) as the
completion candidates. The user could pick one to be inserted by clicking
the mouse or cycling to it and hitting RET.

As I said, this would provide a poor man's means of inserting a multibyte
character - useful in some contexts, for some people, perhaps. [Quick, how
do you insert an Ethiopian character or a math summation symbol or a
paragraph symbol (pilcrow)?] Assuming that you have the proper fonts, this
would provide a slow but WYSIWYG way to insert any (?) character (even
character graphics?). (You could still insert the char, even if you didn't
have the fonts, but you wouldn't see what you were inserting!)

I use a similar method sometimes to insert special characters (math or other
languages) in word-processing applications, as a one-off operation. Many
word-processing apps, even those that provide proper input methods and
support for languages, also provide such a "dummies" way to insert a
character. There are many contexts in which languages or symbol sets are
mixed, and some users are not proficient at using input methods for all of
the character sets involved. Typically, once I've inserted the char (e.g.
summation symbol), I just copy and paste it thereafter, for multiple
occurrences, because that is usually quicker than going through the choosing
operation again.

However, the Emacs completion I'd like to implement might also be quicker
than copying and pasting, depending, perhaps, on how many chars are in a
given character group (generic-char). Because completion in my context
allows regexp (e.g. substring) matching, the initial match against a generic
character can be very quick (for example, type just "20864" or "JISX" or
"Jap"). You can also use multiple substrings (i.e. order-independent)
without knowing any regexp syntax, so it's very quick to match anything.

I tried to find info on inserting multibyte chars in the Elisp manual, but I
didn't really find an explanation that helped me. If you have a suggestion
or can point me to where I can read up on inserting such chars (using Lisp),
please let me know, and maybe I'll take a crack at trying that.

Or, if anyone else besides me is interested in working on this, let me
know - perhaps it could be useful for Emacs. GNU can't accept my code, it
seems, but my implementation of a feature might serve as food for thought
for a similar Emacs feature.

reply via email to

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