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