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