[Xemacs] x-symbol mode for Haskell

Jorge Adriano jadrian@mat.uc.pt
Sat, 3 Aug 2002 23:28:23 +0100


--------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,=20
I've always liked the X-Symbol package for Xemacs=20
http://x-symbol.sourceforge.net/ =20

I've searched for Haskell X-Symbol modes, but there doesn't seem to be on=
e.=20
It's kind of strange because it seems to me like most people who are into=
=20
haskell would like to use non-ascii symbols like greek letters and some n=
ice=20
looking operators -  just take a look at some haskell books, LaTeX modes =
for=20
haskell etc.


I tried to hack an x-symbol haskell mode. *I know nothing about elisp* or=
=20
x-symbol internals so the mode is bloated with useless stuff and *does no=
t=20
works* properly (yet?). It is in fact just a very dirty non working hack.=
=2E.=20
right now I just can't spend much time with it.

I thought I'd ask if anyone (preferably with more experience :) is doing,=
 or=20
thinking about doing some good haskell x-symbol mode.

J.A.
P.S.:
Just in case you want to take a look at it here to understand what it is=20
supposedd to do, it goes in attchment.
After installing it try typing something like

f :: Num _alpha =3D> [_alpha] -> [_alpha]
f  x =3D  x+x

The _alphas will turn into real alphas as you type them, the =3D> and -> =
will=20
also turn into good looking non-ascii arrows. :)
The main problem is that the source file is not beeing saved correctly (d=
ecode=20
token works, but not encode token), so you're not going to be able to com=
pile=20
it. Of course there are many other problems like <=3D turning into an arr=
ow=20
instead of a "less than equal", etc etc etc :)


How to install it:

X-Symbol:
- download the latest x-symbol version.
- run xemacs as root=20
- M-x package-admin-add-binary-package
(it will tell you the directory where it is installed)

The quick-dirty-non-usable-x-symbol-haskell-mode :)
- save the "x-symbol-haskell.el" and  "x-symbol-hooks.el" files
- compile them (open in xemacs, right click buffer, byte-compile this fil=
e)
- copy (as root) the .el and .elc files to the directory where your other=
=20
x-symbol .el and .elc files are. You may want to back up your old=20
"x-symbol-hooks.el" file.=20

To "use" it just "M-x x-symbol-mode" in an haskell buffer and type away.







--------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS
Content-Type: text/plain;
  charset="iso-8859-1";
  name="x-symbol-haskell.el"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="x-symbol-haskell.el"

;;; x-symbol-sgml.el --- token language "SGML entity" for package x-symbol

;; Copyright (C) 1996-1999, 2002 Free Software Foundation, Inc.
;;
;; Author: Christoph Wedler <wedler@users.sourceforge.net>
;; Maintainer: (Please use `M-x x-symbol-package-bug' to contact the maintainer)
;; Version: 4.4
;; Keywords: WYSIWYG, HTML, wp, math, internationalization
;; X-URL: http://x-symbol.sourceforge.net/

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Commentary:

;; If you want to use package x-symbol, please visit the URL (use
;; \\[x-symbol-package-web]) and read the info (use \\[x-symbol-package-info]).

;; Token language haskell is registered in x-symbol-hooks.

;;; Code:

(provide 'x-symbol-haskell)
(require 'x-symbol-vars)


;;;===========================================================================
;;;  Miscellaneous variables
;;;===========================================================================

(defface x-symbol-haskell-non-l1-face
  '((((class color) (background light))
     (:foreground "orange4")))
  "*Face, normally used for tokens only allowed in TeX's math mode.
Used in `x-symbol-tex-class-face-alist'."
  :group 'x-symbol-haskell
  :group 'x-symbol-info-general)

(defcustom x-symbol-haskell-modeline-name "haskell"
  "*String naming the language HASKELL in the modeline."
  :group 'x-symbol-haskell
  :type 'string)

(defcustom x-symbol-haskell-header-groups-alist
  '(("Operator" bigop operator)
    ("Relation" relation)
    ("Arrow, Punctuation" arrow triangle shape
     white line dots punctuation quote parenthesis)
    ("Symbol" symbol currency mathletter setsymbol)
    ("Greek Letter" greek greek1)
    ("Misc. Letter" letter slash)
    ("Cedilla, Ogonek" cedilla ogonek)
    ("Dotaccent, Ring" dotaccent ring)
    ("Tilde, Breve" tilde breve)
    ("Circumflex, Caron" circumflex caron)
    ("Diaeresis, Umlaut" diaeresis hungarumlaut)
    ("Acute, Grave" acute grave))
  "*If non-nil, used in HASKELL specific grid/menu.
See `x-symbol-header-groups-alist'."
  :group 'x-symbol-haskell
  :group 'x-symbol-input-init
  :type 'x-symbol-headers)

(defcustom x-symbol-haskell-class-alist
  '((non-l1)
    (VALID "HASKELL entity" (x-symbol-info-face))
    (INVALID "no HASKELL entity" (x-symbol-emph-info-face)))
  "Alist for HASKELL's token classes displayed by info in echo area.
See `x-symbol-language-access-alist' for details."
  :group 'x-symbol-haskell
  :group 'x-symbol-info-strings
  :set 'x-symbol-set-cache-variable 
  :type 'x-symbol-class-info)

(defcustom x-symbol-haskell-class-face-alist
  '((non-l1 x-symbol-haskell-non-l1-face (x-symbol-haskell-non-l1-face)))
  "Alist for HASKELL's color scheme in HASKELL's grid and info.
See `x-symbol-language-access-alist' for details."
  :group 'x-symbol-haskell
  :group 'x-symbol-input-init
  :group 'x-symbol-info-general
  :set 'x-symbol-set-cache-variable
  :type 'x-symbol-class-faces)

(defcustom x-symbol-haskell-electric-ignore nil
  "*Additional HASKELL version of `x-symbol-electric-ignore'."
  :group 'x-symbol-haskell
  :group 'x-symbol-input-control
  :type 'x-symbol-function-or-regexp)

(defvar x-symbol-haskell-required-fonts nil
  "List of features providing fonts for language `haskell'.")

(defvar x-symbol-haskell-extra-menu-items nil
  "Extra menu entries for language `haskell'.")

(defvar x-symbol-haskell-token-list 'x-symbol-haskell-token-list-netscape
  "Function returning a list of HASKELL entities from table specification.
The TOKEN-SPEC in haskell table look like (NUMBER STRING...) where NUMBER
is the Unicode value.  See `x-symbol-init-language',
`x-symbol-haskell-token-list-name', `x-symbol-haskell-token-list-code' and
`x-symbol-haskell-token-list-netscape'.")

(defvar x-symbol-haskell-token-grammar
  (x-symbol-make-grammar
   :decode-regexp "_[#0-9A-Za-z]+"
   :token-list #'x-symbol-haskell-default-token-list)
  "Token grammar for language `haskell'.")

(defvar x-symbol-haskell-input-token-grammar
  '("_[#0-9A-Za-z]+\\'")
  "Grammar of input method Token for language `haskell'.")

(defvar x-symbol-haskell-user-table nil
  "User table defining HASKELL entities, used in `x-symbol-haskell-table'.")

(defvar x-symbol-haskell-generated-data nil
  "Internal.")


;;;===========================================================================
;;;  Image support
;;;===========================================================================

(defcustom x-symbol-haskell-master-directory 'ignore
  "Function returning the directory of the master file or nil.
See `x-symbol-image-parse-buffer'."
  :group 'x-symbol-haskell
  :group 'x-symbol-image-language
  :type 'function)

(defcustom x-symbol-haskell-image-searchpath '("./")
  "Search path used for implicitly relative image file names.
See `x-symbol-image-use-remote'."
  :group 'x-symbol-haskell
  :group 'x-symbol-image-language
  :type '(repeat directory))

(defcustom x-symbol-haskell-image-cached-dirs '("images/" "pictures/")
  "Directory parts of image file names stored in the memory cache.
See `x-symbol-image-use-remote'."
  :group 'x-symbol-haskell
  :group 'x-symbol-image-language
  :type '(repeat string))

(defcustom x-symbol-haskell-image-file-truename-alist
  '(("\\`file:" . "")
    ("\\`[A-Za-z]+:"))
  "Alist used to determine the file name of an image URL.
Each element looks like
  (REGEXP) or
  (REGEXP . NEWTEXT) or
  (REGEXP FUNCTION ARG...)
If the the image file name is matched by REGEXP, the corresponding
element is processed, if no REGEXP matches, the image file name is used
as it is.  With the first form, the image command will not be
highlighted.  With the second form, replace text matched by REGEXP with
NEWTEXT, see `replace-match' for details.  With the third form,
FUNCTION, call FUNCTION with the image file name and the remaining
arguments ARGs to get the true file name.

E.g., I add the following element to this variable:
  (\"\\\\`http://www\\\\.fmi\\\\.uni-passau\\\\.de/~wedler/\" \. \"~/public_html/\")"
  :group 'x-symbol-haskell
  :group 'x-symbol-image-language
  :type '(repeat (cons :format "%v"
                       :value ("" . "") ; doesn't work (custom bug?)
                       regexp
                       (choice ;;:value ""
                               (const :tag "Not highlighted" nil)
                               (string :tag "Replace match with")
                               (cons :tag "Call"
                                     function
                                     (repeat :tag "With arguments" sexp))))))

(defcustom x-symbol-haskell-image-keywords
  '("\\.\\(gif\\|png\\|jpe?g\\)\\'"
    ("<img[ \t][^\n>]*src=\"\\([^\n\"]+\\)\"[^\n>]*>"
     x-symbol-haskell-image-file-truename 1))
  "Keywords used to find image insertion commands.
See `x-symbol-image-parse-buffer'."
  :group 'x-symbol-haskell
  :group 'x-symbol-image-language
  :type 'x-symbol-image-keywords)

(defun x-symbol-haskell-image-file-truename (num)
  "Return true image file name for last match.
Return text matched by the NUMth regexp group of the corresponding
keyword regexp, after being processed according to
`x-symbol-haskell-image-file-truename-alist'."
  (x-symbol-match-in-alist (setq num (match-string num))
                           x-symbol-haskell-image-file-truename-alist
                           num t))


;;;===========================================================================
;;;  Super- and Subscripts
;;;===========================================================================

(defvar x-symbol-haskell-font-lock-keywords
  '((x-symbol-haskell-match-subscript
     (1 x-symbol-invisible-face t)
     (2 (if (eq (char-after (+ 3 (match-beginning 1))) ?b)
            'x-symbol-sub-face 'x-symbol-sup-face)
        prepend)
     (3 x-symbol-invisible-face t)))
  "HASKELL's font-lock keywords for super- and subscripts.")

