
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MODULE      : math-kbd.scm
;; DESCRIPTION : keyboard shortcuts for mathematics
;; COPYRIGHT   : (C) 1999  Joris van der Hoeven
;;
;; This software falls under the GNU general public license version 3 or later.
;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texmacs-module (math math-kbd)
  (:use (generic generic-kbd)
        (utils edit auto-close)
        (generic format-edit)
        (math math-edit)
        (table table-edit)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Hacks to work around the problem that MacOS reserves Alt-based shortcuts
;; for its own personal use
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when (os-macos?)
  (kbd-map
    (:mode in-math?)
    ("å" (make-above)) ;; Alt-a
    ("Å" (make-wide "<invbreve>")) ;; Alt-A
    ("big-int" (make-below)) ;; Alt-b
    ("ı" (make-wide "<bar>")) ;; Alt-B
    ("Ç" (make-wide "<check>")) ;; Alt-C
    ("<#192>" (make-fraction)) ;; Alt-f
    ("<#192> var" (make 'tfrac))
    ("<#192> var var" (make 'dfrac))
    ("<#192> var var var" (make 'frac*))
    ("<#192> var var var var" (make 'cfrac))
    ("Ø" (make 'op)) ;; Alt-O
    ("ß" (make-sqrt)) ;; Alt-s
    ("ß var" (make-var-sqrt))
    ("†" (make 'tabular)) ;; Alt-t
    ("† var" (make 'tabular*))
    ("† var var" (make 'block))
    ("† var var var" (make 'block*))
    ("† var var var var" (make 'stack))
    ("◊" (make-wide "<vect>")) ;; Alt-V

    ("geq" (make-wide "<dot>")) ;; Alt-.
    ("geq var" (make-wide "<ddot>"))
    ("geq var var" (make-wide "<dddot>"))
    ("geq var var var" (make-wide "<ddddot>"))
    ("æ" (make-wide "<acute>")) ;; Alt-'
    ("Æ" (make-wide "<ddot>")) ;; Alt-"
    ("Æ var" (make-wide "<dddot>"))
    ("Æ var var" (make-wide "<ddddot>"))
    ("ﬂ" (make-wide "^")) ;; Alt-^
    ("–" (make-wide "<wide-bar>")) ;; Alt--
    ("—" (make-wide-under "<wide-bar>")) ;; Alt-_

    ("{ †" (make 'choice)) ;; { Alt-t
    ("( †" (make 'matrix))
    ("[ †" (make 'bmatrix))
    ("| †" (make 'det))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main keyboard shortcuts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(kbd-map
  (:mode in-math?)
  ;; must come first in order not to screw the menus up
  ("accent:deadhat" (make-script #t #t))
  ("accent:deadhat var" "^")
  ("math:left accent:deadhat" (make-script #t #f))
  ("math accent:tilde" (make-wide "~"))          ; yields M-M-~
  ("math accent:deadhat" (make-wide "^"))        ; yields M-M-^
  ("math accent:acute" (make-wide "<acute>"))    ; yields M-M-'
  ("math accent:grave" (make-wide "<grave>"))    ; yields M-M-`
  ("accent:abovedot" (make-wide "<dot>"))        ; yields M-.
  ("accent:umlaut" (make-wide "<ddot>"))         ; yields M-\"
  ("accent:breve" (make-wide "<breve>"))         ; yields M-U
  ("accent:invbreve" (make-wide "<invbreve>"))   ; yields M-A
  ("accent:check" (make-wide "<check>"))         ; yields M-V
  ("math:under accent:tilde" (make-wide-under "~"))
  ("math:under accent:deadhat" (make-wide-under "^"))
  ("math:under accent:acute" (make-wide-under "<acute>"))
  ("math:under accent:grave" (make-wide-under "<grave>"))
  ("math:under accent:abovedot" (make-wide-under "<dot>"))
  ("math:under accent:umlaut" (make-wide-under "<ddot>"))
  ("math:under accent:breve" (make-wide-under "<breve>"))
  ("math:under accent:invbreve" (make-wide-under "<invbreve>"))
  ("math:under accent:check" (make-wide-under "<check>"))
  ;; end

  ("altcmd F5" (make 'math-it))
  ("altcmd F6" (make 'math-bf))
  ("altcmd F7" (make 'math-tt))
  ("altcmd F8" (make 'math-ss))

  ("$" (math-make-math))
  ("math $" (make 'text))
  ("`" (make-lprime "`"))
  ("'" (make-rprime "'"))
  ("\"" (make-rprime "'") (make-rprime "'"))
  ("` var" (make-lprime "'"))
  ("` var var" (make-lprime "<asterisk>"))
  ("` var var var" (make-lprime "<dag>"))
  ("` var var var var" (make-lprime "<ddag>"))
  ("` var var var var var" (make-lprime "<kreuz>"))
  ("' var" (make-rprime "`"))
  ("' var var" (make-rprime "<asterisk>"))
  ("' var var var" (make-rprime "<dag>"))
  ("' var var var var" (make-rprime "<ddag>"))
  ("' var var var var var" (make-rprime "<kreuz>"))
  ("\" var" (make-rprime "`") (make-rprime "`"))
  ("\" var var" (make-rprime "<asterisk>") (make-rprime "<asterisk>"))
  ("\" var var var" (make-rprime "<dag>") (make-rprime "<dag>"))
  ("\" var var var var" (make-rprime "<ddag>") (make-rprime "<ddag>"))
  ("\" var var var var var" (make-rprime "<kreuz>") (make-rprime "<kreuz>"))
  ("math:greek '" (make-rprime "<dag>"))
  ("math:greek \"" (make-rprime "<ddag>"))
  ("math:greek +" (make-rprime "<kreuz>"))
  ("math:greek *" (make-rprime "<asterisk>"))
  ("_" (make-script #f #t))
  ("_ var" "_")
  ("^" (make-script #t #t))
  ("^ var" "^")
  ("math:left _" (make-script #f #f))
  ("math:left ^" (make-script #t #f))
  ("math f" (make-fraction))
  ("math f var" (make 'tfrac))
  ("math f var var" (make 'dfrac))
  ("math f var var var" (make 'frac*))
  ("math f var var var var" (make 'cfrac))
  ("math s" (make-sqrt))
  ("math s var" (make-var-sqrt))
  ("math n" (make-neg))
  ("math O" (make 'op))
  ("math +" (make-rprime "<dag>"))
  ("math a" (make-above))
  ("math b" (make-below))

  ("math:syntax o" (make 'math-ordinary))
  ("math:syntax space" (make 'math-ignore))
  ("math:syntax ," (make 'math-separator))
  ("math:syntax q" (make 'math-quantifier))
  ("math:syntax = >" (make 'math-imply))
  ("math:syntax %" (make 'math-or))
  ("math:syntax &" (make 'math-and))
  ("math:syntax / var" (make 'math-not))
  ("math:syntax =" (make 'math-relation))
  ("math:syntax % var" (make 'math-union))
  ("math:syntax & var" (make 'math-intersection))
  ("math:syntax - var" (make 'math-setminus))
  ("math:syntax +" (make 'math-plus))
  ("math:syntax -" (make 'math-minus))
  ("math:syntax *" (make 'math-times))
  ("math:syntax /" (make 'math-over))
  ("math:syntax #" (make 'math-prefix))
  ("math:syntax !" (make 'math-postfix))
  ("math:syntax (" (make 'math-open))
  ("math:syntax )" (make 'math-close))
  ("math:syntax x" (make 'syntax))

  ("math B" (make-wide "<bar>"))
  ("math C" (make-wide "<check>"))
  ("math U" (make-wide "<breve>"))
  ("math A" (make-wide "<invbreve>"))
  ("math T" (make-wide "<bind>"))
  ("math V" (make-wide "<vect>"))
  ("math ~" (make-wide "~"))
  ("math ^" (make-wide "^"))
  ("math '" (make-wide "<acute>"))
  ("math `" (make-wide "<grave>"))
  ("math -" (make-wide "<wide-bar>"))
  ("math ." (make-wide "<dot>"))
  ("math . var" (make-wide "<ddot>"))
  ("math . var var" (make-wide "<ddot>"))
  ("math . var var var" (make-wide "<ddddot>"))
  ("math \"" (make-wide "<ddot>"))
  ("math \" var" (make-wide "<dddot>"))
  ("math \" var var" (make-wide "<ddddot>"))
  ("math @" (make-wide "<abovering>"))
  ("math _" (make-wide-under "<wide-bar>"))
  ("math:over {" (make-wide "<wide-overbrace>"))
  ("math:over }" (make-wide "<wide-underbrace*>"))
  ("math:over (" (make-wide "<wide-poverbrace>"))
  ("math:over )" (make-wide "<wide-punderbrace*>"))
  ("math:over [" (make-wide "<wide-sqoverbrace>"))
  ("math:over ]" (make-wide "<wide-squnderbrace*>"))
  ("math:over <" (make-wide "<wide-varleftarrow>"))
  ("math:over >" (make-wide "<wide-varrightarrow>"))
  ("math:over < >" (make-wide "<wide-varleftrightarrow>"))
  ("math:over -" (make-wide "<wide-bar>"))
  ("math:under B" (make-wide-under "<bar>"))
  ("math:under C" (make-wide-under "<check>"))
  ("math:under U" (make-wide-under "<breve>"))
  ("math:under A" (make-wide-under "<invbreve>"))
  ("math:under T" (make-wide-under "<bind>"))
  ("math:under V" (make-wide-under "<vect>"))
  ("math:under ~" (make-wide-under "~"))
  ("math:under ^" (make-wide-under "^"))
  ("math:under '" (make-wide-under "<acute>"))
  ("math:under `" (make-wide-under "<grave>"))
  ("math:under -" (make-wide-under "<wide-bar>"))
  ("math:under ." (make-wide-under "<dot>"))
  ("math:under . var" (make-wide-under "<ddot>"))
  ("math:under . var var" (make-wide-under "<dddot>"))
  ("math:under . var var var" (make-wide-under "<ddddot>"))
  ("math:under \"" (make-wide-under "<ddot>"))
  ("math:under \" var" (make-wide-under "<dddot>"))
  ("math:under \" var var" (make-wide-under "<dddot>"))
  ("math:under @" (make-wide-under "<abovering>"))
  ("math:under {" (make-wide-under "<wide-overbrace*>"))
  ("math:under }" (make-wide-under "<wide-underbrace>"))
  ("math:under (" (make-wide-under "<wide-poverbrace*>"))
  ("math:under )" (make-wide-under "<wide-punderbrace>"))
  ("math:under [" (make-wide-under "<wide-sqoverbrace*>"))
  ("math:under ]" (make-wide-under "<wide-squnderbrace>"))
  ("math:under <" (make-wide-under "<wide-varleftarrow>"))
  ("math:under >" (make-wide-under "<wide-varrightarrow>"))
  ("math:under < >" (make-wide-under "<wide-varleftrightarrow>"))

  ("table N c" (make 'choice))
  ("table N m" (make 'matrix))
  ("table N d" (make 'det))
  ("table N s" (make 'stack))
  ("math t" (make 'tabular))
  ("math t var" (make 'tabular*))
  ("math t var var" (make 'block))
  ("math t var var var" (make 'block*))
  ("math t var var var var" (make 'stack))
  ("{ math t" (make 'choice))
  ("( math t" (make 'matrix))
  ("[ math t" (make 'bmatrix))
  ("| math t" (make 'det))

  ("font R" (make-with "math-font" "roman"))
  ("font K" (make-with "math-font" "concrete"))
  ("font F" (make-with "math-font" "Euler"))
  ("font E" (make-with "math-font" "ENR"))
  ("font C" (make-with "math-font" "cal"))
  ("font B" (make-with "math-font" "Bbb*"))
  ("font A" (make-with "math-font" "adobe"))
  ("font o" (make-with "math-font-family" "mr"))
  ("font s" (make-with "math-font-family" "ms"))
  ("font t" (make-with "math-font-family" "mt"))
  ("font m" (make-with "math-font-series" "medium"))
  ("font b" (make-with "math-font-series" "bold"))
  ("font n" (make-with "math-font-shape" "normal"))
  ("font r" (make-with "math-font-shape" "right"))
  ("font l" (make-with "math-font-shape" "slanted"))
  ("font i" (make-with "math-font-shape" "italic"))
  ("font u" (make-with "math-font-shape" "semi-right"))

  ("notsign" "<neg>")
  ("plusminus" "<pm>")
  ("twosuperior" (insert '(rsup "2")))
  ("threesuperior" (insert '(rsup "3")))
  ("mu" "<mu>")
  ("onequarter" (insert '(frac "1" "4")))
  ("onehalf" (insert '(frac "1" "2")))
  ("threequarters" (insert '(frac "3" "4")))

  ("space" (insert-invisible " "))
  ("space var" "<space>")
  ("space var var" "<nospace>")
  ("space space" (noop) (make-space "1em"))
  ("space space space" (noop) (make-space "2em"))
  (", var" "<comma>")
  (", var var" "<nocomma>")
  (", var var space" (insert '(separating-space "0.2em")))
  (", var var space space" (insert '(separating-space "1em")))
  (", var var space space space" (insert '(separating-space "2em")))
  (", space" ",")
  (", space var" (insert '(separating-space "0.2em")))
  (", space space" (insert ",") (make-space "1em"))
  (", space space var" (insert '(separating-space "1em")))
  (", space space space" (insert ",") (make-space "2em"))
  (", space space space var" (insert '(separating-space "2em")))
  (", ," ",<ldots>,")
  ("; ;" ";<ldots>;")
  ("." ".")
  (". var" "<point>")
  (". var var" "<cdummy>")
  (". var var var" "<nosymbol>")

  ("math:symbol a" "<amalg>")
  ("math:symbol d" "<partial>")
  ("math:symbol p" "<wp>")
  ("math:symbol n" "<cap>")
  ("math:symbol n var" "<sqcap>")
  ("math:symbol u" "<cup>")
  ("math:symbol u var" "<sqcup>")
  ("math:symbol w" "<wedge>")
  ("math:symbol w var" "<curlywedge>")
  ("math:symbol w var var" "<curlywedgeuparrow>")
  ("math:symbol w var var var" "<curlywedgedownarrow>")
  ("math:symbol w var var var var" "<wedges>")
  ("math:symbol v" "<vee>")
  ("math:symbol v var" "<curlyvee>")
  ("math:symbol v var var" "<curlyveeuparrow>")
  ("math:symbol v var var var" "<curlyveedownarrow>")
  ("math:symbol x" "<times>")

  ("math:symbol:limits I" (math-big-operator "intlim"))
  ("math:symbol:limits I var" (math-big-operator "upintlim"))
  ("math:symbol:limits I I" (math-big-operator "iintlim"))
  ("math:symbol:limits I I var" (math-big-operator "upidotsintlim"))
  ("math:symbol:limits I I var var" (math-big-operator "upiintlim"))
  ("math:symbol:limits I I I" (math-big-operator "iiintlim"))
  ("math:symbol:limits I I I var" (math-big-operator "upiiintlim"))
  ("math:symbol:limits I I I I" (math-big-operator "iiiintlim"))
  ("math:symbol:limits O" (math-big-operator "ointlim"))
  ("math:symbol:limits O var" (math-big-operator "upointlim"))
  ("math:symbol:limits O O" (math-big-operator "oiintlim"))
  ("math:symbol:limits O O var" (math-big-operator "upoiintlim"))
  ("math:symbol:limits O O O" (math-big-operator "oiiintlim"))
  ("math:symbol:limits O O O var" (math-big-operator "upoiiintlim"))

  ("math:symbol I !" (math-big-operator "intlim"))
  ("math:symbol I var !" (math-big-operator "upintlim"))
  ("math:symbol I I" (math-big-operator "iint"))
  ("math:symbol I I var !" (math-big-operator "iintlim"))
  ("math:symbol I I var var !" (math-big-operator "idotsintlim"))
  ("math:symbol I I var var var !" (math-big-operator "upiintlim"))
  ("math:symbol I I I !" (math-big-operator "iiintlim"))
  ("math:symbol I I I var !" (math-big-operator "upiiintlim"))
  ("math:symbol I I I I var" (math-big-operator "iiintlim"))
  ("math:symbol O !" (math-big-operator "ointlim"))
  ("math:symbol O var !" (math-big-operator "upointlim"))
  ("math:symbol O O !" (math-big-operator "oiintlim"))
  ("math:symbol O O var !" (math-big-operator "upoiintlim"))
  ("math:symbol O O O !" (math-big-operator "oiiintlim"))
  ("math:symbol O O O var !" (math-big-operator "upoiiintlim"))

  ("math:symbol I" (math-big-operator "int"))
  ("math:symbol I var" (math-big-operator "upint"))
  ("math:symbol I var var" (math-big-operator "intlim"))
  ("math:symbol I var var var" (math-big-operator "upintlim"))
  ("math:symbol I I" (math-big-operator "iint"))
  ("math:symbol I I var" (math-big-operator "idotsint"))
  ("math:symbol I I var var" (math-big-operator "upiint"))
  ("math:symbol I I var var var" (math-big-operator "iintlim"))
  ("math:symbol I I var var var var" (math-big-operator "idotsintlim"))
  ("math:symbol I I var var var var var" (math-big-operator "upiintlim"))
  ("math:symbol I I I" (math-big-operator "iiint"))
  ("math:symbol I I I var" (math-big-operator "upiiint"))
  ("math:symbol I I I var var" (math-big-operator "iiintlim"))
  ("math:symbol I I I var var var" (math-big-operator "upiiintlim"))
  ("math:symbol I I I I" (math-big-operator "iiiint"))
  ("math:symbol I I I I var" (math-big-operator "iiiintlim"))
  ("math:symbol O" (math-big-operator "oint"))
  ("math:symbol O var" (math-big-operator "upoint"))
  ("math:symbol O var var" (math-big-operator "ointlim"))
  ("math:symbol O var var var" (math-big-operator "upointlim"))
  ("math:symbol O O" (math-big-operator "oiint"))
  ("math:symbol O O var" (math-big-operator "upoiint"))
  ("math:symbol O O var var" (math-big-operator "oiintlim"))
  ("math:symbol O O var var var" (math-big-operator "upoiintlim"))
  ("math:symbol O O O" (math-big-operator "oiiint"))
  ("math:symbol O O O var" (math-big-operator "upoiiint"))
  ("math:symbol O O O var var" (math-big-operator "oiiintlim"))
  ("math:symbol O O O var var var" (math-big-operator "upoiiintlim"))

  ("math:symbol A" (math-big-operator "amalg"))
  ("math:symbol B" (math-big-operator "parallel"))
  ("math:symbol B var" (math-big-operator "interleave"))
  ("math:symbol N" (math-big-operator "cap"))
  ("math:symbol N var" (math-big-operator "sqcap"))
  ("math:symbol N var var" (math-big-operator "box"))
  ("math:symbol S" (math-big-operator "sum"))
  ("math:symbol P" (math-big-operator "prod"))
  ("math:symbol U" (math-big-operator "cup"))
  ("math:symbol U +" (math-big-operator "pluscup"))
  ("math:symbol U var" (math-big-operator "sqcup"))
  ("math:symbol U var var" (math-big-operator "box"))
  ("math:symbol V" (math-big-operator "vee"))
  ("math:symbol V var" (math-big-operator "curlyvee"))
  ("math:symbol V var var" (math-big-operator "triangledown"))
  ("math:symbol W" (math-big-operator "wedge"))
  ("math:symbol W var" (math-big-operator "curlywedge"))
  ("math:symbol W var var" (math-big-operator "triangleup"))
  ("math:symbol:circled ." (math-big-operator "odot"))
  ("math:symbol:circled +" (math-big-operator "oplus"))
  ("math:symbol:circled x" (math-big-operator "otimes"))
  ("math:symbol:circled *" (math-big-operator "otimes"))

  ("symbol &" "&")
  ("symbol %" "%")
  ("symbol % var" "<permil>")
  ("symbol \\" "\\")
  ("symbol \\ var" "<setminus>")
  ("symbol \\ var var" "<smallsetminus>")
  ("symbol |" "|")
  ("symbol | /" "<nmid>")
  ("symbol | var" "<shortmid>")
  ("symbol | var /" "<nshortmid>")
  ("symbol | var var" "<divides>")
  ("symbol | var var /" "<ndivides>")
  ("symbol | |" "<||>")
  ("symbol | | /" "<nparallel>")
  ("symbol | | var" "<shortparallel>")
  ("symbol | | var /" "<nshortparallel>")

  ("math:small (" (math-bracket-open "(" ")" #f))
  ("math:small ( var" (math-bracket-open "<nobracket>" "<nobracket>" #f))
  ("math:small )" (math-bracket-close ")" "(" #f))
  ("math:small [" (math-bracket-open "[" "]" #f))
  ("math:small [ var" (math-bracket-open "[" "[" #f))
  ("math:small [ var var" (math-bracket-open "]" "]" #f))
  ("math:small [ var var var" (math-bracket-open "]" "[" #f))
  ("math:small ]" (math-bracket-close "]" "[" #f))
  ("math:small [ [" (twice (math-bracket-open "[" "]" #f)))
  ("math:small ] ]" (twice (math-bracket-close "]" "[" #f)))
  ("math:small [ [ var" (math-bracket-open "<llbracket>" "<rrbracket>" #f))
  ("math:small ] ] var" (math-bracket-close "<llbracket>" "<rrbracket>" #f))
  ("math:small {" (math-bracket-open "{" "}" #f))
  ("math:small }" (math-bracket-close "}" "{" #f))
  ("math:small <" (math-bracket-open "<langle>" "<rangle>" #f))
  ("math:small < var" (math-bracket-open "<llangle>" "<rrangle>" #f))
  ("math:small < <" (math-bracket-open "<llangle>" "<rrangle>" #f))
  ("math:small >" (math-bracket-close "<rangle>" "<langle>" #f))
  ("math:small > var" (math-bracket-close "<rrangle>" "<llangle>" #f))
  ("math:small > >" (math-bracket-close "<rrangle>" "<llangle>" #f))
  ("math:small |" (math-bracket-open "|" "|" #f))
  ("math:small | var" (math-separator "|" #f))
  ("math:small | |" (math-bracket-open "<||>" "<||>" #f))
  ("math:small | | var" (math-separator "<||>" #f))
  ("math:small | | |" (math-bracket-open "<interleave>" "<interleave>" #f))
  ("math:small /" (math-bracket-open "/" "\\" #f))
  ("math:small / var" (math-separator "/" #f))
  ("math:small \\" (math-bracket-open "\\" "/" #f))
  ("math:small \\ var" (math-separator "\\" #f))
  ("math:small | ." (math-bracket-open "<lfloor>" "<rfloor>" #f))
  ("math:small . |" (math-bracket-close "<rfloor>" "<lfloor>" #f))
  ("math:small | `" (math-bracket-open "<lceil>" "<rceil>" #f))
  ("math:small ` |" (math-bracket-close "<rceil>" "<lceil>" #f))
  ("math:small | accent:grave" (math-bracket-open "<lceil>" "<rceil>" #f))
  ("math:small accent:grave |" (math-bracket-close "<rceil>" "<lceil>" #f))

  ("math:left (" (math-bracket-open "(" ")" #t))
  ("math:left )" (math-bracket-open ")" "(" #t))
  ("math:left [" (math-bracket-open "[" "]" #t))
  ("math:left ]" (math-bracket-open "]" "[" #t))
  ("math:left {" (math-bracket-open "{" "}" #t))
  ("math:left }" (math-bracket-open "}" "{" #t))
  ("math:left <" (math-bracket-open "<langle>" "<rangle>" #t))
  ("math:left >" (math-bracket-open "<rangle>" "<langle>" #t))
  ("math:left |" (math-bracket-open "|" "|" #t))
  ("math:left | |" (math-bracket-open "<||>" "<||>" #t))
  ("math:left /" (math-bracket-open "/" "\\" #t))
  ("math:left \\" (math-bracket-open "\\" "/" #t))
  ("math:left | ." (math-bracket-open "<lfloor>" "<rfloor>" #t))
  ("math:left | . var" (math-bracket-open "<lfloor>" "<rceil>" #t))
  ("math:left . |" (math-bracket-open "<rfloor>" "<lfloor>" #t))
  ("math:left | `" (math-bracket-open "<lceil>" "<rceil>" #t))
  ("math:left | `" (math-bracket-open "<lceil>" "<rfloor>" #t))
  ("math:left ` | var" (math-bracket-open "<rceil>" "<lceil>" #t))
  ("math:left | accent:grave" (math-bracket-open "<lceil>" "<rceil>" #t))
  ("math:left | accent:grave var" (math-bracket-open "<lceil>" "<rfloor>" #t))
  ("math:left accent:grave |" (math-bracket-open "<rceil>" "<lceil>" #t))
  ("math:left ." (math-bracket-open "<nobracket>" "<nobracket>" #t))

  ("math:middle (" (math-separator "(" #t))
  ("math:middle )" (math-separator ")" #t))
  ("math:middle [" (math-separator "[" #t))
  ("math:middle ]" (math-separator "]" #t))
  ("math:middle {" (math-separator "{" #t))
  ("math:middle }" (math-separator "}" #t))
  ("math:middle <" (math-separator "<langle>" #t))
  ("math:middle >" (math-separator "<rangle>" #t))
  ("math:middle |" (math-separator "|" #t))
  ("math:middle | |" (math-separator "<||>" #t))
  ("math:middle /" (math-separator "/" #t))
  ("math:middle \\" (math-separator "\\" #t))
  ("math:left | ." (math-separator "<lfloor>" #t))
  ("math:left . |" (math-separator "<rfloor>" #t))
  ("math:left | `" (math-separator "<lceil>" #t))
  ("math:left ` |" (math-separator "<rceil>" #t))
  ("math:left | accent:grave" (math-separator "<lceil>" #t))
  ("math:left accent:grave |" (math-separator "<rceil>" #t))
  ("math:middle ." (math-separator "<nobracket>" #t))

  ("math:right (" (math-bracket-close "(" ")" #t))
  ("math:right )" (math-bracket-close ")" "(" #t))
  ("math:right [" (math-bracket-close "[" "]" #t))
  ("math:right ]" (math-bracket-close "]" "[" #t))
  ("math:right {" (math-bracket-close "{" "}" #t))
  ("math:right }" (math-bracket-close "}" "{" #t))
  ("math:right <" (math-bracket-close "<langle>" "<rangle>" #t))
  ("math:right >" (math-bracket-close "<rangle>" "<langle>" #t))
  ("math:right |" (math-bracket-close "|" "|" #t))
  ("math:right | |" (math-bracket-close "<||>" "<||>" #t))
  ("math:right /" (math-bracket-close "/" "\\" #t))
  ("math:right \\" (math-bracket-close "\\" "/" #t))
  ("math:right | ." (math-bracket-close "<lfloor>" "<rfloor>" #t))
  ("math:right . |" (math-bracket-close "<rfloor>" "<lfloor>" #t))
  ("math:right | `" (math-bracket-close "<lceil>" "<rceil>" #t))
  ("math:right ` |" (math-bracket-close "<rceil>" "<lceil>" #t))
  ("math:right | accent:grave" (math-bracket-close "<lceil>" "<rceil>" #t))
  ("math:right accent:grave |" (math-bracket-close "<rceil>" "<lceil>" #t))
  ("math:right ." (math-bracket-close "<nobracket>" "<nobracket>" #t))

  ("(" (math-bracket-open "(" ")" 'default))
  ("( var" (math-bracket-open "<nobracket>" "<nobracket>" 'default))
  (")" (math-bracket-close ")" "(" 'default))
  ("[" (math-bracket-open "[" "]" 'default))
  ("[ var" (math-bracket-open "[" "[" 'default))
  ("[ var var" (math-bracket-open "]" "]" 'default))
  ("[ var var var" (math-bracket-open "]" "[" 'default))
  ("]" (math-bracket-close "]" "[" 'default))
  ("[ [" (twice (math-bracket-open "[" "]" 'default)))
  ("] ]" (twice (math-bracket-close "]" "[" 'default)))
  ("[ [ var" (math-bracket-open "<llbracket>" "<rrbracket>" 'default))
  ("] ] var" (math-bracket-close "<rrbracket>" "<llbracket>" 'default))
  ("{" (math-bracket-open "{" "}" 'default))
  ("{ var" (math-bracket-open "<langle>" "<rangle>" 'default))
  ("{ var var" (math-bracket-open "<llangle>" "<rrangle>" #f))
  ("{ {" (twice (math-bracket-open "{" "}" 'default)))
  ("{ { var" (math-bracket-open "<llangle>" "<rrangle>" #f))
  ("}" (math-bracket-close "}" "{" 'default))
  ("} var" (math-bracket-close "<rangle>" "<langle>" 'default))
  ("} var var" (math-bracket-close "<rrangle>" "<llangle>" #f))
  ("} }" (twice (math-bracket-open "}" "{" 'default)))
  ("} } var" (math-bracket-open "<rrangle>" "<llangle>" #f))
  ("|" (math-bracket-open "|" "|" 'default))
  ("| |" (math-bracket-open "<||>" "<||>" 'default))
  ("| | |" (math-bracket-open "<interleave>" "<interleave>" #f))
  ("| ." (math-bracket-open "<lfloor>" "<rfloor>" 'default))
  ("| . var" (math-bracket-open "<lfloor>" "<rceil>" 'default))
  (". |" (math-bracket-close "<rfloor>" "<lfloor>" 'default))
  ("| `" (math-bracket-open "<lceil>" "<rceil>" 'default))
  ("| ` var" (math-bracket-open "<lceil>" "<rfloor>" 'default))
  ("` |" (math-bracket-close "<rceil>" "<lceil>" 'default))
  ("| accent:grave" (math-bracket-open "<lceil>" "<rceil>" 'default))
  ("| accent:grave var" (math-bracket-open "<lceil>" "<rfloor>" 'default))
  ("accent:grave |" (math-bracket-close "<rceil>" "<lceil>" 'default))
  ("| -" (math-bracket-open "|" "|" 'default) (insert "-"))
  ("| =" (math-bracket-open "|" "|" 'default) (insert "="))
  ("| | -" (math-bracket-open "<||>" "<||>" 'default) (insert "-"))
  ("| | =" (math-bracket-open "<||>" "<||>" 'default) (insert "="))
  ("| | | -" (math-bracket-open "<interleave>" "<interleave>" 'default)
             (insert "-"))
  ("| | | =" (math-bracket-open "<interleave>" "<interleave>" 'default)
             (insert "="))

  ("<" "<less>")
  (">" "<gtr>")
  ("< /" "<nless>")
  ("> /" "<ngtr>")
  ("< =" "<leqslant>")
  ("> =" "<geqslant>")
  ("< = /" "<nleqslant>")
  ("> = /" "<ngeqslant>")
  ("< = var" "<leq>")
  ("> = var" "<geq>")
  ("< = var /" "<nleq>")
  ("> = var /" "<ngeq>")
  ("< <" "<ll>")
  ("< < <" "<lll>")
  ("> >" "<gg>")
  ("> > >" "<ggg>")
  ("< < =" "<lleq>")
  ("< < < =" "<llleq>")
  ("> > =" "<ggeq>")
  ("> > > =" "<gggeq>")
  ("< < /" "<nll>")
  ("< < < /" "<nlll>")
  ("> > /" "<ngg>")
  ("> > > /" "<nggg>")
  ("< < = /" "<nlleq>")
  ("< < < = /" "<nllleq>")
  ("> > = /" "<nggeq>")
  ("> > > = /" "<ngggeq>")
  ("< ." "<lessdot>")
  (". >" "<gtrdot>")
  ("< = ." "<lesseqdot>")
  (". > =" "<gtreqdot>")

  ("< >" "<lessgtr>")
  ("< > var" "<diamondsuit>")
  ("< > var var" "<heartsuit>")
  ("< > var var var" "<spadesuit>")
  ("< > var var var var" "<clubsuit>")
  ("> <" "<gtrless>")
  ("> < var" "<join>")
  ("< ~" "<lesssim>")
  ("< ~ ~" "<lessapprox>")
  ("> ~" "<gtrsim>")
  ("> ~ ~" "<gtrapprox>")
  ("> var ~" "<gtrsim>")
  ("> var ~ ~" "<gtrapprox>")
  ("< = var var" "<leqq>")
  ("> = var var" "<geqq>")
  ("< = var >" "<lesseqgtr>")
  ("> = var <" "<gtreqless>")
  ("< = var var >" "<lesseqqgtr>")
  ("> = var var <" "<gtreqqless>")
  ("< > /" "<nlessgtr>")
  ("> < /" "<ngtrless>")
  ("< ~ /" "<nlesssim>")
  ("< ~ / var" "<lnsim>")
  ("< ~ ~ /" "<nlessapprox>")
  ("< ~ ~ / var" "<lnapprox>")
  ("> ~ /" "<ngtrsim>")
  ("> ~ / var" "<gnsim>")
  ("> ~ ~ /" "<ngtrapprox>")
  ("> ~ ~ / var" "<gnapprox>")
  ("< = var var /" "<nleqq>")
  ("> = var var /" "<ngeqq>")
  ("< = var > /" "<nlesseqgtr>")
  ("> = var < /" "<ngtreqless>")
  ("< = var var > /" "<nlesseqqgtr>")
  ("> = var var < /" "<ngtreqqless>")
  ("< = var / var" "<lneq>")
  ("< = var var / var" "<lneqq>")
  ("< = var var / var var" "<lvertneqq>")
  ("> = var / var" "<gneq>")
  ("> = var var / var" "<gneqq>")
  ("> = var var / var var" "<gvertneqq>")

  ("< var" "<in>")
  ("> var" "<ni>")
  ("< var /" "<nin>")
  ("> var /" "<nni>")

  ("< var var" "<subset>")
  ("> var var" "<supset>")
  ("< var var /" "<nsubset>")
  ("> var var /" "<nsupset>")
  ("< var var =" "<subseteq>")
  ("> var var =" "<supseteq>")
  ("< var var = /" "<nsubseteq>")
  ("> var var = /" "<nsupseteq>")
  ("< var var = var" "<subseteqq>")
  ("> var var = var" "<supseteqq>")
  ("< var var = /" "<nsubseteq>")
  ("> var var = /" "<nsupseteq>")
  ("< var var = var /" "<nsubseteqq>")
  ("> var var = var /" "<nsupseteqq>")
  ("< var var = / var" "<subsetneq>")
  ("> var var = / var" "<supsetneq>")
  ("< var var = / var var" "<varsubsetneq>")
  ("> var var = / var var" "<varsupsetneq>")
  ("< var var = var / var" "<subsetneqq>")
  ("> var var = var / var" "<supsetneqq>")
  ("< var var = var / var var" "<varsubsetneqq>")
  ("> var var = var / var var" "<varsupsetneqq>")
  ("< var var +" "<subsetplus>")
  ("> var var +" "<supsetplus>")
  ("< var var + =" "<subsetpluseq>")
  ("> var var + =" "<supsetpluseq>")
  ("< var var = +" "<subsetpluseq>")
  ("> var var = +" "<supsetpluseq>")
  ("< var var ~" "<subsetsim>")
  ("> var var ~" "<supsetsim>")

  ("< var var var" "<prec>")
  ("> var var var" "<succ>")
  ("< var var var /" "<nprec>")
  ("> var var var /" "<nsucc>")
  ("< var var var =" "<preccurlyeq>")
  ("> var var var =" "<succcurlyeq>")
  ("< var var var = /" "<npreccurlyeq>")
  ("> var var var = /" "<nsucccurlyeq>")
  ("< var var var = var" "<preceq>")
  ("> var var var = var" "<succeq>")
  ("< var var var = var /" "<npreceq>")
  ("> var var var = var /" "<nsucceq>")
  ("< var var var = var / var" "<precneqq>")
  ("> var var var = var / var" "<succneqq>")
  ("< var var var ~" "<precsim>")
  ("> var var var ~" "<succsim>")
  ("< var var var ~ ~" "<precapprox>")
  ("> var var var ~ ~" "<succapprox>")
  ("< var var var ~ /" "<nprecsim>")
  ("> var var var ~ /" "<nsuccsim>")
  ("< var var var ~ / var" "<precnsim>")
  ("> var var var ~ / var" "<succnsim>")
  ("< var var var ~ ~ /" "<nprecapprox>")
  ("> var var var ~ ~ /" "<nsuccapprox>")
  ("< var var var ~ ~ / var" "<precnapprox>")
  ("> var var var ~ ~ / var" "<succnapprox>")
  ("< var var var ." "<precdot>")
  ("< var var var = ." "<preceqdot>")
  ("< . var" "<precdot>")
  (". > var" "<dotsucc>")
  ("< . var =" "<preceqdot>")
  (". > var =" "<dotsucceq>")

  ("< < var" "<precprec>")
  ("< < < var" "<precprecprec>")
  ("> > var" "<succsucc>")
  ("> > > var" "<succsuccsucc>")
  ("< < var =" "<precpreceq>")
  ("< < < var =" "<precprecpreceq>")
  ("> > var =" "<succsucceq>")
  ("> > > var =" "<succsuccsucceq>")
  ("< < var /" "<nprecprec>")
  ("< < < var /" "<nprecprecprec>")
  ("> > var /" "<nsuccsucc>")
  ("> > > var /" "<nsuccsuccsucc>")
  ("< < var = /" "<nprecpreceq>")
  ("< < < var = /" "<nprecprecpreceq>")
  ("> > var = /" "<nsuccsucceq>")
  ("> > > var = /" "<nsuccsuccsucceq>")

  ("< var var var var" "<sqsubset>")
  ("> var var var var" "<sqsupset>")
  ("< var var var var /" "<nsqsubset>")
  ("> var var var var /" "<nsqsupset>")
  ("< var var var var =" "<sqsubseteq>")
  ("> var var var var =" "<sqsupseteq>")
  ("< var var var var = /" "<nsqsubseteq>")
  ("> var var var var = /" "<nsqsupseteq>")

  ("< < var var" "<Subset>")
  ("> > var var" "<Supset>")

  ("< var var var var var" (math-bracket-open "<langle>" "<rangle>" 'default))
  ("> var var var var var" (math-bracket-close "<rangle>" "<langle>" 'default))
  ("< < var var var" (math-bracket-open "<llangle>" "<rrangle>" 'default))
  ("> > var var var" (math-bracket-close "<rrangle>" "<llangle>" 'default))

  ("- >" "<rightarrow>")
  ("- > var" "<downarrow>")
  ("- > var var" "<uparrow>")
  ("- > var var var" "<searrow>")
  ("- > var var var var" "<nearrow>")
  ("< -" "<leftarrow>")
  ("< - var" "<uparrow>")
  ("< - var var" "<downarrow>")
  ("< - var var var" "<nwarrow>")
  ("< - var var var var" "<swarrow>")
  ("< - >" "<leftrightarrow>")
  ("< - > var" "<updownarrow>")
  ("- -" "<longminus>")
  ("- - >" "<longrightarrow>")
  ("- - > var" "<longdownarrow>")
  ("- - > var var" "<longuparrow>")
  ("< - -" "<longleftarrow>")
  ("< - - var" "<longuparrow>")
  ("< - - var var" "<longdownarrow>")
  ("< - - >" "<longleftrightarrow>")
  ("< - - > var" "<longupdownarrow>")
  ("= >" "<Rightarrow>")
  ("= > var" "<Downarrow>")
  ("= > var var" "<Uparrow>")
  ("< = var var var" "<Leftarrow>")
  ("< = >" "<Leftrightarrow>")
  ("< = > var" "<Updownarrow>")
  ("= =" "<longequal>")
  ("= = >" "<Longrightarrow>")
  ("= = > var" "<Longdownarrow>")
  ("= = > var var" "<Longuparrow>")
  ("< = =" "<Longleftarrow>")
  ("< = = var" "<Longuparrow>")
  ("< = = var var" "<Longdownarrow>")
  ("< = = >" "<Longleftrightarrow>")
  ("< = = > var" "<Longupdownarrow>")
  ("- /" "<rightharpoondown>")
  ("- / var" "<rightharpoonup>")
  ("- / var var" "<downharpoonleft>")
  ("- / var var var" "<downharpoonright>")
  ("- / var var var var" "<upharpoonright>")
  ("- / var var var var var" "<upharpoonleft>")
  ("/ -" "<leftharpoonup>")
  ("/ - var" "<leftharpoondown>")
  ("/ - var var" "<upharpoonright>")
  ("/ - var var var" "<upharpoonleft>")
  ("/ - var var var var" "<downharpoonleft>")
  ("/ - var var var var var" "<downharpoonright>")
  ("| - >" "<mapsto>")
  ("| - > var" "<hookrightarrow>")
  ("| - > var var" "<mapsdown>")
  ("| - > var var var" "<hookdownarrow>")
  ("| - > var var var var" "<mapsup>")
  ("| - > var var var var var" "<hookuparrow>")
  ("| - - >" "<longmapsto>")
  ("| - - > var" "<longhookrightarrow>")
  ("| - - > var var" "<longmapsdown>")
  ("| - - > var var var" "<longhookdownarrow>")
  ("| - - > var var var var" "<longmapsup>")
  ("| - - > var var var var var" "<longhookuparrow>")
  ("| var - >" "<mapsto>")
  ("| var - > var" "<hookrightarrow>")
  ("| var - > var var" "<mapsdown>")
  ("| var - > var var var" "<hookdownarrow>")
  ("| var - > var var var var" "<mapsup>")
  ("| var - > var var var var var" "<hookuparrow>")
  ("| var - - >" "<longmapsto>")
  ("| var - - > var" "<longhookrightarrow>")
  ("| var - - > var var" "<longmapsdown>")
  ("| var - - > var var var" "<longhookdownarrow>")
  ("| var - - > var var var var" "<longmapsup>")
  ("| var - - > var var var var var" "<longhookuparrow>")
  ("< - |" "<mapsfrom>")
  ("< - | var" "<hookleftarrow>")
  ("< - | var var" "<mapsup>")
  ("< - | var var var" "<hookuparrow>")
  ("< - | var var var var" "<mapsdown>")
  ("< - | var var var var var" "<hookdownarrow>")
  ("< - - |" "<longmapsfrom>")
  ("< - - | var" "<longhookleftarrow>")
  ("< - - | var var" "<longmapsup>")
  ("< - - | var var var" "<longhookuparrow>")
  ("< - - | var var var var" "<longmapsdown>")
  ("< - - | var var var var var" "<longhookdownarrow>")
  ("~ >" "<rightsquigarrow>")
  ("~ > var" "<downsquigarrow>")
  ("~ > var var" "<upsquigarrow>")
  ("< ~ var" "<leftsquigarrow>")
  ("< ~ var var" "<upsquigarrow>")
  ("< ~ var var var" "<downsquigarrow>")
  ("< ~ >" "<leftrightsquigarrow>")
  ("< - <" "<leftarrowtail>")
  ("> - >" "<rightarrowtail>")
  ("- > - >" "<rightrightarrows>")
  ("- > - > var" "<downdownarrows>")
  ("- > - > var var" "<upuparrows>")
  ("< - < -" "<leftleftarrows>")
  ("< - < - var" "<upuparrows>")
  ("< - < - var var" "<downdownarrows>")
  ("- > < -" "<rightleftarrows>")
  ("- > < - var" "<rightleftharpoons>")
  ("< - - > var" "<leftrightarrows>")
  ("< - - > var var" "<leftrightharpoons>")
  ("- > >" "<twoheadrightarrow>")
  ("< < -" "<twoheadleftarrow>")
  ("- - > >" "<longtwoheadrightarrow>")
  ("< < - -" "<longtwoheadleftarrow>")
  ("- > /" "<nrightarrow>")
  ("< - /" "<nleftarrow>")
  ("< - > /" "<nleftrightarrow>")
  ("= > /" "<nRightarrow>")
  ("< = var var var /" "<nLeftarrow>")
  ("< = > /" "<nLeftrightarrow>")
  ("< - > -" "<leftrightarroweq>")
  ("- | >" "<rightarrowtriangle>")
  ("< | -" "<leftarrowtriangle>")
  ("< | - | >" "<leftrightarrowtriangle>")
  ("| - | >" "<longmapstotriangle>")
  ("| var - | >" "<longmapstotriangle>")
  ("- - | >" "<longrightarrowtriangle>")
  ("< | - -" "<longleftarrowtriangle>")
  ("< | - - | >" "<longleftrightarrowtriangle>")
  ("| - - | >" "<longmapstotriangle>")
  ("| var - - | >" "<longmapstotriangle>")
  ("< - < var" "<leftprec>")
  ("> var - >" "<succright>")
  ("< - < var =" "<leftpreceq>")
  ("> var = - >" "<succeqright>")
  ("< - @" "<looparrowleft>")
  ("@ - >" "<looparrowright>")

  ("- > !" "<rightarrowlim>")
  ("< - !" "<leftarrowlim>")
  ("< - > !" "<leftrightarrowlim>")
  ("| - > !" "<mapstolim>")
  ("| var - > !" "<mapstolim>")
  ("- - > !" "<longrightarrowlim>")
  ("< - - !" "<longleftarrowlim>")
  ("< - - > !" "<longleftrightarrowlim>")
  ("| - - > !" "<longmapstolim>")
  ("| var - - > !" "<longmapstolim>")
  ("~ > !" "<rightsquigarrowlim>")
  ("< ~ !" "<leftsquigarrowlim>")
  ("< ~ > !" "<leftrightsquigarrowlim>")
  ("= !" "<equallim>")
  ("= = !" "<longequallim>")
  ("= > !" "<Rightarrowlim>")
  ("< = !" "<Leftarrowlim>")
  ("< = > !" "<Leftrightarrowlim>")
  ("= = > !" "<Longrightarrowlim>")
  ("< = = !" "<Longleftarrowlim>")
  ("< = = > !" "<Longleftrightarrowlim>")

  ("- ^" (make-long-arrow "<minus>"))
  ("- > ^" (make-long-arrow "<rightarrow>"))
  ("< - ^" (make-long-arrow "<leftarrow>"))
  ("< - > ^" (make-long-arrow "<leftrightarrow>"))
  ("| - > ^" (make-long-arrow "<mapsto>"))
  ("| var - > ^" (make-long-arrow "<mapsto>"))
  ("< - | ^" (make-long-arrow "<mapsfrom>"))
  ("= ^" (make-long-arrow "<equal>"))
  ("= > ^" (make-long-arrow "<Rightarrow>"))
  ("< = ^" (make-long-arrow "<Leftarrow>"))
  ("< = > ^" (make-long-arrow "<Leftrightarrow>"))
  ("- - ^" (make-long-arrow "<minus>"))
  ("- - > ^" (make-long-arrow "<rightarrow>"))
  ("< - - ^" (make-long-arrow "<leftarrow>"))
  ("< - - > ^" (make-long-arrow "<leftrightarrow>"))
  ("| - - > ^" (make-long-arrow "<mapsto>"))
  ("| var - - > ^" (make-long-arrow "<mapsto>"))
  ("< - - | ^" (make-long-arrow "<mapsfrom>"))
  ("= = ^" (make-long-arrow "<equal>"))
  ("= = > ^" (make-long-arrow "<Rightarrow>"))
  ("< = = ^" (make-long-arrow "<Leftarrow>"))
  ("< = = > ^" (make-long-arrow "<Leftrightarrow>"))

  ("- _" (make-long-arrow* "<minus>"))
  ("- > _" (make-long-arrow* "<rightarrow>"))
  ("< - _" (make-long-arrow* "<leftarrow>"))
  ("< - > _" (make-long-arrow* "<leftrightarrow>"))
  ("| - > _" (make-long-arrow* "<mapsto>"))
  ("| var - > _" (make-long-arrow* "<mapsto>"))
  ("< - | _" (make-long-arrow* "<mapsfrom>"))
  ("= _" (make-long-arrow* "<equal>"))
  ("= > _" (make-long-arrow* "<Rightarrow>"))
  ("< = _" (make-long-arrow* "<Leftarrow>"))
  ("< = > _" (make-long-arrow* "<Leftrightarrow>"))
  ("- - _" (make-long-arrow* "<minus>"))
  ("- - > _" (make-long-arrow* "<rightarrow>"))
  ("< - - _" (make-long-arrow* "<leftarrow>"))
  ("< - - > _" (make-long-arrow* "<leftrightarrow>"))
  ("| - - > _" (make-long-arrow* "<mapsto>"))
  ("| var - - > _" (make-long-arrow* "<mapsto>"))
  ("< - - | _" (make-long-arrow* "<mapsfrom>"))
  ("= = _" (make-long-arrow* "<equal>"))
  ("= = > _" (make-long-arrow* "<Rightarrow>"))
  ("< = = _" (make-long-arrow* "<Leftarrow>"))
  ("< = = > _" (make-long-arrow* "<Leftrightarrow>"))

  ("@" "<circ>")
  ("@ /" "<varnothing>")
  ("@ +" "<oplus>")
  ("@ -" "<ominus>")
  ("@ - var" "<mapmulti>")
  ("@ ." "<odot>")
  ("@ :" "<oover>")
  ("@ x" "<otimes>")
  ("@ *" "<otimes>")
  ("@ * var" "<oast>")
  ("@ R" "<circledR>")
  ("@ S" "<circledS>")
  ("@ / var" "<oslash>")
  ("@ \\" "<obslash>")
  ("@ <" "<olessthan>")
  ("@ >" "<ogreaterthan>")
  ("@ &" "<owedge>")
  ("@ |" "<obar>")
  ("@ | var" "<ovee>")
  ("@ v" "<ovee>")
  ("@ @" "<infty>")
  ("@ @ var" "<varocircle>")
  ("@ @ var var" "<propto>")
  ("- @ @" "-<infty>")
  ("@ var" "<box>")
  ("@ var +" "<boxplus>")
  ("@ var -" "<boxminus>")
  ("@ var x" "<boxtimes>")
  ("@ var *" "<boxtimes>")
  ("@ var * var" "<boxast>")
  ("@ var ." "<boxdot>")
  ("@ var /" "<boxslash>")
  ("@ var \\" "<boxbslash>")
  ("@ var @" "<boxcircle>")
  ("@ var @ var" "<boxbox>")
  ("@ var |" "<boxbar>")
  ("@ var var" "<bullet>")
  ("@ var var var" "<blacksquare>")
  ("@ var var var var" "<vartriangle>")
  ("@ var var var var var" "<blacktriangle>")

  ("= var" "<asymp>")
  ("= var var" "<equiv>")
  ("= var var var" "<asympasymp>")
  ("= var var var var" "<simsim>")
  ("~" "<sim>")
  ("~ var" "<backsim>")
  ("~ ~" "<approx>")
  ("~ ~ var" "<Bumpeq>")
  ("~ ~ -" "<approxeq>")
  ("~ -" "<simeq>")
  ("~ - var" "<backsimeq>")
  ("~ - var var" "<bumpeq>")
  ("~ =" "<cong>")
  ("= /" "<neq>")
  ("= var /" "<nasymp>")
  ("= var var /" "<nequiv>")
  ("= var var var /" "<nasympasymp>")
  ("= var var var var /" "<nsimsim>")
  ("~ /" "<nsim>")
  ("~ ~ /" "<napprox>")
  ("~ - /" "<nsimeq>")
  ("~ = /" "<ncong>"))

(kbd-map
  (:mode in-math-or-hybrid?)
  ("/ \\" "<wedge>")
  ("/ \\ var " "<cap>")
  ("/ \\ var var" "<sqcap>")
  ("/ \\ var var var" "<product>")
  ("/ \\ var var var var" "<curlywedge>")
  ("/ \\ var var var var var" "<curlywedgeuparrow>")
  ("/ \\ var var var var var var" "<curlywedgedownarrow>")
  ("/ \\ var var var var var var var" (begin (insert "/") (make-hybrid)))
  ("- / \\" "<barwedge>")
  ("\\ /" "<vee>")
  ("\\ / var" "<cup>")
  ("\\ / var +" "<uplus>")
  ("\\ / var var" "<sqcup>")
  ("\\ / var var var" "<amalg>")
  ("\\ / var var var var" "<curlyvee>")
  ("\\ / var var var var var" "<curlyveedownarrow>")
  ("\\ / var var var var var var" "<curlyveeuparrow>")
  ("\\ / var var var var var var var" (begin (make-hybrid) (insert "/")))
  ("\\ / -" "<veebar>"))

(kbd-map
  (:mode in-math?)
  ("# var" "<sharp>")
  ("# var var" "<natural>")
  ("# var var var" "<flat>")
  ("&" "<wedge>")
  ("& var" "<cap>")
  ("& var var" "<sqcap>")
  ("& var var var" "<product>")
  ("& var var var var" "<curlywedge>")
  ("& var var var var var" "<curlywedgeuparrow>")
  ("& var var var var var var" "<curlywedgedownarrow>")
  ("& var var var var var var var" "&")
  ("- &" "<barwedge>")
  ("%" "<vee>")
  ("% var" "<cup>")
  ("% var +" "<uplus>")
  ("% var var" "<sqcup>")
  ("% var var var" "<amalg>")
  ("% var var var var" "<curlyvee>")
  ("% var var var var var" "<curlyveedownarrow>")
  ("% var var var var var var" "<curlyveeuparrow>")
  ("% var var var var var var var" "<permil>")
  ("% var var var var var var var var" "%")
  ("% -" "<veebar>")

  ("| /" "<nmid>")
  ("| var" "|")
  ("| var /" "<nmid>")
  ("| var var" (math-separator "|" 'default))
  ("| var var/" "<nmid>")
  ("| var var var" "<shortmid>")
  ("| var var var /" "<nshortmid>")
  ("| var var var var" "<divides>")
  ("| var var var var var" "<divides>")
  ("| | var" "<||>")
  ("| | var /" "<nparallel>")
  ("| | var var" (math-separator "<||>" 'default))
  ("| | var var /" "<nparallel>")
  ("| | var var var" "<shortparallel>")
  ("| | var var var /" "<nshortparallel>")
  ("| | | var" "<interleave>")

  ("| - var" "<vdash>")
  ("| - var -" "<vdash>")
  ("| - -" "<longvdash>")
  ("| var -" "<vdash>")
  ("| var - -" "<longvdash>")
  ("| | - var" "<Vdash>")
  ("| | - var -" "<longVdash>")
  ("| | - -" "<longVdash>")
  ("| | var -" "<Vdash>")
  ("| | var - -" "<longVdash>")
  ("| | | - var" "<Vvdash>")
  ("| | | - var -" "<longVvdash>")
  ("| | | - -" "<longVvdash>")
  ("| | | var -" "<Vvdash>")
  ("| | | var - -" "<longVvdash>")
  ("- | var" "<dashv>")
  ("- - |" "<longdashv>")
  ("| = var" "<vDash>")
  ("| = var =" "<longvDash>")
  ("| = =" "<longvDash>")
  ("| var =" "<vDash>")
  ("| var = =" "<longvDash>")
  ;; ("| | = var" "<VDash>")
  ;; ("| | = var =" "<longVDash>")
  ;; ("| | = =" "<longVDash>")
  ;; ("| | var =" "<VDash>")
  ;; ("| | var = =" "<longVDash>")
  ("| - var /" "<nvdash>")
  ("| - /" "<nvdash>")
  ("| var - /" "<nvdash>")
  ("| | - var /" "<nVdash>")
  ("| | - /" "<nVdash>")
  ("| | var - /" "<nVdash>")
  ;; ("- | var /" "<ndashv>")
  ;; ("- | /" "<ndashv>")
  ;; ("- | var | /" "<ndashV>")
  ;; ("- | | var /" "<ndashV>")
  ;; ("- | | /" "<ndashV>")
  ("| = var /" "<nvDash>")
  ("| = /" "<nvDash>")
  ("| var = /" "<nvDash>")
  ;; ("| | = var /" "<nVDash>")
  ;; ("| | = /" "<nVDash>")
  ;; ("| | var = /" "<nVDash>")
  ;; ("= | var /" "<nDashv>")
  ;; ("= | /" "<nDashv>")
  ;; ("= | var | /" "<nDashV>")
  ;; ("= | | var /" "<nDashV>")
  ;; ("= | | /" "<nDashV>")

  ("< | var" "<vartriangleleft>")
  ("< | var var" "<blacktriangleleft>")
  ("< | var /" "<ntriangleleft>")
  ("< | var =" "<trianglelefteqslant>")
  ("< | var = /" "<ntrianglelefteqslant>")
  ("< | var = var" "<trianglelefteq>")
  ("< | var = var /" "<ntrianglelefteq>")
  ("| > var" "<vartriangleright>")
  ("| > var var" "<blacktriangleright>")
  ("| > var /" "<ntriangleright>")
  ("| > var =" "<trianglerighteqslant>")
  ("| > var = /" "<ntrianglerighteqslant>")
  ("| > var = var" "<trianglerighteq>")
  ("| > var = var /" "<ntrianglerighteq>")
  ("| var >" "<vartriangleright>")
  ("| var > var" "<blacktriangleright>")
  ("| var > /" "<ntriangleright>")
  ("| var > =" "<trianglerighteqslant>")
  ("| var > = /" "<ntrianglerighteqslant>")
  ("| var > = var" "<trianglerighteq>")
  ("| var > = var /" "<ntrianglerighteq>")

  ("+ var" "<kreuz>")
  ("+ var var" "<dag>")
  ("+ var var var" "<ddag>")
  ("+ var var var var" "<noplus>")
  ("+ +" "+<cdots>+")
  ("+ -" "<pm>")
  ("- +" "<mp>")
  ("@ =" "<circeq>")
  ("@ = var" "<triangleq>")
  ("= @" "<eqcirc>")
  ("- @" "<multimap>")
  (". =" "<doteq>")
  (". ." "<ldots>")
  (". . var" "<cdots>")
  (". . var !" "<cdotslim>")
  (". . var var" "<hdots>")
  (". . var var var" "<vdots>")
  (". . var var var var" "<ddots>")
  (". . var var var var var" "<udots>")
  (":" ":")
  (": var" "<of>")
  (": var var" "<over>")
  (": :" "<colons>")
  (": >" "<transtype>")
  (": =" "<assign>")
  ("+ =" "<plusassign>")
  ("- =" "<minusassign>")
  ("/ var" "<over>")
  ("/ var var" "<div>")
  ("*" (insert-invisible "*"))
  ("* *" (insert-invisible "*") (insert "<cdots>") (insert-invisible "*"))
  ("* var" "<times>")
  ("* var var" "<ast>")
  ("* var var var" "<cdot>")
  ("* var var var var" "<exterior>")
  ("* var var var var var" "<star>")
  ("* &" "<exterior>")
  ("| * var" "<ltimes>")
  ("| * var |" "<join>")
  ("| var *" "<ltimes>")
  ("| var * |" "<join>")
  ("* | var" "<rtimes>")
  ("* var var |" "<rtimes>")
  ("! var" "<neg>")

  ("math:greek a" "<alpha>")
  ("math:greek b" "<beta>")
  ("math:greek g" "<gamma>")
  ("math:greek g var" "<matheuler>")
  ("math:greek d" "<delta>")
  ("math:greek e" "<varepsilon>")
  ("math:greek e var" "<epsilon>")
  ("math:greek e var var" "<backepsilon>")
  ("math:greek z" "<zeta>")
  ("math:greek h" "<eta>")
  ("math:greek j" "<theta>")
  ("math:greek j var" "<vartheta>")
  ("math:greek i" "<iota>")
  ("math:greek k" "<kappa>")
  ("math:greek k var" "<varkappa>")
  ("math:greek l" "<lambda>")
  ("math:greek l var" "<mathlambda>")
  ("math:greek m" "<mu>")
  ("math:greek n" "<nu>")
  ("math:greek x" "<xi>")
  ("math:greek o" "<omicron>")
  ("math:greek p" "<pi>")
  ("math:greek p var" "<mathpi>")
  ("math:greek p var var" "<varpi>")
  ("math:greek r" "<rho>")
  ("math:greek r var" "<varrho>")
  ("math:greek s" "<sigma>")
  ("math:greek s var" "<varsigma>")
  ("math:greek c" "<varsigma>")
  ("math:greek c var" "<sigma>")
  ("math:greek t" "<tau>")
  ("math:greek u" "<upsilon>")
  ("math:greek f" "<varphi>")
  ("math:greek f var" "<phi>")
  ("math:greek y" "<psi>")
  ("math:greek q" "<chi>")
  ("math:greek w" "<omega>")
  ("math:greek w var" "<mho>")
  ("math:greek v" "<phi>")
  ("math:greek v var" "<varphi>")
  ("math:greek A" "<Alpha>")
  ("math:greek B" "<Beta>")
  ("math:greek G" "<Gamma>")
  ("math:greek G var" "<mathGamma>")
  ("math:greek D" "<Delta>")
  ("math:greek D var" "<mathLaplace>")
  ("math:greek E" "<Epsilon>")
  ("math:greek E var" "<Backepsilon>")
  ("math:greek Z" "<Zeta>")
  ("math:greek H" "<Eta>")
  ("math:greek J" "<Theta>")
  ("math:greek I" "<Iota>")
  ("math:greek K" "<Kappa>")
  ("math:greek L" "<Lambda>")
  ("math:greek M" "<Mu>")
  ("math:greek N" "<Nu>")
  ("math:greek X" "<Xi>")
  ("math:greek O" "<Omicron>")
  ("math:greek P" "<Pi>")
  ("math:greek R" "<Rho>")
  ("math:greek S" "<Sigma>")
  ("math:greek C" "<Sigma>")
  ("math:greek T" "<Tau>")
  ("math:greek U" "<Upsilon>")
  ("math:greek F" "<Phi>")
  ("math:greek Y" "<Psi>")
  ("math:greek Q" "<Chi>")
  ("math:greek W" "<Omega>")
  ("math:greek W var" "<Mho>")
  ("math:greek V" "<Phi>")

  ("math:greek &" "&")
  ("math:greek %" "%")
  ("math:greek % var" "<permil>")
  ("math:greek \\" "\\")
  ("math:greek \\ var" "<setminus>")
  ("math:greek \\ var var" "<smallsetminus>")
  ("math:greek |" "|")
  ("math:greek | /" "<nmid>")
  ("math:greek | var" "<shortmid>")
  ("math:greek | var /" "<nshortmid>")
  ("math:greek | var var" "<divides>")
  ("math:greek | var var /" "<ndivides>")
  ("math:greek | |" "<||>")
  ("math:greek | | /" "<nparallel>")
  ("math:greek | | var" "<shortparallel>")
  ("math:greek | | var /" "<nshortparallel>")

  ("math:bold 0" "<b-0>")
  ("math:bold 1" "<b-1>")
  ("math:bold 2" "<b-2>")
  ("math:bold 3" "<b-3>")
  ("math:bold 4" "<b-4>")
  ("math:bold 5" "<b-5>")
  ("math:bold 6" "<b-6>")
  ("math:bold 7" "<b-7>")
  ("math:bold 8" "<b-8>")
  ("math:bold 9" "<b-9>")
  ("math:bold a" "<b-a>")
  ("math:bold b" "<b-b>")
  ("math:bold c" "<b-c>")
  ("math:bold d" "<b-d>")
  ("math:bold e" "<b-e>")
  ("math:bold f" "<b-f>")
  ("math:bold g" "<b-g>")
  ("math:bold h" "<b-h>")
  ("math:bold i" "<b-i>")
  ("math:bold j" "<b-j>")
  ("math:bold k" "<b-k>")
  ("math:bold l" "<b-l>")
  ("math:bold m" "<b-m>")
  ("math:bold n" "<b-n>")
  ("math:bold o" "<b-o>")
  ("math:bold p" "<b-p>")
  ("math:bold q" "<b-q>")
  ("math:bold r" "<b-r>")
  ("math:bold s" "<b-s>")
  ("math:bold t" "<b-t>")
  ("math:bold u" "<b-u>")
  ("math:bold v" "<b-v>")
  ("math:bold w" "<b-w>")
  ("math:bold x" "<b-x>")
  ("math:bold y" "<b-y>")
  ("math:bold z" "<b-z>")
  ("math:bold A" "<b-A>")
  ("math:bold B" "<b-B>")
  ("math:bold C" "<b-C>")
  ("math:bold D" "<b-D>")
  ("math:bold E" "<b-E>")
  ("math:bold F" "<b-F>")
  ("math:bold G" "<b-G>")
  ("math:bold H" "<b-H>")
  ("math:bold I" "<b-I>")
  ("math:bold J" "<b-J>")
  ("math:bold K" "<b-K>")
  ("math:bold L" "<b-L>")
  ("math:bold M" "<b-M>")
  ("math:bold N" "<b-N>")
  ("math:bold O" "<b-O>")
  ("math:bold P" "<b-P>")
  ("math:bold Q" "<b-Q>")
  ("math:bold R" "<b-R>")
  ("math:bold S" "<b-S>")
  ("math:bold T" "<b-T>")
  ("math:bold U" "<b-U>")
  ("math:bold V" "<b-V>")
  ("math:bold W" "<b-W>")
  ("math:bold X" "<b-X>")
  ("math:bold Y" "<b-Y>")
  ("math:bold Z" "<b-Z>")
  ("math:bold i var" "<b-imath>")
  ("math:bold j var" "<b-jmath>")
  ("math:bold l var" "<b-ell>")
  ("math:bold ~" "<thicksim>")
  ("math:bold ~ ~" "<thickapprox>")

  ("math:bold:up a" "<b-up-a>")
  ("math:bold:up b" "<b-up-b>")
  ("math:bold:up c" "<b-up-c>")
  ("math:bold:up d" "<b-up-d>")
  ("math:bold:up e" "<b-up-e>")
  ("math:bold:up f" "<b-up-f>")
  ("math:bold:up g" "<b-up-g>")
  ("math:bold:up h" "<b-up-h>")
  ("math:bold:up i" "<b-up-i>")
  ("math:bold:up j" "<b-up-j>")
  ("math:bold:up k" "<b-up-k>")
  ("math:bold:up l" "<b-up-l>")
  ("math:bold:up m" "<b-up-m>")
  ("math:bold:up n" "<b-up-n>")
  ("math:bold:up o" "<b-up-o>")
  ("math:bold:up p" "<b-up-p>")
  ("math:bold:up q" "<b-up-q>")
  ("math:bold:up r" "<b-up-r>")
  ("math:bold:up s" "<b-up-s>")
  ("math:bold:up t" "<b-up-t>")
  ("math:bold:up u" "<b-up-u>")
  ("math:bold:up v" "<b-up-v>")
  ("math:bold:up w" "<b-up-w>")
  ("math:bold:up x" "<b-up-x>")
  ("math:bold:up y" "<b-up-y>")
  ("math:bold:up z" "<b-up-z>")
  ("math:bold:up A" "<b-up-A>")
  ("math:bold:up B" "<b-up-B>")
  ("math:bold:up C" "<b-up-C>")
  ("math:bold:up D" "<b-up-D>")
  ("math:bold:up E" "<b-up-E>")
  ("math:bold:up F" "<b-up-F>")
  ("math:bold:up G" "<b-up-G>")
  ("math:bold:up H" "<b-up-H>")
  ("math:bold:up I" "<b-up-I>")
  ("math:bold:up J" "<b-up-J>")
  ("math:bold:up K" "<b-up-K>")
  ("math:bold:up L" "<b-up-L>")
  ("math:bold:up M" "<b-up-M>")
  ("math:bold:up N" "<b-up-N>")
  ("math:bold:up O" "<b-up-O>")
  ("math:bold:up P" "<b-up-P>")
  ("math:bold:up Q" "<b-up-Q>")
  ("math:bold:up R" "<b-up-R>")
  ("math:bold:up S" "<b-up-S>")
  ("math:bold:up T" "<b-up-T>")
  ("math:bold:up U" "<b-up-U>")
  ("math:bold:up V" "<b-up-V>")
  ("math:bold:up W" "<b-up-W>")
  ("math:bold:up X" "<b-up-X>")
  ("math:bold:up Y" "<b-up-Y>")
  ("math:bold:up Z" "<b-up-Z>")

  ("math:bold:greek a" "<b-alpha>")
  ("math:bold:greek b" "<b-beta>")
  ("math:bold:greek g" "<b-gamma>")
  ("math:bold:greek d" "<b-delta>")
  ("math:bold:greek e" "<b-varepsilon>")
  ("math:bold:greek e var" "<b-epsilon>")
  ("math:bold:greek e var var" "<b-backepsilon>")
  ("math:bold:greek z" "<b-zeta>")
  ("math:bold:greek h" "<b-eta>")
  ("math:bold:greek j" "<b-theta>")
  ("math:bold:greek j var" "<b-vartheta>")
  ("math:bold:greek i" "<b-iota>")
  ("math:bold:greek k" "<b-kappa>")
  ("math:bold:greek k var" "<b-varkappa>")
  ("math:bold:greek l" "<b-lambda>")
  ("math:bold:greek m" "<b-mu>")
  ("math:bold:greek n" "<b-nu>")
  ("math:bold:greek x" "<b-xi>")
  ("math:bold:greek o" "<b-omicron>")
  ("math:bold:greek p" "<b-pi>")
  ("math:bold:greek p var" "<b-varpi>")
  ("math:bold:greek r" "<b-rho>")
  ("math:bold:greek r var" "<b-varrho>")
  ("math:bold:greek s" "<b-sigma>")
  ("math:bold:greek s var" "<b-varsigma>")
  ("math:bold:greek c" "<b-varsigma>")
  ("math:bold:greek c var" "<b-sigma>")
  ("math:bold:greek t" "<b-tau>")
  ("math:bold:greek u" "<b-upsilon>")
  ("math:bold:greek f" "<b-varphi>")
  ("math:bold:greek f var" "<b-phi>")
  ("math:bold:greek y" "<b-psi>")
  ("math:bold:greek q" "<b-chi>")
  ("math:bold:greek w" "<b-omega>")
  ("math:bold:greek w var" "<b-mho>")
  ("math:bold:greek v" "<b-phi>")
  ("math:bold:greek v var" "<b-varphi>")
  ("math:bold:greek A" "<b-Alpha>")
  ("math:bold:greek B" "<b-Beta>")
  ("math:bold:greek G" "<b-Gamma>")
  ("math:bold:greek D" "<b-Delta>")
  ("math:bold:greek E" "<b-Epsilon>")
  ("math:bold:greek E var" "<b-Backepsilon>")
  ("math:bold:greek Z" "<b-Zeta>")
  ("math:bold:greek H" "<b-Eta>")
  ("math:bold:greek J" "<b-Theta>")
  ("math:bold:greek I" "<b-Iota>")
  ("math:bold:greek K" "<b-Kappa>")
  ("math:bold:greek L" "<b-Lambda>")
  ("math:bold:greek M" "<b-Mu>")
  ("math:bold:greek N" "<b-Nu>")
  ("math:bold:greek X" "<b-Xi>")
  ("math:bold:greek O" "<b-Omicron>")
  ("math:bold:greek P" "<b-Pi>")
  ("math:bold:greek R" "<b-Rho>")
  ("math:bold:greek S" "<b-Sigma>")
  ("math:bold:greek C" "<b-Sigma>")
  ("math:bold:greek T" "<b-Tau>")
  ("math:bold:greek U" "<b-Upsilon>")
  ("math:bold:greek F" "<b-Phi>")
  ("math:bold:greek Y" "<b-Psi>")
  ("math:bold:greek Q" "<b-Chi>")
  ("math:bold:greek W" "<b-Omega>")
  ("math:bold:greek W var" "<b-Mho>")
  ("math:bold:greek V" "<b-Phi>")

  ("math:cal a" "<cal-a>")
  ("math:cal b" "<cal-b>")
  ("math:cal c" "<cal-c>")
  ("math:cal d" "<cal-d>")
  ("math:cal e" "<cal-e>")
  ("math:cal f" "<cal-f>")
  ("math:cal g" "<cal-g>")
  ("math:cal h" "<cal-h>")
  ("math:cal i" "<cal-i>")
  ("math:cal j" "<cal-j>")
  ("math:cal k" "<cal-k>")
  ("math:cal l" "<cal-l>")
  ("math:cal m" "<cal-m>")
  ("math:cal n" "<cal-n>")
  ("math:cal o" "<cal-o>")
  ("math:cal p" "<cal-p>")
  ("math:cal q" "<cal-q>")
  ("math:cal r" "<cal-r>")
  ("math:cal s" "<cal-s>")
  ("math:cal t" "<cal-t>")
  ("math:cal u" "<cal-u>")
  ("math:cal v" "<cal-v>")
  ("math:cal w" "<cal-w>")
  ("math:cal x" "<cal-x>")
  ("math:cal y" "<cal-y>")
  ("math:cal z" "<cal-z>")
  ("math:cal A" "<cal-A>")
  ("math:cal B" "<cal-B>")
  ("math:cal C" "<cal-C>")
  ("math:cal D" "<cal-D>")
  ("math:cal E" "<cal-E>")
  ("math:cal F" "<cal-F>")
  ("math:cal G" "<cal-G>")
  ("math:cal H" "<cal-H>")
  ("math:cal I" "<cal-I>")
  ("math:cal J" "<cal-J>")
  ("math:cal K" "<cal-K>")
  ("math:cal L" "<cal-L>")
  ("math:cal M" "<cal-M>")
  ("math:cal N" "<cal-N>")
  ("math:cal O" "<cal-O>")
  ("math:cal P" "<cal-P>")
  ("math:cal Q" "<cal-Q>")
  ("math:cal R" "<cal-R>")
  ("math:cal S" "<cal-S>")
  ("math:cal T" "<cal-T>")
  ("math:cal U" "<cal-U>")
  ("math:cal V" "<cal-V>")
  ("math:cal W" "<cal-W>")
  ("math:cal X" "<cal-X>")
  ("math:cal Y" "<cal-Y>")
  ("math:cal Z" "<cal-Z>")

  ("math:bold:cal a" "<b-cal-a>")
  ("math:bold:cal b" "<b-cal-b>")
  ("math:bold:cal c" "<b-cal-c>")
  ("math:bold:cal d" "<b-cal-d>")
  ("math:bold:cal e" "<b-cal-e>")
  ("math:bold:cal f" "<b-cal-f>")
  ("math:bold:cal g" "<b-cal-g>")
  ("math:bold:cal h" "<b-cal-h>")
  ("math:bold:cal i" "<b-cal-i>")
  ("math:bold:cal h" "<b-cal-j>")
  ("math:bold:cal k" "<b-cal-k>")
  ("math:bold:cal l" "<b-cal-l>")
  ("math:bold:cal m" "<b-cal-m>")
  ("math:bold:cal n" "<b-cal-n>")
  ("math:bold:cal o" "<b-cal-o>")
  ("math:bold:cal p" "<b-cal-p>")
  ("math:bold:cal q" "<b-cal-q>")
  ("math:bold:cal r" "<b-cal-r>")
  ("math:bold:cal s" "<b-cal-s>")
  ("math:bold:cal t" "<b-cal-t>")
  ("math:bold:cal u" "<b-cal-u>")
  ("math:bold:cal v" "<b-cal-v>")
  ("math:bold:cal w" "<b-cal-w>")
  ("math:bold:cal x" "<b-cal-x>")
  ("math:bold:cal y" "<b-cal-y>")
  ("math:bold:cal z" "<b-cal-z>")
  ("math:bold:cal A" "<b-cal-A>")
  ("math:bold:cal B" "<b-cal-B>")
  ("math:bold:cal C" "<b-cal-C>")
  ("math:bold:cal D" "<b-cal-D>")
  ("math:bold:cal E" "<b-cal-E>")
  ("math:bold:cal F" "<b-cal-F>")
  ("math:bold:cal G" "<b-cal-G>")
  ("math:bold:cal H" "<b-cal-H>")
  ("math:bold:cal I" "<b-cal-I>")
  ("math:bold:cal J" "<b-cal-J>")
  ("math:bold:cal K" "<b-cal-K>")
  ("math:bold:cal L" "<b-cal-L>")
  ("math:bold:cal M" "<b-cal-M>")
  ("math:bold:cal N" "<b-cal-N>")
  ("math:bold:cal O" "<b-cal-O>")
  ("math:bold:cal P" "<b-cal-P>")
  ("math:bold:cal Q" "<b-cal-Q>")
  ("math:bold:cal R" "<b-cal-R>")
  ("math:bold:cal S" "<b-cal-S>")
  ("math:bold:cal T" "<b-cal-T>")
  ("math:bold:cal U" "<b-cal-U>")
  ("math:bold:cal V" "<b-cal-V>")
  ("math:bold:cal W" "<b-cal-W>")
  ("math:bold:cal X" "<b-cal-X>")
  ("math:bold:cal Y" "<b-cal-Y>")
  ("math:bold:cal Z" "<b-cal-Z>")

  ("math:frak a" "<frak-a>")
  ("math:frak b" "<frak-b>")
  ("math:frak c" "<frak-c>")
  ("math:frak d" "<frak-d>")
  ("math:frak e" "<frak-e>")
  ("math:frak f" "<frak-f>")
  ("math:frak g" "<frak-g>")
  ("math:frak h" "<frak-h>")
  ("math:frak i" "<frak-i>")
  ("math:frak i var" "<frak-imath>")
  ("math:frak j" "<frak-j>")
  ("math:frak j var" "<frak-jmath>")
  ("math:frak k" "<frak-k>")
  ("math:frak l" "<frak-l>")
  ("math:frak m" "<frak-m>")
  ("math:frak n" "<frak-n>")
  ("math:frak o" "<frak-o>")
  ("math:frak p" "<frak-p>")
  ("math:frak q" "<frak-q>")
  ("math:frak r" "<frak-r>")
  ("math:frak s" "<frak-s>")
  ("math:frak t" "<frak-t>")
  ("math:frak u" "<frak-u>")
  ("math:frak v" "<frak-v>")
  ("math:frak w" "<frak-w>")
  ("math:frak x" "<frak-x>")
  ("math:frak y" "<frak-y>")
  ("math:frak z" "<frak-z>")
  ("math:frak A" "<frak-A>")
  ("math:frak B" "<frak-B>")
  ("math:frak C" "<frak-C>")
  ("math:frak D" "<frak-D>")
  ("math:frak E" "<frak-E>")
  ("math:frak F" "<frak-F>")
  ("math:frak G" "<frak-G>")
  ("math:frak H" "<frak-H>")
  ("math:frak I" "<frak-I>")
  ("math:frak J" "<frak-J>")
  ("math:frak K" "<frak-K>")
  ("math:frak L" "<frak-L>")
  ("math:frak M" "<frak-M>")
  ("math:frak N" "<frak-N>")
  ("math:frak O" "<frak-O>")
  ("math:frak P" "<frak-P>")
  ("math:frak Q" "<frak-Q>")
  ("math:frak R" "<frak-R>")
  ("math:frak S" "<frak-S>")
  ("math:frak T" "<frak-T>")
  ("math:frak U" "<frak-U>")
  ("math:frak V" "<frak-V>")
  ("math:frak W" "<frak-W>")
  ("math:frak X" "<frak-X>")
  ("math:frak Y" "<frak-Y>")
  ("math:frak Z" "<frak-Z>")

  ("math:bbb 0" "<bbb-0>")
  ("math:bbb 1" "<bbb-1>")
  ("math:bbb 2" "<bbb-2>")
  ("math:bbb 3" "<bbb-3>")
  ("math:bbb 4" "<bbb-4>")
  ("math:bbb 5" "<bbb-5>")
  ("math:bbb 6" "<bbb-6>")
  ("math:bbb 7" "<bbb-7>")
  ("math:bbb 8" "<bbb-8>")
  ("math:bbb 9" "<bbb-9>")
  ("math:bbb a" "<bbb-a>")
  ("math:bbb b" "<bbb-b>")
  ("math:bbb c" "<bbb-c>")
  ("math:bbb d" "<bbb-d>")
  ("math:bbb e" "<bbb-e>")
  ("math:bbb f" "<bbb-f>")
  ("math:bbb g" "<bbb-g>")
  ("math:bbb h" "<bbb-h>")
  ("math:bbb i" "<bbb-i>")
  ("math:bbb j" "<bbb-j>")
  ("math:bbb k" "<bbb-k>")
  ("math:bbb l" "<bbb-l>")
  ("math:bbb m" "<bbb-m>")
  ("math:bbb n" "<bbb-n>")
  ("math:bbb o" "<bbb-o>")
  ("math:bbb p" "<bbb-p>")
  ("math:bbb q" "<bbb-q>")
  ("math:bbb r" "<bbb-r>")
  ("math:bbb s" "<bbb-s>")
  ("math:bbb t" "<bbb-t>")
  ("math:bbb u" "<bbb-u>")
  ("math:bbb v" "<bbb-v>")
  ("math:bbb w" "<bbb-w>")
  ("math:bbb x" "<bbb-x>")
  ("math:bbb y" "<bbb-y>")
  ("math:bbb z" "<bbb-z>")
  ("math:bbb A" "<bbb-A>")
  ("math:bbb B" "<bbb-B>")
  ("math:bbb C" "<bbb-C>")
  ("math:bbb D" "<bbb-D>")
  ("math:bbb E" "<bbb-E>")
  ("math:bbb F" "<bbb-F>")
  ("math:bbb G" "<bbb-G>")
  ("math:bbb H" "<bbb-H>")
  ("math:bbb I" "<bbb-I>")
  ("math:bbb J" "<bbb-J>")
  ("math:bbb K" "<bbb-K>")
  ("math:bbb L" "<bbb-L>")
  ("math:bbb M" "<bbb-M>")
  ("math:bbb N" "<bbb-N>")
  ("math:bbb O" "<bbb-O>")
  ("math:bbb P" "<bbb-P>")
  ("math:bbb Q" "<bbb-Q>")
  ("math:bbb R" "<bbb-R>")
  ("math:bbb S" "<bbb-S>")
  ("math:bbb T" "<bbb-T>")
  ("math:bbb U" "<bbb-U>")
  ("math:bbb V" "<bbb-V>")
  ("math:bbb W" "<bbb-W>")
  ("math:bbb X" "<bbb-X>")
  ("math:bbb Y" "<bbb-Y>")
  ("math:bbb Z" "<bbb-Z>")

  ("A A" "<bbb-A>")
  ("B B" "<bbb-B>")
  ("C C" "<bbb-C>")
  ("D D" "<bbb-D>")
  ("E E" "<bbb-E>")
  ("F F" "<bbb-F>")
  ("G G" "<bbb-G>")
  ("H H" "<bbb-H>")
  ("I I" "<bbb-I>")
  ("J J" "<bbb-J>")
  ("K K" "<bbb-K>")
  ("L L" "<bbb-L>")
  ("M M" "<bbb-M>")
  ("N N" "<bbb-N>")
  ("O O" "<bbb-O>")
  ("P P" "<bbb-P>")
  ("Q Q" "<bbb-Q>")
  ("R R" "<bbb-R>")
  ("S S" "<bbb-S>")
  ("T T" "<bbb-T>")
  ("U U" "<bbb-U>")
  ("V V" "<bbb-V>")
  ("W W" "<bbb-W>")
  ("X X" "<bbb-X>")
  ("Y Y" "<bbb-Y>")
  ("Z Z" "<bbb-Z>")

  ("R E" "<Re>")
  ("I M" "<Im>"))

(kbd-map
  (:mode in-math-not-hybrid?)
  ("a var" "<alpha>")
  ("b var" "<beta>")
  ("b var var" "<flat>")
  ("s var var" "<varsigma>")
  ("c var" "<varsigma>")
  ("d var" "<delta>")
  ("d var var" "<mathd>")
  ("d var var var" "<partial>")
  ("e var" "<varepsilon>")
  ("e var var" "<mathe>")
  ("e var var var" "<epsilon>")
  ("e var var var var" "<backepsilon>")
  ("v var var" "<varphi>")
  ("f var" "<varphi>")
  ("g var" "<gamma>")
  ("g var var" "<matheuler>")
  ("h var" "<eta>")
  ("h var var" "<hbar>")
  ("i var" "<iota>")
  ("i var var" "<mathi>")
  ("i var var var" "<imath>")
  ("j var" "<theta>")
  ("j var var" "<jmath>")
  ("j var var var" "<vartheta>")
  ("k var" "<kappa>")
  ("k var var" "<varkappa>")
  ("l var" "<lambda>")
  ("l var var" "<mathlambda>")
  ("l var var var" "<ell>")
  ("m var" "<mu>")
  ("n var" "<nu>")
  ("o var" "<omicron>")
  ("p var" "<pi>")
  ("p var var" "<mathpi>")
  ("p var var var" "<varpi>")
  ("q var" "<chi>")
  ("r var" "<rho>")
  ("r var var" "<varrho>")
  ("c var var" "<sigma>")
  ("s var" "<sigma>")
  ("t var" "<tau>")
  ("u var" "<upsilon>")
  ("f var var" "<phi>")
  ("v var" "<phi>")
  ("w var" "<omega>")
  ("w var var" "<mho>")
  ("x var" "<xi>")
  ("y var" "<psi>")
  ("z var" "<zeta>")

  ("A var" "<Alpha>")
  ("A var var" "<forall>")
  ("A var var var" "<aleph>")
  ("B var" "<Beta>")
  ("B var var" "<bot>")
  ("B var var var" "<beth>")
  ("C var" "<Sigma>")
  ("C var var" "<mathcatalan>")
  ("C var var var" "<complement>")
  ("D var" "<Delta>")
  ("D var var" "<mathD>")
  ("D var var var" "<daleth>")
  ("D var var var var" "<mathLaplace>")
  ("E var" "<Epsilon>")
  ("E var var" "<exists>")
  ("E var var var" "<Exists>")
  ("E var var var var" "<Backepsilon>")
  ("F var" "<Phi>")
  ("G var" "<Gamma>")
  ("G var var" "<gimel>")
  ("G var var var" "<mathGamma>")
  ("G var var var var" "<digamma>")
  ("H var" "<Eta>")
  ("I var" "<Iota>")
  ("I var var" "<Im>")
  ("J var" "<Theta>")
  ("K var" "<Kappa>")
  ("L var" "<Lambda>")
  ("M var" "<Mu>")
  ("N var" "<Nu>")
  ("O var" "<Omicron>")
  ("P var" "<Pi>")
  ("P var var" "<wp>")
  ("Q var" "<Chi>")
  ("R var" "<Rho>")
  ("R var var" "<Re>")
  ("S var" "<Sigma>")
  ("T var" "<Tau>")
  ("T var var" "<top>")
  ("T var var var" "<bot>")
  ("T var var var var" "<leftthreetimes>")
  ("T var var var var var" "<rightthreetimes>")
  ("U var" "<Upsilon>")
  ("V var" "<Phi>")
  ("V var var" "<nabla>")
  ("W var" "<Omega>")
  ("W var var" "<Mho>")
  ("X var" "<Xi>")
  ("Y var" "<Psi>")
  ("Z var" "<Zeta>"))
