Initial Commit
[packages] / xemacs-packages / x-symbol / lisp / x-symbol-vars.el
1 ;;; x-symbol-vars.el --- customizable variables for package x-symbol
2
3 ;; Copyright (C) 1995-1999, 2001-2003 Free Software Foundation, Inc.
4 ;;
5 ;; Author: Christoph Wedler <wedler@users.sourceforge.net>
6 ;; Maintainer: (Please use `M-x x-symbol-package-bug' to contact the maintainer)
7 ;; Version: 4.5.X
8 ;; Keywords: WYSIWYG, LaTeX, HTML, wp, math, internationalization
9 ;; X-URL: http://x-symbol.sourceforge.net/
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15 ;;
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20 ;;
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, write to the Free Software
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 ;;; Commentary:
26
27 ;; If you want to use package x-symbol, please visit the URL (use
28 ;; \\[x-symbol-package-web]) and read the info (use \\[x-symbol-package-info]).
29
30 ;; This file contains all customizable variables, except token language
31 ;; specific ones.  It avoids loading the main file when browsing the customize
32 ;; menus.
33
34 ;;; Code:
35
36 (provide 'x-symbol-vars)
37 (require 'x-symbol-hooks)
38 (eval-when-compile (require 'cl))
39
40 (defconst x-symbol-version "4.5.1"
41   "Current development version of package X-Symbol.
42 Check <http://x-symbol.sourceforge.net/> for the newest.")
43
44
45 ;;;===========================================================================
46 ;;;  Custom groups
47 ;;;===========================================================================
48
49 (defgroup x-symbol nil
50   "Semi WYSIWYG for LaTeX, HTML, etc using additional fonts."
51   :group 'wp
52   :link '(info-link "(x-symbol)")
53   :link '(url-link "http://x-symbol.sourceforge.net/")
54   :prefix "x-symbol-")
55
56 (defgroup x-symbol-mode nil
57   "Controlling whether and how to turn on X-Symbol mode."
58   :group 'x-symbol
59   :prefix "x-symbol-")
60
61 (defgroup x-symbol-input-init nil
62   "Initialization of input methods supported by X-Symbol."
63   :group 'x-symbol
64   :prefix "x-symbol-")
65
66 (defgroup x-symbol-input-control nil
67   "Control if input methods supported by X-Symbol."
68   :group 'x-symbol
69   :prefix "x-symbol-")
70
71 (defgroup x-symbol-info-general nil
72   "General customization of X-Symbol info in echo area."
73   :group 'x-symbol
74   :prefix "x-symbol-")
75
76 (defgroup x-symbol-info-strings nil
77   "Customization of X-Symbol info strings in echo area."
78   :group 'x-symbol
79   :prefix "x-symbol-")
80
81 (defgroup x-symbol-miscellaneous nil
82   "Miscellaneous customization for X-Symbol."
83   :group 'x-symbol
84   :prefix "x-symbol-")
85
86 (defgroup x-symbol-image-general nil
87   "General customization of images in X-Symbol buffers."
88   :group 'x-symbol
89   :prefix "x-symbol-")                  ; not "x-symbol-image-" !
90
91 (defgroup x-symbol-image-language nil
92   "Language dependent customization of images in X-Symbol buffers."
93   :group 'x-symbol
94   :prefix "x-symbol-")                  ; not "x-symbol-image-" !
95
96 ;;; language specific groups =================================================
97 ;; they should not be defined in the x-symbol-LANG.el because this would
98 ;; require the custom commands to load all languages when customizing the top
99 ;; group `x-symbol'.
100
101 (defgroup x-symbol-tex nil
102   "X-Symbol token language \"TeX macro\"."
103   :group 'x-symbol
104   :group 'tex
105   :prefix "x-symbol-tex-")
106
107 (defgroup x-symbol-sgml nil
108   "X-Symbol token language \"SGML entity\"."
109   :group 'x-symbol
110   :group 'sgml
111   :prefix "x-symbol-sgml-")
112
113 (defgroup x-symbol-bib nil
114   "X-Symbol token language \"BibTeX macro\"."
115   :group 'x-symbol
116   :group 'tex
117   :prefix "x-symbol-bib-")
118
119 (defgroup x-symbol-texi nil
120   "X-Symbol token language \"TeXinfo command\"."
121   :group 'x-symbol
122   :group 'tex
123   :group 'docs
124   :prefix "x-symbol-texi-")
125
126
127 ;;;===========================================================================
128 ;;;  Custom widgets
129 ;;;===========================================================================
130
131 ;; Shouldn't this be a generally useful widget type?
132 (define-widget 'x-symbol-key 'sexp
133   "A key or mouse stroke."
134   :tag "Key/Mouse stroke")
135
136 (define-widget 'x-symbol-auto-style 'list
137   "Auto-mode setup."
138   ;; Also allows=matches (t) as (t nil nil nil nil nil).  In older XEmacsen,
139   ;; this was not possible and we had to use an "option-group-inline chain".
140   ;; Drop support for all XEmacsen where this is still necessary:
141   ;;  * (group foo bar ...)
142   ;;  * (group foo (option (group :inline t :extra-offset -4 bar (...))))
143   :args '((sexp :tag "Turn on if (eval'd)")
144           (sexp :tag "Coding (eval'd)")
145           (sexp :tag "Save 8bits (eval'd)")
146           (sexp :tag "Unique decoding (eval'd)")
147           (sexp :tag "Super/subscripts (eval'd)")
148           (sexp :tag "Show images (eval'd)")))
149
150
151 ;;;===========================================================================
152 ;;;  Custom widgets, general
153 ;;;===========================================================================
154
155 ;; Shouldn't this be generally a useful widget type?
156 (define-widget 'x-symbol-command 'function
157   "A lisp command."
158   :prompt-match 'commandp
159   :tag "Command")
160
161 (define-widget 'x-symbol-charsym 'symbol
162   "X-Symbol charsym."
163   :tag "X-Symbol charsym")
164
165 (define-widget 'x-symbol-group 'symbol
166   "X-Symbol charsym group."
167   :tag "Charsym group")
168
169 (define-widget 'x-symbol-coding 'choice
170   "X-Symbol 8bit character coding."
171   :tag "8bit coding"
172   :args '((const iso-8859-1)
173           (const iso-8859-2)
174           (const iso-8859-3)
175           (const iso-8859-9)
176           (const iso-8859-15)))
177
178 (define-widget 'x-symbol-function-or-regexp 'choice
179   "Function or regexp, see `x-symbol-call-function-or-regexp'."
180   :args '((const :tag "None" nil) regexp function))
181
182 (define-widget 'x-symbol-fancy-spec 'repeat
183   "X-Symbol specification for fancy strings, without string."
184   :args '((group :value (0 -1 x-symbol-info-face)
185                  (option (group :inline t :extra-offset -4
186                                 :value (0 -1)
187                                 (integer :tag "From")
188                                 (option (integer :tag "To" :value -1))))
189                  (repeat :tag "Faces" :inline t (face :tag "Face")))))
190
191 (define-widget 'x-symbol-fancy 'cons
192   "X-Symbol specification for fancy strings, with string."
193   :args '(string (x-symbol-fancy-spec :tag "Face specifications")))
194
195
196 ;;;===========================================================================
197 ;;;  Custom simple, special
198 ;;;===========================================================================
199
200 (define-widget 'x-symbol-auto-coding 'repeat
201   "X-Symbol automatic coding control."
202   :args '((cons :format "%v"
203                 regexp
204                 (choice x-symbol-coding
205                         (cons :tag "Depending on"
206                               (integer :tag "Match")
207                               (repeat (cons :format "%v"
208                                             (string :tag "Key")
209                                             x-symbol-coding)))))))
210
211 (define-widget 'x-symbol-headers 'repeat
212   "Headers for grid and menu."
213   :args '((cons :format "%v"
214                 (string :tag "Header")
215                 (repeat x-symbol-group))))
216
217 (define-widget 'x-symbol-class-info 'repeat
218   "Definitions for X-Symbol token language classes."
219   :args '((cons :format "%v"
220                 (symbol :tag "Token class" :value VALID)
221                 (choice (const :tag "No info" nil)
222                         (x-symbol-fancy :tag "Info")))))
223
224 (define-widget 'x-symbol-class-faces 'repeat
225   "Definitions for X-Symbol token language classes."
226   :args '((list :format "%v"
227                 (symbol :tag "Token class")
228                 (face :tag "Face in grid" :value default)
229                 (x-symbol-fancy-spec :inline t
230                                      :tag "Faces for tokens in info"))))
231
232 (define-widget 'x-symbol-image-keywords 'cons
233   "Format of image keywords"
234   :args '((regexp :tag "Regexp matching all image files")
235           (repeat
236            (list :format "%v"
237                  :value ("IMAGE \"\\([A-Za-z0-9]\\)\"" 1)
238                  regexp
239                  (option (function :match (lambda (widget arg)
240                                             (and arg (symbolp arg)))
241                                    :value x-symbol-image-default-file-name))
242                  (repeat :inline t :tag "Arguments" sexp)))))
243
244
245 ;;;===========================================================================
246 ;;;  custom set function
247 ;;;===========================================================================
248
249 (defconst x-symbol-cache-variables '(x-symbol-fancy-value-cache
250                                      x-symbol-charsym-info-cache
251                                      x-symbol-charsym-info-cache
252                                      x-symbol-language-info-caches
253                                      x-symbol-coding-info-cache
254                                      x-symbol-keys-info-cache)
255   "Internal.  Cache variables.")
256
257 ;; TODO: not used anymore (would prevent files to be compilable w/o X-Symbol
258 (defun x-symbol-set-cache-variable (var value)
259   "Set VAR's value to VALUE.
260 Custom set function of variables for fancy strings."
261   (set var value)
262   (dolist (cache x-symbol-cache-variables)
263     (and (boundp cache) (set cache nil))))
264
265
266 ;;;===========================================================================
267 ;;;  Language Accesses
268 ;;;===========================================================================
269
270 (defconst x-symbol-LANG-name "Token Language"
271   "Language access: standard name of the token language.
272 For each token language LANG, `x-symbol-LANG-name' is a string with the
273 standard name of the token language LANG.  See
274 `x-symbol-register-language'.")
275
276 (defconst x-symbol-LANG-modes '(major-mode-1 major-mode-2)
277   "Language access: major modes typically using the token language.
278 For each token language LANG, `x-symbol-LANG-modes' is a list of major
279 modes of buffers which will typically use X-Symbol with token language
280 LANG.  See `x-symbol-register-language' and `x-symbol-mode'.")
281
282 (defconst x-symbol-LANG-auto-style '(t nil nil nil nil nil)
283   "Language access: values for X-Symbol's buffer-local variables.
284 For each token language LANG, `x-symbol-LANG-auto-style' determines how
285 to set X-Symbol specific buffer-local variables if these variables do
286 not already have a buffer-local value.
287
288 A value of such a language access looks like
289   (MODE-ON CODING 8BITS UNIQUE SUBSCRIPTS IMAGE)
290
291 If `x-symbol-mode' is not already buffer-local, MODE-ON determines
292 whether to turn the mode on with `turn-on-x-symbol-conditionally'.
293 CODING, 8BITS, UNIQUE, SUBSCRIPTS and IMAGE are used to set
294 `x-symbol-coding', `x-symbol-8bits', `x-symbol-unique',
295 `x-symbol-subscripts' and `x-symbol-image' if these values are not
296 already buffer-local.
297
298 During evaluation, a non-nil `buffer-file-name' is sans backup versions
299 or strings, and without suffixes in `x-symbol-auto-mode-suffixes', and
300 `x-symbol-mode' is bound to the `eval'ed MODE-ON.  Then, the above
301 mentioned variables are set to the `eval'ed CODING, 8BITS, UNIQUE,
302 SUBSCRIPTS and IMAGE in that order, if the variables is not already
303 buffer-local.  If CODING evaluates to nil, `x-symbol-coding' is set
304 according to `x-symbol-auto-8bit-search-limit', if CODING evaluates to
305 `null', `x-symbol-coding' is set to nil.
306
307 Users might prefer to customize `x-symbol-auto-style-alist' instead.")
308
309 ;;        :value (nil nil nil nil nil nil)))
310 ;;(define-widget 'x-symbol-auto-style 'checklist
311 ;;  "Auto-mode setup."
312 ;;  :args '((group
313 ;;         :inline t :extra-offset -4
314 ;;         (sexp :tag "Turn on if (eval'd)")
315 ;;         (option
316 ;;          (group
317 ;;           :inline t :extra-offset -4
318 ;;           (sexp :tag "Coding (eval'd)")
319 ;;           (option
320 ;;            (group
321 ;;             :inline t :extra-offset -4
322 ;;             (sexp :tag "Save 8bit (eval'd)")
323 ;;             (option
324 ;;              (group
325 ;;               :inline t :extra-offset -4
326 ;;               (sexp :tag "Unique decoding (eval'd)")
327 ;;               (option
328 ;;                (group
329 ;;                 :inline t :extra-offset -4
330 ;;                 (sexp :tag "Super/subscripts (eval'd)")
331 ;;                 (option
332 ;;                  (group
333 ;;                   :inline t :extra-offset -4
334 ;;                   (sexp :tag "Show images (eval'd)"))))))))))))))
335
336 (defcustom x-symbol-LANG-modeline-name "lang"
337   "Language access: modeline name of the token language.
338 For each token language LANG, `x-symbol-LANG-modeline-name' is a
339 string with the name of the token language LANG in the modeline."
340   :group 'x-symbol-miscellaneous
341   :type 'string)
342
343 (defconst x-symbol-LANG-required-fonts nil
344   "Language access: features providing required fonts.
345 For each token language LANG, `x-symbol-LANG-required-fonts' is a list
346 of features which are required for the tokens of language LANG.")
347
348 (defconst x-symbol-LANG-token-grammar
349   '(x-symbol-make-grammar :decode-regexp "&[#0-9A-Za-z]+;")
350   "Language access: grammar of token language.
351 For each token language LANG, `x-symbol-LANG-token-grammar' describes
352 the grammar of the language LANG.  The value looks like
353   (x-symbol-make-grammar
354    :token-list    TOKEN-LIST
355    :after-init    AFTER-INIT
356    :case-function CASE-FUNCTION
357    :encode-spec   ENCODE-SPEC
358    :decode-regexp DECODE-REGEXP
359    :decode-spec   DECODE-SPEC
360    :input-regexp  INPUT-REGEXP
361    :input-spec    INPUT-SPEC)
362
363 Optional TOKEN-LIST, if non-nil, is a function which converts TOKEN-SPEC
364 in `x-symbol-LANG-table' into a list with elements \(TOKEN . SHAPE).
365 With value nil, TOKEN-SPEC is must have the form \(TOKEN...) and each
366 SHAPE is defined as nil.
367
368 Optional AFTER-INIT, if non-nil, is a function which is called at the
369 end of the initialization of token language LANG, right before creating
370 the language dependent grid and menu.
371
372 Optional CASE-FUNCTION is non-nil if the token language is case
373 insensitive.  In that case it is a function which normalizes tokens in
374 the buffer.  Typically values are nil, `downcase' and `upcase'.
375
376 Optional ENCODE-SPEC is used during encoding and is either a function
377 FUNC or a cons \(BEFORE . AFTER).  FUNC is called with three arguments,
378 the arguments ENCODE-TABLE, FCHAR-TABLE and FCHAR-FB-TABLE of
379 `x-symbol-encode-lisp'.  See below for BEFORE and AFTER.
380
381 Required DECODE-REGEXP is a regexp matching tokens during decoding.
382
383 Optional DECODE-SPEC is used during decoding and is either a function
384 FUNC or a cons \(BEFORE . AFTER).  FUNC is called with three arguments,
385 DECODE-REGEXP and the arguments DECODE-OBARRAY and UNIQUE of
386 `x-symbol-decode-lisp'.  See below for BEFORE and AFTER.
387
388 Optional INPUT-REGEXP is a regexp or a list of regexps matching tokens
389 for input method Token, see `x-symbol-token-input'.  If it is not
390 provided, it is similar to the regexp DECODE-REGEXP, but only matches at
391 the end of the buffer or restriction.
392
393 Argument INPUT-SPEC is used for input method Token and is either a
394 function FUNC or a cons \(BEFORE . AFTER).  FUNC is called with three
395 arguments, DECODE-REGEXP and the arguments DECODE-OBARRAY and
396 COMMAND-CHAR of `x-symbol-match-token-before'.  See below for BEFORE and
397 AFTER.  Each REGEXP in AFTER matches the string containing COMMAND-CHAR,
398 usually nil or `last-command-char'.  If INPUT-SPEC is not provided, it
399 is set to DECODE-SPEC if this is equal to ENCODE-SPEC and not a
400 function.
401
402 BEFORE and AFTER define bad contexts of the position before and after
403 characters and tokens.  BEFORE is either a character CHAR or a CONTEXT,
404 AFTER is a CONTEXT.  During encoding, having a bad context means
405 inserting an additional space at the position.  During decoding and
406 input method token, having a bad context means no conversion.
407
408 CHAR defines a context which consists of an odd number of characters
409 CHAR before the position.  CONTEXT is a list with elements of the form
410 \(SHAPE . REGEXP).  If the token or token for the current character has
411 the shape SHAPE, REGEXP matches the bad context.  In BEFORE, each REGEXP
412 matches the character before the position.  In AFTER, each REGEXP
413 matches the buffer contents directly following the position, except in
414 INPUT-SPEC.")
415
416 (defconst x-symbol-LANG-generated-data nil
417   "Language access: generated data for token language.
418 For each token language LANG, `x-symbol-LANG-generated-data' is used to
419 store various generated data for a token language, like the conversion
420 tables.")
421
422 (defconst x-symbol-LANG-table '((adiaeresis () "&auml;"))
423   "Language access: table defining tokens for the characters.
424 For each token language LANG, `x-symbol-LANG-table' is a list with
425 elements defining the tokens for the characters with its token classes
426 etc.  Each element in TABLE looks like
427
428   \(CHARSYM CLASSES . TOKEN-SPEC) or nil.
429
430 CHARSYM is the charsym of the character which represents the tokens
431 defined via TOKEN-SPEC, see also TOKEN-LIST in language access
432 `x-symbol-LANG-token-grammar'.  CLASSES are the token classes of the
433 character.")
434
435 (defconst x-symbol-LANG-header-groups-alist nil
436   "Language access: header/submenu specification for characters.
437 For each token language LANG, `x-symbol-LANG-header-groups-alist', if
438 non-nil, is used instead `x-symbol-header-groups-alist' to specify the
439 structure of language specific grid and menu.")
440
441 (defconst x-symbol-LANG-class-alist
442   '((VALID "Language Token" (x-symbol-info-face))
443     (INVALID "no Language Token" (x-symbol-emph-info-face)))
444   "Language access: token classes displayed by info in echo area.
445 For each token language LANG, `x-symbol-LANG-class-alist' is a list of
446 token class specifications used for the info in the echo area, see
447 `x-symbol-character-info'.  Each element looks like
448
449   \(CLASS . SPEC)
450
451 where CLASS is a valid token class, see `x-symbol-init-language' and
452 SPEC is used according to `x-symbol-fancy-string'.  You should define
453 entries for the CLASSes `VALID' and `INVALID'.")
454
455 (defconst x-symbol-LANG-class-face-alist nil
456   "Language access: color scheme in language specific grid and info.
457 For each token language LANG, `x-symbol-LANG-class-face-alist' is used
458 for the color scheme in the language dependent grid and token info.
459 Each element looks like
460
461   \(CLASS FACE . FACE-SPECS)
462
463 where CLASS is a valid token class, FACE is used for the character in
464 the grid, and FACE-SPECS is used according to `x-symbol-fancy-string'.")
465
466 (defconst x-symbol-LANG-electric-ignore nil
467   "Language access: specification restricting input method ELECTRIC.
468 For each token language LANG, `x-symbol-LANG-electric-ignore' is used
469 additionaly to `x-symbol-electric-ignore' to match contexts/charsyms to
470 be ignored by input method ELECTRIC.
471
472 The value is nil, a regexp matching contexts not to be replaced, or a
473 function valled with arguments CONTEXT and CHARSYM, which should return
474 non-nil if the context should not be replaced by the character for
475 CHARSYM.")
476
477 (defconst x-symbol-LANG-extra-menu-items nil
478   "Language access: extra menu items in language specific menu.
479 For each token language LANG, `x-symbol-LANG-extra-menu-items' defines
480 extra menu items to be used in the language specific menu.  Its value is
481 a list of elements in the form \(SUBMENU ITEM...) where SUBMENU is
482 either \"Conversion\" or \"Other Commands\", the ITEMs are additional
483 menu items at the end of the corresponding submenu.")
484
485 (defconst x-symbol-LANG-subscript-matcher nil
486   "Language access: function matching super-/subscripts.
487 For each token language LANG, `x-symbol-LANG-subscript-matcher', if
488 non-nil, is a matcher function for font-lock.  It should return nil for
489 no match, `x-symbol-sup-face'/`x-symbol-sub-face' for a super-/subscript
490 match.  The `match-date' should have three regexp groups: group 1 for
491 the open command, group 2 for the contents, and group 3 for the close
492 command.")
493
494 (defconst x-symbol-LANG-image-keywords nil
495   "Language access: keywords for image insertion commands.
496 For each token language LANG, `x-symbol-LANG-image-keywords' is a list
497
498   \(IMAGE-REGEXP KEYWORD...).
499
500 IMAGE-REGEXP should match all images files and is used to initialize the
501 buffer local memory cache, see `x-symbol-image-init-memory-cache'.
502
503 Each KEYWORD looks like (REGEXP [FUNCTION] ARG...).  Image insertion
504 commands matched by REGEXP are highlighted.  FUNCTION, which defaults to
505 `x-symbol-image-default-file-name', is called with ARGs to get the file
506 name of the corresponding image file.  If FUNCTION returns nil, the
507 command is not highlighted.  See `x-symbol-image-parse-buffer'.")
508
509 (defconst x-symbol-LANG-master-directory nil
510   "Language access: specification of the master directory for images.
511 For each token language LANG, `x-symbol-LANG-master-directory', if
512 non-nil, is a function which returns the directory of the master file,
513 see `x-symbol-image-parse-buffer'.")
514
515 (defconst x-symbol-LANG-image-searchpath nil
516   "Language access: search path for implicitly relative image file names.
517 For each token language LANG, `x-symbol-LANG-image-searchpath' is a list
518 of directories which are checked if the image file name is implicitly
519 relative.  Relative directories are relative to the directory returned
520 by the language access `x-symbol-LANG-master-directory'.  See
521 `x-symbol-image-use-remote'.")
522
523 (defconst x-symbol-LANG-image-cached-dirs nil
524   "Language access: directory parts of images stored in the memory cache.
525 For each token language LANG, `x-symbol-LANG-image-cached-dirs' is a
526 list of directory parts of image file names stored in the memory cache.
527 See `x-symbol-image-use-remote'.")
528
529
530 ;;;===========================================================================
531 ;;;  Identity
532 ;;;===========================================================================
533
534 (defvar x-symbol-package-url "http://x-symbol.sourceforge.net/index.html"
535   "URL used by \\[x-symbol-package-web].
536 If you have a local copy, you might want to change the value.  The
537 default is \"http://x-symbol.sourceforge.net/index.html\".")
538
539 (defconst x-symbol-maintainer-address "wedler@users.sourceforge.net"
540   "E-mail address of maintainer, used by \\[x-symbol-package-bug].")
541
542 (defvar x-symbol-installer-address nil
543   "E-mail address of person who has installed package X-Symbol system-wide.
544 Used for normal reports by \\[x-symbol-package-bug].  If nil, normal
545 reports are sent to `x-symbol-maintainer-address'.")
546
547
548 ;;;===========================================================================
549 ;;;  General Options (appear in the menu)
550 ;;;===========================================================================
551
552 (defcustom x-symbol-token-input t
553   "*If non-nil, enable input method TOKEN.
554 With input method TOKEN, and if the characters before point represent a
555 token, an insertion command after a completed token forces Emacs to
556 replace the token before point by the corresponding character.  Use
557 \"\\[universal-argument] 0 space\" to just replace the token.  Use
558 \\[undo] or \\[unexpand-abbrev] to undo the replacement.
559
560 A command is considered to be a insertion command if it is a self-insert
561 command or has a non-nil symbol property `x-symbol-input'."
562   :group 'x-symbol-input-control
563   :type 'boolean)
564
565 (x-symbol-define-user-options 'x-symbol-token-input '(t))
566
567 (defcustom x-symbol-electric-input t
568   "*If non-nil, enable input method ELECTRIC.
569 With this features, some contexts of input method CONTEXTS are
570 automatically replaced with the corresponding character, i.e., you do
571 not have to invoke \\[x-symbol-modify-key].  Use \\[undo] or
572 \\[unexpand-abbrev] to undo the replacement.
573
574 Because an unwanted replacement of a context with a character can be
575 quite annoying, the following conditions must be fulfilled:
576
577  * The context must have been defined as an electric context for the
578    character, see `x-symbol-init-cset'.
579  * The character must be valid, i.e., represent a token of the current
580    token language, see `x-symbol-valid-charsym-function'.
581  * All characters of the context have been typed without any other
582    command in between, e.g., with language \"TeX macro\", \"- >\" inserts
583    \\to, \"- \\[backward-char] \\[forward-char] >\" simply inserts \"->\".
584  * No prefix argument has been used for any character in the context.
585  * The electric context must not be a suffix of a longer valid context
586    for another character.  E.g., \"''o\" is not changed to \"'\"+`oacute'
587    because \"''o\" is the context for `ohungarumlaut'.
588  * Contexts matched by a global or a token language dependent regexp are
589    not replaced.  Functions can also be used to prevent a context to be
590    replaced by a character.  E.g., with language \"TeX macro\", only
591    replace \"->\" by \\to if we are in TeX's math mode (using texmathp).
592    See `x-symbol-context-ignore' and `x-symbol-electric-ignore'."
593   :group 'x-symbol-input-control
594   :type 'boolean)
595
596 (x-symbol-define-user-options 'x-symbol-electric-input '(t))
597
598 (defcustom x-symbol-local-menu t
599   "*If non-nil, provide a token language specific menu.
600 In a language specific menu, only insertion commands for valid
601 characters appear.  The entries are mentioned and sorted according to
602 the token."
603   :group 'x-symbol-input-control
604   :type 'boolean)
605
606 (x-symbol-define-user-options 'x-symbol-local-menu '(t))
607
608 (defcustom x-symbol-local-grid t
609   "*If non-nil, provide a token language specific grid.
610 See `x-symbol-grid'.  In a language specific grid, only valid characters
611 appear.  They may be also colored according to some language specific
612 token class coloring scheme.  E.g., with language \"TeX macro\", purple
613 character can only be used in TeX's math mode, blue character can only
614 be used in TeX's text mode, see `x-symbol-charsym-face'."
615   :group 'x-symbol-input-control
616   :type 'boolean)
617
618 (x-symbol-define-user-options 'x-symbol-local-grid '(t))
619
620 (defcustom x-symbol-temp-grid nil
621   "*If non-nil, the X-Symbol grid buffer only appears temporarily.
622 If a temporary grid is still visible, the first insertion of an X-Symbol
623 characters restores the window configuration current before the
624 invocation of `x-symbol-grid'."
625   :group 'x-symbol-input-control
626   :type 'boolean)
627
628 (x-symbol-define-user-options 'x-symbol-temp-grid '(t))
629
630 (defcustom x-symbol-temp-help t
631   "*If non-nil, the key completion buffer only appears temporarily.
632 If the temporary key completions buffer is still visible, the first
633 insertion of an X-Symbol characters restores the window configuration
634 current before the invocation of `x-symbol-help'."
635   :group 'x-symbol-input-control
636   :type 'boolean)
637
638 (x-symbol-define-user-options 'x-symbol-temp-help '(t))
639
640 (defvar x-symbol-use-refbuffer-once 'get-buffer-window
641   ;; TODO: customize (probably)
642   ;; `pop-up-frames'=t seems to be broken in XEmacs and I don't like
643   ;; multi-frames anyway, so I cannot say how it is supposed to work whether
644   ;; this really works
645   "*Use reference buffer just once when selecting a X-Symbol character.
646 For both the GRID and the Help buffer.  TODO: more...  A function means,
647 just once if function returns non-nil.  Function is called with the
648 reference buffer and called from within the list buffer.
649
650 E.g. `get-buffer-window' means: just once only if reference and list
651 buffer is on same frame.")
652 ;;;  :group 'x-symbol-input-control
653 ;;;  :type 'boolean) ; no, nil or function or sexp=t
654
655 ;;;(x-symbol-define-user-options 'x-symbol-use-reference-buffer-once '(t))
656
657 (defcustom x-symbol-reveal-invisible t
658   "*If non-nil, reveal invisible characters at point.
659 Usually, with a non-nil `x-symbol-subscripts', some parts of the text
660 might be invisible.  With this feature and if point is in such an area,
661 all the text in the area is revealed and displayed with
662 `x-symbol-revealed-face'.  With value t, also reveal if point is
663 directly after such an area.  See function `x-symbol-reveal-invisible'."
664   :group 'x-symbol-info-general
665   :group 'x-symbol-miscellaneous
666   :type '(radio (const :tag "No" nil)
667                 (const :tag "Characters Around Point" t)
668                 (sexp :tag "Character After Point" :format "%t" :value after)))
669
670 (x-symbol-define-user-options 'x-symbol-reveal-invisible
671     '(after
672       (nil . "No")
673       (after . "Character After Point")
674       (t . "Characters Around Point")))
675
676 (defcustom x-symbol-character-info t
677   "*If non-nil, display info for characters at point in echo area.
678 The info for the character after point includes the character itself,
679 the token of the current language, eventually colored according to some
680 coloring scheme, the token specific classes, the codings in which the
681 characters is considered to be a 8bit character and the key bindings.
682 With value t and no info for the character after point, show info for
683 character before point instead.  See also `x-symbol-context-info'."
684   :group 'x-symbol-info-general
685   :type '(radio (const :tag "None" nil)
686                 (const :tag "Characters Around Point" t)
687                 (sexp :tag "Character After Point" :format "%t" :value after)))
688
689 (x-symbol-define-user-options 'x-symbol-character-info
690     '(after
691       (nil . "None")
692       (after . "Character After Point")
693       (t . "Characters Around Point")))
694
695 (defcustom x-symbol-context-info t
696   "*If non-nil, display info for context before point in echo area.
697 If enabled and no info for characters at point, display the info for
698 the character to which \\[x-symbol-modify-key] would replace the context
699 before point.  See also `x-symbol-character-info'."
700   :group 'x-symbol-info-general
701   :type 'boolean)
702
703 (x-symbol-define-user-options 'x-symbol-context-info '(t))
704
705
706 ;;;===========================================================================
707 ;;;  Texts, Modeline appearance
708 ;;;===========================================================================
709
710 (defcustom x-symbol-charsym-modeline-name "none"
711   "Modeline name of the pseudo language x-symbol charsym.
712 See language access `x-symbol-LANG-modeline-name'."
713   :group 'x-symbol-miscellaneous
714   :type 'string)
715
716 (defcustom x-symbol-coding-name-alist
717   '((iso-8859-1 . "Latin-1")
718     (iso-8859-2 . "Latin-2")
719     (iso-8859-3 . "Latin-3")
720     (iso-8859-9 . "Latin-5")
721     (iso-8859-15 . "Latin-9"))
722   "*Alist of codings with their names presented to the user.
723 The elements look like (CODING . NAME) where CODING is a valid value for
724 `x-symbol-coding' and NAME is the NAME used in the menu."
725   :group 'x-symbol-miscellaneous
726   :type '(repeat (cons :format "%v" x-symbol-coding string)))
727
728 ;;;(defface x-symbol-modeline-warning-face
729 ;;;  `((((class color) (background light))
730 ;;;     (:foreground "red4")))
731 ;;;  "*TODO"
732 ;;;  :group 'x-symbol-mode)
733
734 ;;(defcustom x-symbol-coding-modeline-warning-format "%s-err"
735 ;;  "*Format used to display coding which is not supported.
736 ;;See `x-symbol-coding-modeline-text'."
737 ;;  ;; using text properties with faces for the modeline string doesn't work on
738 ;;  ;; XEmacs-21.4.5...
739 ;;  :group 'x-symbol-mode
740 ;;  :type 'string)
741
742 (defcustom x-symbol-coding-modeline-alist
743   '((iso-8859-1 . "-l1")
744     (iso-8859-2 . "-l2")
745     (iso-8859-3 . "-l3")
746     (iso-8859-9 . "-l5")
747     (iso-8859-15 . "-l9")
748     (info . "-i")
749     (error . "-err"))
750   ;; TODO: describe none, info, error
751   "*Alist of codings with their names in the modeline.
752 The elements look like (CODING . NAME) where CODING is a valid value for
753 `x-symbol-coding' and NAME is used by `x-symbol-coding-modeline-text'."
754   :group 'x-symbol-mode
755   :type '(repeat (cons :format "%v" x-symbol-coding string)))
756
757 (defcustom x-symbol-modeline-state-list
758   '(" XS:"
759     (x-symbol-language . x-symbol-language-modeline-text)
760     (x-symbol-8bits "8")
761     (x-symbol-unique "*")
762     (x-symbol-coding . x-symbol-coding-modeline-text)
763     "/"
764     (x-symbol-subscripts "s")
765     (x-symbol-image "i"))
766   "*Alist used by `x-symbol-update-modeline' to construct the modeline.
767 This function constructs `x-symbol-modeline-string' by concatenating the
768 result from the elements in this list.  Each element looks like
769   SEPARATOR or
770   (VARIABLE NON-NIL . NIL) or
771   (VARIABLE . FUNCTION)
772
773 SEPARATOR is a string and is used directly, only use the first from two
774 consecutive SEPARATORs.  If VARIABLE is non-nil, use NON-NIL, otherwise
775 NIL, both NON-NIL and NIL should be strings or nil.  FUNCTION is called
776 with the value of VARIABLE as argument and should return a string or
777 nil.  Two SEPARATORs where all the elements in between return nil, are
778 considered to be consecutive."
779   :group 'x-symbol-mode
780   :type '(repeat (choice (string :tag "Separator")
781                          (cons :tag "Depending on variable"
782                                variable
783                                (cons :format "%v"
784                                      (choice :tag "Non-nil"
785                                              (const :tag "Nothing" nil) string)
786                                      (choice :tag "Nil"
787                                              (const :tag "Nothing" nil)
788                                              string)))
789                          (cons :tag "Calling function"
790                                (sexp :tag "With argument")
791                                function))))
792
793 ;; Emacs only?
794 (defcustom x-symbol-set-coding-system-if-undecided t ; TODO: nil?
795   "*If non-nil, set coding system if undecided when turning on X-Symbol.
796 If this variable is non-nil, `x-symbol-default-coding' is non-nil, and
797 `buffer-file-coding-system' specifies an undecided coding system, set
798 `buffer-file-coding-system' according to `x-symbol-default-coding'."
799   :group 'x-symbol-mode
800   :type 'boolean)
801
802
803 ;;;===========================================================================
804 ;;;  Minor mode control
805 ;;;===========================================================================
806
807 (defcustom x-symbol-auto-coding-search-limit 10000
808   "*Limits searching for coding strings in the file.
809 Used in variable `x-symbol-auto-mode-alist' when finding an appropriate
810 value for `x-symbol-coding'."
811   :group 'x-symbol-mode
812   :type '(choice (const :tag "No limit" nil) (integer :tag "Limit")))
813
814
815 ;;;===========================================================================
816 ;;;  Misc
817 ;;;===========================================================================
818
819 (defcustom x-symbol-charsym-ascii-alist nil
820   "Alist of charsyms and their Ascii representation.
821 Each element looks like (CHARSYM . ASCII) where CHARSYM is a x-symbol
822 charsym and ASCII is a string.  Used by `x-symbol-translate-to-ascii'.
823
824 E.g., if you prefer the German way to Asciify accented characters, use
825   (setq x-symbol-charsym-ascii-alist
826         '((adiaeresis . \"ae\") (Adiaeresis . \"Ae\")
827           (odiaeresis . \"oe\") (Odiaeresis . \"Oe\")
828           (udiaeresis . \"ue\") (Udiaeresis . \"Ue\")))"
829   :group 'x-symbol-miscellaneous
830   :type '(repeat (cons :format "%v" x-symbol-charsym string)))
831
832 (defcustom x-symbol-charsym-ascii-groups
833   '(digit1
834     letter slash cedilla ogonek dotaccent ring tilde breve
835     circumflex caron diaeresis hungarumlaut acute grave)
836   "Charsym groups with default ascii representations.
837 Charsyms with a group in this list use their subgroup string as the last
838 possibility as the ascii representation.  See `x-symbol-init-cset' for
839 details.  Used by `x-symbol-translate-to-ascii'."
840   :group 'x-symbol-miscellaneous
841   :type '(repeat x-symbol-group))
842
843 (defcustom x-symbol-valid-charsym-function 'x-symbol-default-valid-charsym
844   "Function which should return non-nil if a charsym is valid.
845 Function is called with the charsym and optional language."
846   :group 'x-symbol-input-control
847   :type 'function)
848
849 (defvar x-symbol-user-table nil
850   "List of character definitions: groups, aspects, input.
851 Used to shadow default elements with key CHARSYM in the default tables.
852 The elements have the following form, as explained in
853 `x-symbol-init-cset', DUMMY is not used:
854   (CHARSYM DUMMY GROUPING ASPECTS SCORE INPUT PREFIXES)
855
856 E.g., if you prefer charsym `epsilon1' over `epsilon', you might want to
857 copy the table element from `x-symbol-xsymb1-table' and change its score:
858 use the following element in this table:
859   (epsilon1 t (greek1 \"e\" nil \"epsilon\") nil -3000)")
860
861 (defvar x-symbol-mule-change-default-face nil
862   "If non-nil, change font of default face for existing charsets.
863 The default face is never changed for the charset registry corresponding
864 to `x-symbol-default-coding'.  It is always set for new charsets.
865 Otherwise, this value determines whether it is changed.")
866
867
868 ;;;===========================================================================
869 ;;;  Commands in X-Symbol map
870 ;;;===========================================================================
871
872 (defcustom x-symbol-map-default-keys-alist
873   '((help x-symbol-help)
874     ((control ?h) x-symbol-help)
875     (button1)
876     (button2)
877     (button3)
878     (down-mouse-1 ignore)
879     (down-mouse-2 ignore)
880     (down-mouse-3 ignore)
881     (mouse-1)
882     (mouse-2)
883     (mouse-3)
884     ((meta home) beginning-of-buffer-other-window t)
885     ((meta end) end-of-buffer-other-window t)
886     ((meta prior) scroll-other-window-down t)
887     ((meta next) scroll-other-window t))
888   "Alist used by `x-symbol-map-default-binding'.
889 Each element looks like (KEY COMMAND TEMPORARYP).
890
891 If the last event in the undefined X-Symbol key sequence matches KEY,
892 see `events-to-keys', COMMAND is executed.  If COMMAND is nil, execute
893 command which has binding KEY without prefix of the X-Symbol key
894 sequence.  IF TEMPORARYP is non-nil, use key prefix and the prefix
895 argument for the following command."
896   :group 'x-symbol-input-control
897   :type '(repeat (group x-symbol-key
898                         (choice (const :tag "Usual command" nil)
899                                 x-symbol-command)
900                         (boolean :tag "Temporary"))))
901
902 (defcustom x-symbol-map-default-bindings
903   '(("\C-i"    x-symbol-read-token-direct)
904     ("\C-m"    x-symbol-read-token)
905     (nil       x-symbol-grid)
906     ([(left)]  x-symbol-modify-key)
907     ([(right)] x-symbol-modify-key)
908     ([(up)]    x-symbol-rotate-key)
909     ([(down)]  x-symbol-rotate-key))
910   "TODO.  nil = (vector x-symbol-compose-key)"
911   :group 'x-symbol-input-control
912   :type '(repeat (group (sexp :tag "Key sequence" nil)
913                         x-symbol-command)))
914
915 (defvar x-symbol-after-init-input-hook nil
916   "Hook run after the initialization of all input methods.
917 See `x-symbol-init-input'.  If you want define key bindings starting
918 with \\[x-symbol-map], do it here.  It is a bad idea to use this for
919 additional self insert commands, use \"character descriptions\" in
920 `x-symbol-user-table' instead.")
921
922
923 ;;;===========================================================================
924 ;;;  Menu (option part)
925 ;;;===========================================================================
926
927 ;; As long as custom does not offer a widget for menu entries...no defcustom
928 ;; WARNING: XEmacs-20.4 :suffix STRING
929 (defvar x-symbol-menu
930   '("X-Symbol" :filter x-symbol-menu-filter
931     ("Conversion in %s" :filter x-symbol-extra-filter
932      ["Conversion" nil x-symbol-region-text] ; pseudo entry
933      ["Encode Characters" x-symbol-encode
934       :active (and x-symbol-language (not buffer-read-only))]
935      ["Encode & Recode" x-symbol-encode-recode
936       :active (and x-symbol-coding x-symbol-language (not buffer-read-only)
937                    (not (eq x-symbol-coding x-symbol-default-coding))
938                    (eq (x-symbol-buffer-coding) x-symbol-default-coding)
939                    (assq x-symbol-coding x-symbol-fchar-tables))]
940      ["Decode Tokens" x-symbol-decode
941       :active (and x-symbol-language (not buffer-read-only))]
942      ["Recode & Decode" x-symbol-decode-recode
943       :active (and x-symbol-coding x-symbol-language (not buffer-read-only)
944                    (not (eq x-symbol-coding x-symbol-default-coding))
945                    (eq (x-symbol-buffer-coding) x-symbol-default-coding)
946                    (assq x-symbol-coding x-symbol-fchar-tables))]
947      ["Replace Char Aliases" x-symbol-unalias
948       :active (not buffer-read-only)])
949     ;;
950     ("Other Commands" :filter x-symbol-extra-filter
951      ["Other Commands" nil nil]         ; pseudo entry
952      ["Copy Encoded" x-symbol-copy-region-encoded
953       ;;(x-symbol-copy-region-encoded (region-beginning) (region-end))
954       :active (and x-symbol-language (region-active-p))]
955      ["Paste Decoded" x-symbol-yank-decoded
956       :active (and x-symbol-mode (not buffer-read-only))]
957      "---"
958      ["GRID Of Characters" x-symbol-grid t]
959      ["READ Token Character" x-symbol-read-token (not buffer-read-only)]
960      "---"
961      ["Modify CONTEXT" x-symbol-modify-key (not buffer-read-only)]
962      ["Rotate CONTEXT" x-symbol-rotate-key (not buffer-read-only)]
963      "---"
964      ["Info Page" x-symbol-package-info t]
965      ["Web Page" x-symbol-package-web t]
966      ["Send Bug/Problem Report" x-symbol-package-bug t])
967     ;;
968     ("Buffer/File Options" :filter x-symbol-options-filter
969      ["X-Symbol Mode" x-symbol-mode t]
970      "---"
971      ["Token Language:" x-symbol-language t]
972      ["8bit Char Encoding:" x-symbol-coding t]
973      ["Store 8bit In File" x-symbol-8bits t]
974      ["Unique Decoding" x-symbol-unique t]
975      "---"
976      ["Super-/Subscripts" x-symbol-subscripts
977       (x-symbol-subscripts-available-p)]
978      ["Show Images" x-symbol-image (x-symbol-image-available-p)])
979     ;;
980     ("General Options" :filter x-symbol-options-filter
981      ["Input Method TOKEN" x-symbol-token-input t]
982      ["Input Method ELECTRIC" x-symbol-electric-input t]
983      "---"
984      ["Language Specific GRID" x-symbol-local-grid t]
985      ["Language Specific MENU" x-symbol-local-menu t]
986      "---"
987      ["Temporary GRID" x-symbol-temp-grid t]
988      ["Temporary Key Completions" x-symbol-temp-help t]
989      "---"
990      ["Reveal Invisible" x-symbol-reveal-invisible t]
991      ["Display Character Info" x-symbol-character-info t]
992      ["Display Context Info" x-symbol-context-info t]
993      "---"
994      ["Browse Customization" (customize-browse 'x-symbol) t])
995     "---")
996   "First entries of the x-symbol menu, language specific or not.
997 The next items are submenus with commands to insert x-symbol characters.
998 See also `x-symbol-header-groups-alist'.")
999
1000
1001 ;;;===========================================================================
1002 ;;;  Menu (insert commands part), Grid
1003 ;;;===========================================================================
1004
1005 (defcustom x-symbol-menu-max-items 30
1006   "*Maximum number of entries in submenus of the x-symbol menu.
1007 If the number of character input commands in a submenu exceed this
1008 value, use more than one submenu for the same header.  These submenus
1009 have nearly the same length.  See also `x-symbol-header-groups-alist'."
1010   :group 'x-symbol-input-init
1011   :type 'integer)
1012
1013 (defcustom x-symbol-header-groups-alist
1014   '(("Operator" bigop operator)
1015     ("Relation" relation)
1016     ("Arrow" arrow)
1017     ("Shaped" triangle shape)
1018     ("Punctuation" white line dots punctuation quote parenthesis)
1019     ("Symbol" symbol currency)
1020     ("Math Letter" mathletter setsymbol)
1021     ("Greek Letter" greek greek1)
1022     ("Misc. Letter" letter slash)
1023     ("Cedilla, Ogonek" cedilla ogonek)
1024     ("Dotaccent, Ring" dotaccent ring)
1025     ("Tilde, Breve" tilde breve)
1026     ("Circumflex, Caron" circumflex caron)
1027     ("Diaeresis, Umlaut" diaeresis hungarumlaut)
1028     ("Acute, Grave" acute grave))
1029   "Alist to determine the header/submenu for characters.
1030 Each element looks like (HEADER GROUP...) where HEADER is a string and
1031 GROUP is the group of a character as explained in `x-symbol-init-cset'.
1032 This alist is used for `x-symbol-grid' and the `x-symbol-menu'.
1033 Token languages might define their own alist.
1034
1035 For each token language LANG, `x-symbol-LANG-header-groups-alist', if
1036 non-nil, contains the specification for the language specific grid and
1037 menu."
1038 ;; TODO: mention: before init
1039   :group 'x-symbol-input-init
1040   :type 'x-symbol-headers)
1041
1042 (defcustom x-symbol-completions-buffer "*X-Symbol Key Completions*"
1043   "Buffer name for key completions buffer.
1044 Used by `x-symbol-help', i.e., when pressing Help during a x-symbol
1045 key sequence."
1046   :group 'x-symbol-input-init
1047   :type 'string)
1048
1049 (defcustom x-symbol-grid-buffer-format "*X-Symbol Grid (%s)*"
1050   "Buffer name format for grid buffers.
1051 Used with substitution `x-symbol-charsym-name'/%s when invoked from a
1052 buffer without a valid token language or if `x-symbol-local-grid' has
1053 value nil.  Otherwise, used with substitution NAME/%s where NAME is the
1054 name of `x-symbol-language'."
1055   :group 'x-symbol-input-init
1056   :type 'string)
1057
1058 (defcustom x-symbol-grid-reuse t
1059   "If non-nil, \\[x-symbol-grid] reuses old grid buffers.
1060 If non-nil, avoid unnecessary computations.  You should probably set
1061 this to nil, if you use side-by-side buffers with different width."
1062   :group 'x-symbol-input-control
1063   :type 'boolean)
1064
1065 (defcustom x-symbol-grid-header-echo
1066   '("button2 scrolls up/down, button3 pops up X-Symbol menu  (all non-highlighted parts)"
1067     (8 24 x-symbol-info-face) (33 54 x-symbol-info-face)
1068     (56 x-symbol-info-face))
1069   "Text used for the echo are if mouse if over a heading.
1070 See `x-symbol-fancy-value' for the value type."
1071   :group 'x-symbol-input-init
1072   :group 'x-symbol-info-strings
1073   :set 'x-symbol-set-cache-variable
1074   :type 'x-symbol-fancy)
1075
1076 (defcustom x-symbol-grid-ignore-charsyms '(nobreakspace)
1077   "Charsyms not being displayed in the grid, see `x-symbol-grid'."
1078   :group 'x-symbol-input-control
1079   :type '(repeat x-symbol-charsym))
1080 ;; problems with var-space fonts
1081
1082 (defcustom x-symbol-grid-tab-width 4    ; TODO Emacs better?  3 too small
1083   "Tab width in the grid between characters, see `x-symbol-grid'.
1084 The widest character should not be wider than the tab width if the
1085 default face has font of `x-symbol-heading-face'."
1086   :group 'x-symbol-input-init
1087   :type 'number)
1088
1089 (defface x-symbol-heading-face
1090   `((((class color) (background light))
1091      (:foreground "green4"
1092                   :bold t :family "Helvetica"
1093                   ,@(if (featurep 'xemacs) '(:size "12pt"))
1094                    :underline t)))      ; underline must be last...
1095   ;;(:foreground "green4" :underline t)))
1096   "Face used for headers in the grid buffers.
1097 The defined font is used as default font and influences the correct
1098 value of `x-symbol-grid-tab-width'."
1099   :group 'x-symbol-input-init)
1100
1101 (defvar x-symbol-heading-strut-glyph
1102   (make-glyph (remove-if-not
1103                #'(lambda (spec) (valid-instantiator-p (cdr spec) 'image))
1104                `(((x) . [xbm :data (6 20 ,(make-string 20 0))])
1105                  ((mswindows) . [xbm :data (6 20 ,(make-string 20 0))])
1106                  ((tty) . [string :data " "]))))
1107   "Glyph at the end of headers in grid buffers, see `x-symbol-grid'.
1108 Allows to have a larger interline spacing when the line starts with a
1109 header.")
1110
1111
1112 ;;;===========================================================================
1113 ;;;  Other input methods
1114 ;;;===========================================================================
1115
1116 (defvar x-symbol-key-init-ignore nil
1117   "Regexp matching contexts not being used by input method QUAIL.")
1118 ;; TODO: just regexp, more text
1119
1120 (defvar x-symbol-quail-init-ignore " "
1121   "Regexp matching contexts not being used by input method QUAIL.")
1122 ;; TODO: just regexp, more text
1123
1124 (defvar x-symbol-context-init-ignore " "
1125   "Regexp matching contexts not being used by input method CONTEXT.
1126 As opposed to `x-symbol-context-ignore', this is already used during
1127 initialization.  It also allows the input method CONTEXT to consider the
1128 next shorter context.")
1129 ;; just regexp
1130
1131 (defcustom x-symbol-context-ignore nil
1132   "Regexp matching contexts not to be replaced by input method CONTEXT.
1133 You may also use a function instead of a regexp, see
1134 `x-symbol-call-function-or-regexp'."
1135   :group 'x-symbol-input-control
1136   :type 'x-symbol-function-or-regexp)
1137 ;; TODO: mention that fn is called with CONTEXT CHARSYM
1138
1139 (defcustom x-symbol-electric-ignore "[ \t]\\|'[ls]"
1140   "Regexp matching contexts not to be replaced by input method ELECTRIC.
1141 A language dependent regexp is also checked before a context is
1142 replaced, see `x-symbol-electric-input' for details.  You may also use a
1143 function instead of a regexp, see `x-symbol-call-function-or-regexp'.
1144
1145 For each token language LANG, `x-symbol-LANG-electric-ignore', if
1146 non-nil, defines the language dependent version."
1147   :group 'x-symbol-input-control
1148   :type 'x-symbol-function-or-regexp)
1149
1150 (defcustom x-symbol-rotate-suffix-char ?\#
1151   "Additional suffix character usually used to simulate Greekifying.
1152 \\[x-symbol-modify-key] modifies the longest context before point
1153 whereas \\[x-symbol-rotate-key] appends this character to the context to
1154 determine the correct target character for the context.  The value is
1155 typically a suffix being defined in `x-symbol-group-input-alist'."
1156   :group 'x-symbol-input-control
1157   :type 'character)
1158
1159 (defcustom x-symbol-rotate-prefix-alist
1160   '((8 . north)
1161     (7 . north-west)
1162     (4 . west)
1163     (1 . south-west)
1164     (2 . south)
1165     (28 . vertical)
1166     (82 . vertical)
1167     (3 . south-east)
1168     (6 . east)
1169     (64 . horizontal)
1170     (46 . horizontal)
1171     (9 . north-east)
1172     (5 . nil))
1173   "Alist used if `x-symbol-rotate-key' is called with a prefix arg.
1174 Each element looks like (NUMBER . DIRECTION) where NUMBER is the numeric
1175 value of the prefix argument and DIRECTION is a valid direction in
1176 `x-symbol-rotate-aspects-alist'."
1177   :group 'x-symbol-input-control
1178   :type '(repeat (cons :format "%v"
1179                        (integer :tag "Numeric Prefix Arg")
1180                        (symbol :tag "Direction"))))
1181
1182 (defvar x-symbol-list-mode-hook nil
1183   "Hook run at the end of `x-symbol-list-mode'.")
1184
1185 ;;;  Before init-input: ======================================================
1186
1187 (defvar x-symbol-key-min-length 2
1188   "Minimum number of key strokes in a x-symbol key sequence.
1189 If the key context is shorter than this value, use \"1\" as an
1190 additional key suffix.  See `x-symbol-init-input' for details.")
1191
1192 (defvar x-symbol-quail-suffix-string ";"
1193   "TODO")
1194
1195 (defvar x-symbol-define-input-method-quail (featurep 'mule))
1196
1197
1198 ;;;===========================================================================
1199 ;;;  Invisible and Info (part 1)
1200 ;;;===========================================================================
1201
1202 (defcustom x-symbol-idle-delay 0.5
1203   "*Time in seconds of idle time before showing info in the echo area.
1204 Also used as idle time before revealing invisible characters.  See
1205 `x-symbol-character-info', `x-symbol-context-info' and
1206 `x-symbol-reveal-invisible'.  See also `x-symbol-start-itimer-once'."
1207   :group 'x-symbol-miscellaneous
1208  :type 'number)
1209
1210 (defface x-symbol-revealed-face
1211   '((((class color) (background light))
1212      (:background "pink")))
1213   "Face used when revealing invisible characters.
1214 Used instead `x-symbol-invisible-face'.  See `x-symbol-reveal-invisible'."
1215   :group 'x-symbol-info-general
1216   :group 'x-symbol-miscellaneous)
1217
1218 (defcustom x-symbol-context-info-ignore 'x-symbol-default-context-info-ignore
1219   "Regexp matching contexts not used to display a context info for.
1220 See `x-symbol-context-info'.  You may also use a function instead of a
1221 regexp, see `x-symbol-call-function-or-regexp'."
1222 ;; TODO: mention that fn is called with CONTEXT CHARSYM
1223   :group 'x-symbol-info-general
1224   :type 'x-symbol-function-or-regexp)
1225
1226 (defcustom x-symbol-context-info-threshold 2
1227   "Minimum length of contexts to display a context info for.
1228 Used by `x-symbol-default-context-info-ignore'."
1229   :group 'x-symbol-info-general
1230   :type 'integer)
1231
1232 (defcustom x-symbol-context-info-ignore-regexp "\\`[A-Za-z]+\\'"
1233   "Regexp matching contexts not to display a context info for.
1234 Used by `x-symbol-default-context-info-ignore'."
1235   :group 'x-symbol-info-general
1236   :type 'regexp)
1237
1238 (defcustom x-symbol-context-info-ignore-groups
1239   '(letter
1240     slash cedilla ogonek dotaccent ring tilde breve
1241     circumflex caron diaeresis hungarumlaut acute grave)
1242   "Groups of characters not to display a context info for.
1243 Used by `x-symbol-default-context-info-ignore'."
1244   :group 'x-symbol-info-general
1245   :type '(repeat x-symbol-group))
1246
1247
1248 ;;;===========================================================================
1249 ;;;  Character Info
1250 ;;;===========================================================================
1251
1252 (defface x-symbol-info-face
1253   (eval-when-compile
1254     `((((class color) (background light))
1255        (:foreground "green4" :family "Helvetica"
1256                     ;; :size necessary with XEmacs, I get huge fonts otherwise,
1257                     ;; at least if x-symbol is enabled from a buffer with a
1258                     ;; nonstandard default font...
1259                     ,@(if (featurep 'xemacs) '(:size "12pt"))))))
1260   "Face normally used for the info in the echo area."
1261   :group 'x-symbol-info-strings)
1262
1263 (defface x-symbol-emph-info-face
1264   (eval-when-compile
1265     `((((class color) (background light))
1266        (:foreground "red4" :family "Helvetica"
1267                     ,@(if (featurep 'xemacs) '(:size "12pt"))))))
1268   "Face used for the emphasized info in the echo area."
1269   :group 'x-symbol-info-strings)
1270
1271 (defcustom x-symbol-info-intro-after
1272   '("AFTER:  " (0 -2 x-symbol-info-face))
1273   "Intro spec of info for the character after point.
1274 See `x-symbol-character-info'.  See `x-symbol-fancy-value' for the value
1275 type."
1276   :group 'x-symbol-info-strings
1277   :set 'x-symbol-set-cache-variable
1278   :type 'x-symbol-fancy)
1279
1280 (defcustom x-symbol-info-intro-before
1281   '("BEFORE:  " (0 -2 x-symbol-info-face))
1282   "Intro spec of info for character before point.
1283 See `x-symbol-character-info'.  See `x-symbol-fancy-value' for the value
1284 type."
1285   :group 'x-symbol-info-strings
1286   :set 'x-symbol-set-cache-variable
1287   :type 'x-symbol-fancy)
1288
1289 (defcustom x-symbol-info-intro-highlight
1290   '("button2 inserts:  " (-10 -2 x-symbol-info-face))
1291   "Intro spec of the info character in grid under mouse.
1292 See `x-symbol-fancy-value' for the value type, STRING is passed to
1293 `substitute-command-keys'."
1294   :group 'x-symbol-info-strings
1295   :set 'x-symbol-set-cache-variable
1296   :type 'x-symbol-fancy)
1297
1298 (defcustom x-symbol-info-intro-list
1299   '("\\[x-symbol-list-selected] inserts:  " (-10 -2 x-symbol-info-face))
1300   "Intro spec of the info character in grid under point.
1301 Used by \\[x-symbol-list-info].  See `x-symbol-fancy-value' for the
1302 value type, STRING is passed to `substitute-command-keys'."
1303   :group 'x-symbol-info-strings
1304   :set 'x-symbol-set-cache-variable
1305   :type 'x-symbol-fancy)
1306
1307 (defcustom x-symbol-info-intro-yank
1308   '("\\[yank] inserts:  " (-10 -2 x-symbol-info-face))
1309   "Intro spec of info for the character inserted in read-only buffer.
1310 See `x-symbol-insert-command'.  See `x-symbol-fancy-value' for the value
1311 type, STRING is passed to `substitute-command-keys'."
1312   :group 'x-symbol-info-strings
1313   :set 'x-symbol-set-cache-variable
1314   :type 'x-symbol-fancy)
1315
1316 (defcustom x-symbol-info-alias-after
1317   '("\\[forward-char] \\[x-symbol-modify-key] replaces char alias with:  "
1318     (-27 -2 x-symbol-emph-info-face))
1319   "Intro spec of short info for character alias after point.
1320 See `x-symbol-character-info'.  See `x-symbol-fancy-value' for the value
1321 type, STRING is passed to `substitute-command-keys'."
1322   :group 'x-symbol-info-strings
1323   :set 'x-symbol-set-cache-variable
1324   :type 'x-symbol-fancy)
1325
1326 (defcustom x-symbol-info-alias-before
1327   '("\\[x-symbol-modify-key] replaces char alias with:  "
1328     (-27 -2 x-symbol-emph-info-face))
1329   "Intro spec of short info for character alias before point.
1330 See `x-symbol-character-info'.  See `x-symbol-fancy-value' for the value
1331 type, STRING is passed to `substitute-command-keys'."
1332   :group 'x-symbol-info-strings
1333   :set 'x-symbol-set-cache-variable
1334   :type 'x-symbol-fancy)
1335
1336 (defcustom x-symbol-info-context-pre
1337   '("\\[x-symbol-modify-key] replaces " (-9 -1 x-symbol-info-face))
1338   "Spec of text before context in info for context before point.
1339 See `x-symbol-context-info'.  See `x-symbol-fancy-value' for the value
1340 type, STRING is passed to `substitute-command-keys'."
1341   :group 'x-symbol-info-strings
1342   :set 'x-symbol-set-cache-variable
1343   :type 'x-symbol-fancy)
1344
1345 (defcustom x-symbol-info-context-post
1346   '(" with:  " (1 -2 x-symbol-info-face))
1347   "Spec of text after context in info for context before point.
1348 See `x-symbol-context-info'.  See `x-symbol-fancy-value' for the value
1349 type."
1350   :group 'x-symbol-info-strings
1351   :set 'x-symbol-set-cache-variable
1352   :type 'x-symbol-fancy)
1353
1354 (defcustom x-symbol-info-token-pre '(" = " (x-symbol-info-face))
1355   "Spec of text between character and token in info.
1356 See `x-symbol-fancy-value' for the value type."
1357   :group 'x-symbol-info-strings
1358   :set 'x-symbol-set-cache-variable
1359   :type 'x-symbol-fancy)
1360
1361 (defcustom x-symbol-info-token-charsym
1362   '("<%s>" (0 1 x-symbol-info-face) (-1 x-symbol-info-face))
1363   "Spec with format for x-symbol charsym in info.
1364 See `x-symbol-fancy-string' for the value type, the format with
1365 substitution CHARSYM/%s is the STRING."
1366   :group 'x-symbol-info-strings
1367   :set 'x-symbol-set-cache-variable
1368   :type 'x-symbol-fancy)
1369
1370 (defcustom x-symbol-info-classes-pre '(" (" (1 x-symbol-info-face))
1371   "Spec of text before token classes in info.
1372 See `x-symbol-fancy-associations' for details."
1373   :group 'x-symbol-info-strings
1374   :set 'x-symbol-set-cache-variable
1375   :type 'x-symbol-fancy)
1376
1377 (defcustom x-symbol-info-classes-sep '(", " (x-symbol-info-face))
1378   "Spec of text between token classes in info.
1379 See `x-symbol-fancy-associations' for details."
1380   :group 'x-symbol-info-strings
1381   :set 'x-symbol-set-cache-variable
1382   :type 'x-symbol-fancy)
1383
1384 (defcustom x-symbol-info-classes-post '(")" (x-symbol-info-face))
1385   "Spec of text before after token classes in info.
1386 See `x-symbol-fancy-associations' for details."
1387   :group 'x-symbol-info-strings
1388   :set 'x-symbol-set-cache-variable
1389   :type 'x-symbol-fancy)
1390
1391 (defcustom x-symbol-info-classes-charsym '("charsym" (x-symbol-info-face))
1392   "Spec of token class string for x-symbol charsyms in info.
1393 See `x-symbol-fancy-value' for the value type."
1394   :group 'x-symbol-info-strings
1395   :set 'x-symbol-set-cache-variable
1396   :type 'x-symbol-fancy)
1397
1398 (defcustom x-symbol-info-coding-pre '("." (x-symbol-info-face))
1399   "Spec of text before codings in info.
1400 See `x-symbol-fancy-associations' for details."
1401   :group 'x-symbol-info-strings
1402   :set 'x-symbol-set-cache-variable
1403   :type 'x-symbol-fancy)
1404
1405 (defcustom x-symbol-info-coding-sep '("." (x-symbol-info-face))
1406   "Spec of text between codings in info.
1407 See `x-symbol-fancy-associations' for details."
1408   :group 'x-symbol-info-strings
1409   :set 'x-symbol-set-cache-variable
1410   :type 'x-symbol-fancy)
1411
1412 (defcustom x-symbol-info-coding-post '("")
1413   "Spec of text after codings in info.
1414 See `x-symbol-fancy-associations' for details."
1415   :group 'x-symbol-info-strings
1416   :set 'x-symbol-set-cache-variable
1417   :type 'x-symbol-fancy)
1418
1419 (defcustom x-symbol-info-coding-alist
1420   '((iso-8859-1 "l1" (x-symbol-info-face))
1421     (iso-8859-2 "l2" (x-symbol-info-face))
1422     (iso-8859-3 "l3" (x-symbol-info-face))
1423     (iso-8859-9 "l5" (x-symbol-info-face))
1424     (iso-8859-15 "l9" (x-symbol-info-face)))
1425   "Specs for coding info.
1426 Each element looks like (CODING . SPEC).  Characters which are defined
1427 to be 8bit characters with CODING, are displayed with SPEC in the info.
1428 See `x-symbol-fancy-associations' for details."
1429   :group 'x-symbol-info-strings
1430   :type '(repeat (group x-symbol-coding
1431                         string
1432                         (x-symbol-fancy-spec :inline t
1433                                              :tag "Face specifications"))))
1434
1435 (defcustom x-symbol-info-keys-keymaps 'x-symbol-default-info-keys-keymaps
1436   "Function returning the root keymaps for the key info.
1437 If non-nil, called with the current charsym as argument, the result is
1438 the second argument to `where-is-internal'.  See also
1439 `x-symbol-info-keys-pre'."
1440   :group 'x-symbol-info-strings
1441   :type '(choice (const :tag "Current maps" nil) function))
1442
1443 (defcustom x-symbol-info-keys-pre
1444   '("   \\[x-symbol-map] +: " (-4 -1 x-symbol-info-face))
1445   "Spec of text before key bindings in info.
1446 See `x-symbol-fancy-associations' for details, STRING is passed to
1447 `substitute-command-keys'.  See also `x-symbol-info-keys-keymaps'."
1448   :group 'x-symbol-info-strings
1449   :set 'x-symbol-set-cache-variable
1450   :type 'x-symbol-fancy)
1451   
1452 (defcustom x-symbol-info-keys-sep '(" , " (0 -1 x-symbol-info-face))
1453   "Spec of text between key bindings in info.
1454 See `x-symbol-fancy-associations' for details."
1455   :group 'x-symbol-info-strings
1456   :set 'x-symbol-set-cache-variable
1457   :type 'x-symbol-fancy)
1458
1459 (defcustom x-symbol-info-keys-post '("")
1460   "Spec of text after key bindings in info.
1461 See `x-symbol-fancy-associations' for details."
1462   :group 'x-symbol-info-strings
1463   :set 'x-symbol-set-cache-variable
1464   :type 'x-symbol-fancy)
1465
1466 (defconst x-symbol-fancy-cache-size 25
1467   "Internal.  Number of variables whose fancy values are cached.")
1468
1469 (defvar x-symbol-cache-size 100
1470   "*Size of caches for fancy strings.
1471 See `x-symbol-ensure-hashtable' and `x-symbol-puthash'.")
1472
1473
1474 ;;;===========================================================================
1475 ;;;  Init: aspects, default input
1476 ;;;===========================================================================
1477
1478 (defvar x-symbol-modify-aspects-alist
1479   '((shift     (nil . 0) (up . 300) (down . 600))
1480     (shape     (nil . 0) (round . 1000) (square . 2000) (curly . 3000))
1481     (size      (nil . 0) (big . 5000) (sml . 9000)))
1482   "Alist of modify aspects with their values and scores.
1483 Each element looks like (ASPECT (VALUE . SCORE)...) where ASPECT is a
1484 modify aspect.  It is a good idea to have a value nil with score 0 in
1485 the alist of all aspects.
1486
1487 The aspect value must be equal to one VALUE, the modify score is
1488 incremented by the corresponding SCORE.  A higher modify score makes a
1489 character likely to appear late in the modify-to chain.  See
1490 `x-symbol-init-cset' and `x-symbol-init-input'.")
1491
1492 (defvar x-symbol-rotate-aspects-alist
1493   '((direction (north . -5000) (north-west . -4500) (west . -4000)
1494                (south-west . -3500) (south . -3000) (vertical . -2500)
1495                (south-east . -2000) (east . -1500)
1496                (horizontal . -1000) (north-east . -500) (nil . 0)))
1497   "Alist of rotate aspects with their values and scores.
1498 Each element looks like (ASPECT (VALUE . SCORE)...) where ASPECT is a
1499 rotate aspect.  It is a good idea to have a value nil with score 0 in
1500 the alist of all aspects.  Aspect `direction' is also used by
1501 `x-symbol-rotate-prefix-alist'.
1502
1503 The aspect value must be equal to one VALUE, the rotate score is
1504 incremented by the corresponding SCORE.  A higher rotate score makes a
1505 character likely to appear late in the rotate-to chain.  See
1506 `x-symbol-init-cset' and `x-symbol-init-input'.")
1507
1508 (defvar x-symbol-group-input-alist
1509   '((bigop      0)
1510     (operator   -120)
1511     (relation   -120)
1512     (arrow      0)
1513     (triangle   0)
1514     (shape      0)
1515     (white      1500)
1516     (line       0)
1517     (dots       0)
1518     (punctuation 0)
1519     (quote      0)
1520     (parenthesis 0)
1521     (symbol     0)
1522     (currency   0)
1523     (digit1     0 "%sd")
1524     (mathletter 500 "%s")
1525     (setsymbol  120 "%s")
1526     (greek1     1500 "%s#" "#%s")
1527     (greek      0 "%s#" "#%s")
1528     (letter     0 "%s")
1529     (slash      120 "%s/" "/%s")
1530     (ogonek     250 "%s," ",%s")
1531     (cedilla    120 "%s," ",%s")
1532     (dotaccent  250 "%s." ".%s")
1533     (ring       250 "%s*" "*%s")
1534     (breve      250 "%sv" "v%s")
1535     (caron      120 "%sv" "v%s")
1536     (circumflex 120 "%s^" "^%s")
1537     (tilde      120 t "%s~" "~%s")
1538     (hungarumlaut 250 "''%s")
1539     (diaeresis  120 "%s:" t ":%s" "%s\"" "\"%s")
1540     (grave      120 t "%s`" "`%s")
1541     (acute      120 "%s'" t "'%s"))
1542   "Alist of character groups with their scores and default input formats.
1543 Each element looks like (GROUP GROUP-SCORE . INPUT).  If the group of a
1544 charsym is equal to GROUP, its score is incremented by GROUP-SCORE, see
1545 `x-symbol-init-cset'.
1546
1547 INPUT = nil | (FORMAT . INPUT) | (t FORMAT . INPUT).  It is used if the
1548 charsym has no input definitions, but a SUBGROUP which might have been
1549 processed using `x-symbol-subgroup-string-alist'.  In that case, the
1550 FORMATs with substitutions SUBGROUP/%s are the CONTEXTs as described in
1551 `x-symbol-init-cset'.")
1552
1553
1554 ;;;===========================================================================
1555 ;;;  Init: char syntax
1556 ;;;===========================================================================
1557
1558 (defvar x-symbol-group-syntax-alist
1559   '((bigop      "_")
1560     (operator   "_")
1561     (relation   "_")
1562     (arrow      "_")
1563     (triangle   "_")
1564     (shape      "_")
1565     (white      " ")
1566     (line       ".")
1567     (dots       ".")
1568     (punctuation ".")
1569     (quote       "." (open . "(%s") (close . ")%s"))
1570     (parenthesis "." (open . "(%s") (close . ")%s"))
1571     (symbol     "_")
1572     (currency   "_")
1573     (digit1     "_")
1574     (mathletter "w")
1575     (setsymbol  "w")
1576     (greek      "w")
1577     (greek1     "w")
1578     (letter     "w")
1579     (slash      "w")
1580     (cedilla    "w")
1581     (ogonek     "w")
1582     (dotaccent  "w")
1583     (ring       "w")
1584     (tilde      "w")
1585     (breve      "w")
1586     (circumflex "w")
1587     (caron      "w")
1588     (diaeresis  "w")
1589     (hungarumlaut "w")
1590     (acute      "w")
1591     (grave      "w"))
1592   "Alist of groups with their syntax designators used in XEmacs/Mule.
1593 Each element looks like (GROUP SYNTAX (RAW-SUBGROUP . FORMAT)...).  A
1594 charsym with group GROUP has normally the syntax designator SYNTAX.  If
1595 its raw subgroup, i.e., a symbol, is equal to a RAW-SUBGROUP and the
1596 OPPOSITE of the charsym is defined in the same or previous csets, FORMAT
1597 with substitution CSTRING/%s is used as the syntax designator where
1598 CSTRING is the cstring of OPPOSITE.  See `x-symbol-init-cset' and
1599 `x-symbol-subgroup-string-alist'.")
1600
1601 (defvar x-symbol-subgroup-string-alist
1602   '((accent . " ")
1603     (open . "(")
1604     (close . ")"))
1605   "Alist of subgroup symbols with their string representation.
1606 Each element looks like (RAW . STRING) where RAW is a symbol used in the
1607 SUBGROUP position of entries in cset tables, see `x-symbol-init-cset'
1608 and STRING is its string representation.")
1609
1610
1611 ;;;===========================================================================
1612 ;;;  Fonts
1613 ;;;===========================================================================
1614
1615 (defvar x-symbol-latin-force-use nil
1616   "If non-nil, define latin characters even when fonts are missing.
1617 If nil, it is a bad idea to decode a file when its `x-symbol-coding'
1618 corresponds to a missing font, i.e., 8bit characters are assumed to have
1619 encoding `x-symbol-default-coding' in this case.  If nil, tokens are not
1620 decoded if they require the missing font.  Values other than nil are
1621 safe, but latin characters without correct fonts will look strange.")
1622
1623 (defvar x-symbol-font-sizes '(("\\`-etl-" 16 14) ("" 14 12)))
1624 ;;  '(14 ("\\`-etl-.+_su[bp]-" . 14) ("\\`-etl-" . 16) ("_su[bp]-" . 12)))
1625
1626 (defvar x-symbol-font-lock-with-extra-props
1627   (and (boundp 'x-symbol-emacs-has-font-lock-with-props)
1628        x-symbol-emacs-has-font-lock-with-props))
1629
1630 (defvar x-symbol-latin1-fonts
1631   '("-adobe-helvetica%s-medium-r-normal-*-%d-*-*-*-*-*-iso8859-1")
1632   "Fonts with registry/encoding \"iso8859-1\".
1633 See `x-symbol-latin1-cset' and `x-symbol-init-cset'.")
1634
1635 (defvar x-symbol-latin2-fonts
1636   '("-adobe-helvetica%s-medium-r-normal-*-%d-*-*-*-*-*-iso8859-2"
1637     "-etl-fixed%s-medium-r-normal--%d-%d0-72-72-c-*-iso8859-2")
1638   "Fonts with registry/encoding \"iso8859-2\".
1639 See `x-symbol-latin2-cset' and `x-symbol-init-cset'.")
1640
1641 (defvar x-symbol-latin3-fonts
1642   '("-adobe-helvetica%s-medium-r-normal-*-%d-*-*-*-*-*-iso8859-3"
1643     "-etl-fixed%s-medium-r-normal--%d-%d0-72-72-c-*-iso8859-3")
1644   "Fonts with registry/encoding \"iso8859-3\".
1645 See `x-symbol-latin3-cset' and `x-symbol-init-cset'.")
1646
1647 (defvar x-symbol-latin5-fonts
1648   '("-etl-fixed%s-medium-r-normal--%d-%d0-72-72-c-*-iso8859-9")
1649   "Fonts with registry/encoding \"iso8859-9\".
1650 See `x-symbol-latin5-cset' and `x-symbol-init-cset'.")
1651
1652 ;; for some reason, the font foundry and family name have been renamed, it is
1653 ;; the normal helvetica font...
1654 (defvar x-symbol-latin9-fonts
1655   '("-vh-herilane%s-medium-r-normal-*-%d-*-*-*-*-*-iso8859-15")
1656   "Fonts with registry/encoding \"iso8859-15\".
1657 See `x-symbol-latin9-cset' and `x-symbol-init-cset'.")
1658
1659 (defvar x-symbol-xsymb0-fonts
1660   '("-xsymb-xsymb0%s-medium-r-normal--%d-%d0-75-75-p-*-adobe-fontspecific"
1661     "-adobe-symbol%s-medium-r-normal-*-*-%d0-*-*-*-*-adobe-fontspecific")
1662   "Fonts with registry/encoding \"adobe-fontspecific\".
1663 See `x-symbol-xsymb0-cset' and `x-symbol-init-cset'.")
1664
1665 (defvar x-symbol-xsymb1-fonts
1666   '("-xsymb-xsymb1%s-medium-r-normal--%d-%d0-75-75-p-*-xsymb-xsymb1")
1667   "Fonts with registry/encoding \"xsymb-xsymb1\".
1668 See `x-symbol-xsymb1-cset' and `x-symbol-init-cset'.")
1669
1670
1671 ;;;===========================================================================
1672 ;;;  X-Symbol Image: general
1673 ;;;===========================================================================
1674
1675 (defcustom x-symbol-image-max-width 120
1676   "*Maximum width of glyphs."
1677   :group 'x-symbol-image-general
1678   :type 'integer)
1679
1680 (defcustom x-symbol-image-max-height 80
1681   "*Maximum height of glyphs."
1682   :group 'x-symbol-image-general
1683   :type 'integer)
1684
1685 (defcustom x-symbol-image-update-cache 'old
1686   "*If non-nil, automatically update the image cache file.
1687 With value nil, only create an image cache file if it does not exist.
1688 With value t, always produce a new cache file.  With any other value,
1689 only produce a cache file if it does not exist or is older than the
1690 corresponding image file.  This variable has no influence if a glyph
1691 having used the image cache file in question is stored in the buffer
1692 local memory cache, see `x-symbol-image-memory-cache'.
1693
1694 See `x-symbol-image-cache-directories' for the file name of the
1695 cached image.  See also `x-symbol-image-special-glyphs'."
1696   :group 'x-symbol-image-general
1697   :type '(radio (const :tag "No" nil)
1698                 (const :tag "Always" t)
1699                 (sexp :tag "Old" :format "%t" :value old)))
1700
1701 (defcustom x-symbol-image-use-remote nil
1702   "*If nil, only show glyphs which can be stored in the memory cache.
1703 The memory cache stores glyphs for file names without directory part or
1704 a directory part in the language access
1705 `x-symbol-LANG-image-cached-dirs', e.g., it should contain \"images\",
1706 if \"images/mail.png\" should be stored in the memory cache.
1707
1708 If this variable is nil, use `x-symbol-image-remote-glyph' for image
1709 files not in the memory cache.  If it is non-nil, try to find the image
1710 file during editing, ignoring the searchpath, for speed, though.
1711 Editing lines with image files not in the memory cache will be slow,
1712 since file accesses are necessary for every command.
1713
1714 When searching for the images file, all file names, including
1715 directories in a search path, are relative to the return value of the
1716 function in language access `x-symbol-LANG-master-directory', value nil
1717 means function `default-directory'.
1718
1719 Implicitly relative file names, i.e., those which are neither absolute
1720 nor are matched by `x-symbol-image-explicitly-relative-regexp', are
1721 searched in the directories of language access
1722 `x-symbol-LANG-image-searchpath'."
1723   :group 'x-symbol-image-general
1724   :type 'boolean)
1725
1726 (defcustom x-symbol-image-current-marker " *"
1727   "*Marker to indicate the directory of the image file.
1728 Marker used in `x-symbol-image-menu' to indicate directories in the
1729 image search path containing the image file.  The first marked directory
1730 is used by button2 over an image insertion command."
1731   :group 'x-symbol-image-general
1732   :type 'string)
1733
1734 (defcustom x-symbol-image-scale-method "\\.[0-9][0-9]\\'"
1735   "*Regexp matching the scale factor in the image file name.
1736 If non-nil and this regexp matches the image file name without its final
1737 extension, only the part up to the beginning of the match is used to
1738 determine the name of the image cache file and the design file if it
1739 differs from the image file, see `x-symbol-image-editor-alist'.
1740
1741 Example: with the default values, for the image and image design file
1742 \"file.70.jpeg\", the image cache file is \"file.png\", for the image
1743 file \"file.70.eps\", the image cache file is \"file.png\", the image
1744 design file is \"file.fig\"."
1745   :group 'x-symbol-image-general
1746   :type '(choice (const :tag "No scale method" nil) regexp))
1747
1748 (defcustom x-symbol-image-explicitly-relative-regexp "\\`\\.\\.?/"
1749   "Regexp matching files considered to be explicitly relative."
1750   :group 'x-symbol-image-general
1751   :type 'regexp)
1752
1753 (defcustom x-symbol-image-searchpath-follow-symlink nil
1754   "*Non-nil, if recursive searching for dirs should follow symbolic links.
1755 Directories in the image search path ending with \"//\" are recursively
1756 inserted.  With value nil, do not include subdirectories which are
1757 symbolic links.  Directories which are directly specified in the image
1758 searchpath are always included."
1759   :group 'x-symbol-image-general
1760   :type 'boolean)
1761
1762
1763 ;;;===========================================================================
1764 ;;;  Configuration: Image file cache
1765 ;;;===========================================================================
1766
1767 ;; Influenced by `fast-lock-cache-directories' but different semantics!
1768 (defcustom x-symbol-image-cache-directories
1769   `((,(concat "\\`" (regexp-quote (file-truename "~/"))) . "~/.images/")
1770     ("." . t))
1771   "List of directories for image cache files.
1772 Each element should be of the form:
1773   (REGEXP) or
1774   (REGEXP . t) or
1775   (REGEXP . NEWDIR) or
1776   (REGEXP FUNCTION ARG...)
1777
1778 Used by `x-symbol-image-cache-name' to determine the directory where to
1779 store the image cache files.  The elements in this list are processed
1780 until REGEXP matches the directory part INDIR of the fully expanded
1781 image file name, see `file-truename'.
1782
1783 With the first form, no image cache file will be produced and
1784 `x-symbol-image-junk-glyph' represents the image file.  With the second
1785 form, the image cache file is just produced temporary and is stored in
1786 `x-symbol-image-temp-name'+SUFFIX.  If the glyph for the image file is
1787 not stored in `x-symbol-image-memory-cache', the second form is an alias
1788 for the first form.
1789
1790 With the third form, the match by REGEXP in INDIR is replaced with
1791 NEWDIR, see `replace-match'.  With the fourth from, FUNCTION is called
1792 with INDIR and arguments ARGs.  In both cases, the result is expanded
1793 with INDIR to get the directory for the image cache file.
1794
1795 Example: if we have the value
1796   ((\"\\\\`/home/user/junk/\")
1797    (\"\\\\`/home/user/tmp/.*\" . \".images/\")
1798    (\"\\\\`/home/user/\" . \"~/.images/\")
1799    (\".\" . t)
1800 and the following image files, we get:
1801   /home/user/junk/stupid.eps is not cached, a recycle sign is shown
1802   /home/user/tmp/tmp1/image.eps is cached in /home/user/tmp/tmp1/.images/
1803   /home/user/d1/d2/image.eps is cached in /home/user/.images/d1/d2/
1804   /usr/local/image.eps is temporary cached in file /tmp/xsi-a006JH.SUFFIX"
1805   :group 'x-symbol-image-general
1806   :type '(repeat (cons :format "%v"
1807                        :value (".")
1808                        regexp
1809                        (choice
1810                         (const :tag "Junk" nil)
1811                         (const :tag "Temporary" t)
1812                         (string :tag "Replace match with")
1813                         (cons :tag "Call"
1814                               function
1815                               (repeat :tag "With arguments" sexp))))))
1816
1817 (defvar x-symbol-image-temp-name
1818   (and (featurep 'xemacs)               ; temp image files don't work in Emacs
1819        (if (fboundp 'make-temp-file)
1820            (make-temp-file "xsi-")              ; Emacs
1821          (expand-file-name (make-temp-name "xsi-") (temp-directory))))
1822   "Name without suffix of the temporary image cache file.
1823 This should be a unique, at best generated with `make-temp-name'.  See
1824 `x-symbol-image-cache-directories' for details.")
1825
1826 (defcustom x-symbol-image-convert-mono-regexp
1827   (and x-symbol-image-temp-name (regexp-quote x-symbol-image-temp-name))
1828   "Regexp matching image cache file names not using a colormap.
1829 Used by `x-symbol-image-start-convert-colormap' to determine monochrome
1830 image cache files.  This regexp should match temporary image cache files
1831 since \"convert\" is slow when using a colormap."
1832   :group 'x-symbol-image-general
1833   :type '(choice (const :tag "None" nil) regexp))
1834
1835
1836 ;;;===========================================================================
1837 ;;;  Configuration: highlighting image insertion commands, editor
1838 ;;;===========================================================================
1839
1840 (defcustom x-symbol-image-help-echo
1841   '("button2 runs: %S , button3 pops up menu"
1842     (8 13 x-symbol-info-face) (-23 -21 x-symbol-info-face)
1843     (-12 x-symbol-info-face))
1844   "Format string for info when the mouse is over image insertion commands.
1845 Used with substitution COMMAND/%S, where COMMAND describes the
1846 invocation of the image editor, see `x-symbol-image-editor-alist'."
1847   :group 'x-symbol-image-general
1848   :group 'x-symbol-info-strings
1849   :set 'x-symbol-set-cache-variable
1850   :type 'x-symbol-fancy)
1851
1852 (defcustom x-symbol-image-editor-alist
1853   '(("\\.\\(eps\\|ps\\(tex\\)?\\)\\'" "xfig %s &" ".fig")
1854     ("." "display %s &"))
1855   "Alist of image editors used by `x-symbol-image-editor'.
1856 Each element looks like (REGEXP . EDITOR-SPEC) where EDITOR-SPEC looks
1857 like (SHELL-COMMAND-FORMAT [EXT]) or (FUNCTION ARG...).
1858
1859 If REGEXP matches the image file, EDITOR-SPEC is used.  With the first
1860 form, a shell command SHELL-COMMAND-FORMAT with substitution FILE/%s is
1861 invoked where the image design file FILE is the image file, if used
1862 without optional EXT or EXT with value nil, or the result of
1863 `x-symbol-image-file-name' otherwise, called with arguments image file
1864 name and EXT.
1865
1866 With the second form, calling (FUNCTION FILE nil ARG...) should return a
1867 string describing the editor, used by function
1868 `x-symbol-image-help-echo' and the title of `x-symbol-image-menu'.
1869 Calling (FUNCTION FILE BUFFER ARG...)  should invoke the image editor.
1870 FILE is the image file, BUFFER is the buffer in which the image is
1871 used."
1872   :group 'x-symbol-image-general
1873   :type '(repeat
1874           (cons :format "%v"
1875                 :value ("." "display %s &")
1876                 regexp
1877                 (choice (list :tag "Shell command"
1878                               string
1879                               (choice (const :tag "Unchanged filename" nil)
1880                                       (string :tag "Abstract extension")))
1881                         (cons :tag "Call"
1882                               function
1883                               (repeat :tag "With arguments" sexp))))))
1884
1885 (defvar x-symbol-image-menu
1886   '("Run %S in"
1887     "--:shadowDoubleEtchedIn"
1888     ["Rescan buffer" (x-symbol-image-parse-buffer 'OTHER)
1889      :active (x-symbol-event-in-current-buffer)]
1890     ["Update file cache" (x-symbol-image-parse-buffer t)
1891      :active (x-symbol-event-in-current-buffer)])
1892   "Definition for the popup menu over image insertion commands.
1893 It has the form (HEADER LAST-ITEM...).  The menu title is TITLE with
1894 substitution COMMAND/%S, where COMMAND describes the invocation of the
1895 image editor, see `x-symbol-image-editor-alist'.  The next menu items
1896 are the directories in the image search path, see
1897 `x-symbol-image-use-remote'.  If a image file is found in a
1898 directory, it is marked with `x-symbol-image-current-marker'.")
1899
1900
1901 ;;;===========================================================================
1902 ;;;  Configuration: special-purpose images/glyphs and conversion program
1903 ;;;===========================================================================
1904
1905 ;; `defcustom' with set function
1906 (defvar x-symbol-image-data-directory x-symbol-data-directory
1907   "Configuration variable.  Directory of special purpose images.
1908 See `x-symbol-image-special-glyphs'.")
1909
1910 (defvar x-symbol-image-special-glyphs
1911   '(("RIP.xbm" . xbm) ("hourglass.xbm" . xbm) ("drawing.xbm" . xbm)
1912     ("termlock.xbm" . xbm) ("escherknot.xbm" . xbm) ("recycle.xbm" . xbm))
1913   ;;'(("splat.xbm" . xbm) ("abacus.xbm" . xbm) ("scroll2.xbm" . xbm)
1914   ;;  ("stopsign.xbm" . xbm) ("filing.xbm" . xbm))
1915   "Special images used for recognized image insertion commands.
1916 The value looks like (BROKEN CREATE DESIGN LOCKED REMOTE JUNK).  Each
1917 element looks like (FILE . IMAGE-FORMAT) where FILE is a file name,
1918 expanded with `x-symbol-image-data-directory' and IMAGE-FORMAT is a
1919 image format compiled into your XEmacs.
1920
1921 They are used to initialize variables containing images/glyphs:
1922  * BROKEN for `x-symbol-image-broken-image',
1923  * CREATE for `x-symbol-image-create-image',
1924  * DESIGN for `x-symbol-image-design-glyph',
1925  * LOCKED for `x-symbol-image-locked-glyph',
1926  * REMOTE for `x-symbol-image-remote-glyph' and
1927  * JUNK for `x-symbol-image-junk-glyph'.
1928
1929 Special images are used in the following situations: REMOTE represents
1930 images in a file, if the file is remote or if the image name prohibits
1931 the use of the memory cache as specified by `x-symbol-image-use-remote'.
1932 JUNK is used if `x-symbol-image-converter' is nil, if no image should be
1933 created as specified by `x-symbol-image-cache-directories' or if the
1934 image cache file cannot be written.
1935
1936 LOCKED represents existent image files which cannot be read or
1937 non-existent image files which cannot be created.  DESIGN represents
1938 non-existent image files which could be created.  CREATE is used during
1939 the creation of the image cache file, an old image cache is used instead
1940 if it exists.  BROKEN is used if the creation of the image cache file
1941 failed.")
1942
1943 (defcustom x-symbol-image-convert-file-alist
1944   '(("\\.pstex\\'" . "ps:"))
1945   "Alist to determine a prefix for the INFILE passed to \"convert\".
1946 Each element looks like (REGEXP . PREFIX).  If REGEXP matches INFILE,
1947 INFILE is prefixed by PREFIX for the invocation of \"convert\".  If no
1948 REGEXP matches, no prefix is used.  See `x-symbol-image-convert-file'."
1949   :group 'x-symbol-image-general
1950   :type '(repeat (cons :format "%v"
1951                        regexp (string :tag "Prefix"))))
1952
1953 (defcustom x-symbol-image-convert-program
1954   (if (eq system-type 'windows-nt) "C:\\ImageMagick\\convert" "convert")
1955   "*Name of the program used in `x-symbol-image-converter'."
1956   :group 'x-symbol-image-general
1957   :type 'string)
1958
1959 (defcustom x-symbol-image-converter
1960   (when (console-type)
1961     (save-excursion
1962       (set-buffer (get-buffer-create " *x-symbol-image command*"))
1963       (erase-buffer)
1964       (call-process shell-file-name nil t nil shell-command-switch
1965                     (concat x-symbol-image-convert-program " -list Format"))
1966       (call-process shell-file-name nil t nil shell-command-switch
1967                     (concat x-symbol-image-convert-program " -h"))
1968       (let (iformat)
1969         (cond ((when (featurep 'png)
1970                  (goto-char (point-min))
1971                  (re-search-forward "^[ \t]*[pP][nN][gG]" nil t))
1972                (setq iformat 'png))
1973               ((when (featurep 'gif)
1974                  (goto-char (point-min))
1975                  (re-search-forward "^[ \t]*[gG][iI][fF]" nil t))
1976                (setq iformat 'gif))
1977               (t
1978                (setq iformat (cond ((featurep 'png) 'png)
1979                                    ((featurep 'gif) 'gif)))
1980                (unless iformat
1981                  (warn "x-symbol-image: your Emacs neither supports png nor gif"))
1982                (goto-char (point-min))
1983                (if (re-search-forward "ImageMagick" nil t)
1984                    (if iformat (warn "x-symbol-image: \"convert\" doesn't list recognized formats, I'll try %S" iformat))
1985                  (warn "x-symbol-image: no valid image converter")
1986                  (setq iformat nil))))
1987         (kill-buffer (current-buffer))
1988         (when iformat
1989           (list* iformat
1990                  (cdr (assq iformat '((png . ".png") (gif . ".gif"))))
1991                  (if (and (boundp 'system-type) (eq system-type 'windows-nt))
1992                      'x-symbol-image-start-convert-mswindows
1993                    (let ((colors (if (featurep 'xemacs)
1994                                      (or (device-color-cells) 2)
1995                                    (if (display-color-p) 256 2))))
1996                      (cond ((< colors 32) 'x-symbol-image-start-convert-mono)
1997                            ((> colors 767)
1998                             'x-symbol-image-start-convert-truecolor)
1999                            (x-symbol-image-convert-colormap
2000                             'x-symbol-image-start-convert-colormap)
2001                            (t 'x-symbol-image-start-convert-color)))))))))
2002   "Converter to produce the image cache file from the image file.
2003 This definition has the form (IMAGE-FORMAT EXTENSION . COMMAND).
2004 IMAGE-FORMAT is a image format compiled into your XEmacs.  EXTENSION is
2005 the extension used for image cache file names.
2006
2007 COMMAND, called with arguments INFILE and OUTFILE should start and
2008 return the process which creates the image cache file OUTFILE from the
2009 image file INFILE.  COMMAND should also use `x-symbol-image-max-width'
2010 and `x-symbol-image-max-height'.  Value nil means, use
2011 `x-symbol-image-junk-glyph' instead creating a glyph from IMAGE.
2012
2013 Predefined COMMANDS start \"convert\" from ImageMagick with different
2014 options according to the number of colors in your device:
2015 `x-symbol-image-start-convert-truecolor',
2016 `x-symbol-image-start-convert-color' and
2017 `x-symbol-image-start-convert-mono'."
2018   :group 'x-symbol-image-general
2019   :type '(choice
2020           (const :tag "No image converter" nil)
2021           (cons :tag "Converter"
2022                 (symbol :tag "Image format")
2023                 (cons :format "%v"
2024                       (string :tag "File extension")
2025                       (choice
2026                        :tag "Convert function"
2027                        (function-item :tag "To monochrome"
2028                                       x-symbol-image-start-convert-mono)
2029                        (function-item :tag "To color, restricted"
2030                                       x-symbol-image-start-convert-color)
2031                        (function-item :tag "To color, colormap"
2032                                       x-symbol-image-start-convert-colormap)
2033                        (function-item :tag "To color, unrestricted"
2034                                       x-symbol-image-start-convert-truecolor)
2035                        (function :tag "Other function"))))))
2036
2037
2038 ;;;===========================================================================
2039 ;;;  Package Integration
2040 ;;;===========================================================================
2041
2042 (put 'x-symbol-insert-command 'x-symbol-input t)
2043 (put 'newline 'x-symbol-input t)
2044 (put 'newline-and-indent 'x-symbol-input t)
2045 (put 'reindent-then-newline-and-indent 'x-symbol-input t)
2046 (put 'tex-insert-quote 'x-symbol-input t)
2047 (put 'TeX-insert-quote 'x-symbol-input t)
2048 (put 'TeX-insert-punctuation 'x-symbol-input t)
2049 (put 'TeX-insert-dollar 'x-symbol-input t)
2050 (put 'sgml-close-angle 'x-symbol-input t)
2051 (put 'sgml-slash 'x-symbol-input t)
2052 (put 'completion-separator-self-insert-command 'x-symbol-input t)
2053 (put 'completion-separator-self-insert-autofilling 'x-symbol-input t)
2054
2055 (put 'forward-char 'x-symbol-point-function '1+)
2056 (put 'backward-char 'x-symbol-point-function '1-)
2057 (put 'forward-char-command 'x-symbol-point-function '1+)
2058 (put 'backward-char-command 'x-symbol-point-function '1-)
2059
2060
2061 ;;;===========================================================================
2062 ;;;  For `set-variable'
2063 ;;;===========================================================================
2064
2065 ;;;###autoload
2066 (defun x-symbol-variable-interactive (var)
2067   "Provide interactive specification for `set-variable'.
2068 VAR's options has been defined with `x-symbol-define-user-options'."
2069   (let* ((options (if (functionp (get var 'x-symbol-options))
2070                       (funcall (get var 'x-symbol-options))
2071                     (get var 'x-symbol-options)))
2072          (alist (mapcar (lambda (x) (cons (symbol-name (car x)) (car x)))
2073                         (or (cdr options) (list '(nil) options))))
2074          (val (completing-read (format "Set `%s' to symbol (default %s): "
2075                                        var (symbol-value var))
2076                                alist nil t)))
2077     (list (if (equal val "")
2078               (symbol-value var)
2079             (cdr (assoc val alist))))))
2080
2081 ;;; Local IspellPersDict: .ispell_xsymb
2082 ;;; x-symbol-vars.el ends here