(defcustom x-symbol-haskell-font-lock-regexp "<su[bp]>"
  "Regexp matching the start tag of HASKELL's super- and subscripts.
See also `x-symbol-haskell-font-lock-alist'."
  :group 'x-symbol-haskell
  :type 'regexp)

(defcustom x-symbol-haskell-font-lock-limit-regexp "\n\\|</?su[bp]>"
  "Regexp matching the end tag of HASKELL's super- and subscripts.
This regexp should match the end of line and the closing tags in
`x-symbol-haskell-font-lock-alist'."
  :group 'x-symbol-haskell
  :type 'regexp)

(defcustom x-symbol-haskell-font-lock-contents-regexp "[^ \t\n\240]"
  "*Regexp matching the super- and subscript contents.
This regexp should match the text between the opening and closing super-
or subscript tag."
  :group 'x-symbol-haskell
  :type 'regexp)

(defcustom x-symbol-haskell-font-lock-alist
  '(("<sub>" . "</sub>") ("<sup>" . "</sup>"))
  "Alist for correct tag pairs for HASKELL's super- and subscripts.
Each element looks like (OPEN . CLOSE).  All keys OPEN in this alist
should be matched by `x-symbol-haskell-font-lock-regexp', all CLOSEs should
be matched by `x-symbol-haskell-font-lock-limit-regexp'."
  :group 'x-symbol-haskell
  :type '(repeat (cons :format "%v"
                       (string :tag "Open tag")
                       (string :tag "Close tag"))))


;;;===========================================================================
;;;  The tables
;;;===========================================================================

(defun x-symbol-haskell-default-token-list (tokens)
  (mapcar #'list
          (if (car tokens)
              (if (or (eq x-symbol-haskell-token-list
                          'x-symbol-haskell-token-list-name)
                      (and (eq x-symbol-haskell-token-list
                               'x-symbol-haskell-token-list-netscape)
                           (< (car tokens) 256)))
                  (append (cdr tokens) (list (format "_#%d" (car tokens))))
                (cons (format "_#%d" (car tokens)) (cdr tokens))))))

;; http://www.w3.org/TR/REC-html40/haskell/entities.html
;; (query-replace-regexp "<!ENTITY[ \t]*\\([A-Za-z][A-Za-z0-9]*\\)[ \t]*CDATA[ \t]*\"_#\\([0-9]+\\);\"[ \t]*--\\(.+\\) -->[ \t]*.*$" " (\\1 () \\2 \"_\\1;\") ; \\3")

(defvar x-symbol-haskell-latin1-table
  '((nobreakspace () 160 "_nbsp")
    (exclamdown () 161 "_iexcl")
    (cent () 162 "_cent")
    (sterling () 163 "_pound")
    (currency () 164 "_curren")
    (yen () 165 "_yen")
    (brokenbar () 166 "_brvbar" "_brkbar")
    (section () 167 "_sect")
    (diaeresis () 168 "_uml" "_die")
    (copyright () 169 "_copy")
    (ordfeminine () 170 "_ordf")
    (guillemotleft () 171 "_laquo")
    (notsign () 172 "_not")
    (hyphen () 173 "_shy")
    (registered () 174 "_reg")
    (macron () 175 "_macr" "_hibar")
    (degree () 176 "_deg")
    (plusminus () 177 "_plusmn")
    (twosuperior () 178 "_sup2")
    (threesuperior () 179 "_sup3")
    (acute () 180 "_acute")
    (mu1 () 181 "_micro")
    (paragraph () 182 "_para")
    (periodcentered () 183 "_middot")
    (cedilla () 184 "_cedil")
    (onesuperior () 185 "_sup1")
    (masculine () 186 "_ordm")
    (guillemotright () 187 "_raquo")
    (onequarter () 188 "_frac14")
    (onehalf () 189 "_frac12")
    (threequarters () 190 "_frac34")
    (questiondown () 191 "_iquest")
    (Agrave () 192 "_Agrave")
    (Aacute () 193 "_Aacute")
    (Acircumflex () 194 "_Acirc")
    (Atilde () 195 "_Atilde")
    (Adiaeresis () 196 "_Auml")
    (Aring () 197 "_Aring")
    (AE () 198 "_AElig")
    (Ccedilla () 199 "_Ccedil")
    (Egrave () 200 "_Egrave")
    (Eacute () 201 "_Eacute")
    (Ecircumflex () 202 "_Ecirc")
    (Ediaeresis () 203 "_Euml")
    (Igrave () 204 "_Igrave")
    (Iacute () 205 "_Iacute")
    (Icircumflex () 206 "_Icirc")
    (Idiaeresis () 207 "_Iuml")
    (ETH () 208 "_ETH") ; "_Dstrok" for Dbar (U0110) = latin2#208?
    (Ntilde () 209 "_Ntilde")
    (Ograve () 210 "_Ograve")
    (Oacute () 211 "_Oacute")
    (Ocircumflex () 212 "_Ocirc")
    (Otilde () 213 "_Otilde")
    (Odiaeresis () 214 "_Ouml")
    (multiply () 215 "_times")
    (Ooblique () 216 "_Oslash")
    (Ugrave () 217 "_Ugrave")
    (Uacute () 218 "_Uacute")
    (Ucircumflex () 219 "_Ucirc")
    (Udiaeresis () 220 "_Uuml")
    (Yacute () 221 "_Yacute")
    (THORN () 222 "_THORN")
    (ssharp () 223 "_szlig")
    (agrave () 224 "_agrave")
    (aacute () 225 "_aacute")
    (acircumflex () 226 "_acirc")
    (atilde () 227 "_atilde")
    (adiaeresis () 228 "_auml")
    (aring () 229 "_aring")
    (ae () 230 "_aelig")
    (ccedilla () 231 "_ccedil")
    (egrave () 232 "_egrave")
    (eacute () 233 "_eacute")
    (ecircumflex () 234 "_ecirc")
    (ediaeresis () 235 "_euml")
    (igrave () 236 "_igrave")
    (iacute () 237 "_iacute")
    (icircumflex () 238 "_icirc")
    (idiaeresis () 239 "_iuml")
    (eth () 240 "_eth")
    (ntilde () 241 "_ntilde")
    (ograve () 242 "_ograve")
    (oacute () 243 "_oacute")
    (ocircumflex () 244 "_ocirc")
    (otilde () 245 "_otilde")
    (odiaeresis () 246 "_ouml")
    (division () 247 "_divide")
    (oslash () 248 "_oslash")
    (ugrave () 249 "_ugrave")
    (uacute () 250 "_uacute")
    (ucircumflex () 251 "_ucirc")
    (udiaeresis () 252 "_uuml")
    (yacute () 253 "_yacute")
    (thorn () 254 "_thorn")
    (ydiaeresis () 255 "_yuml"))
  "Table defining HASKELL entities, see `x-symbol-haskell-table'.")

(defvar x-symbol-haskell-latinN-table
  '((Aogonek (non-l1) 260)
    (breve (non-l1) 728)
    (Lslash (non-l1) 321)
    (Lcaron (non-l1) 317)
    (Sacute (non-l1) 346)
    (Scaron (non-l1) 352 "_Scaron")
    (Scedilla (non-l1) 350)
    (Tcaron (non-l1) 356)
    (Zacute (non-l1) 377)
    (Zcaron (non-l1) 381)
    (Zdotaccent (non-l1) 379)
    (aogonek (non-l1) 261)
    (ogonek (non-l1) 731)
    (lslash (non-l1) 322)
    (lcaron (non-l1) 318)
    (sacute (non-l1) 347)
    (caron (non-l1) 711)
    (scaron (non-l1) 353 "_scaron")
    (scedilla (non-l1) 351)
    (tcaron (non-l1) 357)
    (zacute (non-l1) 378)
    (hungarumlaut (non-l1) 733)
    (zcaron (non-l1) 382)
    (zdotaccent (non-l1) 380)
    (Racute (non-l1) 340)
    (Abreve (non-l1) 258)
    (Lacute (non-l1) 313)
    (Cacute (non-l1) 262)
    (Ccaron (non-l1) 268)
    (Eogonek (non-l1) 280)
    (Ecaron (non-l1) 282)
    (Dcaron (non-l1) 270)
    (Dbar (non-l1) 272)
    (Nacute (non-l1) 323)
    (Ncaron (non-l1) 327)
    (Ohungarumlaut (non-l1) 336)
    (Rcaron (non-l1) 344)
    (Uring (non-l1) 366)
    (Uhungarumlaut (non-l1) 368)
    (Tcedilla (non-l1) 354)
    (racute (non-l1) 341)
    (abreve (non-l1) 259)
    (lacute (non-l1) 314)
    (cacute (non-l1) 263)
    (ccaron (non-l1) 269)
    (eogonek (non-l1) 281)
    (ecaron (non-l1) 283)
    (dcaron (non-l1) 271)
    (dbar (non-l1) 273)
    (nacute (non-l1) 324)
    (ncaron (non-l1) 328)
    (ohungarumlaut (non-l1) 337)
    (rcaron (non-l1) 345)
    (uring (non-l1) 367)
    (uhungarumlaut (non-l1) 369)
    (tcedilla (non-l1) 355)
    (dotaccent (non-l1) 729)
    (Hbar (non-l1) 294)
    (Hcircumflex (non-l1) 292)
    (Idotaccent (non-l1) 304)
    (Gbreve (non-l1) 286)
    (Jcircumflex (non-l1) 308)
    (hbar (non-l1) 295)
    (hcircumflex (non-l1) 293)
    (dotlessi (non-l1) 305)
    (gbreve (non-l1) 287)
    (jcircumflex (non-l1) 309)
    (Cdotaccent (non-l1) 266)
    (Ccircumflex (non-l1) 264)
    (Gdotaccent (non-l1) 288)
    (Gcircumflex (non-l1) 284)
    (Ubreve (non-l1) 364)
    (Scircumflex (non-l1) 348)
    (cdotaccent (non-l1) 267)
    (ccircumflex (non-l1) 265)
    (gdotaccent (non-l1) 289)
    (gcircumflex (non-l1) 285)
    (ubreve (non-l1) 365)
    (scircumflex (non-l1) 349)
    (euro (non-l1) 8364 "_euro")
    (OE (non-l1) 338 "_OElig")
    (oe (non-l1) 339 "_oelig")
    (Ydiaeresis (non-l1) 376 "_Yuml"))
  "Table defining HASKELL entities, see `x-symbol-haskell-table'.")

