Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexadd.el @ 364:d69fd7b1ac4d dev yatex-1.78
yatex-1.78
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 26 Dec 2014 01:02:52 +0900 |
parents | b5bf68206bd1 |
children | 77a2fd4fd634 |
rev | line source |
---|---|
287 | 1 ;;; yatexadd.el --- YaTeX add-in functions |
335 | 2 ;;; yatexadd.el rev.21 |
313 | 3 ;;; (c)1991-2014 by HIROSE Yuuji.[yuuji@yatex.org] |
349 | 4 ;;; Last modified Sat Dec 20 14:55:10 2014 on firestorm |
364 | 5 ;;; $Id: yatexadd.el,v 1.78 2014/12/25 15:25:17 yuuji Exp $ |
6 | 6 |
287 | 7 ;;; Code: |
6 | 8 ;;; |
9 ;;Sample functions for LaTeX environment. | |
10 ;;; | |
11 (defvar YaTeX:tabular-default-rule | |
12 "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}" | |
69 | 13 "*Your favorite default rule format.") |
14 | |
23 | 15 (defvar YaTeX:tabular-thick-vrule "\\vrule width %s" |
69 | 16 "*Vertical thick line format (without @{}). %s'll be replaced by its width.") |
17 | |
23 | 18 (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}" |
69 | 19 "*Horizontal thick line format. %s will be replaced by its width.") |
20 | |
6 | 21 (defun YaTeX:tabular () |
18 | 22 "YaTeX add-in function for tabular environment. |
23 Notice that this function refers the let-variable `env' in | |
24 YaTeX-make-begin-end." | |
23 | 25 (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline")) |
72 | 26 (if (string= YaTeX-env-name "tabular*") |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
27 (setq width (concat "{" (YaTeX:read-length "Width: ") "}"))) |
18 | 28 (setq loc (YaTeX:read-position "tb") |
23 | 29 bars (string-to-int |
30 (read-string "Number of columns(0 for default format): " "3"))) | |
31 (if (<= bars 0) | |
32 (setq ;if 0, simple format | |
33 rule YaTeX:tabular-default-rule | |
34 and "& &") | |
35 (while (< j bars) ;repeat bars-1 times | |
36 (setq rule (concat rule "c|") | |
37 and (concat and "& ") | |
38 j (1+ j))) | |
39 (setq rule (concat rule "c")) | |
40 (message "(N)ormal-frame or (T)hick frame? [nt]") | |
41 (setq ans (read-char)) | |
42 (cond | |
43 ((or (equal ans ?t) (equal ans ?T)) | |
44 (setq ans (read-string "Rule width: " "1pt") | |
45 rule (concat | |
46 "@{" (format YaTeX:tabular-thick-vrule ans) "}" | |
47 rule | |
48 "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}") | |
49 hline (format YaTeX:tabular-thick-hrule ans))) | |
50 (t (setq rule (concat "|" rule "|") | |
51 hline "\\hline")))) | |
52 | |
6 | 53 (setq rule (read-string "rule format: " rule)) |
72 | 54 (setq YaTeX-single-command "hline") |
6 | 55 |
69 | 56 (format "%s%s{%s}" width loc rule))) |
57 | |
18 | 58 (fset 'YaTeX:tabular* 'YaTeX:tabular) |
80 | 59 (fset 'YaTeX:supertabular 'YaTeX:tabular) |
60 (defun YaTeX:alignat () | |
61 (concat "{" (read-string "Number of columns: ") "}")) | |
18 | 62 (defun YaTeX:array () |
63 (concat (YaTeX:read-position "tb") | |
69 | 64 "{" (read-string "Column format: ") "}")) |
80 | 65 (defun YaTeX:subequations () |
66 (message (if YaTeX-japan "分かりやすいコメントに変えるとref補完が楽よ" | |
67 "Changing comment string reduces effort at `ref' completion")) | |
68 (concat " " YaTeX-comment-prefix | |
69 (YaTeX::ref-default-label "%H:%M") | |
70 (if YaTeX-japan "の式群" "equations"))) | |
6 | 71 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
72 (defun YaTeX:read-oneof (oneof &optional quick allow-dup) |
23 | 73 (let ((pos "") loc (guide "")) |
74 (and (boundp 'name) name (setq guide (format "%s " name))) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
75 (catch 'quick |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
76 (while (not (string-match |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
77 (setq loc (read-key-sequence |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
78 (format "%s position (`%s') [%s]: " |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
79 guide oneof pos));name is in YaTeX-addin |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
80 loc (if (fboundp 'events-to-keys) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
81 (events-to-keys loc) loc)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
82 "\r\^g\n")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
83 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
84 ((string-match loc oneof) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
85 (if (or allow-dup (not (string-match loc pos))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
86 (setq pos (concat pos loc))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
87 (if quick (throw 'quick t))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
88 ((and (string-match loc "\C-h\C-?") (> (length pos) 0)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
89 (setq pos (substring pos 0 (1- (length pos))))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
90 (t |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
91 (ding) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
92 (message "Please input one of `%s'." oneof) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
93 (sit-for 3))))) |
8 | 94 (message "") |
69 | 95 pos)) |
23 | 96 |
97 (defun YaTeX:read-position (oneof) | |
98 "Read a LaTeX (optional) position format such as `[htbp]'." | |
99 (let ((pos (YaTeX:read-oneof oneof))) | |
69 | 100 (if (string= pos "") "" (concat "[" pos "]")))) |
8 | 101 |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
102 (defun YaTeX:read-length (prompt) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
103 "Read a LaTeX dimensional parameter with magnifying numerics prepend." |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
104 (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
105 (delim "-0-9*+/.") |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
106 (tbl (append YaTeX:style-parameters-local |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
107 YaTeX:style-parameters-private |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
108 YaTeX:style-parameters-default))) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
109 (YaTeX-completing-read-or-skip prompt tbl nil))) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
110 |
220
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
111 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
112 ;; Functions for figure environemnt |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
113 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
114 (defvar YaTeX:figure-caption-first nil |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
115 "Non-nil indicates put caption before figure.") |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
116 (defun YaTeX:figure (&optional type firstp) |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
117 "YaTeX add-in function for figure(*) environment." |
246
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
118 (setq YaTeX-section-name |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
119 (if YaTeX:figure-caption-first "caption" "includegraphics") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
120 YaTeX-env-name "center") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
121 (YaTeX:read-position "htbp")) |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
122 |
220
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
123 |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
124 (fset 'YaTeX:figure* 'YaTeX:figure) |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
125 |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
126 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
127 ;; Functions for table environemnt |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
128 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
129 (defvar YaTeX:table-caption-first t |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
130 "*Non-nil indicates put caption before tabular.") |
8 | 131 (defun YaTeX:table () |
132 "YaTeX add-in function for table environment." | |
73 | 133 (cond |
134 ((eq major-mode 'yatex-mode) | |
246
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
135 (setq YaTeX-section-name |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
136 (if YaTeX:table-caption-first "caption" "label") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
137 YaTeX-env-name "tabular") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
138 (YaTeX:read-position "htbp")) |
73 | 139 ((eq major-mode 'texinfo-mode) |
140 (concat " " | |
141 (completing-read | |
142 "Highlights with: " | |
143 '(("@samp")("@kbd")("@code")("@asis")("@file")("@var")) | |
144 nil nil "@"))))) | |
219
ad4e0a008972
Add-in function for figure and refine table.
yuuji@fusion.yk.gentei.org
parents:
175
diff
changeset
|
145 (fset 'YaTeX:table* 'YaTeX:table) |
6 | 146 |
147 (defun YaTeX:description () | |
148 "Truly poor service:-)" | |
72 | 149 (setq YaTeX-single-command "item[]") |
69 | 150 "") |
6 | 151 |
152 (defun YaTeX:itemize () | |
153 "It's also poor service." | |
72 | 154 (setq YaTeX-single-command "item") |
69 | 155 "") |
6 | 156 |
249 | 157 (defun YaTeX:enumerate () |
158 (setq YaTeX-single-command "item" | |
159 YaTeX-section-name "label") | |
160 "") | |
8 | 161 |
11 | 162 (defun YaTeX:picture () |
163 "Ask the size of coordinates of picture environment." | |
164 (concat (YaTeX:read-coordinates "Picture size") | |
69 | 165 (YaTeX:read-coordinates "Initial position"))) |
11 | 166 |
12 | 167 (defun YaTeX:equation () |
59 | 168 (YaTeX-jmode-off) |
12 | 169 (if (fboundp 'YaTeX-toggle-math-mode) |
69 | 170 (YaTeX-toggle-math-mode t))) ;force math-mode ON. |
171 | |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
172 (mapcar (function (lambda (f) (fset f 'YaTeX:equation))) |
59 | 173 '(YaTeX:eqnarray YaTeX:eqnarray* YaTeX:align YaTeX:align* |
174 YaTeX:split YaTeX:multline YaTeX:multline* YaTeX:gather YaTeX:gather* | |
175 YaTeX:aligned* YaTeX:gathered YaTeX:gathered* | |
176 YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat* | |
177 YaTeX:xxalignat YaTeX:xxalignat*)) | |
12 | 178 |
80 | 179 (defun YaTeX:alignat () |
180 (YaTeX:equation) | |
181 (concat "{" (read-string "Number of cols: ") "}")) | |
182 | |
183 | |
184 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
185 (defun YaTeX:list () |
69 | 186 "%\n{} %default label\n{} %formatting parameter") |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
187 |
18 | 188 (defun YaTeX:minipage () |
189 (concat (YaTeX:read-position "cbt") | |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
190 "{" (YaTeX:read-length "Width: ") "}")) |
18 | 191 |
64 | 192 (defun YaTeX:thebibliography () |
72 | 193 (setq YaTeX-section-name "bibitem") |
77 | 194 (concat "{" (read-string "Longest label: ") "}")) |
64 | 195 |
80 | 196 (defun YaTeX:multicols () |
197 (concat "{" (read-string "Number of columns: ") "}")) | |
198 | |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
199 |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
200 ;; wrapfig.sty |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
201 (defun YaTeX:wrapfigure () |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
202 (YaTeX-help "wrapfigure") |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
203 (concat |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
204 (let ((lines (YaTeX-read-string-or-skip "Wrap Lines(Optional): "))) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
205 (if (string< "" lines) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
206 (concat "[" lines "]"))) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
207 "{" (YaTeX:read-oneof "rlioRLIO" t) "}" |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
208 "{" (YaTeX:read-length "Image width: ") "}")) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
209 |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
210 |
8 | 211 ;;; |
212 ;;Sample functions for section-type command. | |
213 ;;; | |
214 (defun YaTeX:multiput () | |
215 (concat (YaTeX:read-coordinates "Pos") | |
216 (YaTeX:read-coordinates "Step") | |
69 | 217 "{" (read-string "How many times: ") "}")) |
8 | 218 |
219 (defun YaTeX:put () | |
69 | 220 (YaTeX:read-coordinates "Pos")) |
8 | 221 |
222 (defun YaTeX:makebox () | |
23 | 223 (cond |
224 ((YaTeX-in-environment-p "picture") | |
225 (concat (YaTeX:read-coordinates "Dimension") | |
80 | 226 (YaTeX:read-position "lsrtb"))) |
23 | 227 (t |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
228 (let ((width (YaTeX:read-length "Width: "))) |
23 | 229 (if (string< "" width) |
230 (progn | |
231 (or (equal (aref width 0) ?\[) | |
232 (setq width (concat "[" width "]"))) | |
80 | 233 (concat width (YaTeX:read-position |
234 (if YaTeX-use-LaTeX2e "lrs" "lr"))))))))) | |
8 | 235 |
80 | 236 ;; (defun YaTeX:framebox () |
237 ;; (if (YaTeX-quick-in-environment-p "picture") | |
238 ;; (YaTeX:makebox))) | |
239 (fset 'YaTeX:framebox 'YaTeX:makebox) | |
240 | |
241 (defun YaTeX:parbox () | |
242 (YaTeX:read-position "tbc")) | |
104
47a11079cc56
Add add-in function for parbox (YaTeX::parbox).
yuuji@gentei.org
parents:
86
diff
changeset
|
243 (defun YaTeX::parbox (argp) |
47a11079cc56
Add add-in function for parbox (YaTeX::parbox).
yuuji@gentei.org
parents:
86
diff
changeset
|
244 (cond |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
245 ((= argp 1) (YaTeX:read-length "Width: ")) |
104
47a11079cc56
Add add-in function for parbox (YaTeX::parbox).
yuuji@gentei.org
parents:
86
diff
changeset
|
246 ((= argp 2) (read-string "Text: ")))) |
8 | 247 |
105 | 248 (defun YaTeX::dashbox () |
8 | 249 (concat "{" (read-string "Dash dimension: ") "}" |
69 | 250 (YaTeX:read-coordinates "Dimension"))) |
8 | 251 |
105 | 252 (defun YaTeX::savebox (argp) |
80 | 253 (cond |
254 ((= argp 1) (read-string "Saved into name: " "\\")) | |
255 ((= argp 2) (read-string "Text: ")))) | |
256 | |
51 | 257 (defvar YaTeX-minibuffer-quick-map nil) |
258 (if YaTeX-minibuffer-quick-map nil | |
259 (setq YaTeX-minibuffer-quick-map | |
260 (copy-keymap minibuffer-local-completion-map)) | |
261 (let ((ch (1+ ? ))) | |
262 (while (< ch 127) | |
263 (define-key YaTeX-minibuffer-quick-map (char-to-string ch) | |
264 'YaTeX-minibuffer-quick-complete) | |
265 (setq ch (1+ ch))))) | |
266 | |
267 (defvar YaTeX:left-right-delimiters | |
268 '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[") | |
269 ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|") | |
270 ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil") | |
271 ("\\langle" . "\\rangle") ("/") (".") | |
272 ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil") | |
273 ("\\rangle" . "\\langle") ("\\backslash") | |
274 ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow")) | |
275 "TeX math delimiter, which can be completed after \\right or \\left.") | |
276 | |
277 (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.") | |
278 | |
23 | 279 (defun YaTeX:left () |
51 | 280 (let ((minibuffer-completion-table YaTeX:left-right-delimiters) |
72 | 281 delimiter (leftp (string= YaTeX-single-command "left"))) |
51 | 282 (setq delimiter |
283 (read-from-minibuffer | |
284 (format "Delimiter%s: " | |
285 (if YaTeX:left-right-default | |
286 (format "(default=`%s')" YaTeX:left-right-default) | |
287 "(SPC for menu)")) | |
288 nil YaTeX-minibuffer-quick-map)) | |
289 (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default)) | |
72 | 290 (setq YaTeX-single-command (if leftp "right" "left") |
51 | 291 YaTeX:left-right-default |
292 (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter)) | |
293 delimiter)) | |
294 | |
23 | 295 (fset 'YaTeX:right 'YaTeX:left) |
296 | |
80 | 297 (defun YaTeX:langle () |
298 (setq YaTeX-single-command "rangle") | |
299 nil) | |
300 | |
8 | 301 (defun YaTeX:read-coordinates (&optional mes varX varY) |
302 (concat | |
303 "(" | |
304 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X"))) | |
305 "," | |
306 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y"))) | |
69 | 307 ")")) |
8 | 308 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
309 (defun YaTeX:itembox () |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
310 (concat "{" (read-string "Item heading string: ") "}")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
311 |
8 | 312 ;;; |
313 ;;Sample functions for maketitle-type command. | |
314 ;;; | |
315 (defun YaTeX:sum () | |
316 "Read range of summation." | |
317 (YaTeX:check-completion-type 'maketitle) | |
69 | 318 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))) |
8 | 319 |
320 (fset 'YaTeX:int 'YaTeX:sum) | |
321 | |
322 (defun YaTeX:lim () | |
323 "Insert limit notation of \\lim." | |
324 (YaTeX:check-completion-type 'maketitle) | |
325 (let ((var (read-string "Variable: ")) limit) | |
326 (if (string= "" var) "" | |
327 (setq limit (read-string "Limit ($ means infinity): ")) | |
328 (if (string= "$" limit) (setq limit "\\infty")) | |
69 | 329 (concat "_{" var " \\rightarrow " limit "}")))) |
8 | 330 |
331 (defun YaTeX:gcd () | |
332 "Add-in function for \\gcd(m,n)." | |
333 (YaTeX:check-completion-type 'maketitle) | |
69 | 334 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")) |
8 | 335 |
336 (defun YaTeX:read-boundary (ULchar) | |
337 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." | |
11 | 338 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): ")))) |
8 | 339 (if (string= bndry "") "" |
11 | 340 (if (string= bndry "$") (setq bndry "\\infty")) |
69 | 341 (concat ULchar "{" bndry "}")))) |
8 | 342 |
14 | 343 (defun YaTeX:verb () |
344 "Enclose \\verb's contents with the same characters." | |
345 (let ((quote-char (read-string "Quoting char: " "|")) | |
346 (contents (read-string "Quoted contents: "))) | |
69 | 347 (concat quote-char contents quote-char))) |
348 | |
23 | 349 (fset 'YaTeX:verb* 'YaTeX:verb) |
14 | 350 |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
351 (defun YaTeX:footnotemark () |
72 | 352 (setq YaTeX-section-name "footnotetext") |
69 | 353 nil) |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
354 |
48 | 355 (defun YaTeX:cite () |
356 (let ((comment (read-string "Comment for citation: "))) | |
357 (if (string= comment "") "" | |
69 | 358 (concat "[" comment "]")))) |
48 | 359 |
360 (defun YaTeX:bibitem () | |
64 | 361 (let ((label (read-string "Citation label for bibitem: "))) |
48 | 362 (if (string= label "") "" |
69 | 363 (concat "[" label "]")))) |
48 | 364 |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
365 (defun YaTeX:item () |
73 | 366 (cond |
367 ((eq major-mode 'yatex-mode) | |
368 (YaTeX-indent-line) | |
369 (setq YaTeX-section-name "label")) | |
370 ((eq major-mode 'texinfo-mode) | |
371 (setq YaTeX-section-name "dots"))) ;?? | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
372 " ") |
52 | 373 (fset 'YaTeX:item\[\] 'YaTeX:item) |
374 (fset 'YaTeX:subitem 'YaTeX:item) | |
375 (fset 'YaTeX:subsubitem 'YaTeX:item) | |
376 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
377 (defun YaTeX:linebreak () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
378 (let (obl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
379 (message "Break strength 0,1,2,3,4 (default: 4): ") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
380 (setq obl (char-to-string (read-char))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
381 (if (string-match "[0-4]" obl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
382 (concat "[" obl "]") |
69 | 383 ""))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
384 (fset 'YaTeX:pagebreak 'YaTeX:linebreak) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
385 |
14 | 386 ;;; |
387 ;;Subroutine | |
388 ;;; | |
389 | |
8 | 390 (defun YaTeX:check-completion-type (type) |
391 "Check valid completion type." | |
392 (if (not (eq type YaTeX-current-completion-type)) | |
69 | 393 (error "This should be completed with %s-type completion." type))) |
11 | 394 |
395 | |
396 ;;; | |
397 ;;; [[Add-in functions for reading section arguments]] | |
398 ;;; | |
399 ;; All of add-in functions for reading sections arguments should | |
400 ;; take an argument ARGP that specify the argument position. | |
401 ;; If argument position is out of range, nil should be returned, | |
402 ;; else nil should NOT be returned. | |
13 | 403 |
404 ;; | |
405 ; Label selection | |
406 ;; | |
11 | 407 (defvar YaTeX-label-menu-other |
408 (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n")) | |
23 | 409 (defvar YaTeX-label-menu-repeat |
410 (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n")) | |
11 | 411 (defvar YaTeX-label-menu-any |
412 (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n")) | |
413 (defvar YaTeX-label-buffer "*Label completions*") | |
414 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.") | |
415 (defvar YaTeX-label-select-map nil | |
416 "Key map used in label selection buffer.") | |
417 (defun YaTeX::label-setup-key-map () | |
418 (if YaTeX-label-select-map nil | |
419 (message "Setting up label selection mode map...") | |
68 | 420 ;(setq YaTeX-label-select-map (copy-keymap global-map)) |
421 (setq YaTeX-label-select-map (make-keymap)) | |
11 | 422 (suppress-keymap YaTeX-label-select-map) |
423 (substitute-all-key-definition | |
424 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) | |
425 (substitute-all-key-definition | |
426 'next-line 'YaTeX::label-next YaTeX-label-select-map) | |
427 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) | |
428 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) | |
429 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) | |
430 (define-key YaTeX-label-select-map ">" 'end-of-buffer) | |
431 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) | |
432 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) | |
433 (define-key YaTeX-label-select-map " " 'exit-recursive-edit) | |
434 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) | |
435 (define-key YaTeX-label-select-map "/" 'isearch-forward) | |
436 (define-key YaTeX-label-select-map "?" 'isearch-backward) | |
437 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) | |
23 | 438 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) |
11 | 439 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) |
440 (message "Setting up label selection mode map...Done") | |
441 (let ((key ?A)) | |
442 (while (<= key ?Z) | |
443 (define-key YaTeX-label-select-map (char-to-string key) | |
444 'YaTeX::label-search-tag) | |
445 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) | |
446 'YaTeX::label-search-tag) | |
69 | 447 (setq key (1+ key)))))) |
448 | |
11 | 449 (defun YaTeX::label-next () |
450 (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) | |
451 (defun YaTeX::label-previous () | |
452 (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) | |
453 (defun YaTeX::label-search-tag () | |
454 (interactive) | |
68 | 455 (let ((case-fold-search t) |
290
1a4332ecc58b
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
456 (tag (regexp-quote (char-to-string (YaTeX-last-key))))) |
11 | 457 (cond |
458 ((save-excursion | |
459 (forward-char 1) | |
23 | 460 (re-search-forward (concat "^" tag) nil t)) |
11 | 461 (goto-char (match-beginning 0))) |
462 ((save-excursion | |
463 (goto-char (point-min)) | |
23 | 464 (re-search-forward (concat "^" tag) nil t)) |
11 | 465 (goto-char (match-beginning 0)))) |
69 | 466 (message YaTeX-label-guide-msg))) |
467 | |
70 | 468 ; (defun YaTeX::ref (argp &optional labelcmd refcmd) |
469 ; (cond | |
470 ; ((= argp 1) | |
471 ; (let ((lnum 0) e0 label label-list (buf (current-buffer)) | |
472 ; (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref")) | |
473 ; (p (point)) initl line cf) | |
474 ; (message "Collecting labels...") | |
475 ; (save-window-excursion | |
476 ; (YaTeX-showup-buffer | |
477 ; YaTeX-label-buffer (function (lambda (x) (window-width x)))) | |
478 ; (if (fboundp 'select-frame) (setq cf (selected-frame))) | |
479 ; (if (eq (window-buffer (minibuffer-window)) buf) | |
480 ; (progn | |
481 ; (other-window 1) | |
482 ; (setq buf (current-buffer)) | |
483 ; (set-buffer buf) | |
484 ; ;(message "cb=%s" buf)(sit-for 3) | |
485 ; )) | |
486 ; (save-excursion | |
487 ; (set-buffer (get-buffer-create YaTeX-label-buffer)) | |
488 ; (setq buffer-read-only nil) | |
489 ; (erase-buffer)) | |
490 ; (save-excursion | |
491 ; (goto-char (point-min)) | |
492 ; (let ((standard-output (get-buffer YaTeX-label-buffer))) | |
493 ; (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) | |
494 ; (while (YaTeX-re-search-active-forward | |
495 ; (concat "\\\\" labelcmd "\\b") | |
496 ; (regexp-quote YaTeX-comment-prefix) nil t) | |
497 ; (goto-char (match-beginning 0)) | |
498 ; (skip-chars-forward "^{") | |
499 ; (setq label | |
500 ; (buffer-substring | |
501 ; (1+ (point)) | |
502 ; (prog2 (forward-list 1) (setq e0 (1- (point))))) | |
503 ; label-list (cons label label-list)) | |
504 ; (or initl | |
505 ; (if (< p (point)) (setq initl lnum))) | |
506 ; (beginning-of-line) | |
507 ; (skip-chars-forward " \t\n" nil) | |
508 ; (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label | |
509 ; (buffer-substring (point) (point-end-of-line)))) | |
510 ; (setq lnum (1+ lnum)) | |
511 ; (message "Collecting \\%s{}... %d" labelcmd lnum) | |
512 ; (goto-char e0)) | |
513 ; (princ YaTeX-label-menu-other) | |
514 ; (princ YaTeX-label-menu-repeat) | |
515 ; (princ YaTeX-label-menu-any) | |
516 ; );standard-output | |
517 ; (goto-char p) | |
518 ; (or initl (setq initl lnum)) | |
519 ; (message "Collecting %s...Done" labelcmd) | |
520 ; (if (fboundp 'select-frame) (select-frame cf)) | |
521 ; (YaTeX-showup-buffer YaTeX-label-buffer nil t) | |
522 ; (YaTeX::label-setup-key-map) | |
523 ; (setq truncate-lines t) | |
524 ; (setq buffer-read-only t) | |
525 ; (use-local-map YaTeX-label-select-map) | |
526 ; (message YaTeX-label-guide-msg) | |
527 ; (goto-line (1+ initl)) ;goto recently defined label line | |
528 ; (switch-to-buffer (current-buffer)) | |
529 ; (unwind-protect | |
530 ; (progn | |
531 ; (recursive-edit) | |
532 ; (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion | |
533 ; (beginning-of-line) | |
534 ; (setq line (1- (count-lines (point-min)(point)))) | |
535 ; (cond | |
536 ; ((= line -1) (setq label "")) | |
537 ; ((= line lnum) (setq label (YaTeX-label-other))) | |
538 ; ((= line (1+ lnum)) | |
539 ; (save-excursion | |
540 ; (switch-to-buffer buf) | |
541 ; (goto-char p) | |
542 ; (if (re-search-backward | |
543 ; (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) | |
544 ; (setq label (YaTeX-match-string 1)) | |
545 ; (setq label "")))) | |
546 ; ((>= line (+ lnum 2)) | |
547 ; (setq label (read-string (format "\\%s{???}: " refcmd)))) | |
548 ; (t (setq label (nth (- lnum line 1) label-list))))) | |
549 ; (bury-buffer YaTeX-label-buffer))) | |
550 ; label))))) | |
551 | |
80 | 552 (defvar YaTeX-ref-default-label-string "%H%M%S_%d%b%y" |
553 "*Default \\ref time string format. | |
554 This format is like strftime(3) but allowed conversion char are as follows; | |
555 %y -> Last 2 digit of year, %b -> Month name, %m -> Monthe number(1-12), | |
556 %d -> Day, %H -> Hour, %M -> Minute, %S -> Second, | |
557 %qx -> alphabetical-decimal conversion of yymmdd. | |
558 %qX -> alphabetical-decimal conversion of HHMMSS. | |
559 Beware defualt label-string should be always unique. So this format string | |
560 should have both time part (%H+%M+%S or %qX) and date | |
561 part (%y+(%b|%m)+%d or %qx).") | |
562 | |
563 (defun YaTeX::ref-alphabex (n) | |
564 (let ((alphabex "")) | |
565 (while (> n 0) | |
566 (setq alphabex (concat (char-to-string (+ ?a (% n 26))) alphabex) | |
567 n (/ n 26))) | |
568 alphabex)) | |
569 | |
570 (defun YaTeX::ref-default-label (&optional format) | |
571 "Default auto-genarated label string." | |
572 ;; We do not use (format-time-string) for emacs-19 | |
573 (let*((ts (substring (current-time-string) 4)) | |
574 (y (substring ts -2)) | |
575 (b (substring ts 0 3)) | |
576 (d (format "%d" (string-to-int (substring ts 4 6)))) | |
577 (H (substring ts 7 9)) | |
578 (M (substring ts 10 12)) | |
579 (S (substring ts 13 15)) | |
580 (HMS (+ (* 10000 (string-to-int H)) | |
581 (* 100 (string-to-int M)) | |
582 (string-to-int S))) | |
583 (talphabex (YaTeX::ref-alphabex HMS)) | |
584 (mnames "JanFebMarAprMayJunJulAugSepOctNovDec") | |
585 (m (format "%02d" (/ (string-match b mnames) 3))) | |
586 (ymd (+ (* 10000 (string-to-int y)) | |
587 (* 100 (string-to-int m)) | |
588 (string-to-int d))) | |
589 (dalphabex (YaTeX::ref-alphabex ymd))) | |
590 (YaTeX-replace-formats | |
591 (or format YaTeX-ref-default-label-string) | |
592 (list (cons "y" y) | |
593 (cons "b" b) | |
594 (cons "m" m) | |
595 (cons "d" d) | |
596 (cons "H" H) | |
597 (cons "M" M) | |
598 (cons "S" S) | |
599 (cons "qX" talphabex) | |
600 (cons "qx" dalphabex))))) | |
601 | |
602 (defvar YaTeX-ref-generate-label-function 'YaTeX::ref-generate-label | |
603 "*Function to generate default label for unnamed \\label{}s. | |
604 The function pointed to this value should take two arguments. | |
605 First argument is LaTeX macro's name, second is macro's argument.") | |
606 | |
607 (defun YaTeX::ref-generate-label (command arg) | |
70 | 608 "Generate a label string which is unique in current buffer." |
80 | 609 (let ((default (condition-case nil |
610 (YaTeX::ref-default-label) | |
611 (error (substring (current-time-string) 4))))) | |
70 | 612 (read-string "Give a label for this line: " |
613 (if YaTeX-emacs-19 (cons default 1) default)))) | |
614 | |
80 | 615 (defun YaTeX::ref-getset-label (buffer point &optional noset) |
70 | 616 "Get label string in the BUFFER near the POINT. |
80 | 617 Make \\label{xx} if no label. |
618 If optional third argument NOSET is non-nil, do not generate new label." | |
73 | 619 ;;Here, we rewrite the LaTeX source. Therefore we should be careful |
620 ;;to decide the location suitable for \label. Do straightforward! | |
80 | 621 (let (boundary inspoint cc newlabel (labelholder "label") mathp exp1 env |
622 (r-escape (regexp-quote YaTeX-comment-prefix)) | |
623 command arg alreadysought foundpoint) | |
624 (set-buffer buffer) | |
70 | 625 (save-excursion |
626 (goto-char point) | |
627 (setq cc (current-column)) | |
628 (if (= (char-after (point)) ?\\) (forward-char 1)) | |
629 (cond | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
630 ;; In each codition, 'inspoint and 'boundary should be set |
70 | 631 ((looking-at YaTeX-sectioning-regexp) |
80 | 632 (setq command (YaTeX-match-string 0)) |
70 | 633 (skip-chars-forward "^{") |
80 | 634 (setq arg (buffer-substring |
635 (1+ (point)) | |
636 (progn (forward-list 1) (1- (point))))) | |
70 | 637 (skip-chars-forward " \t\n") |
73 | 638 ;(setq boundary "[^\\]") |
77 | 639 (setq inspoint (point)) |
73 | 640 (setq boundary |
641 (save-excursion | |
77 | 642 (if (YaTeX-re-search-active-forward |
643 (concat YaTeX-ec-regexp | |
644 "\\(" YaTeX-sectioning-regexp "\\|" | |
645 "begin\\|item\\)") | |
646 r-escape nil 1) | |
73 | 647 (match-beginning 0) |
648 (1- (point)))))) | |
70 | 649 ((looking-at "item\\s ") |
80 | 650 (setq command "item" |
651 cc (+ cc 6)) | |
73 | 652 ;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")) |
653 (setq boundary | |
654 (save-excursion | |
655 (if (YaTeX-re-search-active-forward | |
656 (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b") | |
657 r-escape nil 1) | |
658 (match-beginning 0) | |
77 | 659 (1- (point)))) |
660 inspoint boundary)) | |
70 | 661 ((looking-at "bibitem") |
80 | 662 (setq labelholder "bibitem" ; label holder is bibitem itself |
663 command "bibitem") | |
73 | 664 (setq boundary |
665 (save-excursion | |
666 (if (YaTeX-re-search-active-forward | |
667 (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b") | |
668 r-escape nil 1) | |
669 (match-beginning 0) | |
77 | 670 (1- (point)))) |
671 inspoint boundary)) | |
80 | 672 ((string-match YaTeX::ref-nestable-counter-regexp |
70 | 673 (setq env (or (YaTeX-inner-environment t) "document"))) |
80 | 674 (let ((curtop (get 'YaTeX-inner-environment 'point)) |
675 (end (point-max)) label) | |
676 (skip-chars-forward " \t\n") | |
677 (setq inspoint (point) ;initial candidate | |
678 cc (current-column) | |
679 command env | |
680 alreadysought t) | |
681 (if (condition-case nil | |
682 (progn | |
683 (goto-char curtop) | |
684 (YaTeX-goto-corresponding-environment)) | |
685 (error nil)) | |
686 (setq end (point))) | |
687 (goto-char inspoint) | |
688 (while (YaTeX-re-search-active-forward | |
689 (concat YaTeX-ec-regexp "label{\\([^}]+\\)}" ) | |
690 r-escape end t) | |
691 (setq label (YaTeX-match-string 1)) | |
692 (if (and (equal env (YaTeX-inner-environment t)) | |
693 (= curtop (get 'YaTeX-inner-environment 'point))) | |
694 ;;I found the label | |
695 (setq alreadysought label | |
696 foundpoint (match-end 0)))) | |
697 )) | |
698 ((string-match YaTeX::ref-mathenv-regexp env) ;env is set in above case | |
699 (setq command env | |
700 mathp t | |
701 exp1 (string-match YaTeX::ref-mathenv-exp1-regexp env)) | |
73 | 702 ;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")) |
703 (setq boundary | |
704 (save-excursion | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
705 (or (catch 'bndry |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
706 (while (YaTeX-re-search-active-forward |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
707 (concat |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
708 YaTeX-ec-regexp "\\(" |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
709 (if exp1 "" "\\\\\\|") |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
710 "\\(end{" env "\\)}\\)") |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
711 r-escape nil 1) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
712 (setq foundpoint (match-beginning 0)) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
713 (if (or (match-beginning 2) ;end of outer math-env |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
714 (equal env (YaTeX-inner-environment t))) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
715 ;; YaTeX-inner-environment destroys match-data |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
716 (throw 'bndry foundpoint)))) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
717 (1- (point)))) |
77 | 718 inspoint boundary)) |
73 | 719 ((looking-at "footnote\\s *{") |
80 | 720 (setq command "footnote") |
73 | 721 (skip-chars-forward "^{") ;move onto `{' |
722 (setq boundary | |
723 (save-excursion | |
724 (condition-case err | |
725 (forward-list 1) | |
726 (error (error "\\\\footnote at point %s's brace not closed" | |
727 (point)))) | |
77 | 728 (1- (point))) |
729 inspoint boundary)) | |
70 | 730 ((looking-at "caption\\|\\(begin\\)") |
80 | 731 (setq command (YaTeX-match-string 0)) |
70 | 732 (skip-chars-forward "^{") |
77 | 733 ;;;;;;(if (match-beginning 1) (forward-list 1)) |
734 ;; caption can be treated as mathenv, is it right?? | |
80 | 735 (setq arg (buffer-substring |
736 (1+ (point)) | |
737 (progn (forward-list 1) (1- (point))))) | |
73 | 738 ;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b")) |
77 | 739 (setq inspoint (point)) |
73 | 740 (setq boundary |
741 (save-excursion | |
742 (if (YaTeX-re-search-active-forward | |
743 (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b") | |
744 r-escape nil 1) | |
745 (match-beginning 0) | |
746 (1- (point)))))) | |
70 | 747 (t )) |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
748 ;;cond by kind of labeling ends here. |
70 | 749 (if (save-excursion (skip-chars-forward " \t") (looking-at "%")) |
750 (forward-line 1)) | |
80 | 751 (cond |
752 ((stringp alreadysought) | |
753 (put 'YaTeX::ref-getset-label 'foundpoint foundpoint) ;ugly... | |
754 alreadysought) | |
755 ((and (null alreadysought) | |
756 (> boundary (point)) | |
757 (save-excursion | |
758 (YaTeX-re-search-active-forward | |
759 ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)") | |
760 labelholder | |
761 (regexp-quote YaTeX-comment-prefix) | |
762 boundary 1)) | |
763 (match-beginning 0)) | |
70 | 764 ;; if \label{hoge} found, return it |
80 | 765 (put 'YaTeX::ref-getset-label 'foundpoint (1- (match-beginning 0))) |
766 (buffer-substring | |
767 (progn | |
768 (goto-char (match-end 0)) | |
769 (skip-chars-forward "^{") (1+ (point))) | |
770 (progn | |
771 (forward-sexp 1) (1- (point))))) | |
70 | 772 ;;else make a label |
73 | 773 ;(goto-char (match-beginning 0)) |
80 | 774 (noset nil) ;do not set label if noset |
775 (t | |
77 | 776 (goto-char inspoint) |
70 | 777 (skip-chars-backward " \t\n") |
80 | 778 (save-excursion |
779 (setq newlabel | |
780 (funcall YaTeX-ref-generate-label-function command arg))) | |
70 | 781 (delete-region (point) (progn (skip-chars-backward " \t") (point))) |
782 (if mathp nil | |
783 (insert "\n") | |
784 (YaTeX-reindent cc)) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
785 (put 'YaTeX::ref-getset-label 'foundpoint (point)) |
70 | 786 (insert (format "\\label{%s}" newlabel)) |
80 | 787 newlabel))))) |
70 | 788 |
80 | 789 (defvar YaTeX::ref-labeling-regexp-alist-default |
790 '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2) | |
791 ("\\\\label{\\([^}]+\\)}" . 1)) | |
792 "Alist of labeling regexp vs. its group number points to label string. | |
793 This alist is used in \\ref's argument's completion.") | |
794 (defvar YaTeX::ref-labeling-regexp-alist-private nil | |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
795 "*Private extension to YaTeX::ref-labeling-regexp-alist. |
80 | 796 See the documetation of YaTeX::ref-labeling-regexp-alist.") |
70 | 797 (defvar YaTeX::ref-labeling-regexp-alist |
80 | 798 (append YaTeX::ref-labeling-regexp-alist-default |
799 YaTeX::ref-labeling-regexp-alist-private)) | |
70 | 800 (defvar YaTeX::ref-labeling-regexp |
801 (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|")) | |
802 (defvar YaTeX::ref-mathenv-regexp | |
80 | 803 ;; See also YaTeX-ams-math-begin-alist in yatex.el |
804 ;; Define only envs which has counter.(without *) | |
805 "equation\\|eqnarray\\|align\\(at\\)?\\|flalign\\|gather\\|xx?alignat\\|multline") | |
806 (defvar YaTeX::ref-mathenv-exp1-regexp | |
807 "\\(equation\\|multline\\)\\b" | |
808 "*Regexp of math-envname which has only one math-expression.") | |
70 | 809 (defvar YaTeX::ref-enumerateenv-regexp |
810 "enumerate") | |
80 | 811 (defvar YaTeX::ref-nestable-counter-regexp |
812 "subequations") | |
70 | 813 |
814 (defvar YaTeX::ref-labeling-section-level 2 | |
72 | 815 "*ref補完で収集するセクショニングコマンドの下限レベル |
70 | 816 YaTeX-sectioning-levelの数値で指定.") |
817 | |
80 | 818 (defun YaTeX::ref (argp &optional labelcmd refcmd predf) |
70 | 819 (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache |
820 (require 'yatexsec) | |
11 | 821 (cond |
822 ((= argp 1) | |
80 | 823 (let*((lnum 0) m0 e0 x cmd label match-point point-list boundary |
70 | 824 (buf (current-buffer)) |
825 (llv YaTeX::ref-labeling-section-level) | |
80 | 826 (mathenvs YaTeX::ref-mathenv-regexp) envname endrx |
70 | 827 (enums YaTeX::ref-enumerateenv-regexp) |
828 (counter | |
829 (or labelcmd | |
830 (concat | |
831 YaTeX-ec-regexp "\\(\\(" | |
832 (mapconcat | |
833 'concat | |
834 (delq nil | |
835 (mapcar | |
72 | 836 (function |
837 (lambda (s) | |
838 (if (>= llv (cdr s)) | |
839 (car s)))) | |
70 | 840 YaTeX-sectioning-level)) |
841 "\\|") | |
77 | 842 "\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){" |
80 | 843 "\\|\\(begin{\\(" mathenvs "\\|" enums "\\)}\\)" |
844 (if YaTeX-use-AMS-LaTeX | |
845 (concat | |
846 "\\|\\(begin{" | |
847 YaTeX::ref-nestable-counter-regexp "}\\)")) | |
848 "\\)"))) | |
70 | 849 (regexp (concat "\\(" counter |
850 "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)")) | |
851 (itemsep (concat YaTeX-ec-regexp | |
852 "\\(\\(bib\\)?item\\|begin\\|end\\)")) | |
86 | 853 (refcmd (or refcmd "\\(page\\)?ref")) |
70 | 854 (p (point)) initl line cf |
855 (percent (regexp-quote YaTeX-comment-prefix)) | |
856 (output | |
857 (function | |
858 (lambda (label p) | |
80 | 859 (while (setq x (string-match "[\n\t]" label)) |
70 | 860 (aset label x ? )) |
80 | 861 (while (setq x (string-match " +" label)) |
70 | 862 (setq label (concat |
863 (substring label 0 (1+ (match-beginning 0))) | |
864 (substring label (match-end 0))))) | |
865 (princ (format "%c: <<%s>>\n" (+ (% lnum 26) ?A) label)) | |
866 (setq point-list (cons p point-list)) | |
867 (message "Collecting labels... %d" lnum) | |
868 (setq lnum (1+ lnum))))) | |
80 | 869 (me (if (boundp 'me) me 'YaTeX::ref)) |
70 | 870 ) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
871 (message "Collecting labels...") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
872 (save-window-excursion |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
873 (YaTeX-showup-buffer |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
874 YaTeX-label-buffer (function (lambda (x) (window-width x)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
875 (if (fboundp 'select-frame) (setq cf (selected-frame))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
876 (if (eq (window-buffer (minibuffer-window)) buf) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
877 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
878 (other-window 1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
879 (setq buf (current-buffer)) |
70 | 880 (set-buffer buf))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
881 (save-excursion |
69 | 882 (set-buffer (get-buffer-create YaTeX-label-buffer)) |
80 | 883 (condition-case () |
884 (if (and YaTeX-use-font-lock (fboundp 'font-lock-mode)) | |
885 (font-lock-mode 1)) | |
886 (error nil)) | |
69 | 887 (setq buffer-read-only nil) |
888 (erase-buffer)) | |
889 (save-excursion | |
70 | 890 (set-buffer buf) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
891 (goto-char (point-min)) |
80 | 892 (let ((standard-output (get-buffer YaTeX-label-buffer)) existlabel) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
893 (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) |
48 | 894 (while (YaTeX-re-search-active-forward |
70 | 895 regexp ;;counter |
896 percent nil t) | |
897 ;(goto-char (match-beginning 0)) | |
898 (setq e0 (match-end 0)) | |
899 (cond | |
80 | 900 ;; |
901 ;;2005/10/21 Skip it if predicate function returns nil | |
902 ((and predf | |
903 (let ((md (match-data))) | |
904 (prog1 | |
905 (condition-case nil | |
906 (not (funcall predf)) | |
907 (error nil)) | |
908 (store-match-data md))))) | |
73 | 909 ((YaTeX-literal-p) nil) |
72 | 910 ((YaTeX-match-string 1) |
70 | 911 ;;if standard counter commands found |
80 | 912 (setq cmd (YaTeX-match-string 2) |
913 m0 (match-beginning 0)) | |
70 | 914 (setq match-point (match-beginning 0)) |
915 (or initl | |
916 (if (< p (point)) (setq initl lnum))) | |
917 (cond | |
80 | 918 ;; In any case, variables e0 should be set |
919 ((and YaTeX-use-AMS-LaTeX | |
920 (string-match YaTeX::ref-nestable-counter-regexp cmd)) | |
921 (let (label) | |
922 (skip-chars-forward "}") | |
923 (setq label (buffer-substring | |
924 (point) (min (+ 80 (point)) (point-max)))) | |
925 ;; to skip (maybe)auto-generated comment | |
926 (skip-chars-forward " \t") | |
927 (if (looking-at YaTeX-comment-prefix) | |
928 (forward-line 1)) | |
929 (setq e0 (point)) | |
930 (skip-chars-forward " \t\n") | |
931 (if (looking-at "\\\\label{\\([^}]+\\)}") | |
932 (setq label (format "(labe:%s)" (YaTeX-match-string 1)) | |
933 e0 (match-end 1))) | |
934 (funcall output (format "--subequation--%s" label) e0))) | |
70 | 935 ((string-match mathenvs cmd) ;;if matches mathematical env |
80 | 936 (skip-chars-forward "}") |
937 (setq x (point) | |
938 envname (substring | |
939 cmd (match-beginning 0) (match-end 0))) | |
940 (save-restriction | |
941 (narrow-to-region | |
942 m0 | |
943 (save-excursion | |
944 (YaTeX-re-search-active-forward | |
945 (setq endrx (format "%send{%s}" YaTeX-ec-regexp | |
946 (regexp-quote envname))) | |
947 percent nil t))) | |
948 (catch 'scan | |
949 (while (YaTeX-re-search-active-forward | |
950 (concat | |
951 "\\\\end{\\(" (regexp-quote envname) "\\)";;(1) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
952 "\\|\\\\\\(notag\\)" ;;2 |
80 | 953 (if (string-match |
954 YaTeX::ref-mathenv-exp1-regexp cmd) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
955 "" "\\|\\(\\\\\\\\\\)$") ;;3 |
80 | 956 ) |
957 percent nil t) | |
958 (let*((quit (match-beginning 1)) | |
959 (notag (match-beginning 2)) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
960 (newln (match-beginning 3)) |
80 | 961 (label ".......................") l2 |
962 (e (point)) (m0 (match-beginning 0)) | |
963 (ln (YaTeX-string-width label))) | |
964 (cond | |
965 (notag | |
966 (YaTeX-re-search-active-forward | |
967 "\\\\\\\\" percent nil 1) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
968 (setq x (point))) ;use x as \label search bound |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
969 ((and newln ; `\\' found |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
970 (not (equal (YaTeX-inner-environment) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
971 envname))) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
972 (YaTeX-end-of-environment) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
973 (goto-char (match-end 0))) |
80 | 974 (t |
975 (if (YaTeX-re-search-active-backward | |
976 YaTeX::ref-labeling-regexp | |
977 percent x t) | |
978 ;; if \label{x} in math-expression, display it | |
979 ;; because formula source is hard to recognize | |
980 (progn | |
981 (goto-char (match-end 0)) | |
982 (setq l2 (format "\"label:%s\"" | |
983 (buffer-substring | |
984 (1- (point)) | |
985 (progn (forward-sexp -1) | |
986 (1+ (point)))))) | |
987 (setq label | |
988 (if (< (YaTeX-string-width l2) ln) | |
989 (concat | |
990 l2 | |
991 (substring | |
992 label | |
993 0 (- ln (YaTeX-string-width l2)))) | |
994 l2)) | |
995 (goto-char e))) | |
996 (funcall output | |
997 (concat | |
998 label " " | |
999 (buffer-substring x m0)) | |
1000 x) | |
1001 (cond | |
1002 ((YaTeX-quick-in-environment-p | |
1003 YaTeX-math-gathering-list) | |
1004 ;; if here is inner split/cases/gathered env., | |
1005 ;; counter for here is only one. | |
1006 ;; Go out this environment and, | |
1007 (YaTeX-end-of-environment) | |
1008 ;; search next expression unit boundary. | |
1009 (YaTeX-re-search-active-forward | |
1010 (concat endrx "\\|\\\\begin{") | |
1011 percent nil 1) | |
1012 (end-of-line))) | |
1013 (if quit (throw 'scan t))))) | |
1014 (setq x (point))))) | |
70 | 1015 (setq e0 (point))) |
1016 ((string-match enums cmd) | |
1017 ;(skip-chars-forward "} \t\n") | |
1018 (save-restriction | |
1019 (narrow-to-region | |
1020 (point) | |
1021 (save-excursion | |
1022 (YaTeX-goto-corresponding-environment) (point))) | |
1023 (forward-line 1) | |
1024 (while (YaTeX-re-search-active-forward | |
1025 (concat YaTeX-ec-regexp "item\\s ") | |
1026 percent nil t) | |
1027 (setq x (match-beginning 0)) | |
1028 (funcall | |
1029 output | |
80 | 1030 (concat |
1031 existlabel | |
1032 (buffer-substring | |
1033 (match-beginning 0) | |
1034 (if (re-search-forward itemsep nil t) | |
1035 (progn (goto-char (match-beginning 0)) | |
1036 (skip-chars-backward " \t") | |
1037 (1- (point))) | |
1038 (point-end-of-line)))) | |
77 | 1039 x)) |
1040 (setq e0 (point-max)))) | |
80 | 1041 ((string-match "bibitem" cmd) ;maybe generated by myself |
1042 (setq label "") | |
1043 (skip-chars-forward " \t") | |
1044 (if (looking-at "{") ;sure to be true!! | |
1045 (forward-list 1)) | |
1046 (let ((list '(30 10 65)) | |
1047 (delim ";") q lim len l str) | |
1048 (save-excursion | |
1049 (setq lim (if (re-search-forward itemsep nil 1) | |
1050 (match-beginning 0) (point)))) | |
1051 (while list | |
1052 (skip-chars-forward " \t\n\\") | |
1053 (setq q (looking-at "[\"'{]") | |
1054 len (car list) | |
1055 str | |
1056 (buffer-substring | |
1057 (point) | |
1058 (progn | |
1059 (if q (forward-sexp 1) | |
1060 (search-forward delim lim 1) | |
1061 (forward-char -1)) | |
1062 (point)))) | |
1063 (if (> (setq l (YaTeX-string-width str)) len) | |
1064 (setq str (concat | |
1065 (YaTeX-truncate-string-width | |
1066 str (- len (if q 5 4))) | |
1067 "... " | |
1068 (if q (substring str -1))))) | |
1069 (if (< (setq l (YaTeX-string-width str)) len) | |
1070 (setq str (concat str (make-string (- len l) ? )))) | |
1071 (if (looking-at delim) (goto-char (match-end 0))) | |
1072 (setq label (concat label " " str) | |
1073 list (cdr list))) | |
1074 (funcall output label match-point))) | |
77 | 1075 ;;else, simple section-type counter |
70 | 1076 ((= (char-after (1- (point))) ?{) |
1077 (setq label (buffer-substring | |
1078 (match-beginning 0) | |
1079 (progn (forward-char -1) | |
1080 (forward-list 1) | |
1081 (point)))) | |
77 | 1082 (funcall output label match-point) |
1083 ;; Skip preceding label if exists | |
80 | 1084 (if (YaTeX::ref-getset-label (current-buffer) match-point t) |
1085 (goto-char (get 'YaTeX::ref-getset-label 'foundpoint))) | |
77 | 1086 (if (save-excursion |
1087 (skip-chars-forward "\t \n") | |
1088 (looking-at YaTeX::ref-labeling-regexp)) | |
1089 (setq e0 (match-end 0)))) | |
70 | 1090 (t |
1091 (skip-chars-forward " \t") | |
1092 (setq label (buffer-substring | |
1093 (match-beginning 0) | |
1094 (if (re-search-forward | |
1095 itemsep | |
1096 nil t) | |
1097 (progn | |
1098 (goto-char (match-beginning 0)) | |
1099 (skip-chars-backward " \t") | |
1100 (1- (point))) | |
1101 (point-end-of-line)))) | |
1102 (funcall output label match-point) | |
77 | 1103 (if (save-excursion |
1104 (skip-chars-forward "\t \n") | |
1105 (looking-at YaTeX::ref-labeling-regexp)) | |
1106 (setq e0 (match-end 0))))) | |
70 | 1107 ) ;;put label buffer |
1108 ;; | |
1109 ;; if user defined label found | |
1110 (t | |
1111 ;; memorize line number and label into property | |
1112 (goto-char (match-beginning 0)) | |
1113 (let ((list YaTeX::ref-labeling-regexp-alist) | |
1114 (cache (symbol-plist 'YaTeX::ref-labeling-regexp))) | |
1115 (while list | |
1116 (if (looking-at (car (car list))) | |
1117 (progn | |
1118 (setq label (YaTeX-match-string 0)) | |
1119 (put 'YaTeX::ref-labeling-regexp lnum | |
1120 (YaTeX-match-string (cdr (car list)))) | |
1121 (funcall output label 0) ;;0 is dummy, never used | |
1122 (setq list nil))) | |
1123 (setq list (cdr list)))) | |
1124 )) | |
11 | 1125 (goto-char e0)) |
1126 (princ YaTeX-label-menu-other) | |
23 | 1127 (princ YaTeX-label-menu-repeat) |
11 | 1128 (princ YaTeX-label-menu-any) |
69 | 1129 );standard-output |
11 | 1130 (goto-char p) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1131 (or initl (setq initl lnum)) |
70 | 1132 (message "Collecting labels...Done") |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1133 (if (fboundp 'select-frame) (select-frame cf)) |
59 | 1134 (YaTeX-showup-buffer YaTeX-label-buffer nil t) |
11 | 1135 (YaTeX::label-setup-key-map) |
1136 (setq truncate-lines t) | |
1137 (setq buffer-read-only t) | |
1138 (use-local-map YaTeX-label-select-map) | |
1139 (message YaTeX-label-guide-msg) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1140 (goto-line (1+ initl)) ;goto recently defined label line |
68 | 1141 (switch-to-buffer (current-buffer)) |
11 | 1142 (unwind-protect |
1143 (progn | |
1144 (recursive-edit) | |
70 | 1145 |
11 | 1146 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion |
1147 (beginning-of-line) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1148 (setq line (1- (count-lines (point-min)(point)))) |
11 | 1149 (cond |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1150 ((= line -1) (setq label "")) |
11 | 1151 ((= line lnum) (setq label (YaTeX-label-other))) |
23 | 1152 ((= line (1+ lnum)) |
1153 (save-excursion | |
1154 (switch-to-buffer buf) | |
1155 (goto-char p) | |
48 | 1156 (if (re-search-backward |
86 | 1157 (concat "\\\\" refcmd "{") nil t) |
1158 (setq label (YaTeX-buffer-substring | |
1159 (progn (goto-char (1- (match-end 0))) | |
1160 (1+ (point))) | |
1161 (progn (forward-list 1) | |
1162 (1- (point))))) | |
23 | 1163 (setq label "")))) |
1164 ((>= line (+ lnum 2)) | |
48 | 1165 (setq label (read-string (format "\\%s{???}: " refcmd)))) |
70 | 1166 (t ;(setq label (nth (- lnum line 1) label-list)) |
1167 (setq label | |
1168 (or (get 'YaTeX::ref-labeling-regexp line) | |
1169 (YaTeX::ref-getset-label | |
1170 buf (nth (- lnum line 1) point-list)))) | |
1171 ))) | |
11 | 1172 (bury-buffer YaTeX-label-buffer))) |
69 | 1173 label))))) |
1174 | |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1175 (defun YaTeX::label-rename-refs (old new &optional def ref) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1176 "Rename reference tag from OLD to NEW. |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1177 Optional arguments DEF and REF specify defining command and |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1178 referring command respectively. |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1179 --------------------------------------------------------- |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1180 CONTROL KEYS - キーの説明 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1181 y Replace 置換する |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1182 n Do not replace 置換しない |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1183 ! Replace All w/o query 残る全部を確認なしで置換 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1184 r Enter Recursive-edit 再帰編集モードへ |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1185 q Quit from replacing ここまでで置換をやめる |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1186 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1187 Don't forget to exit from recursive edit by typing \\[exit-recursive-edit] |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1188 再帰編集に入ったら \\[exit-recursive-edit] で抜け忘れなきよう。" |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1189 (save-window-excursion |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1190 (catch 'exit |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1191 (let*((bufs (YaTeX-yatex-buffer-list)) buf b e |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1192 (oldptn (regexp-quote old)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1193 (sw (selected-window)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1194 (ptn (concat |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1195 "\\(" YaTeX-refcommand-ref-regexp "\\)" |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1196 "\\s *{" oldptn "}")) |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1197 (repface (and (fboundp 'make-overlay) |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1198 (fboundp 'internal-find-face) |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1199 (if (internal-find-face 'isearch) 'isearch 'region))) |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1200 ov |
173
7dc3c2332da5
YaTeX::label: Message for yank should remain.
yuuji@gentei.org
parents:
170
diff
changeset
|
1201 (qmsg "Replace to `%s'? [yn!rq?]") |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1202 continue ch) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1203 (while bufs |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1204 (set-buffer (setq buf (car bufs))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1205 (save-excursion |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1206 (goto-char (point-min)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1207 (while (re-search-forward ptn nil t) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1208 (goto-char (match-end 1)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1209 (skip-chars-forward " \t\n{") |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1210 (unwind-protect |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1211 (if (and |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1212 (looking-at oldptn) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1213 (setq b (match-beginning 0) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1214 e (match-end 0)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1215 (or continue |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1216 (catch 'query |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1217 (if repface |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1218 (if ov (move-overlay ov b e) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1219 (overlay-put |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1220 (setq ov (make-overlay b e)) |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1221 'face repface))) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1222 (switch-to-buffer buf) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1223 (while t |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1224 (message qmsg new) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1225 (setq ch (read-char)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1226 (cond |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1227 ((= ch ?q) (throw 'exit t)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1228 ((= ch ?r) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1229 (message |
173
7dc3c2332da5
YaTeX::label: Message for yank should remain.
yuuji@gentei.org
parents:
170
diff
changeset
|
1230 "Don't forget to exit recursive-edit by `%s'" |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1231 (key-description |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1232 (where-is-internal |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1233 'exit-recursive-edit '(keymap) t))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1234 (sleep-for 2) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1235 (recursive-edit)) |
255
214702e4df54
SPC is the same as `y' like y-or-n-p(YaTeX::label-rename-refs).
HIROSE Yuuji <yuuji@gentei.org>
parents:
254
diff
changeset
|
1236 ((memq ch '(?y ?\ )) (throw 'query t)) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1237 ((= ch ?!) (throw 'query (setq continue t))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1238 ((= ch ??) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1239 (describe-function |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1240 'YaTeX::label-rename-refs) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1241 (select-window (get-buffer-window "*Help*")) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1242 (search-forward "----") |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1243 (forward-line 1) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1244 (set-window-start (selected-window) (point)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1245 (sit-for 0) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1246 (select-window sw)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1247 ((= ch ?n) (throw 'query nil))))))) |
267
388eaa8b695a
Label replacement should be FIXEDCASE.
HIROSE Yuuji <yuuji@gentei.org>
parents:
259
diff
changeset
|
1248 (replace-match new t)) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1249 (and ov (delete-overlay ov))))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1250 (setq bufs (cdr bufs))))))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1251 |
167 | 1252 (defun YaTeX::label (argp &optional labname refname) |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1253 "Read label name and return it with copying \\ref{LABEL-NAME} to kill-ring." |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1254 (cond |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1255 ((= argp 1) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1256 (let*((chmode (boundp (intern-soft "old"))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1257 (dlab (if chmode old ;if called via YaTeX-change-section (tricky...) |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1258 (YaTeX::ref-default-label))) |
167 | 1259 (label (read-string |
1260 (format "New %s name: " (or labname "label")) | |
1261 (cons dlab 1)))) | |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1262 (if (string< "" label) |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1263 (let ((refstr (format "\\%s{%s}" (or refname "ref") label))) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1264 (YaTeX-push-to-kill-ring refstr) |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1265 (and chmode |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1266 (not (equal old label)) |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1267 (YaTeX::label-rename-refs old label)))) |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1268 label)))) |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1269 |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1270 |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1271 (fset 'YaTeX::pageref 'YaTeX::ref) |
312 | 1272 (fset 'YaTeX::cref 'YaTeX::ref) |
80 | 1273 (defun YaTeX::tabref (argp) ; For the style file of IPSJ journal |
1274 (YaTeX::ref | |
1275 argp nil nil | |
1276 (function | |
1277 (lambda () | |
1278 (YaTeX-quick-in-environment-p "table"))))) | |
1279 (defun YaTeX::figref (argp) ; For the style file of IPSJ journal | |
1280 (YaTeX::ref | |
1281 argp nil nil | |
1282 (function | |
1283 (lambda () | |
1284 (YaTeX-quick-in-environment-p "figure"))))) | |
232
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1285 (defun YaTeX::eqref (argp) |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1286 (YaTeX::ref |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1287 argp nil nil |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1288 (function |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1289 (lambda () |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1290 (YaTeX-in-math-mode-p))))) |
70 | 1291 |
80 | 1292 (defun YaTeX::cite-collect-bibs-external (bibptn &rest files) |
1293 "Collect bibentry from FILES(variable length argument) ; | |
70 | 1294 and print them to standard output." |
1295 ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html | |
80 | 1296 (let*((tb (get-buffer-create " *bibtmp*")) |
1297 (bibitemsep "^\\s *@[A-Za-z]") | |
1298 (target (if (string< "" bibptn) bibptn bibitemsep)) | |
1299 (checkrx (concat "\\(" bibptn "\\)\\|" bibitemsep)) | |
1300 beg | |
1301 (searchnext | |
1302 (if (string< "" bibptn) | |
1303 (function | |
1304 (lambda() | |
1305 (setq beg (point)) | |
1306 (and | |
1307 (prog1 | |
1308 (re-search-forward target nil t) | |
1309 (end-of-line)) | |
1310 (re-search-backward bibitemsep beg t)))) | |
1311 (function | |
1312 (lambda() | |
1313 (re-search-forward target nil t))))) | |
1314 ) | |
70 | 1315 (save-excursion |
1316 (set-buffer tb) | |
80 | 1317 (princ (format "%sbegin{thebibliography}\n" YaTeX-ec)) |
70 | 1318 (while files |
1319 (erase-buffer) | |
1320 (cond | |
1321 ((file-exists-p (car files)) | |
1322 (insert-file-contents (car files))) | |
1323 ((file-exists-p (concat (car files) ".bib")) | |
1324 (insert-file-contents (concat (car files) ".bib")))) | |
1325 (save-excursion | |
1326 (goto-char (point-min)) | |
80 | 1327 (while (funcall searchnext) |
70 | 1328 (skip-chars-forward "^{,") |
80 | 1329 (setq beg (point)) |
70 | 1330 (if (= (char-after (point)) ?{) |
1331 (princ (format "%sbibitem{%s}%s\n" | |
1332 YaTeX-ec | |
1333 (buffer-substring | |
1334 (1+ (point)) | |
1335 (progn (skip-chars-forward "^,\n") | |
1336 (point))) | |
80 | 1337 (mapconcat |
1338 (function | |
1339 (lambda (kwd) | |
1340 (goto-char beg) | |
1341 (if (re-search-forward | |
1342 (concat kwd "\\s *=") nil t) | |
1343 (buffer-substring | |
1344 (progn | |
1345 (goto-char (match-end 0)) | |
1346 (skip-chars-forward " \t\n") | |
1347 (point)) | |
1348 (progn | |
1349 (if (looking-at "[{\"]") | |
1350 (forward-sexp 1) | |
1351 (forward-char 1) | |
1352 (skip-chars-forward "^,}")) | |
1353 (point)))))) | |
1354 '("author" "year" "title" ) | |
1355 ";")))) | |
1356 (and (re-search-forward bibitemsep nil t) | |
1357 (forward-line -1)))) | |
1358 (setq files (cdr files))) | |
1359 (princ (format "%sbegin{thebibliography}\n" YaTeX-ec))))) | |
70 | 1360 |
77 | 1361 (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem" |
1362 "*Regexp of macro name of bibitem definition") | |
1363 | |
80 | 1364 (defun YaTeX::cite-collect-bibs-internal (bibptn) |
70 | 1365 "Collect bibentry in the current buffer and print them to standard output." |
77 | 1366 (let ((ptn (concat YaTeX-ec-regexp |
1367 "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b")) | |
80 | 1368 (lim (concat YaTeX-ec-regexp |
1369 "\\(" YaTeX::cite-bibitem-macro-regexp "\\b\\)" | |
1370 "\\|\\(end{\\)")) | |
70 | 1371 (pcnt (regexp-quote YaTeX-comment-prefix))) |
80 | 1372 ;; Using bibptn not yet implemented. |
1373 ;; Do you need it?? 2005/11/22 | |
70 | 1374 (save-excursion |
1375 (while (YaTeX-re-search-active-forward ptn pcnt nil t) | |
1376 (skip-chars-forward "^{\n") | |
1377 (or (eolp) | |
80 | 1378 (princ (format "%sbibitem%s %s\n" |
70 | 1379 YaTeX-ec |
1380 (buffer-substring | |
80 | 1381 (point) |
1382 (progn (forward-sexp 1) (point))) | |
1383 (buffer-substring | |
1384 (progn (skip-chars-forward "\n \t") (point)) | |
1385 (save-excursion | |
1386 (if (YaTeX-re-search-active-forward | |
1387 lim pcnt nil t) | |
1388 (progn | |
1389 (goto-char (match-beginning 0)) | |
1390 (skip-chars-backward "\n \t") | |
1391 (point)) | |
1392 (point-end-of-line))))))))))) | |
70 | 1393 |
80 | 1394 (defun YaTeX::cite (argp &rest dummy) |
48 | 1395 (cond |
1396 ((eq argp 1) | |
70 | 1397 (let* ((cb (current-buffer)) |
1398 (f (file-name-nondirectory buffer-file-name)) | |
1399 (d default-directory) | |
1400 (hilit-auto-highlight nil) | |
1401 (pcnt (regexp-quote YaTeX-comment-prefix)) | |
1402 (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}")) | |
80 | 1403 (bibptn (read-string "Pattern: ")) |
70 | 1404 (bbuf (get-buffer-create " *bibitems*")) |
1405 (standard-output bbuf) | |
80 | 1406 (me 'YaTeX::cite) ;shuld set this for using YaTeX::ref |
70 | 1407 bibs files) |
1408 (set-buffer bbuf)(erase-buffer)(set-buffer cb) | |
1409 (save-excursion | |
1410 (goto-char (point-min)) | |
1411 ;;(1)search external bibdata | |
1412 (while (YaTeX-re-search-active-forward bibrx pcnt nil t) | |
1413 (apply 'YaTeX::cite-collect-bibs-external | |
80 | 1414 bibptn |
70 | 1415 (YaTeX-split-string |
1416 (YaTeX-match-string 1) ","))) | |
1417 ;;(2)search direct \bibitem usage | |
80 | 1418 (YaTeX::cite-collect-bibs-internal bibptn) |
70 | 1419 (if (progn |
1420 (YaTeX-visit-main t) | |
1421 (not (eq (current-buffer) cb))) | |
1422 (save-excursion | |
1423 (goto-char (point-min)) | |
1424 ;;(1)search external bibdata | |
1425 (while (YaTeX-re-search-active-forward bibrx pcnt nil t) | |
1426 (apply 'YaTeX::cite-collect-bibs-external | |
80 | 1427 bibptn |
70 | 1428 (YaTeX-split-string |
1429 (YaTeX-match-string 1) ","))) | |
1430 ;;(2)search internal | |
80 | 1431 (YaTeX::cite-collect-bibs-internal bibptn))) |
70 | 1432 ;;Now bbuf holds the list of bibitem |
1433 (set-buffer bbuf) | |
80 | 1434 ;;;(switch-to-buffer bbuf) |
1435 (if (fboundp 'font-lock-fontify-buffer) (font-lock-fontify-buffer)) | |
77 | 1436 (YaTeX::ref |
1437 argp | |
1438 (concat "\\\\\\(" | |
1439 YaTeX::cite-bibitem-macro-regexp | |
1440 "\\)\\(\\[.*\\]\\)?") | |
1441 "cite")))) | |
1442 | |
48 | 1443 (t nil))) |
11 | 1444 |
167 | 1445 (defun YaTeX::bibitem (argp) |
1446 "Add-in function to insert argument of \\bibitem." | |
1447 (YaTeX::label argp "label" "cite")) | |
1448 | |
77 | 1449 ;;; for Harvard citation style |
1450 (fset 'YaTeX::citeasnoun 'YaTeX::cite) | |
1451 (fset 'YaTeX::possessivecite 'YaTeX::cite) | |
1452 (fset 'YaTeX::citeyear 'YaTeX::cite) | |
1453 (fset 'YaTeX::citename 'YaTeX::cite) | |
80 | 1454 (fset 'YaTeX::citep 'YaTeX::cite) |
1455 (fset 'YaTeX::citet 'YaTeX::cite) | |
70 | 1456 |
48 | 1457 (defun YaTeX-select-other-yatex-buffer () |
1458 "Select buffer from all yatex-mode's buffers interactivelly." | |
1459 (interactive) | |
1460 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) | |
1461 (lnum -1) buf rv | |
11 | 1462 (ff "**find-file**")) |
12 | 1463 (YaTeX-showup-buffer |
1464 lbuf (function (lambda (x) 1))) ;;Select next window surely. | |
69 | 1465 (save-excursion |
1466 (set-buffer (get-buffer lbuf)) | |
1467 (setq buffer-read-only nil) | |
1468 (erase-buffer)) | |
1469 (let ((standard-output (get-buffer lbuf))) | |
11 | 1470 (while blist |
48 | 1471 (princ |
1472 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) | |
1473 (buffer-name (car blist)))) | |
11 | 1474 (setq blist (cdr blist))) |
1475 (princ (format "':{%s}" ff))) | |
59 | 1476 (YaTeX-showup-buffer lbuf nil t) |
11 | 1477 (YaTeX::label-setup-key-map) |
1478 (setq buffer-read-only t) | |
1479 (use-local-map YaTeX-label-select-map) | |
1480 (message YaTeX-label-guide-msg) | |
1481 (unwind-protect | |
1482 (progn | |
1483 (recursive-edit) | |
1484 (set-buffer lbuf) | |
1485 (beginning-of-line) | |
1486 (setq rv | |
1487 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) | |
1488 (buffer-substring (match-beginning 1) (match-end 1)) nil))) | |
1489 (kill-buffer lbuf)) | |
48 | 1490 (if (string= rv ff) |
1491 (progn | |
1492 (call-interactively 'find-file) | |
1493 (current-buffer)) | |
69 | 1494 rv))) |
48 | 1495 |
1496 (defun YaTeX-label-other () | |
1497 (let ((rv (YaTeX-select-other-yatex-buffer))) | |
11 | 1498 (cond |
1499 ((null rv) "") | |
1500 (t | |
1501 (set-buffer rv) | |
80 | 1502 (funcall me argp labelcmd refcmd))))) |
11 | 1503 |
13 | 1504 ;; |
1505 ; completion for the arguments of \newcommand | |
1506 ;; | |
1507 (defun YaTeX::newcommand (&optional argp) | |
1508 (cond | |
1509 ((= argp 1) | |
1510 (let ((command (read-string "Define newcommand: " "\\"))) | |
1511 (put 'YaTeX::newcommand 'command (substring command 1)) | |
1512 command)) | |
1513 ((= argp 2) | |
1514 (let ((argc | |
1515 (string-to-int (read-string "Number of arguments(Default 0): "))) | |
1516 (def (read-string "Definition: ")) | |
1517 (command (get 'YaTeX::newcommand 'command))) | |
1518 ;;!!! It's illegal to insert string in the add-in function !!! | |
1519 (if (> argc 0) (insert (format "[%d]" argc))) | |
1520 (if (and (stringp command) | |
1521 (string< "" command) | |
51 | 1522 (y-or-n-p "Update dictionary?")) |
18 | 1523 (cond |
1524 ((= argc 0) | |
1525 (YaTeX-update-table | |
1526 (list command) | |
1527 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table)) | |
1528 ((= argc 1) | |
1529 (YaTeX-update-table | |
1530 (list command) | |
1531 'section-table 'user-section-table 'tmp-section-table)) | |
1532 (t (YaTeX-update-table | |
1533 (list command argc) | |
1534 'section-table 'user-section-table 'tmp-section-table)))) | |
13 | 1535 (message "") |
1536 def ;return command name | |
1537 )) | |
69 | 1538 (t ""))) |
13 | 1539 |
80 | 1540 (defun YaTeX::newcounter (&optional argp) |
1541 (cond | |
1542 ((= argp 1) | |
1543 (read-string "New counter name: ")) | |
1544 (t ""))) | |
1545 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1546 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1547 ; completion for the arguments of \pagestyle |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1548 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1549 (defun YaTeX::pagestyle (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1550 "Read the pagestyle with completion." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1551 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1552 "Page style: " |
69 | 1553 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))) |
1554 | |
51 | 1555 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle) |
1556 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1557 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1558 ; completion for the arguments of \pagenumbering |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1559 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1560 (defun YaTeX::pagenumbering (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1561 "Read the numbering style." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1562 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1563 "Page numbering style: " |
69 | 1564 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))) |
13 | 1565 |
23 | 1566 ;; |
1567 ; Length | |
1568 ;; | |
1569 (defvar YaTeX:style-parameters-default | |
1570 '(("\\arraycolsep") | |
1571 ("\\arrayrulewidth") | |
1572 ("\\baselineskip") | |
1573 ("\\columnsep") | |
1574 ("\\columnseprule") | |
1575 ("\\doublerulesep") | |
1576 ("\\evensidemargin") | |
1577 ("\\footheight") | |
1578 ("\\footskip") | |
1579 ("\\headheight") | |
1580 ("\\headsep") | |
1581 ("\\itemindent") | |
1582 ("\\itemsep") | |
1583 ("\\labelsep") | |
1584 ("\\labelwidth") | |
1585 ("\\leftmargin") | |
1586 ("\\linewidth") | |
1587 ("\\listparindent") | |
1588 ("\\marginparsep") | |
1589 ("\\marginparwidth") | |
1590 ("\\mathindent") | |
1591 ("\\oddsidemargin") | |
1592 ("\\parindent") | |
1593 ("\\parsep") | |
1594 ("\\parskip") | |
1595 ("\\partopsep") | |
1596 ("\\rightmargin") | |
1597 ("\\tabcolsep") | |
1598 ("\\textheight") | |
1599 ("\\textwidth") | |
324
b6500fb81ee0
Add columnwidth to YaTeX:style-parameters-default
HIROSE Yuuji <yuuji@gentei.org>
parents:
323
diff
changeset
|
1600 ("\\columnwidth") |
23 | 1601 ("\\topmargin") |
1602 ("\\topsep") | |
1603 ("\\topskip") | |
1604 ) | |
1605 "Alist of LaTeX style parameters.") | |
1606 (defvar YaTeX:style-parameters-private nil | |
1607 "*User definable alist of style parameters.") | |
49 | 1608 (defvar YaTeX:style-parameters-local nil |
1609 "*User definable alist of local style parameters.") | |
23 | 1610 |
1611 (defvar YaTeX:length-history nil "Holds history of length.") | |
51 | 1612 (put 'YaTeX:length-history 'no-default t) |
23 | 1613 (defun YaTeX::setlength (&optional argp) |
1614 "YaTeX add-in function for arguments of \\setlength." | |
1615 (cond | |
1616 ((equal 1 argp) | |
49 | 1617 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\") |
1618 (YaTeX-cplread-with-learning | |
1619 "Length variable: " | |
1620 'YaTeX:style-parameters-default | |
1621 'YaTeX:style-parameters-private | |
1622 'YaTeX:style-parameters-local | |
1623 nil nil "\\") | |
1624 ) | |
23 | 1625 ((equal 2 argp) |
69 | 1626 (read-string-with-history "Length: " nil 'YaTeX:length-history)))) |
1627 | |
23 | 1628 (fset 'YaTeX::addtolength 'YaTeX::setlength) |
1629 | |
1630 (defun YaTeX::settowidth (&optional argp) | |
1631 "YaTeX add-in function for arguments of \\settowidth." | |
1632 (cond | |
1633 ((equal 1 argp) | |
49 | 1634 (YaTeX-cplread-with-learning |
1635 "Length variable: " | |
1636 'YaTeX:style-parameters-default | |
1637 'YaTeX:style-parameters-private | |
1638 'YaTeX:style-parameters-local | |
1639 nil nil "\\")) | |
23 | 1640 ((equal 2 argp) |
69 | 1641 (read-string "Text: ")))) |
1642 | |
23 | 1643 (defun YaTeX::newlength (&optional argp) |
1644 "YaTeX add-in function for arguments of \\newlength" | |
1645 (cond | |
1646 ((equal argp 1) | |
1647 (let ((length (read-string "Length variable: " "\\"))) | |
49 | 1648 (if (string< "" length) |
1649 (YaTeX-update-table | |
1650 (list length) | |
1651 'YaTeX:style-parameters-default | |
1652 'YaTeX:style-parameters-private | |
1653 'YaTeX:style-parameters-local)) | |
69 | 1654 length)))) |
23 | 1655 |
1656 ;; \multicolumn's arguments | |
1657 (defun YaTeX::multicolumn (&optional argp) | |
1658 "YaTeX add-in function for arguments of \\multicolumn." | |
1659 (cond | |
1660 ((equal 1 argp) | |
1661 (read-string "Number of columns: ")) | |
1662 ((equal 2 argp) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1663 (YaTeX:read-oneof "|lrc" nil t)) |
23 | 1664 ((equal 3 argp) |
69 | 1665 (read-string "Item: ")))) |
23 | 1666 |
49 | 1667 (defvar YaTeX:documentstyles-default |
1668 '(("article") ("jarticle") ("j-article") | |
1669 ("book") ("jbook") ("j-book") | |
1670 ("report") ("jreport") ("j-report") | |
1671 ("letter") ("ascjletter")) | |
1672 "List of LaTeX documentstyles.") | |
1673 (defvar YaTeX:documentstyles-private nil | |
1674 "*User defined list of LaTeX documentstyles.") | |
1675 (defvar YaTeX:documentstyles-local nil | |
1676 "*User defined list of local LaTeX documentstyles.") | |
1677 (defvar YaTeX:documentstyle-options-default | |
1678 '(("a4j") ("a5j") ("b4j") ("b5j") | |
1679 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig")) | |
1680 "List of LaTeX documentstyle options.") | |
1681 (defvar YaTeX:documentstyle-options-private nil | |
1682 "*User defined list of LaTeX documentstyle options.") | |
1683 (defvar YaTeX:documentstyle-options-local nil | |
1684 "List of LaTeX local documentstyle options.") | |
1685 | |
1686 (defun YaTeX:documentstyle () | |
1687 (let*((delim ",") | |
1688 (dt (append YaTeX:documentstyle-options-local | |
1689 YaTeX:documentstyle-options-private | |
1690 YaTeX:documentstyle-options-default)) | |
1691 (minibuffer-completion-table dt) | |
1692 (opt (read-from-minibuffer | |
1693 "Style options ([opt1,opt2,...]): " | |
51 | 1694 nil YaTeX-minibuffer-completion-map nil)) |
49 | 1695 (substr opt) o) |
1696 (if (string< "" opt) | |
1697 (progn | |
1698 (while substr | |
1699 (setq o (substring substr 0 (string-match delim substr))) | |
1700 (or (assoc o dt) | |
1701 (YaTeX-update-table | |
1702 (list o) | |
1703 'YaTeX:documentstyle-options-default | |
1704 'YaTeX:documentstyle-options-private | |
1705 'YaTeX:documentstyle-options-local)) | |
1706 (setq substr | |
1707 (if (string-match delim substr) | |
1708 (substring substr (1+ (string-match delim substr)))))) | |
1709 (concat "[" opt "]")) | |
1710 ""))) | |
1711 | |
1712 (defun YaTeX::documentstyle (&optional argp) | |
51 | 1713 "YaTeX add-in function for arguments of \\documentstyle." |
49 | 1714 (cond |
1715 ((equal argp 1) | |
72 | 1716 (setq YaTeX-env-name "document") |
49 | 1717 (let ((sname |
1718 (YaTeX-cplread-with-learning | |
1719 (format "Documentstyle (default %s): " | |
1720 YaTeX-default-document-style) | |
1721 'YaTeX:documentstyles-default | |
1722 'YaTeX:documentstyles-private | |
1723 'YaTeX:documentstyles-local))) | |
1724 (if (string= "" sname) (setq sname YaTeX-default-document-style)) | |
69 | 1725 (setq YaTeX-default-document-style sname))))) |
49 | 1726 |
80 | 1727 (defun YaTeX::include (argp &optional prompt) |
86 | 1728 "Read file name setting default directory to that of main file." |
80 | 1729 (cond |
1730 ((= argp 1) | |
86 | 1731 (save-excursion |
1732 (YaTeX-visit-main t) | |
1733 (let*((insert-default-directory) | |
321
f654ef888a4c
Set old file name as default value on read-file-name at \include*
HIROSE Yuuji <yuuji@gentei.org>
parents:
308
diff
changeset
|
1734 (default (and (boundp 'old) (stringp old) old)) |
f654ef888a4c
Set old file name as default value on read-file-name at \include*
HIROSE Yuuji <yuuji@gentei.org>
parents:
308
diff
changeset
|
1735 (file (read-file-name (or prompt "Input file: ") "" |
f654ef888a4c
Set old file name as default value on read-file-name at \include*
HIROSE Yuuji <yuuji@gentei.org>
parents:
308
diff
changeset
|
1736 default nil default))) |
86 | 1737 (setq file (substring file 0 (string-match "\\.tex$" file)))))))) |
80 | 1738 |
1739 (fset 'YaTeX::input 'YaTeX::include) | |
1740 | |
1741 | |
57 | 1742 ;;; -------------------- LaTeX2e stuff -------------------- |
1743 (defvar YaTeX:documentclass-options-default | |
70 | 1744 '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt") |
57 | 1745 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") |
1746 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") | |
70 | 1747 ("tombow") ("titlepage") ("notitlepage") ("dvips") |
175
6e959a05ae19
Add `jsarticle' and `jsbook' to YaTeX:documentclasses-default.
yuuji@gentei.org
parents:
173
diff
changeset
|
1748 ("mingoth") ;for jsarticle |
57 | 1749 ("clock") ;for slides class only |
1750 ) | |
1751 "Default options list for documentclass") | |
1752 (defvar YaTeX:documentclass-options-private nil | |
1753 "*User defined options list for documentclass") | |
1754 (defvar YaTeX:documentclass-options-local nil | |
1755 "*User defined options list for local documentclass") | |
1756 | |
1757 (defun YaTeX:documentclass () | |
1758 (let*((delim ",") | |
1759 (dt (append YaTeX:documentclass-options-local | |
1760 YaTeX:documentclass-options-private | |
1761 YaTeX:documentclass-options-default)) | |
1762 (minibuffer-completion-table dt) | |
1763 (opt (read-from-minibuffer | |
1764 "Documentclass options ([opt1,opt2,...]): " | |
1765 nil YaTeX-minibuffer-completion-map nil)) | |
1766 (substr opt) o) | |
1767 (if (string< "" opt) | |
1768 (progn | |
1769 (while substr | |
70 | 1770 |
57 | 1771 (setq o (substring substr 0 (string-match delim substr))) |
1772 (or (assoc o dt) | |
1773 (YaTeX-update-table | |
1774 (list o) | |
1775 'YaTeX:documentclass-options-default | |
1776 'YaTeX:documentclass-options-private | |
1777 'YaTeX:documentclass-options-local)) | |
1778 (setq substr | |
1779 (if (string-match delim substr) | |
1780 (substring substr (1+ (string-match delim substr)))))) | |
1781 (concat "[" opt "]")) | |
1782 ""))) | |
1783 | |
1784 (defvar YaTeX:documentclasses-default | |
1785 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") | |
175
6e959a05ae19
Add `jsarticle' and `jsbook' to YaTeX:documentclasses-default.
yuuji@gentei.org
parents:
173
diff
changeset
|
1786 ("jsarticle") ("jsbook") |
57 | 1787 ("j-article") ("j-report") ("j-book") |
1788 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) | |
1789 "Default documentclass alist") | |
1790 (defvar YaTeX:documentclasses-private nil | |
1791 "*User defined documentclass alist") | |
1792 (defvar YaTeX:documentclasses-local nil | |
1793 "*User defined local documentclass alist") | |
1794 (defvar YaTeX-default-documentclass (if YaTeX-japan "jarticle" "article") | |
1795 "*Default documentclass") | |
1796 | |
1797 (defun YaTeX::documentclass (&optional argp) | |
1798 (cond | |
1799 ((equal argp 1) | |
72 | 1800 (setq YaTeX-env-name "document") |
57 | 1801 (let ((sname |
1802 (YaTeX-cplread-with-learning | |
1803 (format "Documentclass (default %s): " YaTeX-default-documentclass) | |
1804 'YaTeX:documentclasses-default | |
1805 'YaTeX:documentclasses-private | |
1806 'YaTeX:documentclasses-local))) | |
1807 (if (string= "" sname) (setq sname YaTeX-default-documentclass)) | |
252
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1808 (setq YaTeX-section-name "title" |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1809 YaTeX-default-documentclass sname))))) |
57 | 1810 |
249 | 1811 (defun YaTeX::title (&optional argp) |
1812 (prog1 (read-string "Document Title: ") | |
1813 (setq YaTeX-section-name "author" | |
1814 YaTeX-single-command "maketitle"))) | |
1815 | |
1816 (defun YaTeX::author (&optional argp) | |
1817 (prog1 (read-string "Document Author: ") | |
1818 (setq YaTeX-section-name "date" | |
1819 YaTeX-single-command "maketitle"))) | |
1820 | |
252
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1821 (defun YaTeX:document () |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1822 (setq YaTeX-section-name |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1823 (if (string-match "book\\|bk" YaTeX-default-documentclass) |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1824 "chapter" |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1825 "section")) |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1826 "") |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1827 |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1828 |
70 | 1829 (defvar YaTeX:latex2e-named-color-alist |
1830 '(("GreenYellow") ("Yellow") ("Goldenrod") ("Dandelion") ("Apricot") | |
1831 ("Peach") ("Melon") ("YellowOrange") ("Orange") ("BurntOrange") | |
1832 ("Bittersweet") ("RedOrange") ("Mahogany") ("Maroon") ("BrickRed") | |
1833 ("Red") ("OrangeRed") ("RubineRed") ("WildStrawberry") ("Salmon") | |
1834 ("CarnationPink") ("Magenta") ("VioletRed") ("Rhodamine") ("Mulberry") | |
1835 ("RedViolet") ("Fuchsia") ("Lavender") ("Thistle") ("Orchid")("DarkOrchid") | |
1836 ("Purple") ("Plum") ("Violet") ("RoyalPurple") ("BlueViolet") | |
1837 ("Periwinkle") ("CadetBlue") ("CornflowerBlue") ("MidnightBlue") | |
1838 ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue") | |
1839 ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen") | |
1840 ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen") | |
1841 ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen") | |
1842 ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White")) | |
141 | 1843 "Colors defined in $TEXMF/tex/plain/dvips/colordvi.tex") |
70 | 1844 |
1845 (defvar YaTeX:latex2e-basic-color-alist | |
1846 '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan") | |
1847 ("magenta")) | |
1848 "Basic colors") | |
1849 | |
1850 (defun YaTeX:textcolor () | |
1851 "Add-in for \\color's option" | |
1852 (if (y-or-n-p "Use `named' color? ") | |
1853 "[named]")) | |
1854 | |
1855 (defun YaTeX::color-completing-read (prompt) | |
1856 (let ((completion-ignore-case t) | |
1857 (namedp (save-excursion | |
1858 (skip-chars-backward "^\n\\[\\\\") | |
1859 (looking-at "named")))) | |
1860 (completing-read | |
1861 prompt | |
1862 (if namedp | |
1863 YaTeX:latex2e-named-color-alist | |
1864 YaTeX:latex2e-basic-color-alist) | |
1865 nil t))) | |
1866 | |
1867 (defun YaTeX::textcolor (argp) | |
1868 "Add-in for \\color's argument" | |
1869 (cond | |
1870 ((= argp 1) (YaTeX::color-completing-read "Color: ")) | |
1871 ((= argp 2) (read-string "Colored string: ")))) | |
1872 | |
1873 (fset 'YaTeX:color 'YaTeX:textcolor) | |
1874 (fset 'YaTeX::color 'YaTeX::textcolor) | |
1875 (fset 'YaTeX:colorbox 'YaTeX:textcolor) | |
1876 (fset 'YaTeX::colorbox 'YaTeX::textcolor) | |
1877 (fset 'YaTeX:fcolorbox 'YaTeX:textcolor) | |
80 | 1878 (fset 'YaTeX:pagecolor 'YaTeX:textcolor) |
1879 (fset 'YaTeX::pagecolor 'YaTeX::textcolor) | |
70 | 1880 |
1881 (defun YaTeX::fcolorbox (argp) | |
1882 (cond | |
1883 ((= argp 1) (YaTeX::color-completing-read "Frame color: ")) | |
1884 ((= argp 2) (YaTeX::color-completing-read "Inner color: ")) | |
1885 ((= argp 3) (read-string "Colored string: ")))) | |
1886 | |
1887 (defun YaTeX:scalebox () | |
80 | 1888 "Add-in for \\scalebox" |
1889 (let ((vmag (read-string | |
1890 (if YaTeX-japan "倍率(負で反転): " | |
1891 "Magnification(Negative for flipped): "))) | |
1892 (hmag (read-string (if YaTeX-japan "縦倍率(省略可): " | |
1893 "Vertical magnification(Optional): ")))) | |
70 | 1894 (if (and hmag (string< "" hmag)) |
1895 (format "{%s}[%s]" vmag hmag) | |
1896 (format "{%s}" vmag)))) | |
1897 | |
80 | 1898 (defun YaTeX:rotatebox () |
1899 "Optional argument add-in for \\rotatebox" | |
1900 (message "Rotate origin? (N)one (O)rigin (X)-Y: ") | |
1901 (let ((c (read-char)) r (defx "x=mm") x (defy "y=mm") y something) | |
1902 (cond | |
1903 ((memq c '(?O ?o)) | |
1904 (if (string< "" (setq r (YaTeX:read-oneof "htbpB"))) | |
1905 (concat "[origin=" r "]"))) | |
1906 ((memq c '(?X ?x ?Y ?y)) | |
1907 (setq r (read-string "" (if YaTeX-emacs-19 (cons defx 3) defx)) | |
1908 x (if (string< "x=" r) r) | |
1909 r (read-string "" (if YaTeX-emacs-19 (cons defy 3) defy)) | |
1910 y (if (string< "y=" r) r) | |
1911 something (or x y)) | |
1912 (format "%s%s%s%s%s" | |
1913 (if something "[" "") | |
1914 (if x x "") | |
1915 (if (and x y) "," "") | |
1916 (if y y "") | |
1917 (if something "]" "")))))) | |
1918 | |
1919 (defun YaTeX::rotatebox (argp) | |
1920 "Argument add-in for \\rotatebox" | |
1921 (cond | |
1922 ((= argp 1) | |
1923 (read-string (if YaTeX-japan "回転角(度; 左回り): " | |
1924 "Angle in degree(unclockwise): "))) | |
1925 ((= argp 2) | |
1926 (read-string (if YaTeX-japan "テキスト: " "Text: "))))) | |
1927 | |
73 | 1928 (defun YaTeX:includegraphics () |
1929 "Add-in for \\includegraphics's option" | |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
1930 (let (width height (scale "") angle str) |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
1931 (setq width (YaTeX:read-length "Width: ") |
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
1932 height (YaTeX:read-length "Height: ")) |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1933 (or (string< "" width) (string< "" height) |
237
af1e6c48eac0
YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents:
234
diff
changeset
|
1934 (setq scale (YaTeX-read-string-or-skip "Scale: "))) |
af1e6c48eac0
YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents:
234
diff
changeset
|
1935 (setq angle (YaTeX-read-string-or-skip "Angle(0-359): ")) |
73 | 1936 (setq str |
1937 (mapconcat | |
1938 'concat | |
1939 (delq nil | |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
1940 (mapcar (function (lambda (s) |
73 | 1941 (and (stringp (symbol-value s)) |
1942 (string< "" (symbol-value s)) | |
349 | 1943 (format "%s=%s" s (symbol-value s))))) |
1944 '(width height scale angle))) | |
73 | 1945 ",")) |
1946 (if (string= "" str) "" | |
1947 (concat "[" str "]")))) | |
1948 | |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1949 (defun YaTeX::get-boundingbox (file) |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1950 "Return the bound box as a string |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1951 This function relies on gs(ghostscript) command installed." |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1952 (let ((str (YaTeX-command-to-string |
335 | 1953 (format "%s -sDEVICE=bbox -dBATCH -dNOPAUSE %s" |
1954 YaTeX-cmd-gs file)))) | |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1955 (if (string-match |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1956 "%%BoundingBox:\\s \\([0-9]+\\s [0-9]+\\s [0-9]+\\s [0-9]+\\)" |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1957 str) |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1958 (substring str (match-beginning 1) (match-end 1))))) |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1959 |
330 | 1960 (defun YaTeX::includegraphics (argp &optional file doclip) |
70 | 1961 "Add-in for \\includegraphics" |
340 | 1962 (let*((imgfile (or file (YaTeX::include argp "Image File: "))) |
338
c731bc210af1
Image inspection should be done in parent-file's directory
HIROSE Yuuji <yuuji@gentei.org>
parents:
335
diff
changeset
|
1963 (imgfilepath |
c731bc210af1
Image inspection should be done in parent-file's directory
HIROSE Yuuji <yuuji@gentei.org>
parents:
335
diff
changeset
|
1964 (save-excursion |
c731bc210af1
Image inspection should be done in parent-file's directory
HIROSE Yuuji <yuuji@gentei.org>
parents:
335
diff
changeset
|
1965 (YaTeX-visit-main t) |
c731bc210af1
Image inspection should be done in parent-file's directory
HIROSE Yuuji <yuuji@gentei.org>
parents:
335
diff
changeset
|
1966 (expand-file-name imgfile default-directory))) |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1967 (case-fold-search t) info bb noupdate needclose c) |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1968 (and (string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\|pdf\\)$" imgfile) |
338
c731bc210af1
Image inspection should be done in parent-file's directory
HIROSE Yuuji <yuuji@gentei.org>
parents:
335
diff
changeset
|
1969 (file-exists-p imgfilepath) |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1970 (or (fboundp 'yahtml-get-image-info) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1971 (progn |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1972 (load "yahtml" t) (featurep 'yahtml))) ;(require 'yahtml nil t) |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1973 (if (string-match "\\.pdf" imgfile) |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1974 (and |
338
c731bc210af1
Image inspection should be done in parent-file's directory
HIROSE Yuuji <yuuji@gentei.org>
parents:
335
diff
changeset
|
1975 (setq info (YaTeX::get-boundingbox imgfilepath)) |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1976 (stringp info) |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1977 (string< "" info) |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1978 (setq bb (format "bb=%s" info))) |
338
c731bc210af1
Image inspection should be done in parent-file's directory
HIROSE Yuuji <yuuji@gentei.org>
parents:
335
diff
changeset
|
1979 (setq info (yahtml-get-image-info imgfilepath)) |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1980 (car info) ;if has width value |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1981 (car (cdr info)) ;if has height value |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1982 (setq bb (format "bb=%d %d %d %d" 0 0 (car info) (car (cdr info))))) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1983 (save-excursion |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1984 (cond |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1985 ((and (save-excursion |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1986 (YaTeX-re-search-active-backward |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1987 "\\\\\\(includegraphics\\)\\|\\(bb=[-+ \t0-9]+\\)" |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1988 YaTeX-comment-prefix nil t)) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1989 (match-beginning 2) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1990 (not (setq noupdate (equal (YaTeX-match-string 2) bb))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1991 (y-or-n-p (format "Update `bb=' line to `%s'?: " bb))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1992 (message "") |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1993 (replace-match bb)) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1994 (noupdate nil) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1995 ((and (match-beginning 1) |
330 | 1996 (or doclip |
1997 (prog2 | |
1998 (message "Insert `%s'? Y)es N)o C)yes+`clip': " bb) | |
1999 (memq (setq c (read-char)) '(?y ?Y ?\ ?c ?C)) | |
332 | 2000 (setq doclip (memq c '(?c ?C))) |
330 | 2001 (message "")))) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2002 (goto-char (match-end 0)) |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2003 (message "`bb=' %s" |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2004 (format |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2005 (if YaTeX-japan |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2006 "の値はファイル名の上で `%s' を押してファイル名を再入力して更新できます。" |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2007 "values can be update by typing `%s' on file name.") |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2008 (key-description |
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2009 (car (where-is-internal 'YaTeX-change-*))))) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2010 (if (looking-at "\\[") (forward-char 1) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2011 (insert-before-markers "[") |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2012 (setq needclose t)) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2013 (insert-before-markers bb) |
332 | 2014 (if doclip (insert-before-markers ",clip")) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2015 (if needclose (insert-before-markers "]") |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2016 (or (looking-at "\\]") (insert-before-markers ",")))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2017 (t (YaTeX-push-to-kill-ring bb))))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
2018 (setq YaTeX-section-name "caption") |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
2019 imgfile)) |
70 | 2020 |
86 | 2021 (defun YaTeX::verbfile (argp) |
2022 "Add-in for \\verbfile" | |
2023 (YaTeX::include argp "Virbatim File: ")) | |
2024 | |
68 | 2025 (defun YaTeX:caption () |
72 | 2026 (setq YaTeX-section-name "label") |
68 | 2027 nil) |
2028 | |
80 | 2029 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2030 (defvar YaTeX::usepackage-alist-default |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2031 '(("version") ("plext") ("url") ("fancybox") ("pifont") ("longtable") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2032 ("ascmac") ("bm") ("graphics") ("graphicx") ("alltt") ("misc") ("eclbkbox") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2033 ("amsmath") ("amssymb") ("xymtex") ("chemist") |
308
5c0f3d315bf9
Automatic `bb=...' insertion also works on PDF files
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
2034 ("a4j") ("array") ("epsf") ("color") ("xcolor") ("epsfig") ("floatfig") |
80 | 2035 ("landscape") ("path") ("supertabular") ("twocolumn") |
311
f1d2753cb4f1
Completing read in optional argument reader for `includegraphcis'
HIROSE Yuuji <yuuji@gentei.org>
parents:
308
diff
changeset
|
2036 ("latexsym") ("times") ("makeidx") ("geometry") ("type1cm")) |
80 | 2037 "Default completion table for arguments of \\usepackage") |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2038 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2039 (defvar YaTeX::usepackage-alist-private nil |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2040 "*Private completion list of the argument for usepackage") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2041 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2042 (defvar YaTeX::usepackage-alist-local nil |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2043 "Directory local completion list of the argument for usepackage") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2044 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2045 (defun YaTeX::usepackage (&optional argp) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2046 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2047 ((equal argp 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2048 (setq YaTeX-env-name "document") |
80 | 2049 (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map) |
2050 (delim ",")) | |
2051 (YaTeX-cplread-with-learning | |
2052 (if YaTeX-japan "Use package(カンマで区切ってOK): " | |
2053 "Use package(delimitable by comma): ") | |
2054 'YaTeX::usepackage-alist-default | |
2055 'YaTeX::usepackage-alist-private | |
2056 'YaTeX::usepackage-alist-local))))) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2057 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2058 (defun YaTeX::mask (argp) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2059 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2060 ((equal argp 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2061 (read-string "String: ")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2062 ((equal argp 2) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2063 (let (c) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2064 (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2065 (message "Mask type(A..K): ") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2066 (setq c (upcase (read-char)))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2067 (format "%c" c))))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2068 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2069 (defun YaTeX::maskbox (argp) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2070 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2071 ((equal argp 1) |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
2072 (YaTeX:read-length "Width: ")) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2073 ((equal argp 2) |
342
90bdb4173c97
Add-in for wrapfigure and YaTeX:read-length added
HIROSE Yuuji <yuuji@gentei.org>
parents:
340
diff
changeset
|
2074 (YaTeX:read-length "Height: ")) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2075 ((equal argp 3) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2076 (let (c) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2077 (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2078 (message "Mask type(A..K): ") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2079 (setq c (upcase (read-char)))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2080 (format "%c" c))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2081 ((equal argp 4) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2082 (YaTeX:read-oneof "lcr" 'quick)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2083 ((equal argp 5) |
80 | 2084 (read-string "String: ")))) |
2085 | |
2086 (defun YaTeX::textcircled (argp) | |
2087 (cond | |
2088 ((equal argp 1) | |
2089 (let ((char (read-string "Circled char: ")) | |
2090 (left "") (right "") c) | |
2091 (setq c (read-char | |
2092 "Enclose also with (s)mall (t)iny s(C)riptsize (N)one:")) | |
2093 (cond | |
2094 ((memq c '(?s ?S)) (setq left "{\\small " right "}")) | |
2095 ((memq c '(?t ?T)) (setq left "{\\tiny " right "}")) | |
2096 ((memq c '(?c ?C)) (setq left "{\\scriptsize " right "}"))) | |
2097 (format "%s%s%s" left char right))))) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2098 |
68 | 2099 ;;; -------------------- math-mode stuff -------------------- |
2100 (defun YaTeX::tilde (&optional pos) | |
2101 "For accent macros in mathmode" | |
2102 (cond | |
2103 ((equal pos 1) | |
2104 (message "Put accent on variable: ") | |
2105 (let ((v (char-to-string (read-char))) (case-fold-search nil)) | |
2106 (message "") | |
2107 (cond | |
2108 ((string-match "i\\|j" v) | |
2109 (concat "\\" v "math")) | |
2110 ((string-match "[\r\n\t ]" v) | |
2111 "") | |
2112 (t v)))) | |
2113 (nil ""))) | |
2114 | |
2115 (fset 'YaTeX::hat 'YaTeX::tilde) | |
2116 (fset 'YaTeX::check 'YaTeX::tilde) | |
2117 (fset 'YaTeX::bar 'YaTeX::tilde) | |
2118 (fset 'YaTeX::dot 'YaTeX::tilde) | |
2119 (fset 'YaTeX::ddot 'YaTeX::tilde) | |
2120 (fset 'YaTeX::vec 'YaTeX::tilde) | |
2121 | |
2122 (defun YaTeX::widetilde (&optional pos) | |
2123 "For multichar accent macros in mathmode" | |
2124 (cond | |
2125 ((equal pos 1) | |
2126 (let ((m "Put over chars[%s ]: ") v v2) | |
2127 (message m " ") | |
2128 (setq v (char-to-string (read-char))) | |
2129 (message "") | |
2130 (if (string-match "[\r\n\t ]" v) | |
2131 "" | |
2132 (message m v) | |
2133 (setq v2 (char-to-string (read-char))) | |
2134 (message "") | |
2135 (if (string-match "[\r\n\t ]" v2) | |
2136 v | |
2137 (concat v v2))))) | |
2138 (nil ""))) | |
2139 | |
2140 (fset 'YaTeX::widehat 'YaTeX::widetilde) | |
2141 (fset 'YaTeX::overline 'YaTeX::widetilde) | |
2142 (fset 'YaTeX::overrightarrow 'YaTeX::widetilde) | |
2143 | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2144 ; |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2145 ; for \frac{}{} region |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2146 (defun YaTeX::frac-region (beg end) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2147 (if (catch 'done |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2148 (while (re-search-forward "\\s *\\(\\\\over\\|/\\)\\s *" end t) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2149 (goto-char (match-beginning 0)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2150 (if (y-or-n-p |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2151 (format "Replace this `%s' with `}{'" (YaTeX-match-string 0))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2152 (throw 'done t)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2153 (goto-char (match-end 0)))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2154 (let (p (b0 (match-beginning 0)) e0) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2155 (replace-match "}{") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2156 (setq e0 (point)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2157 (save-restriction |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2158 (narrow-to-region beg end) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2159 (goto-char e0) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2160 (skip-chars-forward " \t") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2161 (setq p (point)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2162 (YaTeX-goto-corresponding-paren) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2163 (forward-char 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2164 (skip-chars-forward " \t\r\n") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2165 (if (= end (1+ (point))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2166 (progn |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2167 (goto-char p) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2168 (if (looking-at "\\\\") (forward-char 1)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2169 (YaTeX-kill-paren nil))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2170 (goto-char beg) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2171 (skip-chars-forward " \t") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2172 (setq p (point)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2173 (YaTeX-goto-corresponding-paren) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2174 (forward-char 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2175 (skip-chars-forward " \t\r\n") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2176 (if (>= (point) b0) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2177 (progn |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2178 (goto-char p) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2179 (if (looking-at "\\\\") (forward-char 1)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2180 (YaTeX-kill-paren nil)))))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2181 (message "")) |
68 | 2182 |
80 | 2183 (defun YaTeX::DeclareMathOperator (argp) |
2184 (cond | |
2185 ((equal argp 1) | |
2186 (read-string "Operator: " "\\")))) | |
2187 | |
68 | 2188 ;;; |
2189 ;; Add-in functions for large-type command. | |
2190 ;;; | |
2191 (defun YaTeX:em () | |
2192 (cond | |
2193 ((eq YaTeX-current-completion-type 'large) "\\/") | |
2194 (t nil))) | |
2195 (fset 'YaTeX:it 'YaTeX:em) | |
2196 | |
23 | 2197 ;;; -------------------- End of yatexadd -------------------- |
2198 (provide 'yatexadd) | |
72 | 2199 ; Local variables: |
2200 ; fill-prefix: ";;; " | |
2201 ; paragraph-start: "^$\\|\\|;;;$" | |
2202 ; paragraph-separate: "^$\\|\\|;;;$" | |
80 | 2203 ; coding: sjis |
72 | 2204 ; End: |