home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / packages / tex-latin1.el < prev    next >
Encoding:
Text File  |  1994-09-20  |  13.5 KB  |  525 lines

  1. ;; gm-lingo.el 
  2. ;; Translate to ISO from/to net/TeX conventions  ...
  3. ;; Copyright 1993 Michael Gschwind (mike@vlsivie.tuwien.ac.at)
  4.  
  5. ;; Keywords: tex, iso, latin, 8bit
  6.  
  7. ;;  From: mike@vlsivie.tuwien.ac.at (Michael Gschwind)
  8. ;;  Newsgroups: gnu.emacs.sources
  9. ;;  Subject: tex sequence to ISO latin conversions (and back)
  10. ;;  Date: 13 Oct 1993 12:12:35 GMT
  11. ;;  
  12. ;;  The enclosed elisp file installs hooks which automatically translate
  13. ;;  TeX sequences to ISO latin1 upon loading of a TeX file in emacs. This
  14. ;;  allows editing of TeX documents without having to type escape
  15. ;;  sequences.  Upon saving a file, ISO latin1 characters are converted
  16. ;;  back to TeX sequences. (If you have a tex style which can handle 8 bit
  17. ;;  characters, this part is not necessary, but the loading half is still
  18. ;;  neat to convert old files to 8 bit - also, 8 bit are less portable
  19. ;;  than 7...) 
  20. ;;  
  21. ;;  It also contains a function 'german which translates net conventions
  22. ;;  for typing german characters into the real thing - if you install this
  23. ;;  in news-reader/mail/whatever hooks, you'll never again be bothered
  24. ;;  with having to read characters like "s or \3 or "a etc.
  25. ;;  
  26. ;;  mike
  27. ;;  
  28.  
  29. ;; This file works with GNU Emacs19 or higher, but is not part of GNU Emacs.
  30.  
  31. ;; This program is free software; you can redistribute it and/or modify
  32. ;; it under the terms of the GNU General Public License as published by
  33. ;; the Free Software Foundation; either version 2 of the License, or
  34. ;; (at your option) any later version.
  35. ;;
  36. ;; This program is distributed in the hope that it will be useful,
  37. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  39. ;; GNU General Public License for more details.
  40. ;;
  41. ;; You should have received a copy of the GNU General Public License
  42. ;; along with this program; if not, write to the Free Software
  43. ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  44.  
  45. ; it's the author's first lisp program in a long time, so don't judge 
  46. ; him by it :( 
  47.  
  48. ; to do: translate buffer when displaying from GNUS, 
  49. ; use function 'german which does the Right Thing
  50. ; upon saving, the buffer reverts to TeX format...
  51.  
  52. ; Description:
  53. ; calling 'german will turn the net convention f. umlauts ("a etc.) 
  54. ; into ISO latin umlaute for easy reading.
  55. ; hooks change TeX files to latin1 for editing and back to TeX sequences 
  56. ; for calling TeX. An alternative is a TeX style that handles 
  57. ; 8 bit ISO files (available on ftp.vlsivie.tuwien.ac.at in /pub/8bit) 
  58. ; - but these files are difficult to transmit ... so while the net is  
  59. ; still @ 7 bit this may be useful
  60.  
  61. (defvar spanish-trans-tab '(
  62.                 ("~n" "±")
  63.                 ("\([a-zA-Z]\)#" "\\1±")
  64.                 ("~N" "╤")
  65.                 ( "\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  66.                 ( "\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  67.                 ( "\\([-a-zA-Z]\\)'o" "\\1≤")
  68.                 ( "\\([-a-zA-Z]\\)'O" "\\╙")
  69.                 ( "\\([-a-zA-Z]\\)'e" "\\1Θ")
  70.                 ( "\\([-a-zA-Z]\\)'E" "\\1╔")
  71.                 ( "\\([-a-zA-Z]\\)'a" "\\1ß")
  72.                 ( "\\([-a-zA-Z]\\)'A" "\\1A")
  73.                 ( "\\([-a-zA-Z]\\)'i" "\\1φ")
  74.                 ( "\\([-a-zA-Z]\\)'I" "\\1═")
  75.                )
  76.   "Spanish")
  77.  
  78. (defun translate-conventions (trans-tab)
  79.   (interactive)
  80.   (save-excursion
  81.     (widen)
  82.     (goto-char (point-min))
  83.     (let ((work-tab trans-tab)
  84.       (buffer-read-only nil))
  85.       (while work-tab
  86.     (save-excursion
  87.       (let ((trans-this (car work-tab)))
  88.         (while (re-search-forward (car trans-this) nil t)
  89.           (replace-match (car (cdr trans-this)) nil nil)))
  90.       (setq work-tab (cdr work-tab)))))))
  91.  
  92. (defun spanish ()
  93.   "Translate net conventions for Spanish to ISO"
  94.   (interactive)
  95.   (translate-conventions spanish-trans-tab))
  96.  
  97. (defvar aggressive-german-trans-tab '(
  98.            ( "\"a" "Σ")
  99.            ( "\"A" "─")
  100.            ( "\"o" "÷")
  101.            ( "\"O" "╓")
  102.            ( "\"u" "ⁿ")
  103.            ( "\"U" "▄")
  104.            ( "\"s" "▀")
  105.            ( "\\\\3" "▀")
  106.            )
  107.   "German - may do too much")
  108.  
  109. (defvar conservative-german-trans-tab '(
  110.            ( "\\([-a-zA-Z\"`]\\)\"a" "\\1Σ")
  111.            ( "\\([-a-zA-Z\"`]\\)\"A" "\\1─")
  112.            ( "\\([-a-zA-Z\"`]\\)\"o" "\\1÷")
  113.            ( "\\([-a-zA-Z\"`]\\)\"O" "\\1╓")
  114.            ( "\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  115.            ( "\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  116.            ( "\\([-a-zA-Z\"`]\\)\"s" "\\1▀")
  117.            ( "\\([-a-zA-Z\"`]\\)\\\\3" "\\1▀")
  118.            )
  119.   "conservative German - may do too little")
  120.  
  121.  
  122. (defvar german-trans-tab aggressive-german-trans-tab "used for char translation")
  123.  
  124. (defun german ()
  125.  "Translate net conventions for German to ISO"
  126.  (interactive)
  127.  (translate-conventions german-trans-tab))
  128.  
  129. (defvar iso2tex-trans-tab '(
  130.                 ("Σ" "{\\\\\"a}")
  131.                 ("α" "{\\\\`a}")
  132.                 ("ß" "{\\\\'a}")
  133.                 ("π" "{\\\\~a}")
  134.                 ("Γ" "{\\\\^a}")
  135.                 ("δ" "{\\\\\"e}")
  136.                 ("Φ" "{\\\\`e}")
  137.                 ("Θ" "{\\\\'e}")
  138.                 ("Ω" "{\\\\^e}")
  139.                 ("∩" "{\\\\\"\\\\i}")
  140.                 ("∞" "{\\\\`\\\\i}")
  141.                 ("φ" "{\\\\'\\\\i}")
  142.                 ("ε" "{\\\\^\\\\i}")
  143.                 ("÷" "{\\\\\"o}")
  144.                 ("≥" "{\\\\`o}")
  145.                 ("≤" "{\\\\'o}")
  146.                 ("⌡" "{\\\\~o}")
  147.                 ("⌠" "{\\\\^o}")
  148.                 ("ⁿ" "{\\\\\"u}")
  149.                 ("∙" "{\\\\`u}")
  150.                 ("·" "{\\\\'u}")
  151.                 ("√" "{\\\\^u}")
  152.                 ("─" "{\\\\\"A}")
  153.                 ("└" "{\\\\`A}")
  154.                 ("┴" "{\\\\'A}")
  155.                 ("├" "{\\\\~A}")
  156.                 ("┬" "{\\\\^A}")
  157.                 ("╦" "{\\\\\"E}")
  158.                 ("╚" "{\\\\`E}")
  159.                 ("╔" "{\\\\'E}")
  160.                 ("╩" "{\\\\^E}")
  161.                 ("╧" "{\\\\\"I}")
  162.                 ("╠" "{\\\\`I}")
  163.                 ("═" "{\\\\'I}")
  164.                 ("╬" "{\\\\^I}")
  165.                 ("╓" "{\\\\\"O}")
  166.                 ("╥" "{\\\\`O}")
  167.                 ("╙" "{\\\\'O}")
  168.                 ("╒" "{\\\\~O}")
  169.                 ("╘" "{\\\\^O}")
  170.                 ("▄" "{\\\\\"U}")
  171.                 ("┘" "{\\\\`U}")
  172.                 ("┌" "{\\\\'U}")
  173.                 ("█" "{\\\\^U}")
  174.                 ("±" "{\\\\~n}")
  175.                 ("╤" "{\\\\~N}")
  176.                 ("τ" "{\\\\c c}")
  177.                 ("╟" "{\\\\c C}")
  178.                 ("▀" "{\\\\ss}")
  179.                 ("┐" "{?`}")
  180.                 ("í" "{!`}")
  181.                 )
  182.   )
  183.  
  184.  
  185.  
  186.  
  187. (defun iso2tex ()
  188.  "Translate ISO to TeX"
  189.  (interactive)
  190.  (translate-conventions iso2tex-trans-tab))
  191.  
  192.  
  193. (defvar tex2iso-trans-tab '(
  194.                 ( "{\\\\\"a}" "Σ")
  195.                 ( "{\\\\`a}" "α")
  196.                 ( "{\\\\'a}" "ß")
  197.                 ( "{\\\\~a}" "π")
  198.                 ( "{\\\\^a}" "Γ")
  199.                 ( "{\\\\\"e}" "δ")
  200.                 ( "{\\\\`e}" "Φ")
  201.                 ( "{\\\\'e}" "Θ")
  202.                 ( "{\\\\^e}" "Ω")
  203.                 ( "{\\\\\"\\\\i}" "∩")
  204.                 ( "{\\\\`\\\\i}" "∞")
  205.                 ( "{\\\\'\\\\i}" "φ")
  206.                 ( "{\\\\^\\\\i}" "ε")
  207.                 ( "{\\\\\"i}" "∩")
  208.                 ( "{\\\\`i}" "∞")
  209.                 ( "{\\\\'i}" "φ")
  210.                 ( "{\\\\^i}" "ε")
  211.                 ( "{\\\\\"o}" "÷")
  212.                 ( "{\\\\`o}" "≥")
  213.                 ( "{\\\\'o}" "≤")
  214.                 ( "{\\\\~o}" "⌡")
  215.                 ( "{\\\\^o}" "⌠")
  216.                 ( "{\\\\\"u}" "ⁿ")
  217.                 ( "{\\\\`u}" "∙")
  218.                 ( "{\\\\'u}" "·")
  219.                 ( "{\\\\^u}" "√")
  220.                 ( "{\\\\\"A}" "─")
  221.                 ( "{\\\\`A}" "└")
  222.                 ( "{\\\\'A}" "┴")
  223.                 ( "{\\\\~A}" "├")
  224.                 ( "{\\\\^A}" "┬")
  225.                 ( "{\\\\\"E}" "╦")
  226.                 ( "{\\\\`E}" "╚")
  227.                 ( "{\\\\'E}" "╔")
  228.                 ( "{\\\\^E}" "╩")
  229.                 ( "{\\\\\"I}" "╧")
  230.                 ( "{\\\\`I}" "╠")
  231.                 ( "{\\\\'I}" "═")
  232.                 ( "{\\\\^I}" "╬")
  233.                 ( "{\\\\\"O}" "╓")
  234.                 ( "{\\\\`O}" "╥")
  235.                 ( "{\\\\'O}" "╙")
  236.                 ( "{\\\\~O}" "╒")
  237.                 ( "{\\\\^O}" "╘")
  238.                 ( "{\\\\\"U}" "▄")
  239.                 ( "{\\\\`U}" "┘")
  240.                 ( "{\\\\'U}" "┌")
  241.                 ( "{\\\\^U}" "█")
  242.                 ( "{\\\\~n}" "±")
  243.                 ( "{\\\\~N}" "╤")
  244.                 ( "{\\\\c c}" "τ")
  245.                 ( "{\\\\c C}" "╟")
  246.                 ( "\\\\\"{a}" "Σ")
  247.                 ( "\\\\`{a}" "α")
  248.                 ( "\\\\'{a}" "ß")
  249.                 ( "\\\\~{a}" "π")
  250.                 ( "\\\\^{a}" "Γ")
  251.                 ( "\\\\\"{e}" "δ")
  252.                 ( "\\\\`{e}" "Φ")
  253.                 ( "\\\\'{e}" "Θ")
  254.                 ( "\\\\^{e}" "Ω")
  255.                 ( "\\\\\"{\\\\i}" "∩")
  256.                 ( "\\\\`{\\\\i}" "∞")
  257.                 ( "\\\\'{\\\\i}" "φ")
  258.                 ( "\\\\^{\\\\i}" "ε")
  259.                 ( "\\\\\"{i}" "∩")
  260.                 ( "\\\\`{i}" "∞")
  261.                 ( "\\\\'{i}" "φ")
  262.                 ( "\\\\^{i}" "ε")
  263.                 ( "\\\\\"{o}" "÷")
  264.                 ( "\\\\`{o}" "≥")
  265.                 ( "\\\\'{o}" "≤")
  266.                 ( "\\\\~{o}" "⌡")
  267.                 ( "\\\\^{o}" "⌠")
  268.                 ( "\\\\\"{u}" "ⁿ")
  269.                 ( "\\\\`{u}" "∙")
  270.                 ( "\\\\'{u}" "·")
  271.                 ( "\\\\^{u}" "√")
  272.                 ( "\\\\\"{A}" "─")
  273.                 ( "\\\\`{A}" "└")
  274.                 ( "\\\\'{A}" "┴")
  275.                 ( "\\\\~{A}" "├")
  276.                 ( "\\\\^{A}" "┬")
  277.                 ( "\\\\\"{E}" "╦")
  278.                 ( "\\\\`{E}" "╚")
  279.                 ( "\\\\'{E}" "╔")
  280.                 ( "\\\\^{E}" "╩")
  281.                 ( "\\\\\"{I}" "╧")
  282.                 ( "\\\\`{I}" "╠")
  283.                 ( "\\\\'{I}" "═")
  284.                 ( "\\\\^{I}" "╬")
  285.                 ( "\\\\\"{O}" "╓")
  286.                 ( "\\\\`{O}" "╥")
  287.                 ( "\\\\'{O}" "╙")
  288.                 ( "\\\\~{O}" "╒")
  289.                 ( "\\\\^{O}" "╘")
  290.                 ( "\\\\\"{U}" "▄")
  291.                 ( "\\\\`{U}" "┘")
  292.                 ( "\\\\'{U}" "┌")
  293.                 ( "\\\\^{U}" "█")
  294.                 ( "\\\\~{n}" "±")
  295.                 ( "\\\\~{N}" "╤")
  296.                 ( "\\\\c{c}" "τ")
  297.                 ( "\\\\c{C}" "╟")
  298.                 ( "{\\\\ss}" "▀")
  299.                 ( "{?`}" "┐")
  300.                 ( "{!`}" "í")
  301.                 )
  302.   )
  303.  
  304. (defun tex2iso ()
  305.  "Translate TeX to ISO"
  306.  (interactive)
  307.  (translate-conventions tex2iso-trans-tab))
  308.  
  309. (defvar gtex2iso-trans-tab '(
  310.                 ( "\"a" "Σ")
  311.                 ( "\"A" "─")
  312.                 ( "\"o" "÷")
  313.                 ( "\"O" "╓")
  314.                 ( "\"u" "ⁿ")
  315.                 ( "\"U" "▄")
  316.                 ( "\"s" "▀")
  317.                 ( "\\\\3" "▀")
  318.                 ( "{\\\\\"a}" "Σ")
  319.                 ( "{\\\\`a}" "α")
  320.                 ( "{\\\\'a}" "ß")
  321.                 ( "{\\\\~a}" "π")
  322.                 ( "{\\\\^a}" "Γ")
  323.                 ( "{\\\\\"e}" "δ")
  324.                 ( "{\\\\`e}" "Φ")
  325.                 ( "{\\\\'e}" "Θ")
  326.                 ( "{\\\\^e}" "Ω")
  327.                 ( "{\\\\\"\\\\i}" "∩")
  328.                 ( "{\\\\`\\\\i}" "∞")
  329.                 ( "{\\\\'\\\\i}" "φ")
  330.                 ( "{\\\\^\\\\i}" "ε")
  331.                 ( "{\\\\\"i}" "∩")
  332.                 ( "{\\\\`i}" "∞")
  333.                 ( "{\\\\'i}" "φ")
  334.                 ( "{\\\\^i}" "ε")
  335.                 ( "{\\\\\"o}" "÷")
  336.                 ( "{\\\\`o}" "≥")
  337.                 ( "{\\\\'o}" "≤")
  338.                 ( "{\\\\~o}" "⌡")
  339.                 ( "{\\\\^o}" "⌠")
  340.                 ( "{\\\\\"u}" "ⁿ")
  341.                 ( "{\\\\`u}" "∙")
  342.                 ( "{\\\\'u}" "·")
  343.                 ( "{\\\\^u}" "√")
  344.                 ( "{\\\\\"A}" "─")
  345.                 ( "{\\\\`A}" "└")
  346.                 ( "{\\\\'A}" "┴")
  347.                 ( "{\\\\~A}" "├")
  348.                 ( "{\\\\^A}" "┬")
  349.                 ( "{\\\\\"E}" "╦")
  350.                 ( "{\\\\`E}" "╚")
  351.                 ( "{\\\\'E}" "╔")
  352.                 ( "{\\\\^E}" "╩")
  353.                 ( "{\\\\\"I}" "╧")
  354.                 ( "{\\\\`I}" "╠")
  355.                 ( "{\\\\'I}" "═")
  356.                 ( "{\\\\^I}" "╬")
  357.                 ( "{\\\\\"O}" "╓")
  358.                 ( "{\\\\`O}" "╥")
  359.                 ( "{\\\\'O}" "╙")
  360.                 ( "{\\\\~O}" "╒")
  361.                 ( "{\\\\^O}" "╘")
  362.                 ( "{\\\\\"U}" "▄")
  363.                 ( "{\\\\`U}" "┘")
  364.                 ( "{\\\\'U}" "┌")
  365.                 ( "{\\\\^U}" "█")
  366.                 ( "{\\\\~n}" "±")
  367.                 ( "{\\\\~N}" "╤")
  368.                 ( "{\\\\c c}" "τ")
  369.                 ( "{\\\\c C}" "╟")
  370.                 ( "\\\\\"{a}" "Σ")
  371.                 ( "\\\\`{a}" "α")
  372.                 ( "\\\\'{a}" "ß")
  373.                 ( "\\\\~{a}" "π")
  374.                 ( "\\\\^{a}" "Γ")
  375.                 ( "\\\\\"{e}" "δ")
  376.                 ( "\\\\`{e}" "Φ")
  377.                 ( "\\\\'{e}" "Θ")
  378.                 ( "\\\\^{e}" "Ω")
  379.                 ( "\\\\\"{\\\\i}" "∩")
  380.                 ( "\\\\`{\\\\i}" "∞")
  381.                 ( "\\\\'{\\\\i}" "φ")
  382.                 ( "\\\\^{\\\\i}" "ε")
  383.                 ( "\\\\\"{i}" "∩")
  384.                 ( "\\\\`{i}" "∞")
  385.                 ( "\\\\'{i}" "φ")
  386.                 ( "\\\\^{i}" "ε")
  387.                 ( "\\\\\"{o}" "÷")
  388.                 ( "\\\\`{o}" "≥")
  389.                 ( "\\\\'{o}" "≤")
  390.                 ( "\\\\~{o}" "⌡")
  391.                 ( "\\\\^{o}" "⌠")
  392.                 ( "\\\\\"{u}" "ⁿ")
  393.                 ( "\\\\`{u}" "∙")
  394.                 ( "\\\\'{u}" "·")
  395.                 ( "\\\\^{u}" "√")
  396.                 ( "\\\\\"{A}" "─")
  397.                 ( "\\\\`{A}" "└")
  398.                 ( "\\\\'{A}" "┴")
  399.                 ( "\\\\~{A}" "├")
  400.                 ( "\\\\^{A}" "┬")
  401.                 ( "\\\\\"{E}" "╦")
  402.                 ( "\\\\`{E}" "╚")
  403.                 ( "\\\\'{E}" "╔")
  404.                 ( "\\\\^{E}" "╩")
  405.                 ( "\\\\\"{I}" "╧")
  406.                 ( "\\\\`{I}" "╠")
  407.                 ( "\\\\'{I}" "═")
  408.                 ( "\\\\^{I}" "╬")
  409.                 ( "\\\\\"{O}" "╓")
  410.                 ( "\\\\`{O}" "╥")
  411.                 ( "\\\\'{O}" "╙")
  412.                 ( "\\\\~{O}" "╒")
  413.                 ( "\\\\^{O}" "╘")
  414.                 ( "\\\\\"{U}" "▄")
  415.                 ( "\\\\`{U}" "┘")
  416.                 ( "\\\\'{U}" "┌")
  417.                 ( "\\\\^{U}" "█")
  418.                 ( "\\\\~{n}" "±")
  419.                 ( "\\\\~{N}" "╤")
  420.                 ( "\\\\c{c}" "τ")
  421.                 ( "\\\\c{C}" "╟")
  422.                 ( "{\\\\ss}" "▀")
  423.                 ( "{?`}" "┐")
  424.                 ( "{!`}" "í")
  425.                 )
  426.   )
  427.  
  428. (defvar iso2gtex-trans-tab '(
  429.                 ("Σ" "\"a")
  430.                 ("α" "{\\\\`a}")
  431.                 ("ß" "{\\\\'a}")
  432.                 ("π" "{\\\\~a}")
  433.                 ("Γ" "{\\\\^a}")
  434.                 ("δ" "{\\\\\"e}")
  435.                 ("Φ" "{\\\\`e}")
  436.                 ("Θ" "{\\\\'e}")
  437.                 ("Ω" "{\\\\^e}")
  438.                 ("∩" "{\\\\\"\\\\i}")
  439.                 ("∞" "{\\\\`\\\\i}")
  440.                 ("φ" "{\\\\'\\\\i}")
  441.                 ("ε" "{\\\\^\\\\i}")
  442.                 ("÷" "\"o")
  443.                 ("≥" "{\\\\`o}")
  444.                 ("≤" "{\\\\'o}")
  445.                 ("⌡" "{\\\\~o}")
  446.                 ("⌠" "{\\\\^o}")
  447.                 ("ⁿ" "\"u")
  448.                 ("∙" "{\\\\`u}")
  449.                 ("·" "{\\\\'u}")
  450.                 ("√" "{\\\\^u}")
  451.                 ("─" "\"A")
  452.                 ("└" "{\\\\`A}")
  453.                 ("┴" "{\\\\'A}")
  454.                 ("├" "{\\\\~A}")
  455.                 ("┬" "{\\\\^A}")
  456.                 ("╦" "{\\\\\"E}")
  457.                 ("╚" "{\\\\`E}")
  458.                 ("╔" "{\\\\'E}")
  459.                 ("╩" "{\\\\^E}")
  460.                 ("╧" "{\\\\\"I}")
  461.                 ("╠" "{\\\\`I}")
  462.                 ("═" "{\\\\'I}")
  463.                 ("╬" "{\\\\^I}")
  464.                 ("╓" "\"O")
  465.                 ("╥" "{\\\\`O}")
  466.                 ("╙" "{\\\\'O}")
  467.                 ("╒" "{\\\\~O}")
  468.                 ("╘" "{\\\\^O}")
  469.                 ("▄" "\"U")
  470.                 ("┘" "{\\\\`U}")
  471.                 ("┌" "{\\\\'U}")
  472.                 ("█" "{\\\\^U}")
  473.                 ("±" "{\\\\~n}")
  474.                 ("╤" "{\\\\~N}")
  475.                 ("τ" "{\\\\c c}")
  476.                 ("╟" "{\\\\c C}")
  477.                 ("▀" "\\\\3")
  478.                 ("┐" "{?`}")
  479.                 ("í" "{!`}")
  480.                 )
  481.   )
  482.  
  483.  
  484.  
  485. (defun gtex2iso ()
  486.  "Translate german TeX to ISO"
  487.  (interactive)
  488.  (translate-conventions gtex2iso-trans-tab))
  489.  
  490.  
  491. (defun iso2gtex ()
  492.  "Translate ISO to german TeX"
  493.  (interactive)
  494.  (translate-conventions iso2gtex-trans-tab))
  495.  
  496.  
  497. (defun german-texP ()
  498.  "Check if tex buffer is german LaTeX"
  499.  (save-excursion
  500.    (widen)
  501.    (goto-char (point-min))
  502.    (re-search-forward "\\\\documentstyle\\[.*german.*\\]" nil t)))
  503.  
  504.  
  505. (defun fix-iso2tex ()
  506.   "Turn ISO latin1 into TeX sequences"
  507.   (if (equal major-mode 'latex-mode)
  508.       (if (german-texP)
  509.       (iso2gtex)
  510.     (iso2tex)))
  511.   (if (equal major-mode 'tex-mode)
  512.       (iso2tex)))
  513.  
  514. (defun fix-tex2iso ()
  515.   "Turn TeX sequences into ISO latin1"
  516.   (if (equal major-mode 'latex-mode)
  517.       (if (german-texP)
  518.       (gtex2iso)
  519.     (tex2iso)))
  520.   (if (equal major-mode 'tex-mode)
  521.       (tex2iso)))
  522.  
  523. (add-hook 'find-file-hooks 'fix-tex2iso)
  524. (add-hook 'write-file-hooks 'fix-iso2tex)
  525.