(defvar x-symbol-haskell-xsymb0-table
  '((Delta (non-l1) 916 "_Delta")
    (Phi (non-l1) 934 "_Phi")
    (Gamma (non-l1) 915 "_Gamma")
    (theta1 (non-l1) 977 "_thetasym")
    (Lambda (non-l1) 923 "_Lambda")
    (Pi (non-l1) 928 "_Pi")
    (Theta (non-l1) 920 "_Theta")
    (Sigma (non-l1) 931 "_Sigma")
    (sigma1 (non-l1) 962 "_sigmaf")
    (Omega (non-l1) 937 "_Omega")
    (Xi (non-l1) 926 "_Xi")
    (Psi (non-l1) 936 "_Psi")
    (alpha (non-l1) 945 "_alpha")
    (beta (non-l1) 946 "_beta")
    (chi (non-l1) 967 "_chi")
    (delta (non-l1) 948 "_delta")
    (epsilon (non-l1) 949 "_epsilon")
    (phi (non-l1) 966 "_phi")
    (gamma (non-l1) 947 "_gamma")
    (eta (non-l1) 951 "_eta")
    (iota (non-l1) 953 "_iota")
    (kappa (non-l1) 954 "_kappa")
    (lambda (non-l1) 955 "_lambda")
    (mu (non-l1) 956 "_mu")
    (nu (non-l1) 957 "_nu")
    (pi (non-l1) 960 "_pi")
    (theta (non-l1) 952 "_theta")
    (rho (non-l1) 961 "_rho")
    (sigma (non-l1) 963 "_sigma")
    (tau (non-l1) 964 "_tau")
    (upsilon (non-l1) 965 "_upsilon")
    (omega1 (non-l1) 982 "_piv")
    (omega (non-l1) 969 "_omega")
    (xi (non-l1) 958 "_xi")
    (psi (non-l1) 968 "_psi")
    (zeta (non-l1) 950 "_zeta")
    (Upsilon1 (non-l1) 978 "_upsih")

    (florin (non-l1) 402 "_fnof")
    (bullet (non-l1) 8226 "_bull")
    (ellipsis (non-l1) 8230 "_hellip")
    (minute (non-l1) 8242 "_prime")
    (second (non-l1) 8243 "_Prime")
    (radicalex (non-l1) 8254 "_oline")
    (fraction (non-l1) 8260 "_frasl")
    (weierstrass (non-l1) 8472 "_weierp")
    (Ifraktur (non-l1) 8465 "_image")
    (Rfraktur (non-l1) 8476 "_real")
    (trademark (non-l1) 8482 "_trade")
    (aleph (non-l1) 8501 "_alefsym")
    (arrowleft (non-l1) 8592 "_larr")
    (arrowup (non-l1) 8593 "_uarr")
    (arrowright (non-l1) 8594 "_rarr")
    (arrowdown (non-l1) 8595 "_darr")
    (arrowboth (non-l1) 8596 "_harr")
    (carriagereturn (non-l1) 8629 "_crarr")
    (arrowdblleft (non-l1) 8656 "_lArr")
    (arrowdblup (non-l1) 8657 "_uArr")
    (arrowdblright (non-l1) 8658 "_rArr")
    (arrowdbldown (non-l1) 8659 "_dArr")
    (arrowdblboth (non-l1) 8660 "_hArr")

    (partialdiff (non-l1) 8706 "_part")
    (emptyset (non-l1) 8709 "_empty")
    (gradient (non-l1) 8711 "_nabla")
    (element (non-l1) 8712 "_isin")
    (notelement (non-l1) 8713 "_notin")
    (suchthat (non-l1) 8715 "_ni")
    (product (non-l1) 8719 "_prod")
    (summation (non-l1) 8721 "_sum")
    (minus1 (non-l1) 8722 "_minus")
    (asterisk1 (non-l1) 8727 "_lowast")
    (radical (non-l1) 8730 "_radic")
    (proportional (non-l1) 8733 "_prop")
    (infinity (non-l1) 8734 "_infin")
    (angle (non-l1) 8736 "_ang")
    (logicaland (non-l1) 8743 "_and")
    (logicalor (non-l1) 8744 "_or")
    (intersection (non-l1) 8745 "_cap")
    (union (non-l1) 8746 "_cup")
    (integral (non-l1) 8747 "_int")
    (similar (non-l1) 8764 "_sim")
    (congruent (non-l1) 8773 "_cong")
    (notequal (non-l1) 8800 "_ne")
    (equivalence (non-l1) 8801 "_equiv")
    (lessequal (non-l1) 8804 "_le")
    (greaterequal (non-l1) 8805 "_ge")
    (propersubset (non-l1) 8834 "_sub")
    (propersuperset (non-l1) 8835 "_sup")
    (notsubset (non-l1) 8836 "_nsub")
    (reflexsubset (non-l1) 8838 "_sube")
    (reflexsuperset (non-l1) 8839 "_supe")
    (circleplus (non-l1) 8853 "_oplus")
    (circlemultiply (non-l1) 8855 "_otimes")
    (perpendicular (non-l1) 8869 "_perp")
    (periodcentered1 (non-l1) 8901 "_sdot")
    (angleleft (non-l1) 9001 "_lang")
    (angleright (non-l1) 9002 "_rang")
    (lozenge (non-l1) 9674 "_loz")
    (spade (non-l1) 9824 "_spades")
    (club (non-l1) 9827 "_clubs")
    (heart (non-l1) 9829 "_hearts")
    (diamond (non-l1) 9830 "_diams"))
  "Table defining HASKELL entities, see `x-symbol-haskell-table'.")

(defvar x-symbol-haskell-xsymb1-table
  '((ampersand2 () 38 "_amp")
    (quotedbl1 () 34 "_quot")
    (less2 () 60 "_lt")
    (greater2 () 62 "_gt")
    (universal1 (non-l1) 8704 "_forall")
    (existential1 (non-l1) 8707 "_exist")
    (circumflex (non-l1) 710 "_circ")
    (tilde (non-l1) 732 "_tilde")
    ;;(ensp (non-l1) 8194 "_ensp") ;  en space, U+2002 ISOpub
    ;;(emsp (non-l1) 8195 "_emsp") ;  em space, U+2003 ISOpub
    ;;(thinsp (non-l1) 8201 "_thinsp") ;  thin space, U+2009 ISOpub
    ;;(zwnj (non-l1) 8204 "_zwnj") ;  zero width non-joiner, U+200C NEW RFC 2070
    ;;(zwj (non-l1) 8205 "_zwj") ;  zero width joiner, U+200D NEW RFC 2070
    ;;(lrm (non-l1) 8206 "_lrm") ;  left-to-right mark, U+200E NEW RFC 2070
    ;;(rlm (non-l1) 8207 "_rlm") ;  right-to-left mark, U+200F NEW RFC 2070
    (endash (non-l1) 8211 "_ndash")
    (emdash (non-l1) 8212 "_mdash")
    ;;(lsquo (non-l1) 8216 "_lsquo") ;  left single quotation mark, U+2018 ISOnum
    ;;(rsquo (non-l1) 8217 "_rsquo") ;  right single quotation mark, U+2019 ISOnum
    ;;(sbquo (non-l1) 8218 "_sbquo") ;  single low-9 quotation mark, U+201A NEW
    ;;(ldquo (non-l1) 8220 "_ldquo") ;  left double quotation mark, U+201C ISOnum
    ;;(rdquo (non-l1) 8221 "_rdquo") ;  right double quotation mark, U+201D ISOnum
    ;;(bdquo (non-l1) 8222 "_bdquo") ;  double low-9 quotation mark, U+201E NEW
    (dagger (non-l1) 8224 "_dagger")
    (daggerdbl (non-l1) 8225 "_Dagger")
    (perthousand (non-l1) 8240 "_permil")
    (guilsinglleft (non-l1) 8249 "_lsaquo")
    (guilsinglright (non-l1) 8250 "_rsaquo")
    (therefore1 (non-l1) 8756 "_there4")
    (ceilingleft (non-l1) 8968 "_lceil")
    (ceilingright (non-l1) 8969 "_rceil")
    (floorleft (non-l1) 8970 "_lfloor")
    (floorright (non-l1) 8971 "_rfloor")
    (asym (non-l1) 8776 "_asymp")
    )
  "Table defining HASKELL entities, see `x-symbol-haskell-table'.")

;; Should I add symbols from http://www.bbsinc.com/iso8859.html ?
(defvar x-symbol-haskell-table
  (append x-symbol-haskell-user-table
          '(nil)
          x-symbol-haskell-latin1-table
          x-symbol-haskell-latinN-table
          x-symbol-haskell-xsymb0-table
          x-symbol-haskell-xsymb1-table)
  "Complete table defining HASKELL entities.
Use `x-symbol-haskell-user-table' to define/shadow private entities.
See `x-symbol-init-language' and `x-symbol-haskell-token-list'.")


;;;===========================================================================
;;;  Subscript functions
;;;===========================================================================

(defun x-symbol-haskell-match-subscript (limit)
  ;; checkdoc-params: (limit)
  "Match and skip over super- and subscripts.
Return nil if `x-symbol-mode' or `x-symbol-subscripts' is nil.  Uses
`x-symbol-haskell-font-lock-regexp'."
  (and x-symbol-mode x-symbol-subscripts
       (let (open-beg open-end close-end close-beg)
         (while
             (and (setq open-end (re-search-forward
                                  x-symbol-haskell-font-lock-regexp limit t))
                  (setq open-beg (match-beginning 0))
                  (not
                   (and (setq close-end
                              (re-search-forward
                               x-symbol-haskell-font-lock-limit-regexp
                               limit 'limit))
                        (setq close-beg (match-beginning 0))
                        (equal (cdr (assoc (downcase
                                            (buffer-substring open-beg
                                                              open-end))
                                           x-symbol-haskell-font-lock-alist))
                               (downcase (buffer-substring close-beg
                                                           close-end)))
                        (save-excursion
                          (goto-char open-end)
                          (re-search-forward
                           x-symbol-haskell-font-lock-contents-regexp
                           close-beg t))))))
         (when open-end
           (store-match-data (list open-beg close-end
                                   open-beg open-end
                                   open-end close-beg
                                   close-beg close-end))
           t))))

;;; Local IspellPersDict: .ispell_xsymb
;;; x-symbol-haskell.el ends here

--------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS
Content-Type: text/plain;
  charset="iso-8859-1";
  name="x-symbol-hooks.el"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="x-symbol-hooks.el"

;;; x-symbol-hooks.el --- pre-loaded stuff for package x-symbol

;; Copyright (C) 1996-1999, 2001-2002 Free Software Foundation, Inc.
;;
;; Author: Christoph Wedler <wedler@users.sourceforge.net>
;; Maintainer: (Please use `M-x x-symbol-package-bug' to contact the main=
tainer)
;; Version: 4.4.X
;; Keywords: WYSIWYG, LaTeX, HTML, wp, math, internationalization
;; X-URL: http://x-symbol.sourceforge.net/

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Commentary:

;; If you want to use package x-symbol, please visit the URL (use
;; \\[x-symbol-package-web]) and read the info (use \\[x-symbol-package-i=
nfo]).

;; This file provides `autoload's for package x-symbol, adds functions to=
 hooks
;; for the automatic conversion and defines variables which control the
;; conversion.

;;; Code:

(provide 'x-symbol-hooks)
(require 'font-lock)
(eval-when-compile (require 'cl))
(eval-when-compile
  (defvar x-symbol-coding-name-alist)=09; in "x-symbol-vars"
  (defvar x-symbol-image-colormap-allocation) ; here
  (defvar x-symbol-image-convert-colormap) ; here
  (defvar x-symbol-cstring-table)=09; in x-symbol.el, only needed if load=
ed
  )
(eval-when-compile
  (defvar lazy-shot-minimum-size)
  (defvar comint-input-sender)
  (defvar comint-last-input-end)
  (defvar comint-last-output-start)
  (defvar fast-lock-save-faces)
  (defvar latex-mode-hook)
  (defvar LaTeX-mode-hook)
  (defvar LaTeX-math-insert-function)
  (defvar orig-buffer)
  (defvar reftex-translate-to-ascii-function)
)

(put 'x-symbol-define-user-options 'lisp-indent-function 2)
(put 'x-symbol-dolist-delaying 'lisp-indent-function 2)
(put 'x-symbol-do-plist 'lisp-indent-function 1)
(put 'x-symbol-while-charsym 'lisp-indent-function 1)
(put 'x-symbol-encode-for-charsym 'lisp-indent-function 1)
(put 'x-symbol-decode-for-charsym 'lisp-indent-function 2)

(defvar x-symbol-warn-of-old-emacs t
  "If non-nil, issue warning when using a old/buggy XEmacs.
XEmacs-21.0 to XEmacs-21.1.8 has been reported to core when using input
method token.")

;; CW: if possible, back to x-symbol.el, do not load too many files at in=
it
(require (if (featurep 'xemacs) 'x-symbol-xmacs 'x-symbol-emacs))


=0C
;;;;#####################################################################=
#####
;;;;  Variables
;;;;#####################################################################=
#####


(defvar x-symbol-data-directory
  (or (locate-data-directory "x-symbol")
      (progn (warn "X-Symbol is not installed at the proper place")
=09     nil))
  "Directory of data files that come with package X-Symbol.")

(defvar x-symbol-font-directory
  (and x-symbol-data-directory
       (expand-file-name "pcf/" x-symbol-data-directory))
  "Directory for additional X-Symbol fonts.
If non-nil, used in function `x-symbol-initialize'.")


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Custom groups
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defgroup x-symbol nil
  "Semi WYSIWYG for LaTeX, HTML, etc using additional fonts."
  :group 'wp
  :link '(info-link "(x-symbol)")
  :link '(url-link "http://x-symbol.sourceforge.net/")
  :prefix "x-symbol-")

