home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / help-lucid-emacs / text0427.txt < prev    next >
Encoding:
Text File  |  1993-07-14  |  7.7 KB  |  172 lines

  1. Per Abrahamsen wrote:
  2. > How do I map 248 (?°) into 'oslash?
  3.  
  4. There's not currently a good way to do that, but you're right, it should
  5. be possible.  Enclosed is a patch to lisp/x11/x-iso8859-1.el which defines
  6. a variable which does this mapping.
  7.  
  8. > I would have written 
  9. >     
  10. >     (define-key global-map [°] 'self-insert-command)
  11. > which I hope you agree is obvious, but feared what the mail and news
  12. > software might do to the `°'.
  13.  
  14. Yes, that is more obvious; I'm not sure of a good way to make that work,
  15. however.  The problem is that the `symbols' which one can use as an
  16. argument to define-key are essentially equivalent to X keysyms.  You can
  17. use the symbols `A' and `a' because those are the official X keysym names
  18. of characters 65 and 97 in the Latin1 character set.  But the traditional
  19. ASCII printing characters are the only keysyms which have one-character
  20. names.  So `°', being a symbol whose name is the one-character string
  21. "\370", is not a valid X keysym name.
  22.  
  23. I don't pretend to know the rationale for this decision of the X
  24. designers, but one good reason is that \370 is character-set dependent;
  25. the names of the keysyms are expressed in Latin1, but `oslash' could
  26. concievably have a different character code in some other character set,
  27. which would be confusing.
  28.  
  29. One of the things I've been trying to do with lemacs is avoid any
  30. character-set dependence.  I don't claim that I've accomplished this, but
  31. that's what I've been striving for...  All of the patches I've seen for
  32. v18 have simply traded one character set (ASCII) for another (ISO8859/1).
  33. I want to avoid that.
  34.  
  35. > I get a Danish keyboard layout on a US Style keyboard using the Latin 1
  36. > character set.  That is, pressing "'" will insert oslash because the "'"
  37. > key is located at the place where oslash would be found on a Danish 
  38. > keyboard.  
  39. > This works on all flavours of Emacs 18 and 19 as long as the
  40. > translation is 7-bit to 7-bit or 7-bit to 8-bit. Now someone wanted to
  41. > do 8-bit to 7-bit (ISO 8859-1 to ISO 646 SE) and this does not work in
  42. > Emacs 19 under X (emacs 18 and non-X11 emacses are too stupid to give 
  43. > any problems).  
  44. > The translation tables are also used for text, so I would rather not
  45. > store keyboard event directly in the tables.  Especially since I want 
  46. > them to work on all GNU Emacs flavours.
  47.  
  48. (I assume that by "Emacs 19" you mean "Lucid Emacs" and not "FSF v19" or
  49. "Lucid Emacs as well as FSF v19", but one should be careful about this 
  50. ambiguity these days...)
  51.  
  52. I'm not sure what the right solution here is.  At one level, you're mapping
  53. keysyms to keysyms: doing what xmodmap does.  But at the next level down,
  54. you're using character codes, since they were the same thing in v18.
  55.  
  56. My first thought was that, if you were writing this from scratch for the 
  57. lemacs keyboard model, the right thing would be to include keysym names
  58. instead of their character codes, since the name->charcode mapping happens
  59. internally.  (You might need to include the charcodes in this table as well
  60. in order to support the v18 input model, but remember, the v18 input model
  61. is "considered obsolete" :-)  It's just not expressive enough, and this
  62. equivalence of keysyms and character codes was a big part of the problem.)
  63.  
  64. But then, why not just use the new mapping table that I've added below, in
  65. the variable iso8859/1-code-to-x-keysym-table?  Well, it's name suggests
  66. that it is X-specific.  But is it, really?
  67.  
  68. This brings up an interesting question, which is whether by including the
  69. symbol/keysym `oslash' into one's code, one has introduced an X-specific
  70. name.  I'm not sure.  Does anyone know whether there is a standard set of
  71. names for the ISO-8859/1 characters, and whether X is using those names?
  72. (Are things specified well enough that it's clear that the name should be
  73. "oslash" and not "o-slash" or "o slash"?  And what about things like 
  74. "Adiaeresis" -- might that legally be called "Aumlaut"?  And what about
  75. "ETH" and "THORN"?  Is it specified that those should be all caps?)
  76.  
  77. Because I wasn't sure, I had been assuming that those names were X
  78. specific; that's why lisp/prim/iso8859-1.el deals with all aspects of that
  79. character set except the keysym names, which have been shuffled off to the
  80. file lisp/x11/x-iso8859-1.el.  If it turns out that the names which X uses
  81. are officially sanctioned as window-system-independent, then most of what's
  82. in x-iso8859-1.el can be moved to iso8859-1.el, and the new variable the
  83. patch belows adds (iso8859/1-code-to-x-keysym-table) can be more officially
  84. sanctioned with a non-X-specific name.
  85.  
  86. Conversely, if it turns out that there is a standard for these names but
  87. the X keysyms don't follow it, then perhaps it would be worthwhile to add
  88. a translation down in event-Xt.c so that define-key always works with the
  89. ISO names and never with the nonstandard X names.  And presumably some
  90. hypothetical future non-X port of lemacs will also do this translation to
  91. the officially sanctioned names if necessary.
  92.  
  93. If there's no standard, I don't see how to avoid introducing some level of
  94. window system dependence into user code...  Emacs could adopt the X keysym
  95. names as the "Emacs" keysym names, and these future hypothetical other
  96. window systems could translate to that, but this makes those other window
  97. systems be second-class citizens again, which is another thing I wanted to
  98. avoid.
  99.  
  100. (As an aside, using the term "8-bit input" to refer to these issues isn't
  101. quite correct.  It reflects the historical fact that old input devices
  102. could only deliver 8 bits worth of "keysym", which isn't true under a
  103. window system.  If you're thinking of hitting a key and having it deliver
  104. some particular integer (which happens to take 8 bits to represent) then
  105. you're not taking into account an important aspect of this whole mess.)
  106.  
  107.     -- Jamie
  108.  
  109. diff -c -r1.3 x-iso8859-1.el
  110. *** 1.3    1992/08/20 01:37:30
  111. --- x-iso8859-1.el    1993/05/31 20:19:20
  112. ***************
  113. *** 1,5 ****
  114.   ;; Mapping between X keysym names and ISO 8859-1 (aka Latin1) character codes.
  115. ! ;; Copyright (C) 1992 Free Software Foundation, Inc.
  116.   
  117.   ;; This file is part of GNU Emacs.
  118.   
  119. --- 1,5 ----
  120.   ;; Mapping between X keysym names and ISO 8859-1 (aka Latin1) character codes.
  121. ! ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
  122.   
  123.   ;; This file is part of GNU Emacs.
  124.   
  125. ***************
  126. *** 37,42 ****
  127. --- 37,48 ----
  128.   
  129.   (require 'iso8859-1)
  130.   
  131. + (defconst iso8859/1-code-to-x-keysym-table nil
  132. +   "Maps iso8859/1 to an X keysym name which corresponds to it.
  133. + There may be more than one X name for this keycode; this returns the first one.
  134. + Note that this is X specific; one should avoid using this table whenever 
  135. + possible, in the interest of portability.")
  136.   ;; (This esoteric little construct is how you do MACROLET in elisp.  It
  137.   ;; generates the most efficient code for the .elc file by unwinding the
  138.   ;; loop at compile-time.)
  139. ***************
  140. *** 62,67 ****
  141. --- 68,91 ----
  142.              (list 'global-set-key (list 'quote (car sym-and-code))
  143.                ''self-insert-command))
  144.           syms-and-iso8859/1-codes)
  145. +     ;;
  146. +     ;; Then emit the value of iso8859/1-code-to-x-keysym-table.
  147. +     ;;
  148. +     (let ((v (make-vector 256 nil)))
  149. +       ;; the printing ASCII chars have 1-char names.
  150. +       (let ((i 33))
  151. +         (while (< i 127)
  152. +           (aset v i (intern (make-string 1 i)))
  153. +           (setq i (1+ i))))
  154. +       ;; these are from the keyboard character set.
  155. +       (mapcar '(lambda (x) (aset v (car x) (car (cdr x))))
  156. +           '((8 backspace) (9 tab) (10 linefeed) (13 return)
  157. +             (27 escape) (32 space) (127 delete)))
  158. +       (mapcar '(lambda (sym-and-code)
  159. +              (or (aref v (car (cdr sym-and-code)))
  160. +              (aset v (car (cdr sym-and-code)) (car sym-and-code))))
  161. +           syms-and-iso8859/1-codes)
  162. +       (list (list 'setq 'iso8859/1-code-to-x-keysym-table v)))
  163.       ))))
  164.   
  165.    ;; The names and capitalization here are as per the MIT X11R4 and X11R5
  166.  
  167.