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