yatex

diff yatexmth.el @ 13:eafae54794a0

Show message at comment-region on begin/end mode. Greek letters completion in yatexmth. YaTeX-mark environment and YaTeX-%-menu added. Erase cursor at the execution of dviout(DOS). Enable recursive completion at section-type completion.
author yuuji
date Sat, 29 Jan 1994 07:59:59 +0000
parents 390df0e505da
children b7b023a74293
line diff
     1.1 --- a/yatexmth.el	Mon Sep 20 08:56:09 1993 +0000
     1.2 +++ b/yatexmth.el	Sat Jan 29 07:59:59 1994 +0000
     1.3 @@ -1,22 +1,124 @@
     1.4  ;;; -*- Emacs-Lisp -*-
     1.5  ;;; YaTeX interface for math-mode.
     1.6 -;;; yatexmth.el rev.0
     1.7 -;;; (C)1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
     1.8 -;;; Last modified Tue Aug  3 23:37:07 1993 on 98fa
     1.9 +;;; yatexmth.el rev.2
    1.10 +;;; (c )1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
    1.11 +;;; Last modified Sat Jan 29 16:55:03 1994 on gloria
    1.12  ;;; $Id$
    1.13  
    1.14 +;;; [Customization guide]
    1.15 +;;;
    1.16 +;;;	  By default,  you can use two  completion  groups in YaTeX math
    1.17 +;;;	mode, `,' for mathematical signs and `/' for greek letters.  But
    1.18 +;;;	you  can add other completion groups   by defining the  alist of
    1.19 +;;;	`prefix  key'    vs   `completion   list'    into  the  variable
    1.20 +;;;	YaTeX-math-key-list-private.  If  you wish  to    accomplish the
    1.21 +;;;	completion as follows(prefix key is `;'):
    1.22 +;;;
    1.23 +;;;		KEY		COMPLETION
    1.24 +;;;		s		\sin
    1.25 +;;;		S		\arcsin
    1.26 +;;;		c		\cos
    1.27 +;;;		C		\arccos
    1.28 +;;;			:
    1.29 +;;;		T		\arctan
    1.30 +;;;		l		\log
    1.31 +;;;		hs		\sinh
    1.32 +;;;
    1.33 +;;;	Typing `s' after `;' makes `\sin', `hs' after `;' makes `\sinh'
    1.34 +;;;	and so on.  First, you have to define list of key-completion
    1.35 +;;;	pairs.  Variable name(YaTeX-math-funcs-list) is arbitrary.
    1.36 +;;;
    1.37 +;;;		(setq YaTeX-math-funcs-list
    1.38 +;;;		      '(("s"	"sin")
    1.39 +;;;			("S"	"arcsin")
    1.40 +;;;				:
    1.41 +;;;			("hs"	"sinh")))
    1.42 +;;;
    1.43 +;;;	Next, define the list of prefix-key vs completion list(defined
    1.44 +;;;	above) into the variable YaTeX-math-key-list-private.
    1.45 +;;;
    1.46 +;;;		(setq YaTeX-math-key-list-private
    1.47 +;;;		      '((";" . YaTeX-math-funcs-list)
    1.48 +;;;			("'" . Other-List-if-any)))
    1.49 +;;;
    1.50 +;;;	  Put these expressions into your ~/.emacs, and you can use this
    1.51 +;;;	completion in the YaTeX-math-mode.
    1.52 +;;;
    1.53 +;;;	  And you can add your favorite completion sequences to the
    1.54 +;;;	default completion list invoked with `,', by defining those lists
    1.55 +;;;	into variable YaTeX-math-sign-alist-private.
    1.56 +
    1.57 +;;; 【イメージ補完の追加方法】
    1.58 +;;;
    1.59 +;;;	  標準のイメージ補完では、「,」で始まる数式記号補完と、「/」で始
    1.60 +;;;	まるギリシャ文字補完が使用可能ですが、これ以外の文字で始まる補完
    1.61 +;;;	シリーズも定義することができます。例えば、「;」で始まる次のよう
    1.62 +;;;	な補完シリーズを定義する場合を考えてみます。
    1.63 +;;;
    1.64 +;;;		補完キー	補完結果
    1.65 +;;;		s		\sin
    1.66 +;;;		S		\arcsin
    1.67 +;;;		c		\cos
    1.68 +;;;		C		\arccos
    1.69 +;;;			:
    1.70 +;;;		T		\arctan
    1.71 +;;;		l		\log
    1.72 +;;;		hs		\sinh
    1.73 +;;;
    1.74 +;;;	「;」のあとに s を押すと \sin が、hs を押すと \sinh が入力されま
    1.75 +;;;	す。このような補完リストの登録は以下のようにします(変数名は任意)。
    1.76 +;;;
    1.77 +;;;		(setq YaTeX-math-funcs-list
    1.78 +;;;		      '(("s"	"sin")
    1.79 +;;;			("S"	"arcsin")
    1.80 +;;;				:
    1.81 +;;;			("hs"	"sinh")))
    1.82 +;;;
    1.83 +;;;	さらに、「;」を押した時にイメージ補完が始まるよう次の変数に、起動キー
    1.84 +;;;	と上で定義した補完用変数の登録を行ないます。
    1.85 +;;;
    1.86 +;;;		(setq YaTeX-math-key-list-private
    1.87 +;;;		      '((";" . YaTeX-math-funcs-list)
    1.88 +;;;			("'" . ほかに定義したいシリーズがあれば…)))
    1.89 +;;;
    1.90 +;;;	これらを ~/.emacs に書いておけば、野鳥の math-mode で自分専用の
    1.91 +;;;	イメージ補完が利用できます。
    1.92 +
    1.93 +(defvar YaTeX-jisold
    1.94 +  (and (boundp 'dos-machine-type)
    1.95 +       (eq dos-machine-type 'pc98)))
    1.96 +
    1.97 +(defmacro YaTeX-setq-math-sym (sym old new)
    1.98 +  (list 'setq sym (list 'if 'YaTeX-jisold old new)))
    1.99 +
   1.100 +(YaTeX-setq-math-sym YaTeX-image-in		"E"    		"∈")
   1.101 +(YaTeX-setq-math-sym YaTeX-image-ni		"ヨ"		"∋")
   1.102 +(YaTeX-setq-math-sym YaTeX-image-subset		" _\n(\n ~"	"⊂")
   1.103 +(YaTeX-setq-math-sym YaTeX-image-subseteq	" _\n(_\n ~"	"⊆")
   1.104 +(YaTeX-setq-math-sym YaTeX-image-supset		"_\n )\n~"	"⊃")
   1.105 +(YaTeX-setq-math-sym YaTeX-image-supseteq	"_\n_)\n~" 	"⊇")
   1.106 +(YaTeX-setq-math-sym YaTeX-image-nabla		"___\n\\\\/"	"∇")
   1.107 +(YaTeX-setq-math-sym YaTeX-image-partial	" -+\n+-+\n+-+" "∂")
   1.108 +(YaTeX-setq-math-sym YaTeX-image-dagger		"+\n|"		"†")
   1.109 +(YaTeX-setq-math-sym YaTeX-image-ddagger	"+\n+\n|"	"‡")
   1.110 +(YaTeX-setq-math-sym YaTeX-image-equiv		"=\n ̄"	"≡")
   1.111 +(YaTeX-setq-math-sym YaTeX-image-int		" /\\\n \\\n\\/" "∫")
   1.112 +(YaTeX-setq-math-sym YaTeX-image-bot		"|\n ̄"	"⊥")
   1.113 +(YaTeX-setq-math-sym YaTeX-image-neg		"イ"		"¬")
   1.114 +(YaTeX-setq-math-sym YaTeX-image-flat		"b"		"♭")
   1.115 +
   1.116  (setq
   1.117 - YaTeX-math-key-alist-default
   1.118 + YaTeX-math-sign-alist-default
   1.119   '(
   1.120     ;frequently used
   1.121     ("||"	"|"		("||"		"‖"))
   1.122     ("sum"	"sum"		("\\-+\n >\n/-+" "Σ"))
   1.123     ("sigma"	"sum"		("\\-+\n >\n/-+" "Σ"))
   1.124 -   ("integral"	"int"		" /\\\n \\\n\\/")
   1.125 +   ("integral"	"int"		(" /\\\n \\\n\\/" YaTeX-image-int))
   1.126     ("ointegral"	"oint"		" /\\\n(\\)\n\\/")
   1.127     ("A"		"forall"	"|_|\nV")
   1.128     ("E"		"exists"	"-+\n-+\n-+")
   1.129 -   ("!"		"neg"		"--+\n  |")
   1.130 +   ("!"		"neg"		("--+\n  |" YaTeX-image-neg))
   1.131     ("oo"	"infty"		("oo"		"∞"))
   1.132     ("\\"	"backslash"	("\\"		"\"))
   1.133  
   1.134 @@ -54,26 +156,26 @@
   1.135     ("o/"	"oslash"	" _\n(/)\n ~")
   1.136     ("o."	"odot"		"(.)")
   1.137     ("O"		"bigcirc"	"O")
   1.138 -   ("t"		"dagger"	"+\n|")
   1.139 -   ("tt"	"ddagger"	"+\n+\n|")
   1.140 +   ("t"		"dagger"	("+\n|" YaTeX-image-dagger))
   1.141 +   ("tt"	"ddagger"	("+\n+\n|" YaTeX-image-ddagger))
   1.142     ("II"	"amalg"		"II")
   1.143     ;	:
   1.144     ;;relational operators
   1.145     ("<"		"leq"		("<\n-"		"≦"))
   1.146     (">"		"geq"		(">\n-"		"≧"))
   1.147 -   ("-="	"equiv"		"=\n-")
   1.148 -   ("=-"	"equiv"		"=\n-")
   1.149 -   ("---"	"equiv"		"=\n-")
   1.150 -   ("("		"subset"	" _\n(\n ~")
   1.151 -   ("(-"	"subseteq"	" _\n(_\n~")
   1.152 -   (")"		"supset"	"_\n )\n~")
   1.153 -   (")-"	"supseteq"	"_\n_)\n~")
   1.154 +   ("-="	"equiv"		("=\n-"		YaTeX-image-equiv))
   1.155 +   ("=-"	"equiv"		("=\n-"		YaTeX-image-equiv))
   1.156 +   ("---"	"equiv"		("=\n-"		YaTeX-image-equiv))
   1.157 +   ("("		"subset"	(" _\n(\n ~"	YaTeX-image-subset))
   1.158 +   ("(-"	"subseteq"	(" _\n(_\n ~"	YaTeX-image-subseteq))
   1.159 +   (")"		"supset"	("_\n )\n~"	YaTeX-image-supset))
   1.160 +   (")-"	"supseteq"	("_\n_)\n~"	YaTeX-image-supseteq))
   1.161     ("["		"sqsubset"	"[")
   1.162     ("[-"	"sqsubseteq"	"[\n~")
   1.163     ("]"		"sqsupset"	"]")
   1.164     ("]-"	"sqsupseteq"	"]\n~")
   1.165 -   ("{"		"in"		"(-")
   1.166 -   ("}"		"ni"		"-)")
   1.167 +   ("{"		"in"		("(-" YaTeX-image-in))
   1.168 +   ("}"		"ni"		("-)" YaTeX-image-ni))
   1.169     ("|-"	"vdash"		"|-")
   1.170     ("-|"	"dashv"		"-|")
   1.171     ("~"		"sim"		"~(tild)")
   1.172 @@ -98,10 +200,12 @@
   1.173     ;	:
   1.174     ;;arrows
   1.175     ("<-"	"leftarrow"	("<-"		"←"))
   1.176 -   ("<--"	"longleftarrow"	("<-"		"←--"))
   1.177 +   ("\C-b"	"leftarrow"	("<-"		"←"))
   1.178 +   ("<--"	"longleftarrow"	("<--"		"←--"))
   1.179     ("<="	"Leftarrow"	"<=")
   1.180     ("<=="	"Longleftarrow"	"<==")
   1.181     ("->"	"rightarrow"	("->"		"→"))
   1.182 +   ("\C-f"	"rightarrow"	("->"		"→"))
   1.183     ("-->"	"longrightarrow" ("-->"		"--→"))
   1.184     ("==>"	"Longrightarrow" "==>")
   1.185     ("<->"	"leftrightarrow" ("<->"		"←→"))
   1.186 @@ -109,9 +213,11 @@
   1.187     ("<=>"	"leftrightarrow" "<=>")
   1.188     ("<==>"	"Longleftrightarrow" "<==>")
   1.189     ("^|"	"uparrow"	("^\n|" "↑"))
   1.190 +   ("\C-p"	"uparrow"	("^\n|" "↑"))
   1.191     ("^||"	"Uparrow"	"/\\\n||")
   1.192     ("\C-n"	"downarrow"	("|\nv" "↓"))
   1.193 -   ("^|"	"uparrow"	("^\n|" "↑"))
   1.194 +   ("v|"	"downarrow"	("|\nv" "↓"))
   1.195 +   ("v||"	"Downarrow"	"||\n\\/")
   1.196     ("|->"	"mapsto"	("|->"		"|→"))
   1.197     ("<-)"	"hookleftarrow"	("   ,\n<--+"	"   ヽ\n<--/"))
   1.198     ("/-"	"leftharpoonup"	"/\n~~~")
   1.199 @@ -131,16 +237,16 @@
   1.200     ("mho"	"mho"		"~|_|~")
   1.201     ("'"		"prime"		"'")
   1.202     ("0"		"emptyset"	"0")
   1.203 -   ("nabla"	"nabla"		"___\n\\\\/")
   1.204 +   ("nabla"	"nabla"		("___\n\\\\/" YaTeX-image-nabla))
   1.205     ("\\/"	"surd"		"-\\/")
   1.206     ("surd"	"surd"		"-\\/")
   1.207     ("top"	"top"		"T")
   1.208 -   ("bot"	"bot"		"_|_")
   1.209 -   ("b"		"flat"		"b")
   1.210 +   ("bot"	"bot"		("_|_"		YaTeX-image-bot))
   1.211 +   ("b"		"flat"		("b"		YaTeX-image-flat))
   1.212     ("LT"	"natural"	"|\nLT\n |")
   1.213 -   ("6"		"partial"	" -+\n+-+\n+-+")
   1.214 -   ("partial"	"partial"	" -+\n+-+\n+-+")
   1.215 -   ("round"	"partial"	" -+\n+-+\n+-+")
   1.216 +   ("6"		"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
   1.217 +   ("partial"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
   1.218 +   ("round"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
   1.219     ("[]"	"box"		"[]")
   1.220     ("Diamond"	"Diamond"	"/\\\n\\/")
   1.221     ("3"		"triangle"	"/\\\n~~")
   1.222 @@ -151,23 +257,82 @@
   1.223  
   1.224     ))
   1.225  
   1.226 -(defvar YaTeX-math-key-alist-private nil
   1.227 +(defvar YaTeX-math-sign-alist-private nil
   1.228    "*User definable key vs LaTeX-math-command alist.")
   1.229  
   1.230  (defvar YaTeX-math-quit-with-strict-match nil
   1.231    "*T for quitting completion as soon as strict-match is found.")
   1.232 -(setq YaTeX-math-key-alist
   1.233 -      (append YaTeX-math-key-alist-private YaTeX-math-key-alist-default))
   1.234 +(setq YaTeX-math-sign-alist
   1.235 +      (append YaTeX-math-sign-alist-private YaTeX-math-sign-alist-default))
   1.236  
   1.237 -(setq YaTeX-math-key-array
   1.238 -  (let ((array (make-vector (length YaTeX-math-key-alist) ""))
   1.239 -	(list YaTeX-math-key-alist) (i 0))
   1.240 -    (while list
   1.241 -      (aset array i (car (car list)))
   1.242 -      (setq i (1+ i) list (cdr list)))
   1.243 -    array))
   1.244 +;;(defun YaTeX-math-alist2array (alist array)
   1.245 +;;  (set array
   1.246 +;;       (let ((array (make-vector (length alist) "")) (list alist) (i 0))
   1.247 +;;	 (while list
   1.248 +;;	   (aset array i (car (car list)))
   1.249 +;;	   (setq i (1+ i) list (cdr list)))
   1.250 +;;	 array))
   1.251 +;;)
   1.252  
   1.253 -(defvar YaTeX-ec "\\" "Escape character of mark-up language.")
   1.254 +(setq YaTeX-greek-key-alist-default
   1.255 +  '(
   1.256 +    ("a"	"alpha"		("a" "α"))
   1.257 +    ("b"	"beta"		("|>\n|>\n|" "β"))
   1.258 +    ("g"	"gamma"		("~r" "γ"))
   1.259 +    ("G"	"Gamma"		("|~" "Γ"))
   1.260 +    ("d"	"delta"		("<~\n<>" "δ"))
   1.261 +    ("D"	"Delta"		("/\\\n~~" "Δ"))
   1.262 +    ("e"	"epsilon"	"<\n<~")
   1.263 +    ("e-"	"varepsilon"	("(\n(~" "ε"))
   1.264 +    ("z"	"zeta"		("(~\n >" "ζ"))
   1.265 +    ("et"	"eta"		("n\n/" "η"))
   1.266 +    ("th"	"theta"		("8" "θ"))
   1.267 +    ("Th"	"Theta"		("(8)" "Θ"))
   1.268 +    ("th-"	"vartheta"	("-8" "-θ"))
   1.269 +    ("i"	"iota"		("i\n\\_/" "ι"))
   1.270 +    ("k"	"kappa"		("k" "κ"))
   1.271 +    ("l"	"lambda"	("\\n/\\" "λ"))
   1.272 +    ("L"	"Lambda"	("/\\" "Λ"))
   1.273 +    ("m"	"mu"		(" u_\n/" "μ"))
   1.274 +    ("n"	"nu"		("|/" "ν"))
   1.275 +    ("x"	"xi"		("E\n >" "ξ"))
   1.276 +    ("X"	"Xi"		("---\n -\n---" "Ξ"))
   1.277 +    ("p"	"pi"		("__\n)(" "π"))
   1.278 +    ("P"	"Pi"		("__\n||" "Π"))
   1.279 +    ("p-"	"varpi"		("_\nw" "__\nω"))
   1.280 +    ("r"	"rho"		("/O" "ρ"))
   1.281 +    ("r-"	"varrho"	("/O\n~~" "ρ\n~~"))
   1.282 +    ("s"	"sigma"		("o~" "σ"))
   1.283 +    ("S"	"Sigma"		("\\-+\n >\n/-+" "Σ"))
   1.284 +    ("s-"	"varsigma"	"(~~ \n>")
   1.285 +    ("t"	"tau"		("__\n(" "τ"))
   1.286 +    ("u"	"upsilon"	("~v" "υ"))
   1.287 +    ("y"	"upsilon"	("~v" "υ"))
   1.288 +    ("U"	"Upsilon"	("~Y~" "Υ"))
   1.289 +    ("Y"	"Upsilon"	("~Y~" "Υ"))
   1.290 +    ("ph"	"phi"		("  /\n(/)\n/" "φ"))
   1.291 +    ("Ph"	"Phi"		(" _\n(|)\n ~" "Φ"))
   1.292 +    ("ph-"	"varphi"	"\\O\n|")
   1.293 +    ("c"	"chi"		("x" "χ"))
   1.294 +    ("ps"	"psi"		("\\|/\\n |" "ψ"))
   1.295 +    ("Ps"	"Psi"		(" ~\n\\|/\\n |" "Ψ"))
   1.296 +    ("o"	"omega"		("w" "ω"))
   1.297 +    ("w"	"omega"		("w" "ω"))
   1.298 +    ("O"	"Omega"		("(~)\n~ ~" "Ω"))
   1.299 +    ("W"	"Omega"		("(~)\n~ ~" "Ω"))
   1.300 +    ("f" "foo")
   1.301 +    )
   1.302 +)
   1.303 +
   1.304 +(defvar YaTeX-greek-key-alist-private nil
   1.305 +  "*User definable key vs LaTeX-math-command alist.")
   1.306 +
   1.307 +(setq YaTeX-greek-key-alist
   1.308 +      (append YaTeX-greek-key-alist-private YaTeX-greek-key-alist-default))
   1.309 +
   1.310 +;;(mapcar (function (lambda (x) (YaTeX-math-alist2array x)))
   1.311 +;;	YaTeX-math-key-list)
   1.312 +
   1.313  (setq YaTeX-math-indicator
   1.314    "KEY\tLaTeX sequence\t\tsign")
   1.315  
   1.316 @@ -201,11 +366,69 @@
   1.317    (define-key YaTeX-math-menu-map "\^m"	'exit-recursive-edit)
   1.318    (define-key YaTeX-math-menu-map "q"	'abort-recursive-edit))
   1.319  
   1.320 +(defvar YaTeX-math-key-list-default
   1.321 +  '(("," . YaTeX-math-sign-alist)
   1.322 +    ("/" . YaTeX-greek-key-alist))
   1.323 +  "Default key sequence to invoke math-mode's image completion."
   1.324 +)
   1.325 +(defvar YaTeX-math-key-list-private nil
   1.326 +  "*User defined alist, math-mode-prefix vs completion alist"
   1.327 +)
   1.328 +(defvar YaTeX-math-key-list
   1.329 +  (append YaTeX-math-key-list-private YaTeX-math-key-list-default)
   1.330 +  "Key sequence to invoke math-mode's image completion."
   1.331 +)
   1.332 +(defvar YaTeX-math-exit-key "\e"
   1.333 +  "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode."
   1.334 +)
   1.335 +
   1.336  (defmacro YaTeX-math-japanese-sign (list)
   1.337    (list 'nth 1 list))
   1.338  
   1.339  (defvar YaTeX-math-cmd-regexp (concat (regexp-quote YaTeX-ec) "[A-z]"))
   1.340  
   1.341 +;;;
   1.342 +;;YaTeX math-mode functions
   1.343 +;;;
   1.344 +;##autoload from yatex.el
   1.345 +(defun YaTeX-toggle-math-mode (&optional arg)
   1.346 +  (interactive "P")
   1.347 +  (require 'yatexmth)
   1.348 +  (or (memq 'YaTeX-math-mode mode-line-format) nil
   1.349 +      (setq mode-line-format
   1.350 +	    (append (list "" 'YaTeX-math-mode) mode-line-format)))
   1.351 +  (if (or arg (null YaTeX-math-mode))
   1.352 +      (let ((keys ""))
   1.353 +	(setq YaTeX-math-mode "math:")
   1.354 +	(mapcar
   1.355 +	 (function (lambda (x)
   1.356 +		     (let ((key (car x)) (list (cdr x)))
   1.357 +		       (setq keys (concat keys " " key))
   1.358 +		       (put 'YaTeX-math-key-list list (key-binding key))
   1.359 +		       (define-key YaTeX-mode-map key
   1.360 +			 'YaTeX-math-insert-sequence))))
   1.361 +	 YaTeX-math-key-list)
   1.362 +	(message "Turn on math mode. Prefix keys are %s" keys)
   1.363 +	(sit-for 3)
   1.364 +	(message
   1.365 +	 (concat "To exit from math-mode, type `ESC' after prefix, "
   1.366 +		 "or type `"
   1.367 +		 (key-description
   1.368 +		  (car
   1.369 +		   (where-is-internal 'YaTeX-switch-mode-menu YaTeX-mode-map)))
   1.370 +		 " $'")))
   1.371 +    (setq YaTeX-math-mode nil)
   1.372 +    (mapcar
   1.373 +     (function (lambda (x)
   1.374 +		 (let ((key (car x)) (list (cdr x)))
   1.375 +		   (define-key YaTeX-mode-map key
   1.376 +		     (get 'YaTeX-math-key-list list)))))
   1.377 +     YaTeX-math-key-list)
   1.378 +    (setq YaTeX-math-mode nil)
   1.379 +    (message "Exit from math mode."))
   1.380 +  (set-buffer-modified-p (buffer-modified-p))
   1.381 +)
   1.382 +
   1.383  (defun YaTeX-math-forward (arg)
   1.384    (interactive "p")
   1.385    (re-search-forward YaTeX-math-cmd-regexp nil t arg))
   1.386 @@ -214,13 +437,22 @@
   1.387    (interactive "p")
   1.388    (re-search-backward YaTeX-math-cmd-regexp nil t arg))
   1.389  
   1.390 +(defun YaTeX-math-gets (sign)
   1.391 +  (cond
   1.392 +   ((null sign) nil)
   1.393 +   ((listp sign)
   1.394 +    (setq sign
   1.395 +	  (cond
   1.396 +	   (YaTeX-japan (YaTeX-math-japanese-sign sign))
   1.397 +	   (t (car sign))))
   1.398 +    (YaTeX-math-gets sign))
   1.399 +   ((symbolp sign)
   1.400 +    (YaTeX-math-gets (symbol-value sign)))
   1.401 +   (t sign))
   1.402 +)
   1.403 +
   1.404  (defun YaTeX-math-get-sign (list)
   1.405 -  (let ((sign (car (cdr (cdr list)))))
   1.406 -    (if (listp sign)
   1.407 -	(setq sign (cond
   1.408 -		    (YaTeX-japan (YaTeX-math-japanese-sign sign))
   1.409 -		    (t (car sign)))))
   1.410 -    sign)
   1.411 +  (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))
   1.412  )
   1.413  
   1.414  (defun YaTeX-math-display-list (list cols)
   1.415 @@ -236,7 +468,7 @@
   1.416      (insert "\\" (car (cdr list)))
   1.417      (setq indent (+ indent YaTeX-math-max-seq))
   1.418      (setq sign (YaTeX-math-get-sign list))
   1.419 -    (while (not (string= "" sign))
   1.420 +    (while (and sign (not (string= "" sign)))
   1.421        (setq to (string-match "\n" sign)
   1.422  	    str (if to (substring sign 0 to) sign))
   1.423        (end-of-line)
   1.424 @@ -253,8 +485,10 @@
   1.425      (pop-to-buffer YaTeX-math-menu-buffer)
   1.426      (let ((maxcols (max 1 (/ (screen-width) YaTeX-math-sign-width)))
   1.427  	  (case-fold-search nil)
   1.428 -	  (cols 0) (list YaTeX-math-key-alist) command)
   1.429 +	  (cols 0) (list alist) command)
   1.430        (erase-buffer)
   1.431 +      (insert 
   1.432 +       "Candidates of sign. [n:next p:prev f:forw b:back q:quit RET:select]\n")
   1.433        (insert YaTeX-math-indicator "\t")
   1.434        (insert YaTeX-math-indicator)
   1.435        (newline 1)
   1.436 @@ -265,7 +499,7 @@
   1.437  	    (progn (YaTeX-math-display-list (car list) cols)
   1.438  		   (setq cols (% (1+ cols) maxcols))))
   1.439  	(setq list (cdr list)))
   1.440 -      (goto-char (point-min))
   1.441 +      (goto-line 4)
   1.442        (use-local-map YaTeX-math-menu-map)
   1.443        (unwind-protect
   1.444  	  (recursive-edit)
   1.445 @@ -286,67 +520,85 @@
   1.446  erase it on the next keystroke.  The window is recentered if necessary
   1.447  to make the whole string visible.  If the window isn't large enough,
   1.448  at least you get to read the beginning."
   1.449 -  (let ((buffer-read-only nil)
   1.450 -	(modified (buffer-modified-p))
   1.451 -	(name buffer-file-name)
   1.452 -	insert-start
   1.453 -	insert-end)
   1.454 -    (unwind-protect
   1.455 -	(progn
   1.456 -	  (save-excursion
   1.457 -	    ;; defeat file locking... don't try this at home, kids!
   1.458 -	    (setq buffer-file-name nil)
   1.459 -	    (forward-line 1)
   1.460 -	    (setq insert-start (point))
   1.461 -	    (if (eobp) (newline))
   1.462 -	    (insert image)
   1.463 -	    (setq insert-end (point)))
   1.464 -	  ; make sure the whole string is visible
   1.465 -	  (if (not (pos-visible-in-window-p insert-end))
   1.466 -	      (recenter (max 0
   1.467 -			     (- (window-height)
   1.468 -				(count-lines insert-start insert-end)
   1.469 -				2))))
   1.470 -	  (let ((char (read-char)))
   1.471 -	    (or (eq char exit-char)
   1.472 -		(setq unread-command-char char))))
   1.473 -      (if insert-end
   1.474 -	  (save-excursion
   1.475 -	    (delete-region insert-start insert-end)))
   1.476 -      (setq buffer-file-name name)
   1.477 -      (set-buffer-modified-p modified))))
   1.478 +  (if (and image (not (string= image "")))
   1.479 +      (let ((buffer-read-only nil)
   1.480 +	    (modified (buffer-modified-p))
   1.481 +	    (name buffer-file-name)
   1.482 +	    insert-start
   1.483 +	    insert-end)
   1.484 +	(unwind-protect
   1.485 +	    (progn
   1.486 +	      (save-excursion
   1.487 +		;; defeat file locking... don't try this at home, kids!
   1.488 +		(setq buffer-file-name nil)
   1.489 +		(forward-line 1)
   1.490 +		(setq insert-start (point))
   1.491 +		(if (eobp) (newline))
   1.492 +		(insert image)
   1.493 +		(setq insert-end (point)))
   1.494 +					; make sure the whole string is visible
   1.495 +	      (if (not (pos-visible-in-window-p insert-end))
   1.496 +		  (recenter (max 0
   1.497 +				 (- (window-height)
   1.498 +				    (count-lines insert-start insert-end)
   1.499 +				    2))))
   1.500 +	      (let ((char (read-char)))
   1.501 +		(or (eq char exit-char)
   1.502 +		    (setq unread-command-char char))))
   1.503 +	  (if insert-end
   1.504 +	      (save-excursion
   1.505 +		(delete-region insert-start insert-end)))
   1.506 +	  (setq buffer-file-name name)
   1.507 +	  (set-buffer-modified-p modified)))))
   1.508  
   1.509  (defun YaTeX-math-insert-sequence ()
   1.510    (interactive)
   1.511 -  (let ((key "") regkey str  last-char list i
   1.512 -	(case-fold-search nil) match
   1.513 -	(n (length YaTeX-math-key-array)) (beg (point)) result)
   1.514 +  (let*((key "") regkey str  last-char list i
   1.515 +	(case-fold-search nil) match sign
   1.516 +	(this-key (char-to-string last-command-char))
   1.517 +	(alist (symbol-value (cdr (assoc this-key YaTeX-math-key-list))))
   1.518 +	(n (length alist)) (beg (point)) result)
   1.519      (setq result
   1.520  	  (catch 'complete
   1.521  	    (while t
   1.522 +	      (message "Sequence: %s" key)
   1.523  	      (setq last-char (read-char)
   1.524  		    key (concat key (char-to-string last-char))
   1.525 -		    regkey (concat "^" (regexp-quote key)) i 0)
   1.526 +		    i 0)
   1.527  	      (cond
   1.528 -	       ((string= key YaTeX-math-invoke-key)	;;invoke key itself
   1.529 +	       ((string= key this-key)	;;invoke key itself
   1.530  		(throw 'complete 'escape))
   1.531 +	       ((string= key YaTeX-math-exit-key)	;;exit from math-mode
   1.532 +		(throw 'complete 'exit))
   1.533  	       ((string-match "[\C-g\C-c]" key) (throw 'complete 'abort))
   1.534 -	       ((string-match "[\n\r]" key) (throw 'complete 'menu)))
   1.535 +	       ((string-match "[\n\r]" key) (throw 'complete 'menu))
   1.536 +	       ((string-match "[\C-h\C-?]" key)
   1.537 +		(if (string= key "") (throw 'complete 'abort))
   1.538 +		(setq key (substring key 0 -2))))
   1.539 +	      
   1.540 +	      (setq regkey (concat "^" (regexp-quote key)))
   1.541 +	      (message "Sequence: %s" key)
   1.542  	      (if
   1.543  		  (catch 'found
   1.544  		    ;;(1)input string strictly matches with alist
   1.545  		    (setq single-command (car (cdr match))
   1.546  			  ;;remember previous match
   1.547 -			  match (assoc key YaTeX-math-key-alist))
   1.548 +			  match (assoc key alist))
   1.549  		    ;;(2)search partial match into alist
   1.550 +		    (setq list alist)
   1.551  		    (while (< i n)
   1.552  		      (if (string-match
   1.553 -			   regkey (aref YaTeX-math-key-array i))
   1.554 +			   regkey
   1.555 +			   ;;(aref array i)
   1.556 +			   ;;(car (nth i alist))
   1.557 +			   (car (car list))
   1.558 +			   )
   1.559  			  (progn
   1.560  			    (or match
   1.561 -				(setq match (nth i YaTeX-math-key-alist)))
   1.562 +				;;(setq match (nth i alist))
   1.563 +				(setq match (car list)))
   1.564  			    (throw 'found t)))
   1.565 -		      (setq i (1+ i)))) 		;catch 'found
   1.566 +		      (setq i (1+ i) list (cdr list))))	;catch 'found
   1.567  		  nil ;;if any match, continue reading
   1.568  		;;else reading of sequence has been done.
   1.569  		(message "complete.")
   1.570 @@ -355,9 +607,9 @@
   1.571  	      (if match
   1.572  		  (progn (delete-region beg (point))
   1.573  			 (insert YaTeX-ec (car (cdr match)))
   1.574 -			 (if YaTeX-math-need-image
   1.575 -			     (YaTeX-math-show-image
   1.576 -			      (concat (YaTeX-math-get-sign match) "\n")))
   1.577 +			 (if (and YaTeX-math-need-image
   1.578 +				  (setq sign (YaTeX-math-get-sign match)))
   1.579 +			     (YaTeX-math-show-image (concat sign "\n")))
   1.580  			 )
   1.581  		nil)
   1.582  	      )))
   1.583 @@ -370,7 +622,7 @@
   1.584  	;;(recursive-edit)
   1.585  	(insert YaTeX-ec single-command)
   1.586  	)
   1.587 -      (sit-for 1)
   1.588 +      ;;;(sit-for 1)
   1.589        (setq unread-command-char last-char)
   1.590        (insert (YaTeX-addin single-command)))
   1.591       ((eq result 'abort)
   1.592 @@ -378,7 +630,10 @@
   1.593        (message "Abort."))
   1.594       ((eq result 'escape)
   1.595        (delete-region beg (point))
   1.596 -      (insert YaTeX-math-invoke-key))
   1.597 +      (insert this-key))
   1.598 +     ((eq result 'exit)
   1.599 +      (delete-region beg (point))
   1.600 +      (YaTeX-toggle-math-mode))
   1.601       ((eq result 'menu)
   1.602        (delete-region beg (point))
   1.603        (setq key (concat "^" (regexp-quote (substring key 0 -1))))
   1.604 @@ -386,3 +641,9 @@
   1.605  )
   1.606  ;;
   1.607  (provide 'yatexmth)
   1.608 +
   1.609 +; Local variables: 
   1.610 +; fill-prefix: ";;;	" 
   1.611 +; paragraph-start: "^$\\|\\|;;;$" 
   1.612 +; paragraph-separate: "^$\\|\\|;;;$" 
   1.613 +; End: