annotate yatexgen.el @ 164:59e47ed6b334 dev

New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
author yuuji@gentei.org
date Mon, 14 Feb 2011 12:40:11 +0900
parents 0734be649cb8
children 5921f28ef77c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
1 ;;; -*- Emacs-Lisp -*-
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
2 ;;; YaTeX add-in function generator.
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
3 ;;; yatexgen.el rev.5
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 72
diff changeset
4 ;;; (c)1991-1995,1999,2000 by HIROSE Yuuji.[yuuji@yatex.org]
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 72
diff changeset
5 ;;; Last modified Fri Jun 27 12:09:37 2003 on firestorm
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
6 ;;; $Id$
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
7
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
8 (require 'yatex)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
10 (defmacro YaTeX-setq (var japanese english)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
11 (list 'setq var
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
12 (if YaTeX-japan japanese english))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
13 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
14
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
15 (put 'YaTeX-setq 'lisp-indent-hook 1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
16
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
17 (YaTeX-setq YaTeX-generate-initial-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
18 " 自動生成モードへようこそ!!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
19
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
20 初めてやる人はこのバッファの例にしたがって指示通りにやって練習してね。
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
21 本番の時もこのバッファに出るメッセージを *よく読んで* 操作しないとう
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
22 まく関数が作れないよ!!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
23
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
24 ではリターンキーを押して下さい。"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
25 " Welcome to auto-generation mode!!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
26
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
27 If this is your first trial, exercise this according to example and
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
28 following my messages. Then, at making actual function, operate
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
29 reading my messages *carefully*, or you'll fail to generate appropriate
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
30 function.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
31
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
32 Hit return key!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
33 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
34
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
35 (YaTeX-setq YaTeX-generate-start-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
36 "さぁはじめるよ.\n1.登録したい補完をやってみて.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
37 たとえば section 型補完の \\documentstyle だったら \\documentstyle{}
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
38 だけをいれてみてね. ちゃんと『〜型補完』を使わないとダメよ!。
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
39 で、おわったらりたーん!!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
40 "Let's begin completion for which you want to make add-in function.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
41 If you want to make add-in function for \\documentstyle input only
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
42 `\\documentstyle{}' *with* completion of yatex-mode.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
43 If you finish this, please press RET."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
44 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
45
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
46 (YaTeX-setq YaTeX-generate-abort-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
47 "やめた、やめた〜いめんどくせ〜"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
48 "Aborted."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
49 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
50
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
51 (YaTeX-setq YaTeX-generate-same-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
52 "それじゃ、なにも変わってねぇだろーが! やめた。"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
53 "I found no difference between them. So I'm quitting."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
54 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
55
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
56 (YaTeX-setq YaTeX-generate-invalid-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
57 "それは、ちと無理というものじゃ."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
58 "It's impossible."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
59 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
60
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
61 (YaTeX-setq YaTeX-generate-idontknow-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
62 "う〜ん、難しくてよくわからないなぁ。ばかでごめんねェ〜"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
63 "Sorry I can't tell your adding method."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
64 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
65
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
66 (YaTeX-setq YaTeX-generate-confirm-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
67 "ということは、付け足したい部分はこれでいいのね"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
68 "Is it additional string of add-in function?"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
69 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
70
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
71 (YaTeX-setq YaTeX-generate-output-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
72 "2.じゃ、それにくっつけたいものを *カーソルの位置に* 足してみて.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
73 さっきの \\documentstyle{} の例だと \\documentstyle[12pt]{} とかにするの。
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
74 しつこいようだけど、今の位置からカーソル動かしちゃダメよ!!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
75 で、またおわったらりたーん!!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
76 "2.Then input additional string *at CURSOR POSITION*
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
77 According to last example \\documentstyle{},
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
78 modify it \\documentstyle[12pt]{}. RET to finish."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
79 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
80
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
81 (YaTeX-setq YaTeX-generate-put-arg-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
82 "3.このうち、キーボードから読み込んで欲しい文字列を順に入れて。
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
83 さっきの \\documentstyle[12pt]{} だったら、付加する文字は[12pt]だけど
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
84 手で入れたいのは 12pt の部分だけですね。
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
85 で、全部入れ終ったら、りたーんだけうってね!!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
86 "3.In this string, extract string which you want to input from key
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
87 board with quiry afterwards. For example, though additional string is
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
88 \\documentstyle[12pt]{}, but you want enter only `12pt' by hand.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
89 RET to finish!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
90 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
91
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
92 (YaTeX-setq YaTeX-generate-read-prompt-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
93 "4.では、あとでこれらの文字列を読み込む時に、どういうプロンプトを
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
94 出したいですか? 順に入れて下さい。面倒なら単にリターンを打ってね。
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
95 さっきの 12pt の部分だったら、『サイズは』とかがおすすめ。"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
96 "4.When you use this add-in function afterwards, what message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
97 do you like to be prompted with to enter these values. In last
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
98 example `12pt', typical prompt string may be `Size?: '."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
99 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
100
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
101 (YaTeX-setq YaTeX-generate-done-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
102 "よし! これが、君の作りたかった関数だ。~/.emacs にでも入れてせいぜい
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
103 楽してくれ。このバッファ(*ご案内*)を yatex-mode にしておくから
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
104 できた関数が本当にお望みの動作をするか確かめてみるといいかもね。
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
105 ところで、この関数こんなに簡単だろう? そろそろ自分で書いたらどう?
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
106 "
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
107 "OK! This is the definition of function you want to make! Add
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
108 this description to your ~/.emacs or so. Use this buffer(*Guide*)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
109 for testing of this function please.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
110 But you can see this function quite easy, can't you? You had better
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
111 write your most favorite add-in function yourself!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
112 "
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
113 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
114
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
115 (YaTeX-setq YaTeX-generate-nomatch-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
116 "こらこら、そんな文字列どこにもねーぞ!!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
117 "No such string in additional string."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
118 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
119 (YaTeX-setq YaTeX-generate-buffer
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
120 "*付加関数生成バッファ*"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
121 "*Generate-add-in-function*"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
122 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
123
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
124 (YaTeX-setq YaTeX-generate-message-buffer
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
125 "*ご案内*"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
126 "*Guide*"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
127 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
128
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
129 (YaTeX-setq YaTeX-generate-bug-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
130 "ごめ〜ん!! ちょっと、このアドイン関数つくるの失敗しちゃったみたい!!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
131 作者まで連絡してくださ〜〜〜い!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
132 "Sorry I failed to make add-in function for you...
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
133 Send bug report to me."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
134 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
135
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
136 (YaTeX-setq YaTeX-generate-narrow-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
137 "画面がせますぎるような気がします。"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
138 "Too narrow screen height."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
139 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
140
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
141 (defvar YaTeX-generate-message-height
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
142 10 "Window height of YaTeX-generate-message-buffer")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
143
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
144 ;; Do you need learning for generated function?
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 59
diff changeset
145 ;; If you need, please tell me (yuuji@yatex.org)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
146 ;;(defvar YaTeX-generate-variables-for-learning nil)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
147 ;;(defvar YaTeX-generate-current-completion-table nil)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
148
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
149 ;;;
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
150 ;Generate mode.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
151 ;;;
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
152 (defun YaTeX-generate ()
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
153 "Genarate YaTeX add-in function with enquiry."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
154 (interactive)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 59
diff changeset
155 (if (< (YaTeX-screen-height) (+ YaTeX-generate-message-height 10))
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
156 (error YaTeX-generate-narrow-message))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
157 (put 'YaTeX-generate 'disabled t)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
158 (save-window-excursion
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
159 (unwind-protect
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
160 (let (input output (i 0) (beg 0) end add-in map map1 si str slist
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
161 (from (make-marker)) (to (make-marker)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
162 (delete-other-windows)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
163 (switch-to-buffer YaTeX-generate-message-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
164 (yatex-mode)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
165 (erase-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
166 (insert YaTeX-generate-initial-message)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
167 (read-string
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
168 (if YaTeX-japan "リターンキーを押して下さい." "Press RETURN."))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
169 (erase-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
170 (insert YaTeX-generate-start-message)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
171 (pop-to-buffer (get-buffer-create YaTeX-generate-buffer))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
172 (enlarge-window (- (window-height) YaTeX-generate-message-height 1))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
173 (erase-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
174 (yatex-mode)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
175 (use-local-map (setq map (copy-keymap YaTeX-mode-map)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
176 (define-key (current-local-map) "\n" 'exit-recursive-edit)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
177 (define-key (current-local-map) "\r" 'exit-recursive-edit)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
178 (define-key (current-local-map) "\C-g" 'abort-recursive-edit)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
179 (setq map1 (copy-keymap map))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
180 (YaTeX-suppress-sparse-keymap map)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
181 ;;First get input form.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
182 (recursive-edit)
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
183 (setq input (YaTeX-minibuffer-string)
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
184 end (1- (length input)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
185 (if (string= "" input) (error YaTeX-generate-abort-message))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
186 (YaTeX-generate-move-to-add-in-position)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
187 (set-marker from (1- (point))) ;;Can't write before `from'
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
188 (set-marker to (1+ (point))) ;;Can't write after `to'
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
189 ;;Second get output form.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
190 (setq beg (1- (point)));;Cheat begin point!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
191 (YaTeX-generate-display-message YaTeX-generate-output-message)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
192 (use-local-map map1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
193 (fset 'si (symbol-function 'self-insert-command))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
194 (defun self-insert-command (arg)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
195 (interactive "p")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
196 (if (or (not (equal (buffer-name) YaTeX-generate-buffer))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
197 (and (> (point) (marker-position from))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
198 (< (point) (marker-position to))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
199 (insert (this-command-keys)) (ding)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
200 (unwind-protect
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
201 (recursive-edit)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
202 (fset 'self-insert-command (symbol-function 'si)))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
203 (setq output (YaTeX-minibuffer-string))
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
204 (cond ((string= "" output) (error YaTeX-generate-abort-message))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
205 ((string= input output) (error YaTeX-generate-same-message))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
206 ((< (length output) (length input))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
207 (error YaTeX-generate-invalid-message)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
208 ;;(while (and (< beg end) (= (aref input beg) (aref output i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
209 ;; (setq beg (1+ beg) i (1+ i))) ;;for universal use.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
210 (setq i (1- (length output)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
211 (while (and (>= end beg) (= (aref output i) (aref input end)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
212 (setq end (1- end) i (1- i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
213 (setq add-in (substring output beg
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
214 (if (= i (1- (length output))) nil (1+ i))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
215 (erase-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
216 (insert add-in)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
217 (if (not (y-or-n-p YaTeX-generate-confirm-message))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
218 (error YaTeX-generate-idontknow-message))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
219 ;;Extract arguments.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
220 (YaTeX-generate-display-message YaTeX-generate-put-arg-message)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
221 (setq i 1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
222 (while (not (string=
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
223 "" (setq str (read-string (format "Arg %d: " i)))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
224 (if (not (string-match (regexp-quote str) add-in))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
225 (progn
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
226 (ding)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
227 (YaTeX-generate-display-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
228 YaTeX-generate-nomatch-message -1))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
229 (setq slist (append slist (list (list str))) i (1+ i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
230 );input all of arguments.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
231 ;;Compare with output string.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
232 (set-buffer YaTeX-generate-buffer) ;;for safety
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
233 (emacs-lisp-mode)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
234 (if (> i 1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
235 (YaTeX-generate-parse-add-in slist add-in)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
236 (erase-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
237 (insert "(defun " (YaTeX-generate-function-name) " ()\n")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
238 (insert "\"" (YaTeX-generate-lisp-quote add-in) "\")\n")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
239 (indent-region (point-min) (point-max) nil)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
240 (message (if YaTeX-japan
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
241 "このくらいの関数手で書け!!"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
242 "You don't need me to make such easy function.")))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
243 );let
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
244 (put 'YaTeX-generate 'disabled nil)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
245 (put 'YaTeX-addin 'disabled nil)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
246 ))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
247 (YaTeX-generate-display-message YaTeX-generate-done-message)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
248 (switch-to-buffer YaTeX-generate-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
249 (condition-case error
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
250 (eval-current-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
251 (error (insert YaTeX-generate-bug-message)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
252 (pop-to-buffer YaTeX-generate-message-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
253 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
254
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
255 (defun YaTeX-generate-parse-add-in (args add-in)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
256 "Parse add-in string and extract argument for it.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
257 Variable add-in is referred in parent function."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
258 (let ((i 1) j (case-fold-search nil) ;i holds argument number
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
259 (prompt (make-vector (length args) ""))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
260 (used (make-vector (length add-in) nil))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
261 func-name (string ""))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
262 ;;Phase 1. extract argument from add-in string.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
263 (mapcar
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
264 '(lambda (arg)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
265 (let ((index 0) (match 0) beg end (carg (car arg)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
266 (YaTeX-generate-display-message
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
267 YaTeX-generate-read-prompt-message)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
268 (aset prompt (1- i)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
269 (read-string
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
270 (format
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
271 (if YaTeX-japan "%d番目(%s)を読む時?: "
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
272 "When reading argument #%d(%s)?: ") i (car arg))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
273 (while (string-match (regexp-quote carg) (substring add-in index))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
274 (setq beg (+ index (match-beginning 0))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
275 end (+ index (match-end 0)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
276 (if (aref used beg) nil
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
277 (setq match (1+ match))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
278 (cond
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
279 ((= match 1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
280 ;;(setq arg (append arg (list (list beg end))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
281 (YaTeX-generate-register-match))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
282 ((YaTeX-generate-ask-match-position)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
283 (YaTeX-generate-register-match))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
284 (setq index end))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
285 (setq i (1+ i))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
286 args)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
287 ;;Phase 2. Generate function!!
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
288 (setq i 0)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
289 (setq func-name (YaTeX-generate-function-name))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
290 (while (< i (length add-in))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
291 (setq beg i j (aref used i))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
292 (while (and (< i (length add-in)) (equal j (aref used i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
293 (setq i (1+ i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
294 (if j ;If it is argument.
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
295 (setq string (concat string (format " arg%d" j)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
296 (setq string
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
297 (concat string " \""
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
298 (YaTeX-generate-quote-quote (substring add-in beg i))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
299 "\""))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
300 ))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
301 (erase-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
302 (setq i 1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
303 (insert
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
304 "(defun " func-name " ()\n"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
305 " (let (")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
306 (mapcar
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
307 '(lambda (arg)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
308 (insert (format "(arg%d (read-string \"%s: \"))\n"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
309 i (aref prompt (1- i))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
310 (setq i (1+ i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
311 args)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
312 (delete-region (point) (progn (forward-line -1) (end-of-line) (point)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
313 (insert ")\n(concat " (YaTeX-generate-lisp-quote string)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
314 ")))\n")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
315 (indent-region (point-min) (point) nil)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
316 used)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
317 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
318
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
319 (defun YaTeX-generate-ask-match-position ()
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
320 "Ask user whether match-position is in his expectation,
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
321 Referencing variables in parent function YaTeX-generate-parse-add-in."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
322 (pop-to-buffer YaTeX-generate-message-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
323 (goto-char (point-max))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
324 (insert "\n\n"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
325 (format (if YaTeX-japan "%d 番目の引数 %s って"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
326 "Is argument #%d's value `%s' also corresponding to")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
327 i carg) "\n" add-in "\n")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
328 (indent-to-column beg)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
329 (let ((c beg))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
330 (while (< c end) (insert "^") (setq c (1+ c))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
331 (insert "\n" (if YaTeX-japan "ここにも対応してるの?"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
332 "this underlined part too?"))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
333 (other-window -1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
334 (y-or-n-p (if YaTeX-japan "下線部はあってますか" "Is underline right"))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
335 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
336
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
337 (defun YaTeX-generate-register-match ()
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
338 (nconc arg (list (list beg end)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
339 (let ((x beg))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
340 (while (< x end) (aset used x i)(setq x (1+ x))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
341 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
342
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
343 (defun YaTeX-generate-display-message (mes &optional bottom)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
344 "Display message to generation buffer."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
345 (pop-to-buffer YaTeX-generate-message-buffer)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
346 (goto-char (point-max))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
347 (insert "\n\n")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
348 (if bottom (recenter (1- bottom)) (recenter 0))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
349 (insert mes)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
350 (other-window -1)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
351 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
352
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
353 (defun YaTeX-generate-move-to-add-in-position ()
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
354 "Move cursor where add-in function should insert string."
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
355 (cond
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
356 ((eq YaTeX-current-completion-type 'begin)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
357 (goto-char (point-min))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
358 (skip-chars-forward "^{")
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
359 (setq YaTeX-env-name
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
360 (buffer-substring (1+ (point))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
361 (progn (skip-chars-forward "^}") (point))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
362 (forward-char 1))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
363 ((eq YaTeX-current-completion-type 'section)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
364 (goto-char (point-min))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
365 (skip-chars-forward "^{"))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
366 ((eq YaTeX-current-completion-type 'maketitle)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
367 (goto-char (point-max))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
368 (if (= (preceding-char) ? )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
369 (forward-char -1)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
370 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
371 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
372
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
373 (defun YaTeX-generate-function-name ()
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
374 (concat
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
375 "YaTeX:"
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
376 (cond
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
377 ((eq YaTeX-current-completion-type 'begin) YaTeX-env-name)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
378 ((eq YaTeX-current-completion-type 'section) YaTeX-section-name)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
379 ((eq YaTeX-current-completion-type 'maketitle) YaTeX-single-command)))
9
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
380 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
381
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
382 (defun YaTeX-generate-lisp-quote (str)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
383 (let ((len (length str))(i 0) (quote ""))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
384 (while (< i len)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
385 (if (= (aref str i) ?\\)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
386 (setq quote (concat quote "\\")))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
387 (if (= (aref str i) 127)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
388 (setq quote (concat quote "\""))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
389 (setq quote (concat quote (substring str i (1+ i)))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
390 (setq i (1+ i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
391 quote)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
392 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
393
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
394 (defun YaTeX-generate-quote-quote (str)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
395 (let ((len (length str))(i 0) (quote ""))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
396 (while (< i len)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
397 (if (= (aref str i) ?\")
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
398 (setq quote (concat quote (char-to-string 127))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
399 (setq quote (concat quote (substring str i (1+ i))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
400 (setq i (1+ i)))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
401 quote)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
402 )
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
403
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
404 (defun YaTeX-suppress-sparse-keymap (map)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
405 (let ((i ? ))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
406 (while (< i 127)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
407 (define-key map (char-to-string i) 'undefined)
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
408 (setq i (1+ i))))
7becca042f80 Initial revision.
yuuji
parents:
diff changeset
409 )
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
410
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
411 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
412 ;; Auto-generate Function for Lispers.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
413 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
414 (defun YaTeX-generate-read-completion-type (nth)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
415 (message
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
416 "Read type(%d): (S)tring (C)omplete (F)ile ([)option (P)osition co(O)rd. (q)uit" nth)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
417 (let ((c (read-char)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
418 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
419 ((= c ?s) 'string)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
420 ((= c ?c) 'completion)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
421 ((= c ?f) 'file)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
422 ((= c ?\[) 'option)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
423 ((= c ?p) 'oneof)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
424 ((= c ?o) 'coord)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
425 ;;((= c ?m) 'macro)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
426 (t 'quit)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
427 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
428 (defun YaTeX-generate-read-completion-table ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
429 (let ((i 1) cand (cands "(") (cb (current-buffer))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
430 (buf (get-buffer-create " *Candidates*")))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
431 (save-window-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
432 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
433 (YaTeX-showup-buffer buf nil)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
434 (set-buffer buf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
435 (erase-buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
436 (while (string<
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
437 ""
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
438 (setq cand (read-string (format "Item[%d](RET to exit): " i))))
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
439 (setq cands (concat cands (format "(\"%s\")\n" cand))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
440 i (1+ i))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
441 (insert cand "\n"))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
442 (kill-buffer buf)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
443 ;;(set-buffer cb)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
444 (setq YaTeX-generate-current-completion-table (concat cands ")")))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
445 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
446 (defun YaTeX-generate-corresponding-paren (left)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
447 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
448 ((equal left "{") "}")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
449 ((equal left "[") "]")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
450 ((equal left "(") ")")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
451 ((equal left "<") ">")
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 52
diff changeset
452 ((equal left "\\begin{") "}")
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
453 (t left))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
454 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
455 (defun YaTeX-generate-create-read-string (&optional nth)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
456 (concat
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
457 "(read-string \""
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
458 (read-string (if nth (format "Prompt for argument#%d: " nth) "Prompt: "))
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
459 ": \"\n"
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
460 "\"" (read-string "Default: ") "\""
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
461 ")\n")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
462 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
463 (defun YaTeX-generate-create-completing-read (&optional nth)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
464 (prog1
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
465 (concat
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
466 "(completing-read \""
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
467 (read-string
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
468 (if nth (format "Prompt for argument#%d: " nth) "Prompt: "))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
469 ": \"\n"
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
470 (format "'%s\n" (YaTeX-generate-read-completion-table))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
471 "nil "
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
472 (format "%s)" (y-or-n-p "Require match? ")))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
473 (if nil ;;;(y-or-n-p "Do you need learning for this completion?")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
474 (setq YaTeX-generate-variables-for-learning
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
475 (cons
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
476 (cons (format "YaTeX-%s-%d" command (or nth 0))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
477 YaTeX-generate-current-completion-table)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
478 YaTeX-generate-variables-for-learning))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
479 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
480 (defun YaTeX-generate-create-read-file-name (&optional nth)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
481 (concat
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
482 "(read-file-name \""
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
483 (read-string (if nth (format "Prompt for argument#%d: " nth) "Prompt: "))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
484 ": \" "" \"\" t \"\")\n")
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
485 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
486 (defun YaTeX-generate-create-read-oneof (&optional nth readpos)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
487 (concat
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
488 (if readpos
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
489 "(YaTeX:read-position \""
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
490 "(YaTeX:read-oneof \"")
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
491 (read-string "Acceptable characters: " "lcr") "\")\n")
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
492 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
493 (defun YaTeX-generate-option-type (command)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
494 (let ((func (format "YaTeX:%s" command)) leftp
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
495 (buf (get-buffer-create YaTeX-generate-buffer)) type (n 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
496 (set-buffer buf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
497 (erase-buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
498 (insert "(defun " func " ()\n (concat\n")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
499 (catch 'done
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
500 (while t
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
501 (setq type (YaTeX-generate-read-completion-type n))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
502 (insert
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
503 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
504 ;;Read string
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
505 ((eq type 'string)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
506 (concat "\"" (setq leftp (read-string "Left parenthesis: " "("))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
507 "\"\n"
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
508 (YaTeX-generate-create-read-string)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
509 "\"" (YaTeX-generate-corresponding-paren leftp) "\"")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
510 )
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
511 ;;Completing-read
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
512 ((eq type 'completion)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
513 (concat "\"" (setq leftp (read-string "Left parenthesis: " "{"))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
514 "\"\n"
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
515 (YaTeX-generate-create-completing-read)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
516 "\"" (YaTeX-generate-corresponding-paren leftp) "\"")
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
517 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
518 ((eq type 'file)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
519 (concat "\"" (setq leftp (read-string "Left parenthesis: " "("))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
520 "\"\n"
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
521 (YaTeX-generate-create-read-file-name)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
522 "\"" (YaTeX-generate-corresponding-paren leftp) "\"")
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
523 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
524 ((eq type 'oneof)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
525 (YaTeX-generate-create-read-oneof nil t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
526 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
527 ((eq type 'option)
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
528 (concat "(let ((op (read-string \""
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
529 (read-string "Prompt: ")
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
530 ": \")))\n"
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
531 "(if (string< \"\" op)\n"
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
532 " (concat \"[\" op \"]\")\n"
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
533 " \"\"))\n")
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
534 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
535 ((eq type 'coord)
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
536 (concat "(YaTeX:read-coordinates \""
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
537 (read-string "Prompt for coordinates: ")
46
cd1b63102eed Support Mule2
yuuji
parents: 23
diff changeset
538 ": \")\n")
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
539 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
540 ((eq type 'macro)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
541 (error "not yet supported")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
542 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
543 (t (throw 'done t))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
544 (setq n (1+ n))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
545 (insert "))\n") ;close defun
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
546 (goto-char (point-min))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
547 (while (not (eobp)) (lisp-indent-line) (forward-line 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
548 (eval-current-buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
549 buf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
550 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
551 (defun YaTeX-generate-argument-type (command argc)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
552 "Create an argument-type add-in function."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
553 (interactive)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
554 (let ((func (format "YaTeX::%s" command)) (argp 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
555 (cb (current-buffer))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
556 (buf (get-buffer-create YaTeX-generate-buffer)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
557 (set-buffer buf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
558 (erase-buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
559 (insert "(defun " func " (&optional argp)\n(cond\n")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
560 (while (<= argp argc)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
561 (insert (format "((equal argp %d)\n" argp))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
562 (setq type (YaTeX-generate-read-completion-type argp))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
563 (insert
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
564 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
565 ((eq type 'string)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
566 (concat (YaTeX-generate-create-read-string argp)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
567 ((eq type 'completion)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
568 (concat (YaTeX-generate-create-completing-read argp)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
569 ((eq type 'oneof)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
570 (YaTeX-generate-create-read-oneof))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
571 ((eq type 'file)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
572 (concat (YaTeX-generate-create-read-file-name argp)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
573 (t ""))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
574 ")\n")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
575 (setq argp (1+ argp)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
576 (insert "))\n")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
577 (goto-char (point-min))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
578 (while (not (eobp)) (lisp-indent-line) (forward-line 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
579 (eval-current-buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
580 (set-buffer cb)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
581 (YaTeX-update-table
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
582 (if (> argc 1) (list command argc) (list command))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
583 'section-table 'user-section-table 'tmp-section-table)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
584 buf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
585 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
586 (defun YaTeX-generate-simple (&optional command)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
587 "Simple but requiring some elisp knowledge add-in generator."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
588 (interactive)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
589 (setq YaTeX-generate-variables-for-learning nil)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
590 (or command
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
591 (setq command
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
592 (completing-read
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
593 (format
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
594 "Making add-in function for (default %s): " YaTeX-section-name)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
595 (append
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
596 section-table user-section-table tmp-section-table
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
597 env-table user-env-table tmp-env-table
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
598 singlecmd-table user-singlecmd-table tmp-singlecmd-table)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
599 nil nil)
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
600 command (if (string= "" command) YaTeX-section-name command)))
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
601 (message
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
602 (cond
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
603 (YaTeX-japan "(o)追加型? (a)引数型? (yatexadd.docを参照のこと) :")
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
604 (t "(O)ption? (A)rgument?")))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
605 (YaTeX-showup-buffer
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
606 (if (= (read-char) ?o)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
607 (YaTeX-generate-option-type command)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
608 (YaTeX-generate-argument-type
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
609 command
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
610 (string-to-int (read-string "How many arguments?: ")))) nil)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 14
diff changeset
611 )
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 59
diff changeset
612 (provide 'yatexgen)

yatex.org