Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexpkg.el @ 449:c2c547e147c7 dev
YaTeX-math-other-env-alist-* for additional math-environments
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 17 Jan 2017 22:38:37 +0900 |
parents | 7a9d30752353 |
children | 7bf780961390 |
rev | line source |
---|---|
395 | 1 ;;; yatexpkg.el --- YaTeX package manager -*- coding: sjis -*- |
287 | 2 ;;; |
443 | 3 ;;; (c)2003-2017 by HIROSE, Yuuji [yuuji@yatex.org] |
449
c2c547e147c7
YaTeX-math-other-env-alist-* for additional math-environments
HIROSE Yuuji <yuuji@gentei.org>
parents:
443
diff
changeset
|
4 ;;; Last modified Tue Jan 17 17:42:47 2017 on firestorm |
368 | 5 ;;; $Id$ |
78 | 6 |
287 | 7 ;;; Code: |
80 | 8 (defvar YaTeX-package-ams-envs |
9 (mapcar 'car YaTeX-ams-env-table)) | |
10 | |
78 | 11 (defvar YaTeX-package-alist-default |
193 | 12 '(("version" (env "comment") ;by tsuchiya<at>pine.kuee.kyoto-u.ac.jp |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
13 (section "includeversion" "excludeversion")) |
78 | 14 |
193 | 15 ("plext" (section "bou")) ;by yas.axis<at>ma.mni.ne.jp |
78 | 16 |
193 | 17 ("url" (section "url")) ;by fujieda<at>jaist.ac.jp |
78 | 18 |
19 ("fancybox" (section "shadowbox" "doublebox" "ovalbox" "Ovalbox")) | |
80 | 20 ("slashbox" (section "slashbox" "backslashbox")) |
78 | 21 ("pifont" (section "ding")) |
22 ("longtable" (env "longtable")) | |
23 ("ascmac" (env "screen" "boxnote" "shadebox" "itembox") | |
24 (maketitle "return" "Return" "yen") | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
25 (section "keytop") ("mask") ("maskbox")) |
193 | 26 ("bm" (section "bm")) ;by aoyama<at>le.chiba-u.ac.jp |
78 | 27 |
28 ("alltt" (env "alltt")) | |
29 ("misc" (section "verbfile" "listing")) | |
441
564510b9caca
Add verbatim package for verbatiminput macro
HIROSE Yuuji <yuuji@gentei.org>
parents:
418
diff
changeset
|
30 ("verbatim" (section "verbatiminput")) |
80 | 31 ("eclbkbox" (env "breakbox")) |
32 ("supertabular" (env "supertabular")) | |
33 ("amsmath" (env . YaTeX-package-ams-envs) | |
34 (section "tag" "tag*")) | |
134 | 35 ("amssymb" (maketitle "leqq" "geqq" "mathbb" "mathfrak" |
305
53709ee88448
Add \because and \therefore to math-image completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
304
diff
changeset
|
36 "fallingdotseq" "therefore" "because" |
134 | 37 "lll" "ggg")) ;very few. Please tell us! |
80 | 38 ("graphicx" (section "includegraphics" |
39 "rotatebox" "scalebox" "resizebox" "reflectbox") | |
40 (option . YaTeX-package-graphics-driver-alist)) | |
41 ("color" (section "textcolor" "colorbox" "pagecolor" "color") | |
303
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
42 (option . YaTeX-package-graphics-driver-alist) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
43 (default-option . "usenames,dvipsnames")) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
44 ("xcolor" (same-as . "color")) |
80 | 45 ("ulem" (section "uline" "uuline" "uwave") |
46 (option ("normalem"))) | |
312 | 47 ("multicol" (env "multicols")) |
314
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
48 ("cref" (section "cleveref")) |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
49 ("crefrange" (same-as . "cref")) |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
50 ("cpageref" (same-as . "cref")) |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
51 ("labelcref" (same-as . "cref")) |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
52 ("labelcpageref" (same-as . "cref")) |
346 | 53 ("wrapfig" (env "wrapfigure" "wraptable")) |
418 | 54 ("setspace" (env "spacing") (section "setstretch")) |
449
c2c547e147c7
YaTeX-math-other-env-alist-* for additional math-environments
HIROSE Yuuji <yuuji@gentei.org>
parents:
443
diff
changeset
|
55 ("cases" (env "numcases" "subnumcases")) |
314
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
56 ) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
57 "Default package vs. macro list. |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
58 Alists contains '(PACKAGENAME . MACROLIST) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
59 PACKAGENAME Basename of package(String). |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
60 MACROLIST List of '(TYPE . MACROS) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
61 TYPE One of 'env, 'section or 'maketitle according to completion-type |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
62 MACROS List of macros |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
63 |
80 | 64 If TYPE is 'option, its cdr is alist of completion candidates for that |
65 package. Its cdr can be a symbol whose value is alist. | |
66 | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
78
diff
changeset
|
67 An good example is the value of YaTeX-package-alist-default.") |
78 | 68 |
80 | 69 (defvar YaTeX-package-graphics-driver-alist |
303
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
70 '(("dvips") ("dvipsnames") ("usenames") |
333
30a8f68abe0a
Supply `dvipdfmx' completion instead of `dvipdf'
HIROSE Yuuji <yuuji@gentei.org>
parents:
314
diff
changeset
|
71 ("xdvi") ("dvipdfmx") ("pdftex") ("dvipsone") ("dviwindo") |
80 | 72 ("emtex") ("dviwin") ("oztex") ("textures") ("pctexps") ("pctexwin") |
73 ("pctexhp") ("pctex32") ("truetex") ("tcidvi") ("vtex")) | |
74 "Drivers alist of graphics/color stylefile's supporting deveces. | |
75 This list is taken from | |
76 %% graphics.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz | |
77 %% Copyright (C) 1995 1996 1997 1998 David Carlisle | |
78 as of 2004/1/19. Thanks.") | |
79 | |
78 | 80 (defvar YaTeX-package-alist-private nil |
81 "*User defined package vs. macro list. See also YaTeX-package-alist-default") | |
82 | |
83 (defun YaTeX-package-lookup (macro &optional type) | |
84 "Look up a package which contains a definition of MACRO. | |
85 Optional second argument TYPE limits the macro type. | |
86 TYPE is a symbol, one of 'env, 'section, 'maketitle." | |
87 (let ((list (append YaTeX-package-alist-private YaTeX-package-alist-default)) | |
304
a57f4c74179a
(yatexpkg)YaTeX-package-lookup sees 'same-as entry.
HIROSE Yuuji <yuuji@gentei.org>
parents:
303
diff
changeset
|
88 origlist element x sameas val pkg pkglist r) |
a57f4c74179a
(yatexpkg)YaTeX-package-lookup sees 'same-as entry.
HIROSE Yuuji <yuuji@gentei.org>
parents:
303
diff
changeset
|
89 (setq origlist list) |
78 | 90 (while list |
91 (setq element (car list) | |
92 pkg (car element) | |
93 element (cdr element)) | |
304
a57f4c74179a
(yatexpkg)YaTeX-package-lookup sees 'same-as entry.
HIROSE Yuuji <yuuji@gentei.org>
parents:
303
diff
changeset
|
94 (if (setq sameas (assq 'same-as element)) ;non-recursive retrieval |
a57f4c74179a
(yatexpkg)YaTeX-package-lookup sees 'same-as entry.
HIROSE Yuuji <yuuji@gentei.org>
parents:
303
diff
changeset
|
95 (setq element (cdr (assoc (cdr sameas) origlist)))) |
78 | 96 (if (setq r (catch 'found |
97 (while element | |
80 | 98 (setq x (car element) |
99 val (cdr x)) | |
100 (if (symbolp val) (setq val (symbol-value val))) | |
101 (and (or (null type) | |
78 | 102 (eq type (car x))) |
80 | 103 (YaTeX-member macro val) |
78 | 104 (throw 'found (car x))) ;car x is type |
105 (setq element (cdr element))))) | |
106 (setq pkglist (cons (cons pkg r) pkglist))) | |
107 (setq list (cdr list))) | |
108 pkglist)) | |
109 | |
303
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
110 (defun YaTeX-package-option-lookup (pkg &optional key) |
80 | 111 "Look up options for specified pkg and returne them in alist form. |
303
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
112 Just only associng against the alist of YaTeX-package-alist-*" |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
113 (let*((list (append YaTeX-package-alist-private YaTeX-package-alist-default)) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
114 (l (cdr (assq (or key 'option) (assoc pkg list)))) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
115 (recur (cdr (assq 'same-as (assoc pkg list))))) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
116 (cond |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
117 (recur (YaTeX-package-option-lookup recur key)) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
118 ((symbolp l) (symbol-value l)) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
119 (t l)))) |
80 | 120 |
78 | 121 (defvar YaTeX-package-resolved-list nil |
122 "List of macros whose package is confirmed to be loaded.") | |
123 | |
356
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
124 (defun YaTeX-package-auto-usepackage (macro type &optional autopkg autoopt) |
78 | 125 "(Semi)Automatically add the \\usepackage line to main-file. |
356
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
126 Search the usepackage for MACRO of the TYPE. |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
127 Optional second and third argument AUTOPKG, AUTOOPT are selected |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
128 without query. Thus those two argument (Full)automatically add |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
129 a \\usepackage line." |
78 | 130 (let ((cb (current-buffer)) |
131 (wc (current-window-configuration)) | |
132 (usepackage (concat YaTeX-ec "usepackage")) | |
80 | 133 (pkglist (YaTeX-package-lookup macro type)) |
78 | 134 (usepkgrx (concat |
135 YaTeX-ec-regexp | |
136 "\\(usepackage\\|include\\)\\b")) | |
353
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
346
diff
changeset
|
137 (register (function |
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
346
diff
changeset
|
138 (lambda () (set-buffer cb) |
78 | 139 (set (make-local-variable 'YaTeX-package-resolved-list) |
353
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
346
diff
changeset
|
140 (cons macro YaTeX-package-resolved-list))))) |
78 | 141 (begdoc (concat YaTeX-ec "begin{document}")) |
80 | 142 pb pkg optlist (option "") mb0 uspkgargs) |
78 | 143 (if (or (YaTeX-member macro YaTeX-package-resolved-list) |
144 (null pkglist)) | |
145 nil ;nothing to do | |
146 ;; Search `usepackage' into main-file | |
147 (YaTeX-visit-main t) ;set buffer to parent file | |
148 (setq pb (current-buffer)) | |
149 (save-excursion | |
150 (save-restriction | |
151 (if (catch 'found | |
152 (goto-char (point-min)) | |
153 (YaTeX-search-active-forward ;if search fails, goto eob | |
154 begdoc YaTeX-comment-prefix nil 1) | |
80 | 155 (while ;(YaTeX-re-search-active-backward |
156 ;usepkgrx YaTeX-comment-prefix nil t) | |
157 ;;allow commented out \usepackages 2004/3/16 | |
158 (re-search-backward usepkgrx nil t) | |
78 | 159 (setq mb0 (match-beginning 0)) |
160 (skip-chars-forward "^{") | |
80 | 161 (setq uspkgargs (YaTeX-buffer-substring |
162 (point) | |
163 (progn | |
164 ;;(forward-list 1) is more precise, | |
165 ;; but higher risk. | |
166 (skip-chars-forward "^}\n")(point)))) | |
78 | 167 (let ((pl pkglist)) |
168 (while pl ;(car pl)'s car is package, cdr is type | |
80 | 169 (if (string-match |
170 (concat "[{,]\\s *" | |
171 (regexp-quote (car (car pl))) | |
172 "\\>") | |
173 uspkgargs) | |
78 | 174 (throw 'found t)) |
175 (setq pl (cdr pl))) | |
176 (goto-char mb0)))) | |
177 ;;corresponding \usepackage found | |
178 (funcall register) | |
179 ;; not found, insert it. | |
356
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
180 (if (or |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
181 autopkg |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
182 (y-or-n-p |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
183 (format "`%s' requires package. Put \\usepackage now?" |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
184 macro))) |
78 | 185 (progn |
80 | 186 (require 'yatexadd) |
78 | 187 (setq pkg |
356
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
188 (or autopkg |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
189 (completing-read |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
190 "Load which package?(TAB for list): " |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
191 pkglist nil nil |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
192 ;;initial input |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
193 (if (= (length pkglist) 1) |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
194 (let ((w (car (car pkglist)))) |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
195 (if YaTeX-emacs-19 (cons w 0) w))))) |
80 | 196 optlist |
197 (YaTeX-package-option-lookup pkg)) | |
198 (if optlist | |
199 (let ((minibuffer-completion-table optlist) | |
303
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
200 (delim ",") (w (car (car optlist))) |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
201 (dflt (YaTeX-package-option-lookup |
13a62b7c8354
(yatexpkg)Add default option for package completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
202 pkg 'default-option))) |
80 | 203 (setq option |
356
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
204 (or |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
205 autoopt |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
206 (read-from-minibuffer |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
207 (format "Any option for {%s}?: " pkg) |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
208 (let ((v (or dflt |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
209 (and (= (length optlist) 1) w)))) |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
210 (and v (if YaTeX-emacs-19 (cons v 0) v))) |
af0bd0f86b27
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
211 YaTeX-minibuffer-completion-map)) |
80 | 212 option (if (string< "" option) |
213 (concat "[" option "]") | |
214 "")))) | |
78 | 215 (set-buffer pb) |
216 (goto-char (point-min)) | |
217 (if (YaTeX-re-search-active-forward | |
218 (concat YaTeX-ec-regexp | |
219 "document\\(style\\|class\\){") | |
220 YaTeX-comment-prefix nil t) | |
221 (forward-line 1)) | |
222 (if (YaTeX-search-active-forward | |
223 begdoc YaTeX-comment-prefix nil t) | |
224 (goto-char (match-beginning 0))) | |
225 (insert | |
226 usepackage | |
80 | 227 (format "%s{%s}\t%% required for `\\%s' (yatex added)\n" |
228 option pkg macro)) | |
78 | 229 (funcall register)) |
120
8772bd5d1f02
Do not ask again when user answer n to usepackage addition.
yuuji@gentei.org
parents:
80
diff
changeset
|
230 (funcall register) |
78 | 231 (message "Don't forget to put \\usepackage{%s} yourself later" |
232 (car (car pkglist)))) ;doing car car is negligence... | |
233 )))))) |