changeset 11:390df0e505da

Label completion works.
author yuuji
date Mon, 20 Sep 1993 08:56:09 +0000
parents 796a929a7b13
children a7f397790cdc
files docs/yatex.ref yatex.el yatex.new yatexadd.el yatexgen.el yatexm-o.el yatexmth.el yatexprc.el
diffstat 8 files changed, 671 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/docs/yatex.ref	Tue May 04 13:02:40 1993 +0000
+++ b/docs/yatex.ref	Mon Sep 20 08:56:09 1993 +0000
@@ -104,9 +104,13 @@
 	  \begin{}, \end{} のペア、または %#BEGIN, %#END のペアを一挙に削
 	除します。
 
+	◆領域を()で括る		[prefix] )
 	◆領域を{}で括る		[prefix] }
 	◆領域を[]で括る		[prefix] ]
 
+	◆モード切り替え		[prefix] w
+
+	  新規作成/更新モード、数式モードの切り替えメニューが出ます。
 
 								   広瀬雄二
 							yuuji@ae.keio.ac.jp
Binary file yatex.el has changed
--- a/yatex.new	Tue May 04 13:02:40 1993 +0000
+++ b/yatex.new	Mon Sep 20 08:56:09 1993 +0000
@@ -2,6 +2,13 @@
 	Yet Another tex-mode for Emacs
 	yatex.el 各バージョンの変更点について。
 
+1.43:	環境のネストに応じたインデント(変数YaTeX-environment-indentで指定)。
+	数式環境記号補完モード(yatexmth)添付。
+	modify-mode の値で開き括弧の動作を決定する。
+	LaTeX error 発生ファイルの検出の確実化。
+	\ref のラベルをバッファ中の\labelを検索してメニュー形式で補完。
+	タイプセットなどでウィンドウ利用の最適化。
+
 1.42:	fill-paragraph と、(un)comment-paragraph の適正化。
 	[prefix] k での削除範囲の適正化。
 	YaTeX-end-environment などで verb(atim)中のbegin/endは数えない。
--- a/yatexadd.el	Tue May 04 13:02:40 1993 +0000
+++ b/yatexadd.el	Mon Sep 20 08:56:09 1993 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX add-in functions.
-;;; yatexadd.el rev.3
+;;; yatexadd.el rev.5
 ;;; (c)1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
-;;; Last modified Tue May  4 21:50:37 1993 on figaro
+;;; Last modified Sat Sep 18 04:13:41 1993 on 98fa
 ;;; $Id$
 
 (provide 'yatexadd)
@@ -67,6 +67,12 @@
 
 (fset 'YaTeX:enumerate 'YaTeX:itemize)
 
+(defun YaTeX:picture ()
+  "Ask the size of coordinates of picture environment."
+  (concat (YaTeX:read-coordinates "Picture size")
+	  (YaTeX:read-coordinates "Initial position"))
+)
+
 ;;;
 ;;Sample functions for section-type command.
 ;;;
@@ -133,8 +139,9 @@
 
 (defun YaTeX:read-boundary (ULchar)
   "Read boundary usage by _ or ^.  _ or ^ is indicated by argument ULchar."
-  (let ((bndry (read-string (concat ULchar "{...}: "))))
+  (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): "))))
     (if (string= bndry "") ""
+      (if (string= bndry "$") (setq bndry "\\infty"))
       (concat ULchar "{" bndry "}")))
 )
 
@@ -143,3 +150,180 @@
   (if (not (eq type YaTeX-current-completion-type))
       (error "This should be completed with %s-type completion." type))
 )
