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