(defgroup x-symbol-mode nil
  "Controlling whether and how to turn on X-Symbol mode."
  :group 'x-symbol
  :prefix "x-symbol-")

(defgroup x-symbol-input-init nil
  "Initialization of input methods supported by X-Symbol."
  :group 'x-symbol
  :prefix "x-symbol-")

(defgroup x-symbol-input-control nil
  "Control if input methods supported by X-Symbol."
  :group 'x-symbol
  :prefix "x-symbol-")

(defgroup x-symbol-info-general nil
  "General customization of X-Symbol info in echo area."
  :group 'x-symbol
  :prefix "x-symbol-")

(defgroup x-symbol-info-strings nil
  "Customization of X-Symbol info strings in echo area."
  :group 'x-symbol
  :prefix "x-symbol-")

(defgroup x-symbol-miscellaneous nil
  "Miscellaneous customization for X-Symbol."
  :group 'x-symbol
  :prefix "x-symbol-")

(defgroup x-symbol-image-general nil
  "General customization of images in X-Symbol buffers."
  :group 'x-symbol
  :prefix "x-symbol-")=09=09=09; not "x-symbol-image-" !

(defgroup x-symbol-image-language nil
  "Language dependent customization of images in X-Symbol buffers."
  :group 'x-symbol
  :prefix "x-symbol-")=09=09=09; not "x-symbol-image-" !

(defgroup x-symbol-tex nil
  "X-Symbol token language \"TeX macro\"."
  :group 'x-symbol
  :prefix "x-symbol-tex-")

(defgroup x-symbol-sgml nil
  "X-Symbol token language \"SGML entity\"."
  :group 'x-symbol
  :prefix "x-symbol-sgml-")

(defgroup x-symbol-haskell nil
  "X-Symbol token language \"HASKELL entity\"."
  :group 'x-symbol
  :prefix "x-symbol-haskell-")


(defgroup x-symbol-bib nil
  "X-Symbol token language \"BibTeX macro\"."
  :group 'x-symbol
  :prefix "x-symbol-bib-")

(defgroup x-symbol-texi nil
  "X-Symbol token language \"TeXinfo command\"."
  :group 'x-symbol
  :prefix "x-symbol-texi-")


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Custom widgets
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

;; Shouldn't this be a generally useful widget type?
(define-widget 'x-symbol-key 'sexp
  "A key or mouse stroke."
  :tag "Key/Mouse stroke")

(define-widget 'x-symbol-modes-or-regexp 'choice
  "Regexp or list of major modes."
  :value nil
  :args '((const :tag "Always" t)
=09  (regexp :tag "When matched by")
=09  (repeat :tag "In major modes" :menu-tag "In major modes"
=09=09  (function :value text-mode))))

(define-widget 'x-symbol-auto-mode 'group
  "Auto-mode setup."
  :args '((x-symbol-modes-or-regexp :tag "Turn on")
=09  (sexp :tag "Language (eval'd)")
=09  (option
=09   (group :inline t :extra-offset -4
=09=09  (sexp :tag "Coding (eval'd)")
=09=09  (option
=09=09   (group :inline t :extra-offset -4
=09=09=09  (sexp :tag "Save 8bit (eval'd)")
=09=09=09  (option
=09=09=09   (group :inline t :extra-offset -4
=09=09=09=09  (sexp :tag "Super/subscripts (eval'd)")
=09=09=09=09  (option
=09=09=09=09   (group :inline t :extra-offset -4
=09=09=09=09=09  (sexp :tag "Show images (eval'd)")
=09=09=09=09=09  (option
=09=09=09=09=09   (sexp :tag
=09=09=09=09=09=09 "Unique decoding (eval'd)"
=09=09=09=09=09=09 ))))))))))))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Functions to set user options
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defun x-symbol-define-user-options (var options &optional after-set set-=
fn)
  "Define options and setting behavior for user option VAR.
OPTIONS has the form (FALLBACK . ALIST) where ALIST has elements of the
form (OPTION . MENU-TEXT).  If ALIST is non-nil, one OPTION should be
equal to FALLBACK, its MENU-TEXT is used for any values not being keys
in ALIST.  OPTIONS can also be a function which should return the form
mention above.

If ALIST is nil, `x-symbol-submenu-filter', which is used by
`x-symbol-menu', uses a toggle button with FALLBACK as the non-nil value
and \\[set-variable] offers completion with matches nil and FALLBACK.
Otherwise, the menu uses radio buttons for all OPTIONs, where MENU-TEXT
is the name of the menu item, and \\[set-variable] offers completion
over all OPTIONs.

`x-symbol-set-variable', which is invoked by the menu callbacks, uses
SET-FN instead `set' to set the value of VAR if SET-FN is non-nil.
Otherwise, all functions in AFTER-SET are invoked after `set'ting VAR."
  (put var 'x-symbol-options options)
  (put var 'variable-interactive
       (list 'x-symbol-variable-interactive (list 'quote var)))
  (while after-set
    (pushnew (pop after-set) (get var 'x-symbol-after-set-hook) :test 'eq=
ual))
  (if set-fn (put var 'x-symbol-set-function set-fn)))

;; CW: autoload important if var `x-symbol-auto-mode-suffixes' is saved b=
y
;; custom
;;;###autoload
(defun x-symbol-auto-mode-suffixes (&optional suffixes)
  "Return REGEXPs of three-value elements in `auto-mode-alist'.
These REGEXPs are added to SUFFIXES."
  (setq suffixes (reverse suffixes))
  (let ((alist auto-mode-alist))
    (while alist
      (and (consp (cdar alist))
=09   (null (member (caar alist) suffixes))
=09   (push (caar alist) suffixes))
      (setq alist (cdr alist)))
    (nreverse suffixes)))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Initialization
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defcustom x-symbol-initialize t
  "Whether to do an extended initialization of package X-Symbol.
If t, do full initialization.  Otherwise, the value should be a list
with element.  To enable, include

 * `languages' to register all supported token languages,
 * `global' to turn on X-Symbol's global mode, i.e., as files are
   loaded, execute `turn-on-x-symbol-conditionally',
 * `keys' to set up the usual X-Symbol key bindings in `global-map',
 * `font-path' to add `x-symbol-font-directory' to the font-path,
 * `comint' to make X-Symbol work with comint,
 * `fast-lock' to make X-Symbol work with fast-lock,
 * `auctex' to make X-Symbol optimally work with AucTeX 9.8a+, it
   changes AucTeX's `TeX-region-hook', `TeX-translate-location-hook',
   and `LaTeX-math-insert-function',
 * `reftex' to make X-Symbol optimally work with RefTeX 3.26+,
 * `bib-cite' to make X-Symbol not overwriting bib-cite's highlighting.

You do not have to install the packages whose initialization is
enabled."
  :group 'x-symbol-mode
  :type '(choice (const :tag "All" t)
=09=09 (set :value (languages global keys font-path comint
=09=09=09=09=09fast-lock auctex reftex bib-cite)
=09=09      (const :tag "Token languages" languages)
=09=09      (const :tag "Global mode" global)
=09=09      (const :tag "Key bindings" keys)
=09=09      (const :tag "Font path" font-path)
=09=09      (const :tag "Package comint" comint)
=09=09      (const :tag "Package fast-lock" fast-lock)
=09=09      (const :tag "Package AucTeX" auctex)
=09=09      (const :tag "Package RefTeX" reftex)
=09=09      (const :tag "Package bib-cite" bib-cite))))

(defvar x-symbol-orig-comint-input-sender 'comint-simple-send
  "Original function which sends a string to the comint process.")


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Determine Locale
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defun x-symbol-coding-system-from-locale ()
  ;; See also EMACS/lisp/international/mule-cmds.el, `set-locale-environm=
ent'.
  "Get value for `x-symbol-default-coding' from locale.