+
+
+;;;
+;;;		[[Add-in functions for reading section arguments]]
+;;;
+;; All of add-in functions for reading sections arguments should
+;; take an argument ARGP that specify the argument position.
+;; If argument position is out of range, nil should be returned,
+;; else nil should NOT be returned.
+(defvar YaTeX-label-menu-other
+  (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n"))
+(defvar YaTeX-label-menu-any
+  (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n"))
+(defvar YaTeX-label-buffer "*Label completions*")
+(defvar YaTeX-label-guide-msg "Select label and hit RETURN.")
+(defvar YaTeX-label-select-map nil
+  "Key map used in label selection buffer.")
+(defun YaTeX::label-setup-key-map ()
+  (if YaTeX-label-select-map nil
+    (message "Setting up label selection mode map...")
+    (setq YaTeX-label-select-map (copy-keymap global-map))
+    (suppress-keymap YaTeX-label-select-map)
+    (substitute-all-key-definition
+     'previous-line 'YaTeX::label-previous YaTeX-label-select-map)
+    (substitute-all-key-definition
+     'next-line 'YaTeX::label-next YaTeX-label-select-map)
+    (define-key YaTeX-label-select-map "\C-n"	'YaTeX::label-next)
+    (define-key YaTeX-label-select-map "\C-p"	'YaTeX::label-previous)
+    (define-key YaTeX-label-select-map "<"	'beginning-of-buffer)
+    (define-key YaTeX-label-select-map ">"	'end-of-buffer)
+    (define-key YaTeX-label-select-map "\C-m"	'exit-recursive-edit)
+    (define-key YaTeX-label-select-map "\C-j"	'exit-recursive-edit)
+    (define-key YaTeX-label-select-map " "	'exit-recursive-edit)
+    (define-key YaTeX-label-select-map "\C-g"	'abort-recursive-edit)
+    (define-key YaTeX-label-select-map "/"	'isearch-forward)
+    (define-key YaTeX-label-select-map "?"	'isearch-backward)
+    (define-key YaTeX-label-select-map "'"	'YaTeX::label-search-tag)
+    (define-key YaTeX-label-select-map "*"	'YaTeX::label-search-tag)
+    (message "Setting up label selection mode map...Done")
+    (let ((key ?A))
+      (while (<= key ?Z)
+	(define-key YaTeX-label-select-map (char-to-string key)
+	  'YaTeX::label-search-tag)
+	(define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A)))
+	  'YaTeX::label-search-tag)
+	(setq key (1+ key)))))
+)
+(defun YaTeX::label-next ()
+  (interactive) (forward-line 1) (message YaTeX-label-guide-msg))
+(defun YaTeX::label-previous ()
+  (interactive) (forward-line -1) (message YaTeX-label-guide-msg))
+(defun YaTeX::label-search-tag ()
+  (interactive)
+  (let ((case-fold-search t))
+    (cond
+     ((save-excursion
+	(forward-char 1)
+	(re-search-forward (concat "^" (this-command-keys)) nil t))
+      (goto-char (match-beginning 0)))
+     ((save-excursion
+	(goto-char (point-min))
+	(re-search-forward (concat "^" (this-command-keys)) nil t))
+      (goto-char (match-beginning 0))))
+    (message YaTeX-label-guide-msg))
+)
+(defun YaTeX::ref (argp)
+  (cond
+   ((= argp 1)
+    (save-excursion
+      (let ((lnum 0) e0 m1 e1 label label-list (buf (current-buffer))
+	    (p (point)) initl line)
+	(goto-char (point-min))
+	(message "Collecting labels...")
+	(save-window-excursion
+	  (with-output-to-temp-buffer YaTeX-label-buffer
+	    (while (re-search-forward "\\label{\\([^}]+\\)}" nil t)
+	      (setq e0 (match-end 0) m1 (match-beginning 1) e1 (match-end 1))
+	      (if (search-backward
+		   YaTeX-comment-prefix (point-beginning-of-line) t) nil
+		(setq label (buffer-substring m1 e1)
+		      label-list (cons label label-list))
+		(or initl
+		    (if (< p (point)) (setq initl lnum)))
+		(beginning-of-line)
+		(skip-chars-forward " \t\n" nil)
+		(princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
+			       (buffer-substring (point) (point-end-of-line))))
+		(setq lnum (1+ lnum))
+		(message "Collecting \\label{}... %d" lnum))
+	      (goto-char e0))
+	    (princ YaTeX-label-menu-other)
+	    (princ YaTeX-label-menu-any)
+	    );with
+	  (goto-char p)
+	  (message "Collecting labels...Done")
+	  (pop-to-buffer YaTeX-label-buffer)
+	  (YaTeX::label-setup-key-map)
+	  (setq truncate-lines t)
+	  (setq buffer-read-only t)
+	  (use-local-map YaTeX-label-select-map)
+	  (message YaTeX-label-guide-msg)
+	  (goto-line (or initl lnum))	;goto recently defined label line
+	  (unwind-protect
+	      (progn
+		(recursive-edit)
+		(set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
+		(beginning-of-line)
+		(setq line (count-lines (point-min)(point)))
+		(cond
+		 ((= line lnum) (setq label (YaTeX-label-other)))
+		 ((>= line (1+ lnum ))
+		  (setq label (read-string "\\ref{???}: ")))
+		 (t (setq label (nth (- lnum line 1) label-list)))))
+	    (bury-buffer YaTeX-label-buffer)))
+	label
+	))
+    ))
+)
+
+(defun YaTeX-label-other ()
+  (let ((lbuf "*YaTeX mode buffers*") (blist (buffer-list)) (lnum -1) buf rv
+	(ff "**find-file**"))
+    (with-output-to-temp-buffer lbuf
+      (while blist
+	(if (and (buffer-file-name (setq buf (car blist)))
+		 (progn (set-buffer buf) (eq major-mode 'yatex-mode)))
+	    (princ
+	     (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
+		     (buffer-name buf))))
+	(setq blist (cdr blist)))
+      (princ (format "':{%s}" ff)))
+    (pop-to-buffer lbuf)
+    (YaTeX::label-setup-key-map)
+    (setq buffer-read-only t)
+    (use-local-map YaTeX-label-select-map)
+    (message YaTeX-label-guide-msg)
+    (unwind-protect
+	(progn
+	  (recursive-edit)
+	  (set-buffer lbuf)
+	  (beginning-of-line)
+	  (setq rv
+		(if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t)
+		    (buffer-substring (match-beginning 1) (match-end 1)) nil)))
+      (kill-buffer lbuf))
+    (cond
+     ((null rv) "")
+     ((string= rv ff)
+      (call-interactively 'find-file)
+      (YaTeX::ref argp))
+     (t
+      (set-buffer rv)
+      (YaTeX::ref argp)))
+    )
+)
+
+;;;
+;; global subroutines
+;;;
+(defun substitute-all-key-definition (olddef newdef keymap)
+  "Replace recursively OLDDEF with NEWDEF for any keys in KEYMAP now
+defined as OLDDEF. In other words, OLDDEF is replaced with NEWDEF
+where ever it appears."
+  (if (arrayp keymap)
+      (let ((len (length keymap))
+	    (i 0))
+	(while (< i len)
+	  (let ((map (aref keymap i)))
+	    (cond
+	     ((arrayp map) (substitute-key-definition olddef newdef map))
+	     ((equal map olddef)
+	      (aset keymap i newdef)))
+	    (setq i (1+ i)))))
+    (while keymap
+      (if (equal (cdr-safe (car-safe keymap)) olddef)
+	  (setcdr (car keymap) newdef))
+      (setq keymap (cdr keymap)))))
--- a/yatexgen.el	Tue May 04 13:02:40 1993 +0000
+++ b/yatexgen.el	Mon Sep 20 08:56:09 1993 +0000
@@ -2,7 +2,7 @@
 ;;; Generate add-in functions for YaTeX.
 ;;; yatexgen.el rev.1(beta2)
 ;;; (c)1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
-;;; Last modified Tue May  4 21:51:23 1993 on figaro
+;;; Last modified Mon Sep 20 17:55:13 1993 on gloria
 ;;; $Id$
 
 (require 'yatex)
--- a/yatexm-o.el	Tue May 04 13:02:40 1993 +0000
+++ b/yatexm-o.el	Mon Sep 20 08:56:09 1993 +0000
@@ -1,8 +1,7 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; Sample startup file to invoke yatex-mode with outline-minor mode.
 ;;; (C)1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
-;;; Last modified Tue May  4 22:02:41 1993 on figaro
-;;; $Id$
+;;; Last modified Wed Apr 28 04:25:16 1993 on 98fa
 
 ;;;
 ;; outline-minor-mode(使用しない場合は不要です)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yatexmth.el	Mon Sep 20 08:56:09 1993 +0000
@@ -0,0 +1,388 @@
+;;; -*- Emacs-Lisp -*-
+;;; YaTeX interface for math-mode.
+;;; yatexmth.el rev.0
+;;; (C)1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
+;;; Last modified Tue Aug  3 23:37:07 1993 on 98fa
+;;; $Id$
+
+(setq
+ YaTeX-math-key-alist-default
+ '(
+   ;frequently used
+   ("||"	"|"		("||"		"‖"))
+   ("sum"	"sum"		("\\-+\n >\n/-+" "Σ"))
+   ("sigma"	"sum"		("\\-+\n >\n/-+" "Σ"))
+   ("integral"	"int"		" /\\\n \\\n\\/")
+   ("ointegral"	"oint"		" /\\\n(\\)\n\\/")
+   ("A"		"forall"	"|_|\nV")
+   ("E"		"exists"	"-+\n-+\n-+")
+   ("!"		"neg"		"--+\n  |")
+   ("oo"	"infty"		("oo"		"∞"))
+   ("\\"	"backslash"	("\\"		"\"))
+
+   ;;binary operators
+   ("+-"	"pm"		("+\n-" "±"))
+   ("-+"	"mp"		"-\n+")
+   ("x"		"times"		("x" "×"))
+   ("/"		"div"		(",\n-\n'" "÷"))
+   ("*"		"ast"		"*")
+   ("#"		"star"		("_/\\_\n\\  /\n//\\\\" "★"))
+   ("o"		"circ"		"o")
+   ("o*"	"bullet"	" _\n(*)\n ~")
+   ("."		"cdot"		".")
+   ("cap"	"cap"		"/-\\\n| |")
+   ("cup"	"cup"		"| |\n\\-/")
+   ("u+"	"uplus"		"|+|\n\\-/")
+   ("|~|"	"sqcap"		"|~|")
+   ("|_|"	"sqcup"		"|_|")
+   ("v"		"vee"		"v")
+   ("^"		"wedge"		"^")
+   ("\\\\"	"setminus"	"\\")
+   (")("	"wr"		" )\n(")
+   ("<>"	"diamond"	"<>")
+   ("/\-"	"bigtriangleup"	("/\\\n~~" "△"))
+   ("-\\/"	"bigtriangledown" ("__\n\\/" "▽"))
+   ("<|"	"triangleleft"	"<|")
+   ("|>"	"triangleright"	"|>")
+   ("<||"	"lhd"		"/|\n\\|")
+   ("||>"	"rhd"		"|\\\n|/")
+   ("<|-"	"unlhd"		"<|\n~~")
+   ("|>-"	"unrhd"		"|>\n~~")
+   ("o+"	"oplus"		" _\n(+)\n ~")
+   ("o-"	"ominus"	" _\n(-)\n ~")
+   ("ox"	"otimes"	" _\n(x)\n ~")
+   ("o/"	"oslash"	" _\n(/)\n ~")
+   ("o."	"odot"		"(.)")
+   ("O"		"bigcirc"	"O")
+   ("t"		"dagger"	"+\n|")
+   ("tt"	"ddagger"	"+\n+\n|")
+   ("II"	"amalg"		"II")
+   ;	:
+   ;;relational operators
+   ("<"		"leq"		("<\n-"		"≦"))
+   (">"		"geq"		(">\n-"		"≧"))
+   ("-="	"equiv"		"=\n-")
+   ("=-"	"equiv"		"=\n-")
+   ("---"	"equiv"		"=\n-")
+   ("("		"subset"	" _\n(\n ~")
+   ("(-"	"subseteq"	" _\n(_\n~")
+   (")"		"supset"	"_\n )\n~")
+   (")-"	"supseteq"	"_\n_)\n~")
+   ("["		"sqsubset"	"[")
+   ("[-"	"sqsubseteq"	"[\n~")
+   ("]"		"sqsupset"	"]")
+   ("]-"	"sqsupseteq"	"]\n~")
+   ("{"		"in"		"(-")
+   ("}"		"ni"		"-)")
+   ("|-"	"vdash"		"|-")
+   ("-|"	"dashv"		"-|")
+   ("~"		"sim"		"~(tild)")
+   ("~-"	"simeq"		"~\n-")
+   ("asymp"	"asymp"		"v\n^")
+   ("~~"	"approx"	"~\n~")
+   ("~="	"cong"		"~\n=")
+   ("=/"	"neq"		("=/="		"≠"))
+   (".="	"doteq"		".\n=")
+   ("o<"	"propto"	"o<")
+   ("|="	"models"	"|=")
+   ("_|_"	"perp"		"_|_")
+   ("|"		"mid"		"|")
+   ("||"	"parallel"	"||")
+   ("bowtie"	"bowtie"	"|><|(wide)")
+   ("|><|"	"join"		"|><|")
+   ("\\_/"	"smile"		"\\_/")
+   ("/~\\"	"frown"		"/~~\\")
+   ("-<"	"prec"		("-<"		"く"))
+   ("-<="	"preceq"	("-<\n-"	"く\n="))
+   ("<<"	"ll"		("<<"		"《"))
+   ;	:
+   ;;arrows
+   ("<-"	"leftarrow"	("<-"		"←"))
+   ("<--"	"longleftarrow"	("<-"		"←--"))
+   ("<="	"Leftarrow"	"<=")
+   ("<=="	"Longleftarrow"	"<==")
+   ("->"	"rightarrow"	("->"		"→"))
+   ("-->"	"longrightarrow" ("-->"		"--→"))
+   ("==>"	"Longrightarrow" "==>")
+   ("<->"	"leftrightarrow" ("<->"		"←→"))
+   ("<-->"	"longleftrightarrow" ("<---->"	"←--→"))
+   ("<=>"	"leftrightarrow" "<=>")
+   ("<==>"	"Longleftrightarrow" "<==>")
+   ("^|"	"uparrow"	("^\n|" "↑"))
+   ("^||"	"Uparrow"	"/\\\n||")
+   ("\C-n"	"downarrow"	("|\nv" "↓"))
+   ("^|"	"uparrow"	("^\n|" "↑"))
+   ("|->"	"mapsto"	("|->"		"|→"))
+   ("<-)"	"hookleftarrow"	("   ,\n<--+"	"   ヽ\n<--/"))
+   ("/-"	"leftharpoonup"	"/\n~~~")
+   ("\\-"	"leftharpoondown" "__\n\\")
+   ("-/"	"rightharpoondown"  "__\n/")
+   ("-\\"	"rightharpoonup" "~~\n\\")
+   ;other marks
+   ("Z"		"aleph"		"|\\|")
+   ("|\\|"	"aleph"		"|\\|")
+   ("h-"	"hbar"		"_\nh")
+   ("i"		"imath"		"i")
+   ("j"		"jmath"		"j")
+   ("l"		"ell"		"l")
+   ("wp"	"wp"		"???")
+   ("R"		"Re"		")R")
+   ("Im"	"Im"		"???")
+   ("mho"	"mho"		"~|_|~")
+   ("'"		"prime"		"'")
+   ("0"		"emptyset"	"0")
+   ("nabla"	"nabla"		"___\n\\\\/")
+   ("\\/"	"surd"		"-\\/")
+   ("surd"	"surd"		"-\\/")
+   ("top"	"top"		"T")
+   ("bot"	"bot"		"_|_")
+   ("b"		"flat"		"b")
+   ("LT"	"natural"	"|\nLT\n |")
+   ("6"		"partial"	" -+\n+-+\n+-+")
+   ("partial"	"partial"	" -+\n+-+\n+-+")
+   ("round"	"partial"	" -+\n+-+\n+-+")
+   ("[]"	"box"		"[]")
+   ("Diamond"	"Diamond"	"/\\\n\\/")
+   ("3"		"triangle"	"/\\\n~~")
+   ("C"		"clubsuit"	" o\no+o\n |")
+   ("D"		"diamondsuit"	"/\\\n\\/")
+   ("H"		"heartsuit"	"<^^>\n \\/")
+   ("S"		"spadesuit"	" /\\\n<++>\n /\\")
+
+   ))
+
+(defvar YaTeX-math-key-alist-private nil
+  "*User definable key vs LaTeX-math-command alist.")
+
+(defvar YaTeX-math-quit-with-strict-match nil
+  "*T for quitting completion as soon as strict-match is found.")
+(setq YaTeX-math-key-alist
+      (append YaTeX-math-key-alist-private YaTeX-math-key-alist-default))
+
+(setq YaTeX-math-key-array
+  (let ((array (make-vector (length YaTeX-math-key-alist) ""))
+	(list YaTeX-math-key-alist) (i 0))
+    (while list
+      (aset array i (car (car list)))
+      (setq i (1+ i) list (cdr list)))
+    array))
+
+(defvar YaTeX-ec "\\" "Escape character of mark-up language.")
+(setq YaTeX-math-indicator
+  "KEY\tLaTeX sequence\t\tsign")
+
+(defvar YaTeX-math-need-image t
+  "*T for displaying pseudo image momentarily.")
+(defvar YaTeX-math-max-key 8)
+(defvar YaTeX-math-max-seq
+  (* 8 (1+ (/ (length "\\longleftrightarrow") 8))))
+(defvar YaTeX-math-max-sign 5)
+(defvar YaTeX-math-sign-width
+  (+ YaTeX-math-max-key YaTeX-math-max-seq YaTeX-math-max-sign))
+(defvar YaTeX-math-display-width
+  (* 8 (1+ (/ YaTeX-math-sign-width 8))))
+(defvar YaTeX-math-menu-map nil
+  "Keymap used in YaTeX mathematical sign menu mode."
+)
+(if YaTeX-math-menu-map nil
+  (setq YaTeX-math-menu-map (make-sparse-keymap))
+  (define-key YaTeX-math-menu-map "n"	'next-line)
+  (define-key YaTeX-math-menu-map "p"	'previous-line)
+  (define-key YaTeX-math-menu-map "f"	'YaTeX-math-forward)
+  (define-key YaTeX-math-menu-map "b"	'YaTeX-math-backward)
+  (define-key YaTeX-math-menu-map "v"	'scroll-up)
+  (define-key YaTeX-math-menu-map " "	'scroll-up)
+  (define-key YaTeX-math-menu-map "c"	'scroll-up)
+  (define-key YaTeX-math-menu-map "V"	'scroll-down)
+  (define-key YaTeX-math-menu-map "r"	'scroll-down)
+  (define-key YaTeX-math-menu-map "\^h"	'scroll-down)
+  (define-key YaTeX-math-menu-map "<"	'beginning-of-buffer)
+  (define-key YaTeX-math-menu-map ">"	'end-of-buffer)
+  (define-key YaTeX-math-menu-map "\^m"	'exit-recursive-edit)
+  (define-key YaTeX-math-menu-map "q"	'abort-recursive-edit))
+
+(defmacro YaTeX-math-japanese-sign (list)
+  (list 'nth 1 list))
+
+(defvar YaTeX-math-cmd-regexp (concat (regexp-quote YaTeX-ec) "[A-z]"))
+
+(defun YaTeX-math-forward (arg)
+  (interactive "p")
+  (re-search-forward YaTeX-math-cmd-regexp nil t arg))
+
+(defun YaTeX-math-backward (arg)
+  (interactive "p")
+  (re-search-backward YaTeX-math-cmd-regexp nil t arg))
+
+(defun YaTeX-math-get-sign (list)
+  (let ((sign (car (cdr (cdr list)))))
+    (if (listp sign)
+	(setq sign (cond
+		    (YaTeX-japan (YaTeX-math-japanese-sign sign))
+		    (t (car sign)))))
+    sign)
+)
+
+(defun YaTeX-math-display-list (list cols)
+  (goto-char (point-max))
+  (if (= cols 0) (if (not (eolp)) (newline 1))
+    (forward-line -1)
+    (while (looking-at "[ \t\n]") (forward-line -1)))
+  (end-of-line)
+  (let ((indent (* YaTeX-math-display-width cols)) sign str to)
+    (indent-to indent)
+    (insert (car list))
+    (indent-to (setq indent (+ indent YaTeX-math-max-key)))
+    (insert "\\" (car (cdr list)))
+    (setq indent (+ indent YaTeX-math-max-seq))
+    (setq sign (YaTeX-math-get-sign list))
+    (while (not (string= "" sign))
+      (setq to (string-match "\n" sign)
+	    str (if to (substring sign 0 to) sign))
+      (end-of-line)
+      (indent-to indent)
+      (insert str)
+      (cond ((eobp) (newline 1))
+	    ((> cols 0) (forward-line 1)))
+      (setq sign (if to (substring sign (1+ to)) "")))))
+
+(defvar YaTeX-math-menu-buffer "*math-mode-signs*")
+
+(defun YaTeX-math-show-menu (match-str)
+  (save-window-excursion
+    (pop-to-buffer YaTeX-math-menu-buffer)
+    (let ((maxcols (max 1 (/ (screen-width) YaTeX-math-sign-width)))
+	  (case-fold-search nil)
+	  (cols 0) (list YaTeX-math-key-alist) command)
+      (erase-buffer)
+      (insert YaTeX-math-indicator "\t")
+      (insert YaTeX-math-indicator)
+      (newline 1)
+      (insert-char ?- (1- (screen-width)))
+      (newline 1)
+      (while list
+	(if (string-match match-str (car (car list)))
+	    (progn (YaTeX-math-display-list (car list) cols)
+		   (setq cols (% (1+ cols) maxcols))))
+	(setq list (cdr list)))
+      (goto-char (point-min))
+      (use-local-map YaTeX-math-menu-map)
+      (unwind-protect
+	  (recursive-edit)
+	(skip-chars-backward "^ \t\n")
+	(setq command
+	      (if (re-search-forward YaTeX-math-cmd-regexp nil t)
+		  (buffer-substring
+		   (match-beginning 0)
+		   (prog2 (skip-chars-forward "^ \t\n") (point)))
+		nil))
+	(kill-buffer YaTeX-math-menu-buffer))
+      command))
+)
+
+;
+(defun YaTeX-math-show-image (image &optional exit-char)
+  "Momentarily display IMAGE at the beginning of the next line;
+erase it on the next keystroke.  The window is recentered if necessary
+to make the whole string visible.  If the window isn't large enough,
+at least you get to read the beginning."
+  (let ((buffer-read-only nil)
+	(modified (buffer-modified-p))
+	(name buffer-file-name)
+	insert-start
+	insert-end)
+    (unwind-protect
+	(progn
+	  (save-excursion
+	    ;; defeat file locking... don't try this at home, kids!
+	    (setq buffer-file-name nil)
+	    (forward-line 1)
+	    (setq insert-start (point))
+	    (if (eobp) (newline))
+	    (insert image)
+	    (setq insert-end (point)))
+	  ; make sure the whole string is visible
+	  (if (not (pos-visible-in-window-p insert-end))
+	      (recenter (max 0
+			     (- (window-height)
+				(count-lines insert-start insert-end)
+				2))))
+	  (let ((char (read-char)))
+	    (or (eq char exit-char)
+		(setq unread-command-char char))))
+      (if insert-end
+	  (save-excursion
+	    (delete-region insert-start insert-end)))
+      (setq buffer-file-name name)
+      (set-buffer-modified-p modified))))
+
+(defun YaTeX-math-insert-sequence ()
+  (interactive)
+  (let ((key "") regkey str  last-char list i
+	(case-fold-search nil) match
+	(n (length YaTeX-math-key-array)) (beg (point)) result)
+    (setq result
+	  (catch 'complete
+	    (while t
+	      (setq last-char (read-char)
+		    key (concat key (char-to-string last-char))
+		    regkey (concat "^" (regexp-quote key)) i 0)
+	      (cond
+	       ((string= key YaTeX-math-invoke-key)	;;invoke key itself
+		(throw 'complete 'escape))
+	       ((string-match "[\C-g\C-c]" key) (throw 'complete 'abort))
+	       ((string-match "[\n\r]" key) (throw 'complete 'menu)))
+	      (if
+		  (catch 'found
+		    ;;(1)input string strictly matches with alist
+		    (setq single-command (car (cdr match))
+			  ;;remember previous match
+			  match (assoc key YaTeX-math-key-alist))
+		    ;;(2)search partial match into alist
+		    (while (< i n)
+		      (if (string-match
+			   regkey (aref YaTeX-math-key-array i))
+			  (progn
+			    (or match
+				(setq match (nth i YaTeX-math-key-alist)))
+			    (throw 'found t)))
+		      (setq i (1+ i)))) 		;catch 'found
+		  nil ;;if any match, continue reading
+		;;else reading of sequence has been done.
+		(message "complete.")
+		(throw 'complete t)
+		)
+	      (if match
+		  (progn (delete-region beg (point))
+			 (insert YaTeX-ec (car (cdr match)))
+			 (if YaTeX-math-need-image
+			     (YaTeX-math-show-image
+			      (concat (YaTeX-math-get-sign match) "\n")))
+			 )
+		nil)
+	      )))
+    (cond
+     ((eq result t)
+      (setq YaTeX-current-completion-type 'maketitle)
+      (if t nil
+	(delete-region beg (point))
+	(setq single-command (car (cdr match)))
+	;;(recursive-edit)
+	(insert YaTeX-ec single-command)
+	)
+      (sit-for 1)
+      (setq unread-command-char last-char)
+      (insert (YaTeX-addin single-command)))
+     ((eq result 'abort)
+      (delete-region beg (point))
+      (message "Abort."))
+     ((eq result 'escape)
+      (delete-region beg (point))
+      (insert YaTeX-math-invoke-key))
+     ((eq result 'menu)
+      (delete-region beg (point))
+      (setq key (concat "^" (regexp-quote (substring key 0 -1))))
+      (insert (YaTeX-math-show-menu key)))))
+)
+;;
+(provide 'yatexmth)
--- a/yatexprc.el	Tue May 04 13:02:40 1993 +0000
+++ b/yatexprc.el	Mon Sep 20 08:56:09 1993 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX process handler.
-;;; yatexprc.el rev.1.42
+;;; yatexprc.el rev.1.43
 ;;; (c)1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
-;;; Last modified Tue May  4 21:49:59 1993 on figaro
+;;; Last modified Sat Sep 18 04:12:18 1993 on 98fa
 ;;; $Id$
 
 (require 'yatex)
@@ -13,6 +13,18 @@
 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*"
   "Process buffer for jlatex")
 
+(defvar YaTeX-typeset-buffer-syntax nil
+  "*Syntax table for typesetting buffer")
+
+(if YaTeX-typeset-buffer-syntax nil
+  (setq YaTeX-typeset-buffer-syntax
+	(make-syntax-table (standard-syntax-table)))
+  (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax)
+  (modify-syntax-entry ?\} "w" YaTeX-typeset-buffer-syntax)
+  (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax)
+  (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax)
+)
+
 (defun YaTeX-typeset (command buffer)
   "Execute jlatex (or other) to LaTeX typeset."
   (interactive)
@@ -34,23 +46,28 @@
 			     command))
       (set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel)))
   (setq current-TeX-buffer (buffer-name))
-  (other-window 1)
-  (use-local-map YaTeX-typesetting-mode-map)
-  (setq mode-name "typeset")
-  (if YaTeX-typeset-process ; if process is running (maybe on UNIX)
-      (cond ((boundp 'MULE)
-	     (set-current-process-coding-system
-	      YaTeX-latex-message-code YaTeX-coding-system))
-	    ((boundp 'NEMACS)
-	     (set-kanji-process-code YaTeX-latex-message-code))))
-  (message "Type SPC to continue.")
-  (goto-char (point-max))
-  (if (eq system-type 'ms-dos) (message "Done.")
-    (while (bobp) (message "Invoking process. wait...") (sleep-for 1))
-    (insert (message " ")))
-  (if (bolp) (forward-line -1))
-  (recenter -1)
-  (other-window -1)
+  (let ((window (selected-window)))
+    (select-window (get-buffer-window buffer))
+    ;;(other-window 1)
+    (use-local-map YaTeX-typesetting-mode-map)
+    (set-syntax-table YaTeX-typeset-buffer-syntax)
+    (setq mode-name "typeset")
+    (if YaTeX-typeset-process ; if process is running (maybe on UNIX)
+	(cond ((boundp 'MULE)
+	       (set-current-process-coding-system
+		YaTeX-latex-message-code YaTeX-coding-system))
+	      ((boundp 'NEMACS)
+	       (set-kanji-process-code YaTeX-latex-message-code))))
+    (message "Type SPC to continue.")
+    (goto-char (point-max))
+    (if (eq system-type 'ms-dos) (message "Done.")
+      (while (bobp) (message "Invoking process. wait...") (sleep-for 1))
+      (insert (message " ")))
+    (if (bolp) (forward-line -1))
+    (recenter -1)
+    (select-window window)
+  ;;(other-window -1)
+    )
 )
 
 (defun YaTeX-typeset-sentinel (proc mes)
@@ -58,21 +75,17 @@
          ;; buffer killed
          (set-process-buffer proc nil))
         ((memq (process-status proc) '(signal exit))
-         (let* ((obuf (current-buffer)))
+         (let* ((obuf (current-buffer)) (pbuf (process-buffer proc))
+		(owin (selected-window)) win)
            ;; save-excursion isn't the right thing if
            ;;  process-buffer is current-buffer
            (unwind-protect
                (progn
                  ;; Write something in *typesetting* and hack its mode line
-		 (if (equal (current-buffer) (process-buffer proc))
-		     nil
-		   (other-window 1)
-		   (switch-to-buffer (process-buffer proc))
-		   (goto-char (point-max))
-		   (recenter -3)
-		   (other-window -1))
+		 (YaTeX-pop-to-buffer pbuf)
 		 (set-buffer (process-buffer proc))
                  (goto-char (point-max))
+		 (recenter -3)
                  (insert ?\n "latex typesetting " mes)
                  (forward-char -1)
                  (insert " at " (substring (current-time-string) 0 -5) "\n")
@@ -90,6 +103,7 @@
              ;; Force mode line redisplay soon
              (set-buffer-modified-p (buffer-modified-p))
 	     )
+	   (select-window owin)
 	   (set-buffer obuf))))
 )
 
@@ -208,14 +222,19 @@
     (put 'dvi2-command 'region nil))
 )
 
-(defun YaTeX-bibtex-buffer ()
+(defun YaTeX-call-command-on-file (base-cmd buffer)
+  (YaTeX-save-buffers)
+  (YaTeX-typeset
+   (read-string "Call command: "
+		(concat base-cmd " " (YaTeX-get-preview-file-name)))
+   buffer)
+)
+
+(defun YaTeX-bibtex-buffer (cmd)
   "Pass the bibliography data of editing file to bibtex."
   (interactive)
   (YaTeX-save-buffers)
-  (YaTeX-typeset
-   (read-string "BibTeX command: "
-		(concat bibtex-command " " (YaTeX-get-preview-file-name)))
-   "*YaTeX-bibtex*" )
+  (YaTeX-call-command-on-file cmd "*YaTeX-bibtex*" )
 )
 
 (defun YaTeX-kill-typeset-process (proc)
@@ -269,11 +288,12 @@
   "Visit previous error.  The reason why not NEXT-error is to
 avoid make confliction of line numbers by editing."
   (interactive)
-  (let ((cur-buf (buffer-name))
-	YaTeX-error-line error-buffer)
+  (let ((cur-buf (buffer-name)) (cur-win (selected-window))
+	YaTeX-error-line typeset-win error-buffer error-win)
     (if (null (get-buffer YaTeX-typeset-buffer))
 	(message "There is no output buffer of typesetting.")
-      (pop-to-buffer YaTeX-typeset-buffer)
+      (YaTeX-pop-to-buffer YaTeX-typeset-buffer)
+      (setq typeset-win (selected-window))
       (if (eq system-type 'ms-dos)
 	  (if (search-backward latex-dos-emergency-message nil t)
 	      (progn (goto-char (point-max))
@@ -289,37 +309,33 @@
 	      (beginning-of-line)
 	      (setq error-regexp latex-warning-regexp))))
       (if (re-search-backward error-regexp nil t)
-	  (save-restriction
-	    (set-mark-command nil)
-	    (end-of-line)
-	    (narrow-to-region (point) (mark))
-	    (goto-char (point-min))
-	    (re-search-forward "[0-9]")
-	    (forward-char -1)
-	    (set-mark (point))
-	    (skip-chars-forward "0-9")
-	    (narrow-to-region (point) (mark))
-	    (goto-char (point-min))
-	    (setq YaTeX-error-line (read (current-buffer))))
+	  (setq YaTeX-error-line
+		(string-to-int
+		 (buffer-substring
+		  (progn (goto-char (match-beginning 0))
+			 (skip-chars-forward "^0-9")
+			 (point))
+		  (progn (skip-chars-forward "0-9") (point)))))
 	(message "No more error on %s" cur-buf)
-	(ding)
-	)
-      (setq error-buffer (YaTeX-get-error-file cur-buf))
-      (other-window -1)
-      (switch-to-buffer cur-buf)
-      (if (null YaTeX-error-line)
+	(ding))
+      (setq error-buffer (YaTeX-get-error-file cur-buf)); arg. is default buf.
+      (setq error-win (get-buffer-window error-buffer))
+      (select-window cur-win)
+      (if (or (null YaTeX-error-line) (equal 0 YaTeX-error-line))
 	  nil
 	;; if warning or error found
-	(YaTeX-switch-to-buffer error-buffer)
+	(if error-win (select-window error-win)
+	  (YaTeX-switch-to-buffer error-buffer)
+	  (setq error-win (selected-window)))
 	(goto-line YaTeX-error-line)
 	(message "latex error or warning in '%s' at line: %d"
 		 error-buffer YaTeX-error-line)
-	(other-window 1)
+	(select-window typeset-win)
 	(skip-chars-backward "[0-9]")
 	(recenter (/ (window-height) 2))
 	(sit-for 3)
 	(forward-char -1)
-	(other-window -1)
+	(select-window error-win)
 	)))
 )
 
@@ -372,10 +388,11 @@
   (interactive)
   (if (null (get-buffer YaTeX-typeset-buffer))
       (message "No typeset buffer found.")
-    (pop-to-buffer YaTeX-typeset-buffer)
-    (goto-char (point-max))
-    (recenter -1)
-    (other-window -1))
+    (let ((win (selected-window)))
+      (YaTeX-pop-to-buffer YaTeX-typeset-buffer)
+      (goto-char (point-max))
+      (recenter -1)
+      (select-window win)))
 )
 
 (defun YaTeX-get-error-file (default)
@@ -591,4 +608,10 @@
 	    (buffer-list)))
 )
 
+(defun YaTeX-pop-to-buffer (buffer &optional win)
+  (if (setq win (get-buffer-window buffer))
+      (select-window win)
+    (pop-to-buffer buffer))
+)
+
 (provide 'yatexprc)

yatex.org