[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: Mon, 25 Sep 2006 00:55:33 -0700

    From: Kenichi Handa
    I've just committed a change to make single-key-description
    return unique names for generic characters.


    And, you can use a code like this to get characters in a
    generic character.

    (defun chars-in-generic-char (generic-char)
      "Return a list of characters belonging to GENERIC-CHAR.
    An element itself may be a generic character if the charset of
    GENERIC-CHAR is 2-dimensional and GENERIC-CHAR specifies no code
      (or (generic-char-p generic-char)
          (error "Not a generic character: %s" generic-char))
      (let* ((split (split-char generic-char))
         (charset (car split))
         (code1 (nth 1 split))
         (chars (charset-chars charset))
         from to l)
        (if (= chars 94)
        (setq from 33 to 126)
          (setq from 32 to 127))
        (if (> code1 0)
        (while (>= to from)
          (push (make-char charset code1 to) l)
          (setq to (1- to)))
          (while (>= to from)
        (push (make-char charset to) l)
        (setq to (1- to))))

Thanks! I'll take a look later at using it with my code.

    > As I said, this would provide a poor man's means of inserting
    > a multibyte character - useful in some contexts, for some people,
    > perhaps.

    If you have proper fonts, I think M-x list-charset-chars RET
    CHARSET-NAME RET and cut&paste is sufficient.

I didn't know about it. Very good.

In that case, I'd suggest (after the release) perhaps enhancing
list-charset-chars slightly to let someone just click a character to insert
it (in the last buffer accessed). (This is similar to my suggestion about
applying faces by clicking a face in `list-faces-display'.) That would be
slightly more convenient than copy + paste - just click, click, click to
insert characters.

    > I tried to find info on inserting multibyte chars in the
    > Elisp manual, but I didn't really find an explanation that
    > helped me.

    Where is the problem in the Elisp manual about "inserting
    multibyte chars"?  You can use the same functions (insert,
    insert-char) as ASCII characters to insert them.

OK. That's logical. I didn't realize that those functions still applied in
this area. The sections about character sets and multibyte characters
describe what they are, but not how to insert the characters (e.g. into
strings and buffers), and `insert' and `insert-char' are described elsewhere
in the manual (which doesn't mention characters in different character
sets). How about adding a cross reference and mentioning that insertion is
as for any other chars. There is so much that is special when it comes to
these characters, that it's not obvious that some of the standard functions
apply to them too.

I guess my ignorance is more about creating strings and characters, now that
I know I can just use `insert(-char)'. I'd like a section that explains how
to create a string of characters in a given character set, with a simple
example. Maybe it's there somewhere, or probably it's implicit in what is
said in the manual somewhere, but it's not clear to me. What, for instance,
would be the Lisp code to create the string "AB", with uppercase alpha and
beta in charset greek-iso8859-7? Similarly, for some Chinese character.
Would `make-char' be the easiest way to do that, or is there some easier

In the absence of an explanation, and knowing about `insert(-char)' and
`list-charset-chars' now, I try this: Looking at `list-charset-chars' for
`greek-iso8859-7' (thanks to completion), I see that uppercase omega is D9,
which is 217 decimal. Trying (make-char 'greek-iso8859-7), I see that its
base code (or generic-character code or whatever you call it) is 2816.
Trying (split-char 2816), I see that `greek-iso8859-7' is of dimension 1, so
I know that `make-char' needs only code1 for greek. So, I try (insert-char
(make-char 'greek-iso8859-7 217)) and I get an uppercase omega - good.

Is there a more direct way to have figured this out? What about
`chinese-big5-1'? (make-char 'chinese-big5-1) shows its base code as 147456,
and `split-char' of that shows that `chinese-big5-1' is of dimension 2, so
it needs both code1 and code2. But I'm not sure how to get those from the
`list-charset-chars' display (aside from the fact that I don't have the
font). In the case of greek, it was easy to guess that code1 was the address
of the character in the display (and presumably the offset from the base
code 2816), but how do you read the `list-charset-chars' for code1 and

Anyway, you get the idea. I'm not totally unwilling to dig a little, but I
get the impression that this stuff could be explained a little better/more.
If this is common character-set/language knowledge that is independent of
Emacs Lisp, then how about having the manual point to a Web page or
something where people can pick up this knowledge? Again, maybe it's all
there in the manual, but I haven't run across it, or, if I did, I didn't
recognize it.

Another area I'd like to learn about, but I'm not sure where to look, is
installing fonts (e.g. so I can play with the multibyte stuff). I'm on MS
Windows. Is it enough to install, say, Asian fonts and language support on
the Windows box generally, or do I also need to do something to let Emacs
know how to use the installed fonts?

No need for you to answer all my questions, but if you can point me to
somewhere to learn about this, I'd appreciate it.


reply via email to

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