Use \"locale -ck code_set_name charmap\" and search for the value of
\"code_set_name\" or \"charmap\"."
  (save-excursion
    (set-buffer (get-buffer-create " *x-symbol-coding-system-from-locale*=
"))
    (erase-buffer)
    (call-process shell-file-name nil t nil shell-command-switch
=09=09  "locale -ck code_set_name charmap")
    (goto-char (point-min))

    (let* ((case-fold-search t)
=09   ;; The GNU recode manual (www-find "recode charset iso646"), lists =
a
=09   ;; lot of aliases, there are a bit less on
=09   ;; http://mail.nl.linux.org/linux-utf8/2001-10/msg00072.html, I
=09   ;; added some.  But this function shouldn't exceed 40 lines...
=09   (map '((iso-8859-1
=09=09   "iso-8859-1" "iso8859-1" "iso88591" ; HP: iso88591
=09=09   ;; vendor-specific, supersets of ascii
=09=09   "roman8"=09=09; HP: roman8
=09=09   ;; ascii
=09=09   "ascii" "us-ascii" "ansi_x3.4-1968" "646" "iso646"
=09=09   "iso_646.irv")
=09=09  (iso-8859-2
=09=09   "iso-8859-2" "iso8859-2" "iso88592") ; HP: iso88592
=09=09  (iso-8859-3
=09=09   "iso-8859-3" "iso8859-3" "iso88593") ; HP: iso88593
=09=09  (iso-8859-9
=09=09   "iso-8859-9" "iso8859-9" "iso88599")
=09=09  (iso-8859-15
=09=09   "iso-8859-15" "iso8859-15" "iso885915"))) ; HP: iso885915
=09   (charmap (and (re-search-forward "^[ \t]*\\(code_set_name\\|charmap=
\\)[ \t]*=3D[ \t]*\"\\([^\n\"]+\\)\"" nil t)
=09=09=09 (find (downcase (match-string 2)) map
=09=09=09       :test 'member))))
      (kill-buffer (current-buffer))
      (car charmap))))

(defvar x-symbol-default-coding
  (cond (noninteractive 'iso-8859-1)
=09((x-symbol-coding-system-from-locale))
=09(t
=09 (warn "X-Symbol: cannot deduce default encoding, I'll assume `iso-885=
9-1'")
=09 'iso-8859-1))
  "Coding used for 8bit characters in buffers.
Also used for a 8bit file codings where `x-symbol-coding' has value nil.
Supported values are `iso-8859-1', `iso-8859-2', `iso-8859-3' and
`iso-8859-9', it should correspond to the normal charset registry of
your `default' face.

WARNING: Under XEmacs/Mule, package x-symbol is only tested with value
`iso-8859-1'!  It is assumed that you have not changed any of the
various Mule codings-system variables, i.e., it assumes iso-8859-1.  Use
\\[x-symbol-package-bug] to give the author some advice on Mule.")

(unless (or (memq x-symbol-default-coding
=09=09  '(iso-8859-1 iso-8859-2 iso-8859-3 iso-8859-9))
=09    (and (eq x-symbol-default-coding 'iso-8859-15)
=09=09 (or (not (featurep 'xemacs))
=09=09     (not (featurep 'mule))
=09=09     (fboundp 'emacs-version>=3D) (emacs-version>=3D 21 5))))
  (warn "X-Symbol: illegal `x-symbol-default-coding', I'll use `iso-8859-=
1'")
  (setq x-symbol-default-coding 'iso-8859-1))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  General Configuration
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defvar x-symbol-after-init-input-hook nil
  "Hook run after the initialization of all input methods.
See `x-symbol-init-input'.  If you want define key bindings starting
with \\[x-symbol-map], do it here.  It is a bad idea to use this for
additional self insert commands, use \"character descriptions\" in
`x-symbol-user-table' instead.")

(add-hook 'x-symbol-after-init-input-hook 'x-symbol-init-default-keys)

(defcustom x-symbol-compose-key '(control ?\=3D)
  "Key used to access command `x-symbol-map'.
By default, pressing this key twice invokes the GRID: \\[x-symbol-grid].
This is a list, no vector!"
  :group 'x-symbol-input-init
  :type '(x-symbol-key :tag "Prefix key"))


(defcustom x-symbol-auto-key-autoload t
  "*If non-nil, pressing `x-symbol-compose-key' initialize x-symbol.
The binding of `x-symbol-compose-key' is redefined after initialization.
With value nil, you must provide a prefix argument to initialize package
X-Symbol."
  :group 'x-symbol-input-init
  :type 'boolean)

(defvar x-symbol-auto-conversion-method 'auto-slow
  ;;(if (featurep 'crypt) 'slow 'fast)
  "Non-nil means, set up hooks for auto conversion.
Fast methods are used if this variable has value `fast'.  Otherwise,
slower methods are used and \\[vc-register] or \\[vc-next-action] will
fail to decode the buffer contents.

You should set this variable to value `slowest' if, for example, the
symbol for \\alpha looks like \\233a after \\[save-buffer] (this happens
on some systems).  Value `fast' should not be used, if some other
package, e.g., crypt, adds a function to `write-file-hooks' which does
not inspect the remaining functions in this hook.

Default value `auto-slow' is set to `fast' after the initialization of
XEmacs if package crypt has not been loaded by then.")


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Known Token Languages
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defvar x-symbol-language-alist nil
  "Alist of currently registered token languages.
Elements look like (LANGUAGE . NAME) where LANGUAGE is the symbol
representing and NAME is the name normally presented to the user,
see `x-symbol-language-text'.

You should not set this variable directly, use
`x-symbol-register-language' instead!")

(defcustom x-symbol-charsym-name "x-symbol charsym"
  "Name of the pseudo token language x-symbol charsym.
This pseudo language corresponds to `x-symbol-language' having value nil
and is used for input methods, not for decoding and encoding.  See
`x-symbol-language-text'."
  :group 'x-symbol-miscellaneous
  :type 'string)

(defcustom x-symbol-tex-name "TeX macro"
  "Name of token language `tex'.  See `x-symbol-register-language'."
  :group 'x-symbol-tex
  :type 'string)

(defcustom x-symbol-tex-modes
  '(tex-mode latex-mode plain-tex-mode noweb-mode)
  "Major modes using language `tex'.  See `x-symbol-register-language'."
  :group 'x-symbol-tex
  :group 'x-symbol-mode
  :type '(repeat function))

(defcustom x-symbol-sgml-name "SGML entity"
  "Name of token language `sgml'.  See `x-symbol-register-language'."
  :group 'x-symbol-sgml
  :type 'string)

(defcustom x-symbol-sgml-modes '(sgml-mode html-mode)
  "Major modes using language `sgml'.  See `x-symbol-register-language'."
  :group 'x-symbol-sgml
  :group 'x-symbol-mode
  :type '(repeat function))

(defcustom x-symbol-haskell-name "HASKELL entity"
  "Name of token language `haskell'.  See `x-symbol-register-language'."
  :group 'x-symbol-haskell
  :type 'string)

(defcustom x-symbol-haskell-modes '(haskell-mode)
  "Major modes using language `haskell'.  See `x-symbol-register-language=
'."
  :group 'x-symbol-haskell
  :group 'x-symbol-mode
  :type '(repeat function))


(defcustom x-symbol-texi-name "TeXinfo command"
  "Name of token language `tex'.  See `x-symbol-register-language'."
  :group 'x-symbol-texi
  :type 'string)

(defcustom x-symbol-texi-modes '(texinfo-mode)
  "Major modes using language `texi'.  See `x-symbol-register-language'."
  :group 'x-symbol-texi
  :group 'x-symbol-mode
  :type '(repeat function))

(defcustom x-symbol-bib-name "BibTeX macro"
  "Name of token language `bib'.  See `x-symbol-register-language'."
  :group 'x-symbol-bib
  :type 'string)

(defcustom x-symbol-bib-modes '(bibtex-mode)
  "Major modes using language `bib'.  See `x-symbol-register-language'."
  :group 'x-symbol-bib
  :group 'x-symbol-mode
  :type '(repeat function))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Buffer-locals
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defvar x-symbol-mode nil
  "Non-nil if X-Symbol minor mode is enabled.")

(make-variable-buffer-local 'x-symbol-mode)
(x-symbol-define-user-options 'x-symbol-mode '(t)
  nil (lambda (dummy arg) (x-symbol-mode (if arg 1 0))))

(defvar x-symbol-language nil
  "*Token language used in current buffer.
A valid value is required to turn on `x-symbol-mode' which also sets
this variable to a reasonable value if the variable is not yet
buffer-local.  The value influences the conversion, i.e., decoding and
encoding of X-Symbol characters, input methods TOKEN and READ-TOKEN,
fontification of super- and subscripts, image command recognition, the
info in the echo area, etc.")

(make-variable-buffer-local 'x-symbol-language)
(put 'x-symbol-language 'permanent-local t)
(x-symbol-define-user-options 'x-symbol-language
    (lambda () (list* nil '(nil . "None") x-symbol-language-alist))
  '(x-symbol-update-modeline))

(defvar x-symbol-coding nil
  "*Coding of 8bit characters in a file.
Supported values are `iso-8859-1', `iso-8859-2', `iso-8859-3' and
`iso-8859-9', value nil means the value of `x-symbol-default-coding'.
Determines which characters are considered to be 8bit characters for
file operations.  Function `x-symbol-mode' sets this variable to a
reasonable value if the variable is not yet buffer-local.

During decoding, e.g., when visiting a file, the value is always
important for the interpretation of 8bit characters, an invalid value is
considered to be equivalent to value nil.  During encoding, e.g., when
saving a buffer, 8bit characters are not encoded to tokens if the value
is valid and `x-symbol-8bits' is non-nil.")

(make-variable-buffer-local 'x-symbol-coding)
(put 'x-symbol-coding 'permanent-local t)
(x-symbol-define-user-options 'x-symbol-coding
    (lambda () (cons x-symbol-default-coding x-symbol-coding-name-alist))
  '(x-symbol-update-modeline))

(defvar x-symbol-8bits nil
  "*If non-nil, do not encode 8bit characters.
Variable `x-symbol-coding' determines which characters are assumed to be
8bit characters.  Note that tokens representing 8bit characters are
always decoded.  Function `x-symbol-mode' sets this variable to a
reasonable value if the variable is not yet buffer-local.")
;; TODO: link to `x-symbol-unique'

(make-variable-buffer-local 'x-symbol-8bits)
(put 'x-symbol-8bits 'permanent-local t)
(x-symbol-define-user-options 'x-symbol-8bits '(t)
  '(x-symbol-update-modeline))

(defvar x-symbol-unique nil
  "*If non-nil, only decode canonical tokens.")
;; TODO: link to `x-symbol-8bits'

(make-variable-buffer-local 'x-symbol-unique)
(put 'x-symbol-unique 'permanent-local t)
(x-symbol-define-user-options 'x-symbol-unique '(t)
  '(x-symbol-update-modeline))

(defvar x-symbol-subscripts nil
  "*If non-nil, use special fonts to display super- and subscripts.
This feature must be supported by the token language dependent font-lock
keywords.  Function `x-symbol-mode' sets this variable to a reasonable
value if the variable is not yet buffer-local.  Some parts of the text
might be invisible, see also variable `x-symbol-reveal-invisible'.")

(make-variable-buffer-local 'x-symbol-subscripts)
(x-symbol-define-user-options 'x-symbol-subscripts '(t)
  '(x-symbol-update-modeline x-symbol-fontify))

(defvar x-symbol-image nil
  "*If non-nil, show little glyphs after image insertion commands.
This feature must be supported by the token language dependent image
keywords, see `x-symbol-image-parse-buffer'.  Function `x-symbol-mode'
sets this variable to a reasonable value if the variable is not yet
buffer-local.")

(make-variable-buffer-local 'x-symbol-image)
(x-symbol-define-user-options 'x-symbol-image '(t)
  '(x-symbol-update-modeline) 'x-symbol-set-image)


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Minor mode control
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defcustom x-symbol-buffer-mode-alist nil
  "*Alist to setup x-symbol values for specific buffers.
Elements look like
   (BUFFER-NAME MODE-ON LANGUAGE CODING 8BIT SUBSCRIPTS IMAGE UNIQUE)
If the name of the buffer in which command `x-symbol-mode' is invoked is
equal to BUFFER, the rest of the element is used to setup some
buffer-local x-symbol specific variables, see `x-symbol-auto-mode-alist'
for details.  MODE-ON is used directly as the value."
  :group 'x-symbol-mode
  :type '(repeat (group (string :tag "Use for buffer")
=09=09=09(x-symbol-auto-mode :inline t))))

(defcustom x-symbol-auto-mode-suffixes (x-symbol-auto-mode-suffixes)
  "*Regexps matching file suffixes not to be considered.
All suffixes from a file name matching these regexps are deleted before
the file name is used for `x-symbol-auto-mode-alist'.  The default value
includes the REGEXP in all three-valued elements of `auto-mode-alist',
at definition time, of course."
  :group 'x-symbol-mode
  :type '(repeat regexp))

(defcustom x-symbol-auto-8bit-search-limit nil
  "*Limits searching for 8bit characters in the file.
Used when finding an appropriate value for `x-symbol-8bits'.  See also
`x-symbol-mode'."
  :group 'x-symbol-mode
  :type '(choice (const :tag "No limit" nil) (integer :tag "Limit")))


(defcustom x-symbol-auto-mode-alist
  '(((tex-mode latex-mode plain-tex-mode) "\\.tex\\'" 'tex
     (if x-symbol-mode
=09 (x-symbol-auto-coding-alist x-symbol-tex-auto-coding-alist nil
=09=09=09=09     (if x-symbol-tex-coding-master
=09=09=09=09=09 'x-symbol-tex-auto-coding-alist)))
     x-symbol-coding
     x-symbol-mode x-symbol-mode
     (not x-symbol-mode))
    ((sgml-mode html-mode) (html-mode) 'sgml
     (x-symbol-auto-coding-alist x-symbol-sgml-auto-coding-alist)
     x-symbol-coding
     x-symbol-mode x-symbol-mode
     (not x-symbol-mode))
    ((bibtex-mode) t 'bib)
    ((texinfo-mode) t 'texi))
  "*Alist to setup X-Symbol values for buffers visiting files.
Elements look like
  (MATCH MODE-ON LANGUAGE CODING 8BIT SUBSCRIPTS IMAGE UNIQUE)
If MATCH matches a buffer in which command `x-symbol-mode' is invoked,
the rest of the element is used to setup some buffer-local x-symbol
specific variables.  If no element matches, set `x-symbol-language' to
the symbol property `x-symbol-language' of the major mode symbol if the
variable is not already buffer-local.

If `x-symbol-mode' is not already buffer-local, MODE-ON determines
whether to turn the mode on if `x-symbol-mode' is called with a cons as
prefix argument.  LANGUAGE, CODING, 8BIT, UNIQUE, SUBSCRIPTS and IMAGE
are used to set `x-symbol-language', `x-symbol-coding',
`x-symbol-8bits', `x-symbol-unique', `x-symbol-subscripts' and
`x-symbol-image' if these values are not already buffer-local.

MATCH and MODE-ON are either a list of major modes which must include
the mode of the current buffer or a regexp matching the file name
ignoring some suffixes, see `x-symbol-auto-mode-suffixes', or a value
used directly.  LANGUAGE, CODING, 8BIT, UNIQUE, SUBSCRIPTS and IMAGE are
`eval'ed in that order.  During the evaluation, `x-symbol-mode' is
non-nil according to MODE-ON."
  ;; UNIQUE is at the end due to historic reasons
  :group 'x-symbol-mode
  :type '(repeat (group (x-symbol-modes-or-regexp :tag "Use")
=09=09=09(x-symbol-auto-mode :inline t))))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Images
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defun x-symbol-image-set-colormap (var value)
  "Set VAR's value to VALUE.
Custom set function of `x-symbol-image-colormap-allocation' and
`x-symbol-image-convert-colormap'."
  (if var (set var value))
  (if (boundp 'x-symbol-image-convert-colormap)
      (put 'x-symbol-image-convert-colormap 'x-symbol-image-instance
=09   (and (boundp 'x-symbol-image-colormap-allocation)
=09=09x-symbol-image-colormap-allocation
=09=09x-symbol-image-convert-colormap
=09=09(if (featurep 'xemacs)
=09=09    (make-image-instance
=09=09     (vector x-symbol-image-colormap-allocation
=09=09=09     :file x-symbol-image-convert-colormap)
=09=09     nil nil t)
=09=09  (create-image x-symbol-image-convert-colormap
=09=09=09=09x-symbol-image-colormap-allocation))))))

(defcustom x-symbol-image-colormap-allocation 'xpm
  "If non-nil, prevent colors in colormap to be de-allocated.
The non-nil value should be an image format.  See
`x-symbol-image-convert-colormap'."
  :group 'x-symbol-image-general
  :initialize 'custom-initialize-default
  :set 'x-symbol-image-set-colormap
  :type '(choice (const :tag "Colors can be de-allocated" nil)
=09=09 (const :tag "Colormap is xpm file" xpm)
=09=09 (symbol :tag "Other image format")))

(defcustom x-symbol-image-convert-colormap
  (and x-symbol-data-directory
       (expand-file-name "colormap138.xpm" x-symbol-data-directory))
  "File name of colormap files.
Used by `x-symbol-image-start-convert-colormap' for image cache file
names not matched by `x-symbol-image-convert-mono-regexp'.  See also
`x-symbol-image-colormap-allocation'."
  :group 'x-symbol-image-general
  :initialize 'custom-initialize-default
  :set 'x-symbol-image-set-colormap
  :type '(choice (const :tag "No map" nil) file))


=0C
;;;;#####################################################################=
#####
;;;;  Code
;;;;#####################################################################=
#####


(defalias 'x-symbol-cset-registry 'caaar)
(defalias 'x-symbol-cset-coding 'cdaar)
(defalias 'x-symbol-cset-leading 'cadar)
(defalias 'x-symbol-cset-score 'caddar)
(defalias 'x-symbol-cset-left 'cadr)
(defalias 'x-symbol-cset-right 'cddr)

(defvar x-symbol-input-initialized nil
  "Internal.  If non-nil, the input methods are initialized.")


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Key autoload
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

;;;###autoload
(defun x-symbol-key-autoload (&optional arg)
  "Initialize package x-symbol and use the keys for this command again.
Package x-symbol and the functions in `x-symbol-load-hook' should
re-bind all key-sequence which invoke this command.  You should provide
a prefix argument ARG to this command if `x-symbol-auto-key-autoload' is
nil."
  (interactive "P")
  (when x-symbol-input-initialized
    (error "%s should be rebound in `x-symbol-init-input-hook'"
=09   (key-description (this-command-keys))))
  (unless (or arg x-symbol-auto-key-autoload)
    (error "Use %s with prefix argument to initialize the input methods"
=09   (key-description (this-command-keys))))
  (let ((this (append (this-command-keys) nil)))
    ;; for some reason this loop is necessary...
    (while (and this (null (eq (key-binding (vector (car this))) this-com=
mand)))
      (setq this (cdr this)))
    (setq prefix-arg arg)
    (setq unread-command-events this))
  (x-symbol-init-input))

;;;###autoload
(defalias 'x-symbol-map-autoload 'x-symbol-key-autoload)


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Minor mode, fontification
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defun x-symbol-auto-mode-alist ()
  "Compute values to setup X-Symbol variables."
  (let ((name (file-name-sans-versions buffer-file-name))
=09(case-fold-search (eq system-type 'vax-vms))
=09(suffixes x-symbol-auto-mode-suffixes)
=09(alist x-symbol-auto-mode-alist)
=09matcher result)
    (while suffixes
      (if (string-match (pop suffixes) name)
=09  (setq name (substring name 0 (match-beginning 0)))))
    (while alist
      (if (if (consp (setq matcher (caar alist)))
=09      (memq major-mode matcher)
=09    (if (stringp matcher) (string-match matcher name) matcher))
=09  (setq result (cdar alist)
=09=09result (cons (if (consp (setq matcher (car result)))
=09=09=09=09 (memq major-mode matcher)
=09=09=09       (if (stringp matcher)
=09=09=09=09   (string-match matcher name)
=09=09=09=09 matcher))
=09=09=09     (cdr result))
=09=09alist nil)
=09(setq alist (cdr alist))))
    result))

(defun x-symbol-auto-set-variable (symbol form)
  "Set SYMBOL's value to evaluated FORM if SYMBOL is not buffer-local."
  (or (local-variable-p symbol (current-buffer))
      (set symbol (eval form))))

;;;###autoload
(defun x-symbol-mode (&optional arg init)
  "Toggle X-Symbol mode.
If ARG is a cons, e.g., when \\[x-symbol-mode] is preceded by one or
more \\[universal-argument]'s with no digits, turn on X-Symbol mode
conditionally, see MODE-ON in `x-symbol-auto-mode-alist'.  Otherwise,
turn X-Symbol mode on if ARG is positive, else turn it off.  If some
X-Symbol specific local variables are not buffer-local, set them to
reasonable values according to `x-symbol-buffer-mode-alist' and
`x-symbol-auto-mode-alist'.

Turning X-Symbol mode on requires a valid `x-symbol-language' and also
decodes tokens if the mode was turned off before, see
\\[x-symbol-decode].  Turning X-Symbol mode off also encodes x-symbol
characters if the mode was turned on before, see \\[x-symbol-encode].
If argument INIT is non-nil, the old mode status is assumed to be off."
  (interactive "P")
  (let ((old-mode x-symbol-mode)
=09(values (or (cdr (assoc (buffer-name) x-symbol-buffer-mode-alist))
=09=09    (and buffer-file-name (x-symbol-auto-mode-alist))
=09=09    (get major-mode 'x-symbol-language))))
    (when values
      (if (symbolp values) (setq values (list nil (list 'quote values))))
      (let ((x-symbol-mode (car values)))
=09;; bind value for functions in `x-symbol-auto-mode-alist'
=09(x-symbol-auto-set-variable 'x-symbol-language (cadr values))
=09(x-symbol-auto-set-variable 'x-symbol-coding (caddr values))
=09(or (local-variable-p 'x-symbol-8bits (current-buffer))
=09    (setq x-symbol-8bits (or (eval (cadddr values))
=09=09=09=09     (x-symbol-auto-8bit-search))
=09=09  ;; use value `null' to disable 8bit char search
=09=09  x-symbol-8bits (and (not (eq x-symbol-8bits 'null))
=09=09=09=09      x-symbol-8bits)))
=09(x-symbol-auto-set-variable 'x-symbol-unique (nth 6 values))
=09(x-symbol-auto-set-variable 'x-symbol-subscripts (nth 4 values))
=09(x-symbol-auto-set-variable 'x-symbol-image (nth 5 values))))
    (or (null x-symbol-language)=09; e.g., not buffer-local
=09(and (symbolp x-symbol-language)
=09     (get x-symbol-language 'x-symbol-feature))
=09(setq x-symbol-language nil))
    (setq x-symbol-mode
=09  (if arg
=09      (if (consp arg)
=09=09  (if (local-variable-p 'x-symbol-mode (current-buffer))
=09=09      (and x-symbol-mode t)
=09=09    (car values))
=09=09(> (prefix-numeric-value arg) 0))
=09    (not x-symbol-mode)))
    (when (and x-symbol-mode (null x-symbol-language))
      (setq x-symbol-mode nil)
      (or init
=09  (not (interactive-p))
=09  (if (setq x-symbol-language
=09=09    (x-symbol-read-language
=09=09     "Token Language for X-Symbol mode: " nil 'cdr))
=09      (setq x-symbol-mode t)
=09    (error "A valid token language is required to turn on X-Symbol")))=
)
    (if (assq 'x-symbol format-alist)
=09(if x-symbol-mode
=09    (push 'x-symbol buffer-file-format)
=09  (setq buffer-file-format (delq 'x-symbol buffer-file-format))))
    (if init
=09(if x-symbol-mode (x-symbol-mode-internal t))
      (x-symbol-mode-internal (and x-symbol-language
=09=09=09=09   (eq (null old-mode) x-symbol-mode))))))

;;;###autoload
(defun turn-on-x-symbol-conditionally ()
  "Turn on x-symbol mode conditionally, see `x-symbol-mode'.
Call `x-symbol-mode' with a cons for ARG and a non-nil INIT.  Used in
`hack-local-variables-hook'."
  (if (if (local-variable-p 'x-symbol-mode (current-buffer)) x-symbol-mod=
e t)
      (x-symbol-mode '(1) t)))

;;;###autoload
(defun x-symbol-fontify (&optional beg end)
  "Re-fontify region between BEG and END."
  (interactive (and (region-active-p) (list (region-beginning) (region-en=
d))))
  (cond ((not font-lock-mode) (turn-on-font-lock))
=09((and (boundp 'lazy-shot-mode) lazy-shot-mode)
=09 ;; copied from lazy-shot:
=09 (setq font-lock-fontified
=09       (and lazy-shot-minimum-size
=09=09    (>=3D (buffer-size) lazy-shot-minimum-size)))
=09 (if (fboundp 'lazy-shot-after-change-function)
=09     ;; No, I'm not using `compiled-function-arglist' instead...
=09     (lazy-shot-install-extents (point-min) (point-max)=09; XEmacs-20.=
4
=09=09=09=09=09font-lock-fontified)
=09   (lazy-shot-install-extents font-lock-fontified))) ; XEmacs-20.3
=09((and (boundp 'lazy-lock-mode) lazy-lock-mode)
=09 ;; copied from lazy-lock:
=09 (let ((modified (buffer-modified-p)) (inhibit-read-only t)
=09       (buffer-undo-list t)
=09       ;;deactivate-mark
=09       buffer-file-name buffer-file-truename)
=09   (remove-text-properties (or beg 1) (or end (1+ (buffer-size)))
=09=09=09=09   '(fontified nil))
=09   (or modified (set-buffer-modified-p nil))))
=09(t
=09 (font-lock-fontify-buffer))))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  comint support
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defun x-symbol-comint-output-filter (dummy)
  ;; checkdoc-params: (dummy)
  "Decode output of comint's process.
Used as value in `comint-output-filter-functions'."
  (and x-symbol-mode x-symbol-language
       (save-excursion
=09 (x-symbol-decode-region (if (interactive-p)
=09=09=09=09     comint-last-input-end
=09=09=09=09   comint-last-output-start)
=09=09=09=09 (process-mark (get-buffer-process
=09=09=09=09=09=09(current-buffer)))))))

(defun x-symbol-comint-send (proc string)
  "Encode STRING and send it to process PROC.
Used as value of `comint-input-sender', uses
`x-symbol-orig-comint-input-sender'."
  (and x-symbol-mode x-symbol-language
       (setq string
=09     (save-excursion
=09       (let ((orig-buffer (current-buffer))
=09=09     (selective selective-display))
=09=09 (set-buffer (get-buffer-create " x-symbol comint"))
=09=09 (erase-buffer)
=09=09 (insert string)
=09=09 (x-symbol-inherit-from-buffer orig-buffer)
=09=09 (x-symbol-encode-all)
=09=09 (setq selective-display selective))
=09=09 (buffer-string))))
  (funcall x-symbol-orig-comint-input-sender proc string))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Hooks for automatic conversion
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

;; For format fns: check whether read-only stuff is still necessary...

(defun x-symbol-format-decode (start end)
  (if (and x-symbol-mode x-symbol-language)
      (save-restriction
=09(let ((modified (buffer-modified-p)) ; t if `recover-file'!
=09      ;;(buffer-undo-list t) ; do not record changes
=09      ;; we cannot set buffer-undo-list to t even if the previous
=09      ;; value is nil because M-x insert-file as the first command
=09      ;; after reading a file would set the old insert-region
=09      ;; boundaries into the undo-list
=09      (buffer-read-only nil) ; always allow conversion
=09      (inhibit-read-only t)
=09      (first-change-hook nil) ; no `flyspell-mode' here
=09      (after-change-functions nil)) ; no fontification
;;;=09  (and orig-buffer
;;;=09       (not (eq (current-buffer) orig-buffer))
;;;=09       (x-symbol-inherit-from-buffer orig-buffer))
=09  (x-symbol-decode-all)
=09  (or modified (set-buffer-modified-p nil))
=09  (point-max)))
    end))

(defun x-symbol-format-encode (start end orig-buffer)
  (let ((new-buffer (current-buffer)))
    (if (eq new-buffer orig-buffer)
=09(and x-symbol-mode x-symbol-language
=09     (save-restriction
=09       (narrow-to-region start end)
=09       (x-symbol-encode-all)))
      (set-buffer orig-buffer)
      (and x-symbol-mode x-symbol-language
=09   (let ((selective selective-display))
=09     (x-symbol-encode-all new-buffer)
=09     ;; set `selective-display' according to orig buffer
=09     (setq selective-display selective))))))

(defun x-symbol-after-insert-file (len)
  ;; checkdoc-params: (len)
  "Decode tokens, e.g., after \\[vc-register] or \\[vc-next-action].
Added to `after-insert-file-functions' if
`x-symbol-auto-conversion-method' has value `fast'."
  ;; Arg!  In XEmacs, there is no way to know the start position of the r=
egion.
  ;; If `insert-file-contents' is called with argument REPLACE being non-=
nil,
  ;; it is not always point.  Thus, we use `point-min', except when calle=
d from
  ;; `M-x insert-file'.
  (and x-symbol-mode x-symbol-language
       (let ((insert-file-p (or (eq this-command 'insert-file)
=09=09=09=09(and (memq this-command
=09=09=09=09=09   '(minibuffer-complete-and-exit
=09=09=09=09=09     exit-minibuffer))
=09=09=09=09     (eq (car-safe (car command-history))
=09=09=09=09=09 'insert-file)))))
=09 (when (or (null insert-file-p)
=09=09   (<=3D (+ (point) len) (point-max)))
=09   (save-restriction
=09     (if insert-file-p (narrow-to-region (point) (+ (point) len)))
=09     (let ((origpos (point))
=09=09   (modified (buffer-modified-p)) ; t if `recover-file'!
=09=09   ;;(buffer-undo-list t) ; do not record changes
=09=09   ;; we cannot set buffer-undo-list to t even if the previous
=09=09   ;; value is nil because M-x insert-file as the first command
=09=09   ;; after reading a file would set the old insert-region
=09=09   ;; boundaries into the undo-list
=09=09   (buffer-read-only nil) ; always allow conversion
=09=09   (inhibit-read-only t)
=09=09   (first-change-hook nil) ; no `flyspell-mode' here
=09=09   (after-change-functions nil)) ; no fontification
=09       (x-symbol-decode-all)
=09       (goto-char origpos)
=09       (or modified (set-buffer-modified-p nil))
=09       ;; `len' is utterly wrong when not called in `insert-file',
=09       ;; but there is no chance to get it right if we don't know the
=09       ;; start position, see above.
=09       (setq len (- (point-max) (point-min))))))))
  len)

(defun x-symbol-write-region-annotate-function (start end)
  ;; checkdoc-params: (start end)
  "Encode x-symbol characters using another buffer.
Added to `write-region-annotate-functions' if
`x-symbol-auto-conversion-method' has value `fast'."
  (and x-symbol-mode x-symbol-language
       (not (equal start ""))=09=09; kludgy feature of `write-region'
       ;; Without the test, "x-symbol.el" is loaded twice, the initializa=
tion
       ;; done twice (resulting in warnings about charsym redefinitions).
       ;; Reason: in Emacs, `make-temp-name', used for the value of some =
var in
       ;; "x-symbol-vars.el", required by "x-symbol.el", calls `write-reg=
ion'.
       (let ((selective selective-display))
=09 (x-symbol-encode-all (get-buffer-create " x-symbol conversion")
=09=09=09      start end)
=09 ;; set `selective-display' according to orig buffer
=09 (setq selective-display selective)))
  nil)

(defun x-symbol-write-file-hook ()
  "Encode x-symbol characters in current buffer.
Added to `write-file-hooks' if `x-symbol-auto-conversion-method' has a
value other than nil or `fast'.  Refontifies buffer if
`x-symbol-auto-conversion-method' has value `slowest'."
  (and x-symbol-mode x-symbol-language
      (let ((buffer-read-only nil)
=09    (first-change-hook nil)=09; no `flyspell-mode' here
=09    (after-change-functions nil)) ; no fontification!
=09(widen)
=09;; Called inside `save-recursion' and `save-restriction'.
=09(call-with-transparent-undo
=09 (lambda ()
=09   (x-symbol-encode-all)=09; not the safe version!
=09   (continue-save-buffer)))
=09(and (eq x-symbol-auto-conversion-method 'slowest)
=09     font-lock-mode
=09     (x-symbol-fontify))
=09(set-buffer-modified-p nil)
=09'x-symbol-write-file-hook)))=09; do not write again


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Init
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defvar x-symbol-modeline-string ""
  "String that should appear in the modeline when `x-symbol-mode' is on.
Its value is set by `x-symbol-update-modeline'.")
(make-variable-buffer-local 'x-symbol-modeline-string)

(defvar x-symbol-mode-map
  (let ((m (make-sparse-keymap)))
    ;; (substitute-key-definition 'x-symbol-map-autoload 'x-symbol-map
    ;; =09=09=09       m global-map)
    m))

(add-minor-mode 'x-symbol-mode 'x-symbol-modeline-string x-symbol-mode-ma=
p)
(put 'x-symbol-mode :menu-tag "X-Symbol")

(defun x-symbol-init-language-accesses (language alist)
  "Initialize accesses for token language LANGUAGE according to ALIST.
The symbol property `x-symbol-feature' of LANGUAGE must be set before.
See also `x-symbol-language-access-alist'."
  ;;If optional NO-TEST is nil, accesses which do not point to a bound
  ;;variable are not set.
  (let ((feature (get language 'x-symbol-feature))
=09symbol)
    (unless feature
      (error "Illegal X-Symbol token language `%s'" language))
    (dolist (item alist)
      (and (null (get language (car item)))
=09   (stringp
=09    (setq symbol (if (consp (cdr item))
=09=09=09     (if (featurep 'mule) (cadr item) (cddr item))
=09=09=09   (cdr item))))
=09   (setq symbol (intern (format "%s-%s" feature symbol)))
=09   (or (boundp symbol)
=09       (progn (warn "X-Symbol language %s forgot to define `%s'"
=09=09=09    language symbol)
=09=09      nil))
=09   (put language (car item) symbol)))))

;;;###autoload
(defun x-symbol-register-language (language feature modes)
  "Register token language LANGUAGE.
FEATURE is a feature which `provide's LANGUAGE.  MODES are major modes
which typically use LANGUAGE.  Using LANGUAGE's accesses will initialize
LANGUAGE, see `x-symbol-language-value'."
  (unless (get language 'x-symbol-feature)
    (put language 'x-symbol-feature feature))
  (x-symbol-init-language-accesses language '((x-symbol-name . "name")))
  (unless (assq language x-symbol-language-alist)
    (setq x-symbol-language-alist
=09  (nconc x-symbol-language-alist
=09=09 (list (cons language
=09=09=09     (symbol-value (get language 'x-symbol-name)))))))
  (dolist (mode modes)
    (put mode 'x-symbol-language language)
    (put mode 'x-symbol-font-lock-language language)))

;;;###autoload
(defun x-symbol-initialize (&optional arg)
  "Initialize package X-Symbol.
See variable `x-symbol-initialize' and function `x-symbol-after-init'.
Also allocate colormap, see `x-symbol-image-colormap-allocation'.
Unless optional argument ARG is non-nil, do not initialize package
X-Symbol twice."
  (interactive "P")
  (unless (and (get 'x-symbol 'x-symbol-initialized) (null arg))
    (put 'x-symbol 'x-symbol-initialized t)
    ;; X-Symbol doesn't make sense without the following.  `ctl-arrow' is=
 a
    ;; boolean in Emacs, but not in XEmacs: despite its docstring, value =
t
    ;; means the same as 256 (and 255 sometimes, which is probably wrong)=
=2E
    (or (default-value 'ctl-arrow) (setq-default ctl-arrow 'iso-8859/1))
    ;; Token languages --------------------------------------------------=
-----
    (when (or (eq x-symbol-initialize t)
=09      (memq 'languages x-symbol-initialize))
      (x-symbol-register-language 'tex 'x-symbol-tex x-symbol-tex-modes)
      (x-symbol-register-language 'sgml 'x-symbol-sgml x-symbol-sgml-mode=
s)
      (x-symbol-register-language 'haskell 'x-symbol-haskell x-symbol-has=
kell-modes)
      (x-symbol-register-language 'bib 'x-symbol-bib x-symbol-bib-modes)
      (x-symbol-register-language 'texi 'x-symbol-texi x-symbol-texi-mode=
s))
    ;; Global mode ------------------------------------------------------=
-----
    (when (or (eq x-symbol-initialize t)
=09      (memq 'global x-symbol-initialize))
      (add-hook 'hack-local-variables-hook 'turn-on-x-symbol-conditionall=
y))
    ;; Key bindings -----------------------------------------------------=
-----
    (when (or (eq x-symbol-initialize t)
=09      (memq 'keys x-symbol-initialize))
      (global-set-key (vector x-symbol-compose-key) 'x-symbol-map-autoloa=
d)
      (unless (featurep 'xemacs)
=09(define-key isearch-mode-map (vector x-symbol-compose-key) nil)
=09(define-key isearch-mode-map [menu-bar X-Symbol] nil))
      (global-set-key [(control ?\,)] 'x-symbol-modify-key)
      (global-set-key [(control ?\.)] 'x-symbol-rotate-key))
    ;; Font path --------------------------------------------------------=
-----
    (and (or (eq x-symbol-initialize t)
=09     (memq 'font-path x-symbol-initialize))
=09 x-symbol-font-directory
=09 (file-accessible-directory-p x-symbol-font-directory)
=09 ;; by Jim Radford <radford@robby.caltech.edu>:
=09 (eq (console-type) 'x)
=09 (if (fboundp 'x-set-font-path)
=09     (let ((font-path (x-get-font-path)))
=09       (unless (member x-symbol-font-directory font-path)
=09=09 (x-set-font-path (nconc font-path
=09=09=09=09=09 (list x-symbol-font-directory)))))
=09   ;; This should be commented out until I can figure out how to
=09   ;; get the display name into the -display arg for xset.
=09   (with-temp-buffer
=09     (call-process "xset" nil t nil "q")
=09     (goto-char (point-min))
=09     (unless (search-forward x-symbol-font-directory nil t)
=09       (call-process "xset" nil nil nil "fp+"
=09=09=09     x-symbol-font-directory)))))
    ;; Package fast-lock ------------------------------------------------=
-----
    (when (or (eq x-symbol-initialize t)
=09      (memq 'fast-lock x-symbol-initialize))
      (setq fast-lock-save-faces nil))
    ;; Package AucTeX ---------------------------------------------------=
-------
    (when (or (eq x-symbol-initialize t)
=09      (memq 'auctex x-symbol-initialize))
      (or (fboundp 'x-symbol-tex-error-location) ; esp for preview-latex
=09  (fset 'x-symbol-tex-error-location 'ignore))
      (add-hook 'TeX-translate-location-hook 'x-symbol-tex-error-location=
)
      (add-hook 'TeX-region-hook 'x-symbol-inherit-from-buffer) ; v9.8a+
      (setq LaTeX-math-insert-function 'x-symbol-auctex-math-insert)) ; v=
9.8a+
    ;; Package RefTeX ---------------------------------------------------=
-----
    (when (or (eq x-symbol-initialize t)
=09      (memq 'reftex x-symbol-initialize))
      (unless (and (boundp 'reftex-translate-to-ascii-function)
=09=09   (fboundp reftex-translate-to-ascii-function)
=09=09   (not (eq reftex-translate-to-ascii-function
=09=09=09    'reftex-latin1-to-ascii)))
=09(setq reftex-translate-to-ascii-function 'x-symbol-translate-to-ascii)=
)
      (add-hook 'reftex-pre-refontification-functions
=09=09'x-symbol-inherit-from-buffer)
      (unless (featurep 'mule)
=09;; RefTeX might be invoked from a TeX buffer without X-Symbol
=09(or (fboundp 'x-symbol-nomule-fontify-cstrings)
=09    (fset 'x-symbol-nomule-fontify-cstrings 'ignore))
=09(add-hook 'reftex-display-copied-context-hook
=09=09  'x-symbol-nomule-fontify-cstrings)))
    ;; Miscellaneous ----------------------------------------------------=
-----
    (x-symbol-image-set-colormap nil nil)
    (if init-file-loaded
=09(x-symbol-after-init)
      (add-hook 'after-init-hook 'x-symbol-after-init))))

(defun x-symbol-after-init ()
  "Late initialization for package X-Symbol.
See function `x-symbol-initialize' and variables `x-symbol-initialize'
and `x-symbol-auto-conversion-method'.  Also add elements to
`x-symbol-auto-mode-suffixes' if necessary."
  (when x-symbol-auto-conversion-method
    (and (eq x-symbol-auto-conversion-method 'auto-slow)
=09 (null (featurep 'crypt))
=09 (setq x-symbol-auto-conversion-method 'fast))
    (cond ((eq x-symbol-auto-conversion-method 'format)
=09   (or (assq 'x-symbol format-alist)
=09       (push '(x-symbol "X-Symbol" nil
=09=09=09=09x-symbol-format-decode x-symbol-format-encode
=09=09=09=09t x-symbol-mode t)
=09=09     format-alist)))
=09  ((eq x-symbol-auto-conversion-method 'fast)
=09   (add-hook 'after-insert-file-functions
=09=09     'x-symbol-after-insert-file t)
=09   (add-hook 'write-region-annotate-functions
=09=09     'x-symbol-write-region-annotate-function))
=09  (t
=09   (add-hook 'write-file-hooks 'x-symbol-write-file-hook))))
  ;; misc user additions to `auto-mode-alist':
  (setq x-symbol-auto-mode-suffixes (x-symbol-auto-mode-suffixes
=09=09=09=09     x-symbol-auto-mode-suffixes))
  ;; Package comint -----------------------------------------------------=
-----
  (when (or (eq x-symbol-initialize t)
=09    (memq 'comint x-symbol-initialize))
    (add-hook 'comint-output-filter-functions 'x-symbol-comint-output-fil=
ter)
    (and (boundp 'comint-input-sender)
=09 (not (eq comint-input-sender 'x-symbol-comint-send))
=09 (setq x-symbol-orig-comint-input-sender comint-input-sender))
    (setq comint-input-sender 'x-symbol-comint-send))
  ;; Package bib-cite: X-Symbol decoding would overwrite cite highlightin=
g with
  ;; normal installation of bib-cite ------------------------------------=
-----
  (when (and (or (eq x-symbol-initialize t)
=09=09 (memq 'bib-cite x-symbol-initialize))
=09     (or (and (boundp 'LaTeX-mode-hook)
=09=09      (memq 'turn-on-bib-cite LaTeX-mode-hook))
=09=09 (and (boundp 'latex-mode-hook)
=09=09      (memq 'turn-on-bib-cite latex-mode-hook))))
    (remove-hook 'LaTeX-mode-hook 'turn-on-bib-cite)
    (remove-hook 'latex-mode-hook 'turn-on-bib-cite)
    (add-hook 'find-file-hooks 'x-symbol-turn-on-bib-cite)))


;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
;;;  Support for other packages
;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

(defun x-symbol-inherit-from-buffer (&optional parent action)
  "Inherit X-Symbol's buffer-local variables from buffer PARENT.
Inherit `x-symbol-mode', `x-symbol-coding', `x-symbol-8bits',
`x-symbol-language', and `x-symbol-subscripts' from PARENT and set
`x-symbol-image' to nil.  If PARENT is nil, `orig-buffer' is used if
it is bound.  ACTION is ignored."
  (and (null parent) (boundp 'orig-buffer) (setq parent orig-buffer))
  ;; I don't care too much that people who use X-Symbol in the master buf=
fer,
  ;; but not in the buffer where they invoke M-x TeX-command-region from,=
 won't
  ;; have the X-Symbol characters in the "master envelope" decoded...
  (if (buffer-live-p (get-buffer parent))
      (let (mode-on coding 8bits unique language subscripts)
=09(save-excursion
=09  (set-buffer parent)
=09  (setq mode-on    x-symbol-mode
=09=09coding     x-symbol-coding
=09=098bits=09   x-symbol-8bits
=09=09unique     x-symbol-unique
=09=09language   x-symbol-language
=09=09subscripts x-symbol-subscripts))
=09(setq x-symbol-mode mode-on)
=09(if (local-variable-p 'x-symbol-coding parent)
=09    (setq x-symbol-coding coding))
=09(if (local-variable-p 'x-symbol-8bits parent)
=09    (setq x-symbol-8bits 8bits))
=09(if (local-variable-p 'x-symbol-unique parent)
=09    (setq x-symbol-unique unique))
=09(if (local-variable-p 'x-symbol-language parent)
=09    (setq x-symbol-language language))
=09(if (local-variable-p 'x-symbol-subscripts parent)
=09    (setq x-symbol-subscripts subscripts))
=09(setq x-symbol-image nil))))

(defun x-symbol-auctex-math-insert (string)
  "Insert the character for \\STRING.
Used as value for `LaTeX-math-insert-function'."
  (let ((cstring (and x-symbol-mode x-symbol-language
=09=09      (x-symbol-decode-single-token (concat "\\" string)))))
    (if cstring
=09(insert cstring)
      (TeX-insert-macro string))))

(defun x-symbol-turn-on-bib-cite ()
  "Run `turn-on-bib-cite' if we are in `latex-mode'.
Added to `find-file-hooks' if the initialization for X-Symbol has
removed `turn-on-bib-cite' from `LaTeX-mode-hook' or `latex-mode-hook'.
See variable `x-symbol-initialize'."
  (if (eq major-mode 'latex-mode) (turn-on-bib-cite)))

;;; Local IspellPersDict: .ispell_xsymb
;;; x-symbol-hooks.el ends here

--------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS--