home *** CD-ROM | disk | FTP | other *** search
- Per Abrahamsen wrote:
- >
- > How do I map 248 (?°) into 'oslash?
-
- There's not currently a good way to do that, but you're right, it should
- be possible. Enclosed is a patch to lisp/x11/x-iso8859-1.el which defines
- a variable which does this mapping.
-
- > I would have written
- >
- > (define-key global-map [°] 'self-insert-command)
- >
- > which I hope you agree is obvious, but feared what the mail and news
- > software might do to the `°'.
-
- Yes, that is more obvious; I'm not sure of a good way to make that work,
- however. The problem is that the `symbols' which one can use as an
- argument to define-key are essentially equivalent to X keysyms. You can
- use the symbols `A' and `a' because those are the official X keysym names
- of characters 65 and 97 in the Latin1 character set. But the traditional
- ASCII printing characters are the only keysyms which have one-character
- names. So `°', being a symbol whose name is the one-character string
- "\370", is not a valid X keysym name.
-
- I don't pretend to know the rationale for this decision of the X
- designers, but one good reason is that \370 is character-set dependent;
- the names of the keysyms are expressed in Latin1, but `oslash' could
- concievably have a different character code in some other character set,
- which would be confusing.
-
- One of the things I've been trying to do with lemacs is avoid any
- character-set dependence. I don't claim that I've accomplished this, but
- that's what I've been striving for... All of the patches I've seen for
- v18 have simply traded one character set (ASCII) for another (ISO8859/1).
- I want to avoid that.
-
- > I get a Danish keyboard layout on a US Style keyboard using the Latin 1
- > character set. That is, pressing "'" will insert oslash because the "'"
- > key is located at the place where oslash would be found on a Danish
- > keyboard.
- >
- > This works on all flavours of Emacs 18 and 19 as long as the
- > translation is 7-bit to 7-bit or 7-bit to 8-bit. Now someone wanted to
- > do 8-bit to 7-bit (ISO 8859-1 to ISO 646 SE) and this does not work in
- > Emacs 19 under X (emacs 18 and non-X11 emacses are too stupid to give
- > any problems).
- >
- > The translation tables are also used for text, so I would rather not
- > store keyboard event directly in the tables. Especially since I want
- > them to work on all GNU Emacs flavours.
-
- (I assume that by "Emacs 19" you mean "Lucid Emacs" and not "FSF v19" or
- "Lucid Emacs as well as FSF v19", but one should be careful about this
- ambiguity these days...)
-
- I'm not sure what the right solution here is. At one level, you're mapping
- keysyms to keysyms: doing what xmodmap does. But at the next level down,
- you're using character codes, since they were the same thing in v18.
-
- My first thought was that, if you were writing this from scratch for the
- lemacs keyboard model, the right thing would be to include keysym names
- instead of their character codes, since the name->charcode mapping happens
- internally. (You might need to include the charcodes in this table as well
- in order to support the v18 input model, but remember, the v18 input model
- is "considered obsolete" :-) It's just not expressive enough, and this
- equivalence of keysyms and character codes was a big part of the problem.)
-
- But then, why not just use the new mapping table that I've added below, in
- the variable iso8859/1-code-to-x-keysym-table? Well, it's name suggests
- that it is X-specific. But is it, really?
-
- This brings up an interesting question, which is whether by including the
- symbol/keysym `oslash' into one's code, one has introduced an X-specific
- name. I'm not sure. Does anyone know whether there is a standard set of
- names for the ISO-8859/1 characters, and whether X is using those names?
- (Are things specified well enough that it's clear that the name should be
- "oslash" and not "o-slash" or "o slash"? And what about things like
- "Adiaeresis" -- might that legally be called "Aumlaut"? And what about
- "ETH" and "THORN"? Is it specified that those should be all caps?)
-
- Because I wasn't sure, I had been assuming that those names were X
- specific; that's why lisp/prim/iso8859-1.el deals with all aspects of that
- character set except the keysym names, which have been shuffled off to the
- file lisp/x11/x-iso8859-1.el. If it turns out that the names which X uses
- are officially sanctioned as window-system-independent, then most of what's
- in x-iso8859-1.el can be moved to iso8859-1.el, and the new variable the
- patch belows adds (iso8859/1-code-to-x-keysym-table) can be more officially
- sanctioned with a non-X-specific name.
-
- Conversely, if it turns out that there is a standard for these names but
- the X keysyms don't follow it, then perhaps it would be worthwhile to add
- a translation down in event-Xt.c so that define-key always works with the
- ISO names and never with the nonstandard X names. And presumably some
- hypothetical future non-X port of lemacs will also do this translation to
- the officially sanctioned names if necessary.
-
- If there's no standard, I don't see how to avoid introducing some level of
- window system dependence into user code... Emacs could adopt the X keysym
- names as the "Emacs" keysym names, and these future hypothetical other
- window systems could translate to that, but this makes those other window
- systems be second-class citizens again, which is another thing I wanted to
- avoid.
-
- (As an aside, using the term "8-bit input" to refer to these issues isn't
- quite correct. It reflects the historical fact that old input devices
- could only deliver 8 bits worth of "keysym", which isn't true under a
- window system. If you're thinking of hitting a key and having it deliver
- some particular integer (which happens to take 8 bits to represent) then
- you're not taking into account an important aspect of this whole mess.)
-
- -- Jamie
-
- diff -c -r1.3 x-iso8859-1.el
- *** 1.3 1992/08/20 01:37:30
- --- x-iso8859-1.el 1993/05/31 20:19:20
- ***************
- *** 1,5 ****
- ;; Mapping between X keysym names and ISO 8859-1 (aka Latin1) character codes.
- ! ;; Copyright (C) 1992 Free Software Foundation, Inc.
-
- ;; This file is part of GNU Emacs.
-
- --- 1,5 ----
- ;; Mapping between X keysym names and ISO 8859-1 (aka Latin1) character codes.
- ! ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
-
- ;; This file is part of GNU Emacs.
-
- ***************
- *** 37,42 ****
- --- 37,48 ----
-
- (require 'iso8859-1)
-
- + (defconst iso8859/1-code-to-x-keysym-table nil
- + "Maps iso8859/1 to an X keysym name which corresponds to it.
- + There may be more than one X name for this keycode; this returns the first one.
- + Note that this is X specific; one should avoid using this table whenever
- + possible, in the interest of portability.")
- +
- ;; (This esoteric little construct is how you do MACROLET in elisp. It
- ;; generates the most efficient code for the .elc file by unwinding the
- ;; loop at compile-time.)
- ***************
- *** 62,67 ****
- --- 68,91 ----
- (list 'global-set-key (list 'quote (car sym-and-code))
- ''self-insert-command))
- syms-and-iso8859/1-codes)
- + ;;
- + ;; Then emit the value of iso8859/1-code-to-x-keysym-table.
- + ;;
- + (let ((v (make-vector 256 nil)))
- + ;; the printing ASCII chars have 1-char names.
- + (let ((i 33))
- + (while (< i 127)
- + (aset v i (intern (make-string 1 i)))
- + (setq i (1+ i))))
- + ;; these are from the keyboard character set.
- + (mapcar '(lambda (x) (aset v (car x) (car (cdr x))))
- + '((8 backspace) (9 tab) (10 linefeed) (13 return)
- + (27 escape) (32 space) (127 delete)))
- + (mapcar '(lambda (sym-and-code)
- + (or (aref v (car (cdr sym-and-code)))
- + (aset v (car (cdr sym-and-code)) (car sym-and-code))))
- + syms-and-iso8859/1-codes)
- + (list (list 'setq 'iso8859/1-code-to-x-keysym-table v)))
- ))))
-
- ;; The names and capitalization here are as per the MIT X11R4 and X11R5
-
-