Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatex.el @ 316:c66a2ddb46e4 dev
Now 'YaTeX-use-AMS-LaTeX is t.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 30 Jan 2014 21:37:46 +0900 |
parents | fae84a98372c |
children | b40fe847c16d |
rev | line source |
---|---|
286 | 1 ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*- |
313 | 2 ;;; (c)1991-2014 by HIROSE Yuuji.[yuuji@yatex.org] |
316
c66a2ddb46e4
Now 'YaTeX-use-AMS-LaTeX is t.
HIROSE Yuuji <yuuji@gentei.org>
parents:
314
diff
changeset
|
3 ;;; Last modified Thu Jan 30 21:36:57 2014 on firestorm |
119
34096706b634
Bind local variable source-window for YaTeX-read-section-with-overview
yuuji@gentei.org
parents:
107
diff
changeset
|
4 ;;; $Id$ |
69 | 5 ;;; The latest version of this software is always available at; |
6 ;;; http://www.yatex.org/ | |
5 | 7 |
286 | 8 ;;; Code: |
3 | 9 (require 'comment) |
64 | 10 (require 'yatexlib) |
316
c66a2ddb46e4
Now 'YaTeX-use-AMS-LaTeX is t.
HIROSE Yuuji <yuuji@gentei.org>
parents:
314
diff
changeset
|
11 (defconst YaTeX-revision-number "1.77.3" |
69 | 12 "Revision number of running yatex.el") |
13 | |
0 | 14 ;---------- Local variables ---------- |
22 | 15 (defvar YaTeX-prefix "\C-c" |
59 | 16 "*Prefix key to call YaTeX functions. |
69 | 17 You can select favorite prefix key by setq in your ~/.emacs.") |
18 | |
11 | 19 (defvar YaTeX-environment-indent 1 |
69 | 20 "*Indentation depth at column width in LaTeX environments.") |
21 | |
64 | 22 (defvar YaTeX-fill-prefix nil |
5 | 23 "*fill-prefix used for auto-fill-mode. |
69 | 24 The default value is nil.") |
25 | |
5 | 26 (defvar YaTeX-fill-column 72 |
69 | 27 "*fill-column used for auto-fill-mode.") |
28 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
29 (defvar YaTeX-comment-prefix "%" |
69 | 30 "TeX comment prefix.") |
31 | |
5 | 32 (defvar YaTeX-current-position-register ?3 |
22 | 33 "*Position register to keep where the last completion was done. |
34 All of YaTeX completing input store the current position into | |
5 | 35 the register YaTeX-current-position-register. So every time you |
52 | 36 make a trip to any other part of text other than you are writing, you can |
13 | 37 return to the editing paragraph by calling register-to-point with argument |
69 | 38 YaTeX-current-position-register.") |
39 | |
18 | 40 ;;(defvar YaTeX-tmp-dic-unit 'main-file |
41 ;; "*Default switching unit of temporary dictionary. | |
42 ;;There are two switching unit: | |
43 ;;'main-file : switch tmp-dic according to main-file directory. | |
44 ;;'directory : switch tmp-dic dir by dir." | |
45 ;;) | |
286 | 46 (defvar YaTeX-use-LaTeX2e t "*Use LaTeX2e or not. Nil means latex 2.09") |
72 | 47 |
48 (defvar tex-command | |
49 (cond | |
50 (YaTeX-use-LaTeX2e "platex") | |
51 (YaTeX-japan "jlatex") | |
52 (t "latex")) | |
69 | 53 "*Default command for typesetting LaTeX text.") |
54 | |
7 | 55 (defvar bibtex-command (if YaTeX-japan "jbibtex" "bibtex") |
69 | 56 "*Default command of BibTeX.") |
57 | |
0 | 58 (defvar dvi2-command ;previewer command for your site |
52 | 59 (if YaTeX-dos "dviout -wait=0" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
60 "xdvi -geo +0+0 -s 4") |
5 | 61 "*Default previewer command including its option. |
69 | 62 This default value is for X window system.") |
63 | |
13 | 64 (defvar makeindex-command (if YaTeX-dos "makeind" "makeindex") |
69 | 65 "*Default makeindex command.") |
66 | |
5 | 67 (defvar dviprint-command-format |
13 | 68 (if YaTeX-dos "dviprt %s %f%t" |
5 | 69 "dvi2ps %f %t %s | lpr") |
22 | 70 "*Command line string to print out current file. |
71 Format string %s will be replaced by the filename. Do not forget to | |
72 specify the `from usage' and `to usage' with their option by format string | |
73 %f and %t. | |
69 | 74 See also documentation of dviprint-from-format and dviprint-to-format.") |
75 | |
5 | 76 (defvar dviprint-from-format |
13 | 77 (if YaTeX-dos "%b-" "-f %b") |
69 | 78 "*`From' page format of dvi filter. %b will turn to beginning page number.") |
79 | |
5 | 80 (defvar dviprint-to-format |
13 | 81 (if YaTeX-dos "%e" "-t %e") |
69 | 82 "*`To' page format of dvi filter. %e will turn to end page number.") |
83 | |
123 | 84 (defvar YaTeX-dvipdf-command |
85 "dvipdfmx" | |
86 "*Command name to convert dvi file to PDF.") | |
87 | |
5 | 88 (defvar YaTeX-default-document-style |
89 (concat (if YaTeX-japan "j") "article") | |
69 | 90 "*Default LaTeX Documentstyle for YaTeX-typeset-region.") |
91 | |
5 | 92 (defvar YaTeX-need-nonstop nil |
69 | 93 "*T for adding `\\nonstopmode{}' to text before invoking latex command.") |
94 | |
0 | 95 (defvar latex-warning-regexp "line.* [0-9]*" |
69 | 96 "*Regular expression of line number of warning message by latex command.") |
97 | |
0 | 98 (defvar latex-error-regexp "l\\.[1-9][0-9]*" |
22 | 99 "*Regular expression of line number of latex error. |
100 Perhaps your latex command stops at this error message with line number of | |
69 | 101 LaTeX source text.") |
102 | |
1 | 103 (defvar latex-dos-emergency-message |
3 | 104 "Emergency stop" ;<- for Micro tex, ASCII-pTeX 1.6 |
22 | 105 "Message pattern of emergency stop of typesetting. |
106 Because Demacs (GNU Emacs on DOS) cannot have concurrent process, the | |
0 | 107 latex command which is stopping on a LaTeX error, is terminated by Demacs. |
13 | 108 Many latex command on DOS display some messages when it is terminated by |
109 other process, user or OS. Define to this variable a message string of your | |
110 latex command on DOS shown at abnormal termination. | |
0 | 111 Remember Demacs's call-process function is not oriented for interactive |
69 | 112 process.") |
113 | |
5 | 114 (defvar NTT-jTeX nil |
64 | 115 "*T for using NTT-jTeX for latex command. |
116 More precisely, setting t to this variables inhibits inter-word break on | |
117 typeset document by line-break of source text. That is, YaTeX automatically | |
118 put % after each line at filling. | |
119 ‰üs+ƒCƒ“ƒfƒ“ƒg‚É‚æ‚Á‚ÄAƒ^ƒCƒvƒZƒbƒgŒã‚ÌŽšŠÔ‚ª‹ó‚¢‚Ä‚µ‚Ü‚¤‚Ì‚ð—}§‚·‚éê‡‚É | |
120 t‚É‚·‚é(ŒÃ‚¢NTT-jTeX‚ÅŒ°’˜‚ÉŒ»‚ê‚é)B‹ï‘Ì“I‚É‚ÍAfill‚·‚é‚Æ‚«‚ÉŠes‚ÌI‚í‚è‚É | |
69 | 121 %‚ð•t‰Á‚·‚éB") |
122 | |
70 | 123 |
64 | 124 (defvar YaTeX-item-regexp |
125 (concat (regexp-quote "\\") "\\(sub\\|bib\\)*item") | |
69 | 126 "*Regular expression of item command.") |
127 | |
7 | 128 (defvar YaTeX-sectioning-regexp |
69 | 129 "\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\)\\(\\*\\|\\b\\)" |
130 "*LaTeX sectioning commands regexp.") | |
131 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
132 (defvar YaTeX-paragraph-start |
59 | 133 (concat "^[ \t]*%\\|^[ \t]*$\\|\\'\\|^\C-l\\|\\\\\\\\$\\|^[ \t]*\\\\\\(" |
13 | 134 YaTeX-sectioning-regexp ;sectioning commands |
7 | 135 "\\|[A-z]*item\\|begin{\\|end{" ;special declaration |
70 | 136 "\\|\\[\\|\\]" |
59 | 137 "\\|newpage\\b\\|vspace\\b" |
7 | 138 "\\)") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
139 "*Paragraph starting regexp of common LaTeX source. Use this value |
69 | 140 for YaTeX-uncomment-paragraph.") |
141 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
142 (defvar YaTeX-paragraph-separate |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
143 (concat "^[ \t]*%\\|^[ \t]*$\\|^\C-l\\|\\\\\\\\$\\|^[ \t]*\\\\\\(" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
144 YaTeX-sectioning-regexp ;sectioning commands |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
145 "\\|begin{\\|end{" ;special declaration |
68 | 146 "\\|\\[\\|\\]" |
59 | 147 "\\|newpage\\b\\|vspace\\b" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
148 "\\)") |
7 | 149 "*Paragraph delimiter regexp of common LaTeX source. Use this value |
69 | 150 for YaTeX-uncomment-paragraph.") |
151 | |
49 | 152 (defvar YaTeX-verbatim-environments |
177
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
176
diff
changeset
|
153 '("verbatim" "verbatim*" "alltt") |
49 | 154 "*Assume these environments of this variable disable LaTeX commands.") |
177
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
176
diff
changeset
|
155 (defvar YaTeX-verb-regexp "verb\\*?\\|path" |
51 | 156 "*Regexp of verb family. Do not contain preceding \\\\ nor \\(\\).") |
49 | 157 (defvar YaTeX-fill-inhibit-environments |
158 (append '("tabular" "tabular*" "array" "picture" "eqnarray" "eqnarray*" | |
307
326bd21ad995
Add 'longtable to array like environment
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
159 "longtable" |
69 | 160 "equation" "equation*" "math" "displaymath") |
49 | 161 YaTeX-verbatim-environments) |
13 | 162 "*In these environments, YaTeX inhibits fill-paragraph from formatting. |
69 | 163 Define those environments as a form of list.") |
164 | |
52 | 165 (defvar YaTeX-itemizing-env-regexp |
64 | 166 "itemize\\|enumerate\\|description\\|list\\|thebibliography" |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
167 "*Regexp of itemizing environments") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
168 (defvar YaTeX-equation-env-regexp |
54 | 169 "array\\*?\\|equation\\*?" |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
170 "*Regexp of environments for equations") |
57 | 171 (defvar YaTeX-array-env-regexp |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
172 (concat |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
173 "array\\*?\\|eqnarray\\*?\\|tabbing\\|tabular\\*?\\|" ;LaTeX |
307
326bd21ad995
Add 'longtable to array like environment
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
174 "longtable\\|" ;LaTeX2e |
69 | 175 "matrix\\|pmatrix\\|bmatrix\\|vmatrix\\|Vmatrix\\|" ;AMS-LaTeX |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
176 "align\\*?\\|split\\*?\\|aligned\\*?\\|alignat\\*?\\|" ;AMS-LaTeX |
68 | 177 "[bpvV]?matrix\\|smallmatrix\\|cases\\|" ;AMS-LaTeX |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
178 "xalignat\\*?\\|xxalignat\\*?") ;AMS-LaTeX |
57 | 179 "*Regexp of environments where `&' becomes field delimiter.") |
11 | 180 (defvar YaTeX-uncomment-once t |
22 | 181 "*T for removing all continuous commenting character(%). |
69 | 182 Nil for removing only one commenting character at the beginning-of-line.") |
183 | |
22 | 184 (defvar YaTeX-close-paren-always t |
69 | 185 "*Close parenthesis always when YaTeX-modify-mode is nil.") |
186 | |
22 | 187 (defvar YaTeX-greek-by-maketitle-completion nil |
69 | 188 "*T for greek letters completion by maketitle-type completion.") |
189 | |
22 | 190 (defvar YaTeX-auto-math-mode t |
191 "*T for changing YaTeX-math mode automatically.") | |
316
c66a2ddb46e4
Now 'YaTeX-use-AMS-LaTeX is t.
HIROSE Yuuji <yuuji@gentei.org>
parents:
314
diff
changeset
|
192 (defvar YaTeX-use-AMS-LaTeX t |
69 | 193 "*T for using AMS-LaTeX") |
194 | |
22 | 195 (defvar yatex-mode-hook nil |
69 | 196 "*List of functions to be called at the end of yatex-mode initializations.") |
197 | |
70 | 198 (defvar YaTeX-search-file-from-top-directory t |
72 | 199 "*Non-nil means to search input-files from the directory where main file exists.") |
200 | |
201 (defvar YaTeX-use-font-lock (and (featurep 'font-lock) | |
202 (fboundp 'x-color-values) | |
203 (fboundp 'font-lock-fontify-region)) | |
204 "*Use font-lock to fontify buffer or not.") | |
205 | |
206 (defvar YaTeX-use-hilit19 (and (featurep 'hilit19) (fboundp 'x-color-values) | |
73 | 207 (fboundp 'hilit-translate) |
208 (not YaTeX-use-font-lock)) | |
72 | 209 "*Use hilit19 to highlight buffer or not.") |
70 | 210 |
82 | 211 (defvar YaTeX-tabular-indentation 4 |
212 "*Indentation column-depth of continueing line in tabular environment.") | |
213 | |
22 | 214 ;;-- Math mode values -- |
215 | |
216 (defvar YaTeX-math-key-list-default | |
217 '((";" . YaTeX-math-sign-alist) | |
52 | 218 (":" . YaTeX-greek-key-alist)) |
69 | 219 "Default key sequence to invoke math-mode's image completion.") |
220 | |
22 | 221 (defvar YaTeX-math-key-list-private nil |
69 | 222 "*User defined alist, math-mode-prefix vs completion alist.") |
223 | |
22 | 224 (defvar YaTeX-math-key-list |
225 (append YaTeX-math-key-list-private YaTeX-math-key-list-default) | |
69 | 226 "Key sequence to invoke math-mode's image completion.") |
227 | |
54 | 228 (defvar YaTeX-skip-default-reader nil |
69 | 229 "Non-nil skips default argument reader of section-type completion.") |
230 | |
54 | 231 (defvar YaTeX-simple-messages nil |
69 | 232 "Non-nil makes minibuffer messages simpler.") |
233 | |
64 | 234 (defvar YaTeX-template-file "~/work/template.tex" |
69 | 235 "*Template TeX source file. This will be inserted to empty file.") |
236 | |
57 | 237 (defvar YaTeX-addin-prefix "YaTeX:") |
73 | 238 |
239 (defvar yatex-mode-abbrev-table nil | |
240 "*Abbrev table in use in yatex-mode buffers.") | |
241 (define-abbrev-table 'yatex-mode-abbrev-table ()) | |
242 | |
243 | |
0 | 244 ;------------ Completion table ------------ |
245 ; Set tex-section-like command possible completion | |
22 | 246 (defvar section-table |
70 | 247 (append |
248 '(("part") ("chapter") ("chapter*") ("section") ("section*") | |
249 ("subsection") ("subsection*") | |
250 ("subsubsection") ("paragraph") ("subparagraph") | |
72 | 251 ("author") ("thanks") ("documentstyle") ("pagestyle") ("thispagestyle") |
70 | 252 ("title") ("underline") ("label") ("makebox") |
253 ("footnote") ("footnotetext") ("index") | |
254 ("hspace*") ("vspace*") ("bibliography") ("bibitem") ("cite") | |
255 ("input") ("include") ("includeonly") ("mbox") ("hbox") ("caption") | |
82 | 256 ("arabic") |
257 ("newcounter") | |
70 | 258 ("newlength") ("setlength" 2) ("addtolength" 2) ("settowidth" 2) |
259 ("setcounter" 2) ("addtocounter" 2) ("stepcounter" 2) | |
260 ("newcommand" 2) ("renewcommand" 2) | |
82 | 261 ("newenvironment" 3) ("newtheorem" 2) |
70 | 262 ("cline") ("framebox") ("savebox" 2) ("sbox" 2) ("newsavebox") ("usebox") |
82 | 263 ("date") ("put") ("ref") ("pageref") ("tabref") ("figref") ("raisebox" 2) |
264 ("multicolumn" 3) ("shortstack") ("parbox" 2) | |
70 | 265 ;; for mathmode accent |
266 ("tilde") ("hat") ("check") ("bar") ("dot") ("ddot") ("vec") | |
267 ("widetilde") ("widehat") ("overline") ("overrightarrow") | |
268 ;; section types in mathmode | |
269 ("frac" 2) ("sqrt") ("mathrm") ("mathbf") ("mathit") | |
314
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
270 ;;cleveref |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
271 ("cref") ("crefrange") ("cpageref") ("labelcref") ("labelcpageref") |
70 | 272 ) |
273 (if YaTeX-use-LaTeX2e | |
274 '(("documentclass") ("usepackage") | |
275 ("textbf") ("textgt") ("textit") ("textmc") ("textmd") ("textnormal") | |
276 ("textrm") ("textsc") ("textsf") ("textsl") ("texttt") ("textup") | |
277 ("mathbf") ("mathcal") ("mathit") ("mathnormal") ("mathrm") | |
278 ("mathsf") ("mathtt") | |
82 | 279 ("textcircled") |
70 | 280 ("scalebox" 1) ;is faking of argument position |
82 | 281 ("rotatebox" 2) ("resizebox" 3) ("reflectbox") |
282 ("colorbox" 2) ("fcolorbox" 3) ("textcolor" 2) ("color") ("pagecolor") | |
70 | 283 ("includegraphics") ("includegraphics*") |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
284 ("bou") ;defined in plext |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
285 ("url") ;defined in url |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
286 ("shadowbox") ("doublebox") ("ovalbox") ("Ovalbox") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
287 ("fancyoval") ;defined in fancybox |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
288 ("keytop") ("mask" 2) ("maskbox" 5) ;defined in ascmac |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
289 ("bm") ;deined in bm |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
290 ("verbfile") ("listing") ;defined in misc |
82 | 291 ("slashbox" 2) ("backslashbox" 2) ;defined in slashbox |
292 )) | |
293 (if YaTeX-use-AMS-LaTeX | |
294 '(("DeclareMathOperator" 2) ("boldsymbol") ("pmb") ("eqref") | |
295 ("tag") ("tag*")))) | |
69 | 296 "Default completion table for section-type completion.") |
297 | |
0 | 298 (defvar user-section-table nil) |
6 | 299 (defvar tmp-section-table nil) |
82 | 300 (defvar YaTeX-ams-math-begin-alist |
301 '(("align") ("align*") ("multline") ("multline*") ("gather") ("gather*") | |
302 ("alignat") ("alignat*") ("xalignat") ("xalignat*") | |
303 ("xxalignat") ("xxalignat*") ("flalign") ("flalign*") ("equation*"))) | |
304 (defvar YaTeX-ams-math-gathering-alist | |
305 '(("matrix") ("pmatrix") ("bmatrix") ("Bmatrix") ("vmatrix") ("Vmatrix") | |
306 ("split") ("split*") ("aligned") ("aligned*") ("alignedat") ("gathered") | |
307 ("smallmatrix") ("cases") ("subequations"))) | |
308 ;; Prepare list(not alist) for YaTeX::ref in yatexadd.el | |
309 (defvar YaTeX-math-begin-list | |
310 (mapcar 'car YaTeX-ams-math-begin-alist)) | |
311 (defvar YaTeX-math-gathering-list ;used in yatexadd.el#yatex::ref | |
312 (mapcar 'car YaTeX-ams-math-gathering-alist)) | |
313 | |
314 | |
315 (defvar YaTeX-ams-env-table | |
316 (append YaTeX-ams-math-begin-alist YaTeX-ams-math-gathering-alist) | |
317 "*Standard AMS-LaTeX(2e) environment completion table.") | |
0 | 318 |
319 ; Set tex-environment possible completion | |
22 | 320 (defvar env-table |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
321 (append |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
322 '(("quote") ("quotation") ("center") ("verse") ("document") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
323 ("verbatim") ("itemize") ("enumerate") ("description") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
324 ("list") ("tabular") ("tabular*") ("table") ("tabbing") ("titlepage") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
325 ("sloppypar") ("picture") ("displaymath") |
240
5ab3322d0f03
Intelligent newline of eqnarray(*) is same as align's.
yuuji@gentei.org
parents:
239
diff
changeset
|
326 ("eqnarray") ("eqnarray*") ("figure") ("equation") ("equation*") |
5ab3322d0f03
Intelligent newline of eqnarray(*) is same as align's.
yuuji@gentei.org
parents:
239
diff
changeset
|
327 ("abstract") ("array") |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
328 ("thebibliography") ("theindex") ("flushleft") ("flushright") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
329 ("minipage") |
82 | 330 ("supertabular") |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
331 ) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
332 (if YaTeX-use-LaTeX2e |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
333 '(("comment") ;defined in version |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
334 ("longtable") ;defined in longtable |
82 | 335 ("screen") ("boxnote") ("shadebox") ;; ("itembox") ;in ascmac |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
336 ("alltt") ;defined in alltt |
82 | 337 ("multicols") ;defined in multicol |
338 ("breakbox"))) ;defined in eclbkbox | |
339 (if YaTeX-use-AMS-LaTeX YaTeX-ams-env-table)) | |
69 | 340 "Default completion table for begin-type completion.") |
341 | |
0 | 342 (defvar user-env-table nil) |
6 | 343 (defvar tmp-env-table nil) |
0 | 344 |
13 | 345 ; Set {\Large }-like completion |
22 | 346 (defvar fontsize-table |
347 '(("rm") ("em") ("bf") ("boldmath") ("it") ("sl") ("sf") ("sc") ("tt") | |
348 ("dg") ("dm") | |
349 ("tiny") ("scriptsize") ("footnotesize") ("small")("normalsize") | |
350 ("large") ("Large") ("LARGE") ("huge") ("Huge") | |
70 | 351 ("rmfamily") ("sffamily") ("ttfamily") |
352 ("mdseries") ("bfseries") ("upshape") | |
353 ("itshape") ("slshape") ("scshape") | |
22 | 354 ) |
69 | 355 "Default completion table for large-type completion.") |
356 | |
70 | 357 (defvar LaTeX2e-fontstyle-alist |
358 '(("rm" . "rmfamily") | |
359 ("sf" . "sffamily") | |
360 ("tt" . "ttfamily") | |
361 ("md" . "mdseries") | |
362 ("bf" . "bfseries") | |
363 ("up" . "upshape") | |
364 ("it" . "itshape") | |
365 ("sl" . "slshape") | |
366 ("sc" . "scshape"))) | |
367 | |
0 | 368 (defvar user-fontsize-table nil) |
6 | 369 (defvar tmp-fontsize-table nil) |
0 | 370 |
22 | 371 (defvar singlecmd-table |
51 | 372 (append |
106
45b54410c794
Add 'par to default maketitle-type completion table.
yuuji@gentei.org
parents:
88
diff
changeset
|
373 '(("maketitle") ("makeindex") ("sloppy") ("protect") ("par") |
70 | 374 ("LaTeX") ("TeX") ("item") ("item[]") ("appendix") ("hline") ("kill") |
54 | 375 ;;("rightarrow") ("Rightarrow") ("leftarrow") ("Leftarrow") |
70 | 376 ("pagebreak") ("nopagebreak") ("tableofcontents") |
68 | 377 ("newpage") ("clearpage") ("cleardoublepage") |
51 | 378 ("footnotemark") ("verb") ("verb*") |
59 | 379 ("linebreak") ("pagebreak") ("noindent") ("indent") |
70 | 380 ("left") ("right") ("dots") ("smallskip") ("medskip") ("bigskip") |
82 | 381 ("displaystyle") |
51 | 382 ) |
383 (if YaTeX-greek-by-maketitle-completion | |
384 '(("alpha") ("beta") ("gamma") ("delta") ("epsilon") | |
385 ("varepsilon") ("zeta") ("eta") ("theta")("vartheta") | |
386 ("iota") ("kappa") ("lambda") ("mu") ("nu") ("xi") ("pi") | |
387 ("varpi") ("rho") ("varrho") ("sigma") ("varsigma") ("tau") | |
388 ("upsilon") ("phi") ("varphi") ("chi") ("psi") ("omega") | |
389 ("Gamma") ("Delta") ("Theta") ("Lambda")("Xi") ("Pi") | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
390 ("Sigma") ("Upsilon") ("Phi") ("Psi") ("Omega"))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
391 (if YaTeX-use-LaTeX2e |
82 | 392 '(("return") ("Return") ("yen"))) ;defined in ascmac |
86 | 393 (if YaTeX-use-AMS-LaTeX |
394 '(("nonumber"))) | |
82 | 395 ) |
69 | 396 "Default completion table for maketitle-type completion.") |
397 | |
0 | 398 (defvar user-singlecmd-table nil) |
6 | 399 (defvar tmp-singlecmd-table nil) |
0 | 400 |
401 ;---------- Key mode map ---------- | |
402 ;;; | |
403 ;; Create new key map: YaTeX-mode-map | |
404 ;; Do not change this section. | |
405 ;;; | |
406 (defvar YaTeX-mode-map nil | |
69 | 407 "Keymap used in YaTeX mode") |
408 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
409 (defvar YaTeX-prefix-map nil |
69 | 410 "Keymap used when YaTeX-prefix key pushed") |
411 | |
54 | 412 (defvar YaTeX-user-extensional-map (make-sparse-keymap) |
413 "*Keymap used for the user's customization") | |
7 | 414 (defvar YaTeX-current-completion-type nil |
69 | 415 "Has current completion type. This may be used in YaTeX addin functions.") |
416 | |
22 | 417 (defvar YaTeX-modify-mode nil |
51 | 418 "*Current editing mode. |
419 When non-nil, each opening parentheses only opens, | |
69 | 420 nil enters both open/close parentheses when opening parentheses key pressed.") |
421 | |
22 | 422 (defvar YaTeX-math-mode nil |
69 | 423 "Holds whether current mode is math-mode.") |
0 | 424 ;;; |
425 ;; Define key table | |
426 ;;; | |
427 (if YaTeX-mode-map | |
428 nil | |
429 (setq YaTeX-mode-map (make-sparse-keymap)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
430 (setq YaTeX-prefix-map (make-sparse-keymap)) |
0 | 431 (define-key YaTeX-mode-map "\"" 'YaTeX-insert-quote) |
5 | 432 (define-key YaTeX-mode-map "{" 'YaTeX-insert-braces) |
22 | 433 (define-key YaTeX-mode-map "(" 'YaTeX-insert-parens) |
7 | 434 (define-key YaTeX-mode-map "$" 'YaTeX-insert-dollar) |
69 | 435 (define-key YaTeX-mode-map "|" 'YaTeX-insert-bar) |
57 | 436 (define-key YaTeX-mode-map "&" 'YaTeX-insert-amper) |
22 | 437 (define-key YaTeX-mode-map "[" 'YaTeX-insert-brackets) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
438 (define-key YaTeX-mode-map YaTeX-prefix YaTeX-prefix-map) |
22 | 439 (define-key YaTeX-mode-map "\M-\C-@" 'YaTeX-mark-environment) |
440 (define-key YaTeX-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment) | |
441 (define-key YaTeX-mode-map "\M-\C-e" 'YaTeX-end-of-environment) | |
442 (define-key YaTeX-mode-map "\M-\C-m" 'YaTeX-intelligent-newline) | |
32
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
443 (define-key YaTeX-mode-map "\C-i" 'YaTeX-indent-line) |
13 | 444 (YaTeX-define-key "%" 'YaTeX-%-menu) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
445 (YaTeX-define-key "t" 'YaTeX-typeset-menu) |
11 | 446 (YaTeX-define-key "w" 'YaTeX-switch-mode-menu) |
5 | 447 (YaTeX-define-key "'" 'YaTeX-prev-error) |
448 (YaTeX-define-key "^" 'YaTeX-visit-main) | |
449 (YaTeX-define-key "4^" 'YaTeX-visit-main-other-window) | |
51 | 450 (YaTeX-define-key "4g" 'YaTeX-goto-corresponding-*-other-window) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
451 (YaTeX-define-key "44" 'YaTeX-switch-to-window) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
452 (and YaTeX-emacs-19 window-system |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
453 (progn |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
454 (YaTeX-define-key "5^" 'YaTeX-visit-main-other-frame) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
455 (YaTeX-define-key "5g" 'YaTeX-goto-corresponding-*-other-frame) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
456 (YaTeX-define-key "55" 'YaTeX-switch-to-window))) |
5 | 457 (YaTeX-define-key " " 'YaTeX-do-completion) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
458 (YaTeX-define-key "v" 'YaTeX-version) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
459 |
5 | 460 (YaTeX-define-key "}" 'YaTeX-insert-braces-region) |
461 (YaTeX-define-key "]" 'YaTeX-insert-brackets-region) | |
11 | 462 (YaTeX-define-key ")" 'YaTeX-insert-parens-region) |
463 (YaTeX-define-key "$" 'YaTeX-insert-dollars-region) | |
5 | 464 (YaTeX-define-key "i" 'YaTeX-fill-item) |
165 | 465 (YaTeX-define-key "\\" |
466 '(lambda () (interactive) | |
467 (insert (if (YaTeX-in-math-mode-p) "\\backslash" "\\textbackslash")))) | |
22 | 468 (if YaTeX-no-begend-shortcut |
469 (progn | |
470 (YaTeX-define-key "B" 'YaTeX-make-begin-end-region) | |
471 (YaTeX-define-key "b" 'YaTeX-make-begin-end)) | |
472 (YaTeX-define-begend-key "bc" "center") | |
473 (YaTeX-define-begend-key "bd" "document") | |
474 (YaTeX-define-begend-key "bD" "description") | |
475 (YaTeX-define-begend-key "be" "enumerate") | |
476 (YaTeX-define-begend-key "bE" "equation") | |
477 (YaTeX-define-begend-key "bi" "itemize") | |
478 (YaTeX-define-begend-key "bl" "flushleft") | |
479 (YaTeX-define-begend-key "bm" "minipage") | |
480 (YaTeX-define-begend-key "bt" "tabbing") | |
481 (YaTeX-define-begend-key "bT" "tabular") | |
482 (YaTeX-define-begend-key "b\^t" "table") | |
483 (YaTeX-define-begend-key "bp" "picture") | |
484 (YaTeX-define-begend-key "bq" "quote") | |
485 (YaTeX-define-begend-key "bQ" "quotation") | |
486 (YaTeX-define-begend-key "br" "flushright") | |
487 (YaTeX-define-begend-key "bv" "verbatim") | |
488 (YaTeX-define-begend-key "bV" "verse") | |
489 (YaTeX-define-key "B " 'YaTeX-make-begin-end-region) | |
490 (YaTeX-define-key "b " 'YaTeX-make-begin-end)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
491 (YaTeX-define-key "e" 'YaTeX-end-environment) |
14 | 492 (YaTeX-define-key "S" 'YaTeX-make-section-region) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
493 (YaTeX-define-key "s" 'YaTeX-make-section) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
494 (YaTeX-define-key "L" 'YaTeX-make-fontsize-region) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
495 (YaTeX-define-key "l" 'YaTeX-make-fontsize) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
496 (YaTeX-define-key "m" 'YaTeX-make-singlecmd) |
22 | 497 (YaTeX-define-key "." 'YaTeX-comment-paragraph) |
498 (YaTeX-define-key "," 'YaTeX-uncomment-paragraph) | |
499 (YaTeX-define-key ">" 'YaTeX-comment-region) | |
500 (YaTeX-define-key "<" 'YaTeX-uncomment-region) | |
5 | 501 (YaTeX-define-key "g" 'YaTeX-goto-corresponding-*) |
502 (YaTeX-define-key "k" 'YaTeX-kill-*) | |
503 (YaTeX-define-key "c" 'YaTeX-change-*) | |
504 (YaTeX-define-key "a" 'YaTeX-make-accent) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
505 (YaTeX-define-key "?" 'YaTeX-help) |
22 | 506 (YaTeX-define-key "/" 'YaTeX-apropos) |
507 (YaTeX-define-key "&" 'YaTeX-what-column) | |
52 | 508 (YaTeX-define-key "d" 'YaTeX-display-hierarchy) |
54 | 509 (YaTeX-define-key "x" YaTeX-user-extensional-map) |
5 | 510 (YaTeX-define-key "n" |
82 | 511 '(lambda () (interactive) |
512 (insert "\\" (if (YaTeX-on-section-command-p "o?oalign") "crcr" "\\")))) | |
13 | 513 (if YaTeX-dos |
7 | 514 (define-key YaTeX-prefix-map "\C-r" |
0 | 515 '(lambda () (interactive) |
182
67b1e094e151
Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents:
181
diff
changeset
|
516 (YaTeX-set-screen-height YaTeX-saved-screen-height) (recenter))))) |
0 | 517 |
49 | 518 (defvar YaTeX-section-completion-map nil |
22 | 519 "*Key map used at YaTeX completion in the minibuffer.") |
49 | 520 (if YaTeX-section-completion-map nil |
521 (setq YaTeX-section-completion-map | |
22 | 522 (copy-keymap (or (and (boundp 'gmhist-completion-map) |
523 gmhist-completion-map) | |
524 minibuffer-local-completion-map))) | |
49 | 525 (define-key YaTeX-section-completion-map |
22 | 526 " " 'YaTeX-minibuffer-complete) |
49 | 527 (define-key YaTeX-section-completion-map |
22 | 528 "\C-i" 'YaTeX-minibuffer-complete) |
49 | 529 (define-key YaTeX-section-completion-map |
22 | 530 "\C-v" 'YaTeX-read-section-with-overview)) |
531 | |
14 | 532 (defvar YaTeX-recursive-map nil |
22 | 533 "*Key map used at YaTeX reading arguments in the minibuffer.") |
14 | 534 (if YaTeX-recursive-map nil |
535 (setq YaTeX-recursive-map (copy-keymap global-map)) | |
82 | 536 (define-key YaTeX-recursive-map YaTeX-prefix YaTeX-prefix-map) |
537 (mapcar | |
538 (function | |
539 (lambda (key) | |
540 (define-key YaTeX-mode-map (car key) 'YaTeX-math-insert-sequence) | |
541 (define-key YaTeX-recursive-map (car key) 'YaTeX-math-insert-sequence))) | |
542 YaTeX-math-key-list)) | |
0 | 543 ;---------- Define other variable ---------- |
72 | 544 (defvar YaTeX-env-name "document" "*Initial tex-environment completion") |
545 (defvar YaTeX-section-name | |
546 (if YaTeX-use-LaTeX2e "documentclass" "documentstyle") | |
547 "*Initial tex-section completion") | |
548 (defvar YaTeX-fontsize-name "large" "*Initial fontsize completion") | |
549 (defvar YaTeX-single-command "maketitle" "*Initial LaTeX single command") | |
13 | 550 (defvar YaTeX-kanji-code (if YaTeX-dos 1 2) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
551 "*File kanji code used by Japanese TeX. |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
552 nil: Do not care (Preserve coding-system) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
553 0: no-converion (mule) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
554 1: Shift JIS |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
555 2: JIS |
86 | 556 3: EUC |
557 4: UTF-8") | |
69 | 558 |
22 | 559 (defvar YaTeX-coding-system nil "File coding system used by Japanese TeX.") |
5 | 560 (cond |
64 | 561 (YaTeX-emacs-20 |
562 (setq YaTeX-coding-system | |
563 (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))) | |
5 | 564 ((boundp 'MULE) |
22 | 565 (setq YaTeX-coding-system |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
566 (symbol-value (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))))) |
64 | 567 |
568 (defvar YaTeX-mode-syntax-table nil | |
569 "*Syntax table for yatex-mode") | |
570 | |
571 (if YaTeX-mode-syntax-table nil | |
572 (setq YaTeX-mode-syntax-table (make-syntax-table (standard-syntax-table))) | |
573 (modify-syntax-entry ?\n " " YaTeX-mode-syntax-table) | |
68 | 574 (modify-syntax-entry ?\{ "(}" YaTeX-mode-syntax-table) |
70 | 575 (modify-syntax-entry ?\} "){" YaTeX-mode-syntax-table) |
576 (modify-syntax-entry ?\t " " YaTeX-mode-syntax-table) | |
577 (modify-syntax-entry ?\f ">" YaTeX-mode-syntax-table) | |
578 (modify-syntax-entry ?\n ">" YaTeX-mode-syntax-table) | |
579 (modify-syntax-entry ?$ "$$" YaTeX-mode-syntax-table) | |
580 (modify-syntax-entry ?% "<" YaTeX-mode-syntax-table) | |
581 (modify-syntax-entry ?\\ "/" YaTeX-mode-syntax-table) | |
582 (modify-syntax-entry ?~ " " YaTeX-mode-syntax-table)) | |
52 | 583 |
14 | 584 ;---------- Provide YaTeX-mode ---------- |
0 | 585 ;;; |
586 ;; Major mode definition | |
587 ;;; | |
588 (defun yatex-mode () | |
7 | 589 " Yet Another LaTeX mode: Major mode for editing input files of LaTeX. |
13 | 590 -You can invoke processes concerning LaTeX typesetting by |
7 | 591 \\[YaTeX-typeset-menu] |
22 | 592 -Complete LaTeX environment form of `\\begin{env} ... \\end{env}' by |
7 | 593 \\[YaTeX-make-begin-end] |
594 -Enclose region into some environment by | |
595 \\[universal-argument] \\[YaTeX-make-begin-end] | |
596 -Complete LaTeX command which takes argument like `\\section{}' by | |
597 \\[YaTeX-make-section] | |
598 -Put LaTeX command which takes no arguments like `\\maketitle' by | |
599 \\[YaTeX-make-singlecmd] | |
600 -Complete font or character size descriptor like `{\\large }' by | |
601 \\[YaTeX-make-fontsize] | |
22 | 602 -Enclose region into those descriptors above by |
7 | 603 \\[universal-argument] \\[YaTeX-make-fontsize] |
54 | 604 -Enter European accent notations by |
7 | 605 \\[YaTeX-make-accent] |
13 | 606 -Toggle various modes of YaTeX by |
607 \\[YaTeX-switch-mode-menu] | |
22 | 608 -Change environt name (on the begin/end line) by |
609 \\[YaTeX-change-*] | |
610 -Kill LaTeX command/environment sequences by | |
611 \\[YaTeX-kill-*] | |
612 -Kill LaTeX command/environment with its contents | |
613 \\[universal-argument] \\[YaTeX-kill-*] | |
614 -Go to corresponding object (begin/end, file, labels) by | |
54 | 615 \\[YaTeX-goto-corresponding-*] or |
616 \\[YaTeX-goto-corresponding-*-other-window] (in other window) | |
617 \\[YaTeX-goto-corresponding-*-other-frame] (in other frame) | |
22 | 618 -Go to main LaTeX source text by |
54 | 619 \\[YaTeX-visit-main] or |
620 \\[YaTeX-visit-main-other-window] (in other window) | |
621 \\[YaTeX-visit-main-other-frame] (in other frame) | |
22 | 622 -Comment out or uncomment region by |
623 \\[YaTeX-comment-region] or \\[YaTeX-uncomment-region] | |
624 -Comment out or uncomment paragraph by | |
625 \\[YaTeX-comment-paragraph] or \\[YaTeX-uncomment-paragraph] | |
626 -Make an \\item entry hang-indented by | |
627 \\[YaTeX-fill-item] | |
628 -Enclose the region with parentheses by | |
629 \\[YaTeX-insert-parens-region] | |
630 \\[YaTeX-insert-braces-region] | |
631 \\[YaTeX-insert-brackets-region] | |
632 \\[YaTeX-insert-dollars-region] | |
633 -Look up the corresponding column header of tabular environment by | |
634 \\[YaTeX-what-column] | |
54 | 635 -Enter a newline and an entry suitable for environment by |
636 \\[YaTeX-intelligent-newline] | |
637 -View the structure of file inclusion by | |
638 \\[YaTeX-display-hierarchy] | |
22 | 639 -Refer the online help of popular LaTeX commands by |
54 | 640 \\[YaTeX-help] (help) |
641 \\[YaTeX-apropos] (apropos) | |
13 | 642 -Edit `%# notation' by |
643 \\[YaTeX-%-menu] | |
7 | 644 |
645 Those are enough for fastening your editing of LaTeX source. But further | |
22 | 646 more features are available and they are documented in the manual. |
647 " | |
0 | 648 (interactive) |
649 (kill-all-local-variables) | |
7 | 650 (setq major-mode 'yatex-mode) |
55 | 651 (setq mode-name (if YaTeX-japan "‚â‚Ä‚Ó" "YaTeX")) |
18 | 652 (mapcar 'make-local-variable |
52 | 653 '(dvi2-command fill-column fill-prefix |
18 | 654 tmp-env-table tmp-section-table tmp-fontsize-table |
52 | 655 tmp-singlecmd-table paragraph-start paragraph-separate |
77 | 656 YaTeX-math-mode indent-line-function comment-line-break-function |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
657 comment-start comment-start-skip |
22 | 658 )) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
659 (cond ((null YaTeX-kanji-code) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
660 nil) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
661 ((boundp 'MULE) |
5 | 662 (set-file-coding-system YaTeX-coding-system)) |
69 | 663 ((and YaTeX-emacs-20 (boundp 'buffer-file-coding-system)) |
72 | 664 (setq buffer-file-coding-system |
665 (or (and (fboundp 'set-auto-coding) buffer-file-name | |
666 (save-excursion | |
82 | 667 (goto-char (point-min)) |
73 | 668 (set-auto-coding buffer-file-name (buffer-size)))) |
72 | 669 YaTeX-coding-system))) |
64 | 670 ((featurep 'mule) |
671 (set-file-coding-system YaTeX-coding-system)) | |
69 | 672 ((boundp 'NEMACS) |
5 | 673 (make-local-variable 'kanji-fileio-code) |
674 (setq kanji-fileio-code YaTeX-kanji-code))) | |
675 (setq fill-column YaTeX-fill-column | |
7 | 676 fill-prefix YaTeX-fill-prefix |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
677 paragraph-start YaTeX-paragraph-start |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
678 paragraph-separate YaTeX-paragraph-separate |
52 | 679 indent-line-function 'YaTeX-indent-line |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
680 comment-start YaTeX-comment-prefix |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
681 comment-end "" |
70 | 682 comment-start-skip "[^\\\\]%+[ \t]*" |
73 | 683 local-abbrev-table yatex-mode-abbrev-table) |
77 | 684 (if (fboundp 'comment-indent-new-line) ;for Emacs21 |
685 (setq comment-line-break-function 'YaTeX-comment-line-break)) | |
686 | |
72 | 687 (if (and YaTeX-use-font-lock (featurep 'font-lock)) |
688 (progn | |
77 | 689 (require 'yatex19) |
72 | 690 (YaTeX-font-lock-set-default-keywords) |
691 (or (featurep 'xemacs) | |
692 (set (make-local-variable 'font-lock-defaults) | |
693 (get 'yatex-mode 'font-lock-defaults))) | |
694 ;;(font-lock-mode 1) | |
695 )) | |
0 | 696 (use-local-map YaTeX-mode-map) |
64 | 697 (set-syntax-table YaTeX-mode-syntax-table) |
182
67b1e094e151
Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents:
181
diff
changeset
|
698 (if YaTeX-dos (setq YaTeX-saved-screen-height (YaTeX-screen-height))) |
6 | 699 (YaTeX-read-user-completion-table) |
73 | 700 (and (fboundp 'YaTeX-hilit-setup-alist) (YaTeX-hilit-setup-alist)) |
70 | 701 (makunbound 'inenv) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
702 (turn-on-auto-fill) ;1.63 |
64 | 703 (and (= 0 (buffer-size)) (file-exists-p YaTeX-template-file) |
704 (y-or-n-p (format "Insert %s?" YaTeX-template-file)) | |
705 (insert-file-contents (expand-file-name YaTeX-template-file))) | |
69 | 706 (run-hooks 'text-mode-hook 'yatex-mode-hook)) |
5 | 707 |
0 | 708 ;---------- Define YaTeX-mode functions ---------- |
13 | 709 (defvar YaTeX-ec "\\" "Escape character of current mark-up language.") |
22 | 710 (defvar YaTeX-ec-regexp (regexp-quote YaTeX-ec)) |
13 | 711 (defvar YaTeX-struct-begin |
712 (concat YaTeX-ec "begin{%1}%2") | |
64 | 713 "Keyword format of begin-environment.") |
714 (defvar YaTeX-struct-end | |
715 (concat YaTeX-ec "end{%1}") | |
716 "Keyword format of end-environment.") | |
217
e59126447ee7
Recognize null environment name as \begin{} ... \end{}.
yuuji@gentei.org
parents:
216
diff
changeset
|
717 (defvar YaTeX-struct-name-regexp "[^}]*" |
13 | 718 "Environment name regexp.") |
22 | 719 (defvar YaTeX-TeX-token-regexp |
82 | 720 (cond (YaTeX-japan "[A-Za-z*‚Ÿ-‚ñˆŸ-êž]+") |
22 | 721 (t "[A-Za-z*]+")) |
722 "Regexp of characters which can be a member of TeX command's name.") | |
82 | 723 (defvar YaTeX-kanji-regexp "[‚Ÿ-‚ñˆŸ-êž]" |
724 "Generic regexp of Japanese Kanji (and symbol) characters.") | |
32
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
725 (defvar YaTeX-command-token-regexp YaTeX-TeX-token-regexp |
51 | 726 "Regexp of characters which can be a member of current mark up language's command name.") |
49 | 727 |
13 | 728 ;;(defvar YaTeX-struct-section |
729 ;; (concat YaTeX-ec "%1{%2}") | |
730 ;; "Keyword to make section.") | |
731 | |
0 | 732 ;;; |
22 | 733 ;; autoload section |
734 ;;; | |
735 | |
736 ;;autoload from yatexprc.el | |
737 (autoload 'YaTeX-visit-main "yatexprc" "Visit main LaTeX file." t) | |
738 (autoload 'YaTeX-visit-main-other-window "yatexprc" | |
52 | 739 "Visit main other window." t) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
740 (autoload 'YaTeX-main-file-p "yatexprc" "Check if the file is main." t) |
51 | 741 (autoload 'YaTeX-get-builtin "yatexprc" "Get %# built-in." t) |
59 | 742 (autoload 'YaTeX-system "yatexprc" "Call system command" t) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
743 (autoload 'YaTeX-save-buffers "yatexprc" "Save buffers of same major mode" t) |
22 | 744 |
745 ;;autoload from yatexmth.el | |
746 (autoload 'YaTeX-math-insert-sequence "yatexmth" "Image input." t) | |
747 (autoload 'YaTeX-in-math-mode-p "yatexmth" "Check if in math-env." t) | |
748 (autoload 'YaTeX-toggle-math-mode "yatexmth" "YaTeX math-mode interfaces." t) | |
52 | 749 (autoload 'YaTeX-math-member-p "yatexmth" "Check if a word is math command." t) |
69 | 750 (autoload 'YaTeX-insert-amsparens-region "yatexmth" "AMS parens region" t) |
751 (autoload 'YaTeX-insert-amsbraces-region "yatexmth" "AMS braces region" t) | |
752 (autoload 'YaTeX-insert-amsbrackets-region "yatexmth" "AMS brackets region" t) | |
753 (autoload 'YaTeX-on-parenthesis-p "yatexmth" "Check if on math-parens" t) | |
754 (autoload 'YaTeX-goto-open-paren "yatexmth" "Goto opening paren" t) | |
755 (autoload 'YaTeX-change-parentheses "yatexmth" "Change corresponding parens" t) | |
77 | 756 (autoload 'YaTeX-goto-corresponding-paren "yatexmth" "\bigl\bigr jumps" t) |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
129
diff
changeset
|
757 (autoload 'YaTeX-typeset-math-region "yatexmth" "Typeset math-region" t) |
22 | 758 |
759 ;;autoload from yatexhlp.el | |
760 (autoload 'YaTeX-help "yatexhlp" "YaTeX helper with LaTeX commands." t) | |
761 (autoload 'YaTeX-apropos "yatexhlp" "Apropos for (La)TeX commands." t) | |
762 | |
763 ;;autoload from yatexgen.el | |
764 (autoload 'YaTeX-generate "yatexgen" "YaTeX add-in function generator." t) | |
765 (autoload 'YaTeX-generate-simple "yatexgen" "YaTeX add-in support." t) | |
766 | |
767 ;;autoload from yatexsec.el | |
69 | 768 (autoload 'YaTeX-section-overview "yatexsec" "YaTeX sectioning(view)" t) |
22 | 769 (autoload 'YaTeX-read-section-in-minibuffer "yatexsec" "YaTeX sectioning" t) |
770 (autoload 'YaTeX-make-section-with-overview "yatexsec" "YaTeX sectioning" t) | |
771 | |
772 ;;autoload from yatexenv.el | |
773 (autoload 'YaTeX-what-column "yatexenv" "YaTeX env. specific funcs" t) | |
774 (autoload 'YaTeX-intelligent-newline "yatexenv" "YaTeX env. specific funcs" t) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
775 (autoload 'YaTeX-indent-line-equation "yatexenv" "Indent equation lines." t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
776 (autoload 'YaTeX-goto-corresponding-leftright "yatexenv" "\left\right jumps" t) |
22 | 777 |
52 | 778 ;;autoload from yatexhie.el |
779 (autoload 'YaTeX-display-hierarchy "yatexhie" | |
780 "YaTeX document hierarchy browser" t) | |
61 | 781 (autoload 'YaTeX-display-hierarchy-directly "yatexhie" |
782 "Same as YaTeX-display-hierarchy. Call from mouse." t) | |
52 | 783 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
784 ;;autoload from yatexpkg.el |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
785 (autoload 'YaTeX-package-auto-usepackage "yatexpkg" "Auto \\usepackage" t) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
786 |
22 | 787 ;;; |
0 | 788 ;; YaTeX-mode functions |
789 ;;; | |
22 | 790 (defun YaTeX-insert-begin-end (env region-mode) |
45 | 791 "Insert \\begin{mode-name} and \\end{mode-name}. |
22 | 792 This works also for other defined begin/end tokens to define the structure." |
7 | 793 (setq YaTeX-current-completion-type 'begin) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
794 (let*((ccol (current-column)) beg beg2 exchange |
22 | 795 (arg region-mode) ;for old compatibility |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
796 (indent-column (+ ccol YaTeX-environment-indent))(i 1) func) |
22 | 797 (if (and region-mode (> (point) (mark))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
798 (progn (exchange-point-and-mark) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
799 (setq exchange t |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
800 ccol (current-column) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
801 indent-column (+ ccol YaTeX-environment-indent)))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
802 ;;VER2 (insert "\\begin{" env "}" (YaTeX-addin env)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
803 (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
804 (YaTeX-insert-struc 'begin env) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
805 (setq beg2 (point)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
806 (insert "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
807 (indent-to indent-column) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
808 (save-excursion |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
809 ;;indent optional argument of \begin{env}, if any |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
810 (while (> (point-beginning-of-line) beg) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
811 (skip-chars-forward "\\s " (point-end-of-line)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
812 (indent-to indent-column) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
813 (forward-line -1))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
814 (require 'yatexenv) |
22 | 815 (if region-mode |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
816 ;;if region-mode, indent all text in the region |
7 | 817 (save-excursion |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
818 (if (fboundp (intern-soft (concat "YaTeX-enclose-" env))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
819 (funcall (intern-soft (concat "YaTeX-enclose-" env)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
820 (point) (mark)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
821 (while (< (progn (forward-line 1) (point)) (mark)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
822 (if (eolp) nil |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
823 (skip-chars-forward " \t\n") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
824 (indent-to indent-column)))))) |
22 | 825 (if region-mode (exchange-point-and-mark)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
826 (indent-to ccol) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
827 ;;VER2 (insert "\\end{" env "}\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
828 (YaTeX-insert-struc 'end env) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
829 (YaTeX-reindent ccol) |
22 | 830 (if region-mode |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
831 (progn |
54 | 832 (insert "\n") |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
833 (or exchange (exchange-point-and-mark))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
834 (goto-char beg2) |
215
a67236df3199
Intelligent-newline should always be called.
yuuji@gentei.org
parents:
212
diff
changeset
|
835 (YaTeX-intelligent-newline nil) |
218
58a023f16e07
Guidance of intelligent-newline shoud check fboundp.
yuuji@fusion.yk.gentei.org
parents:
217
diff
changeset
|
836 (if (fboundp (intern-soft (concat "YaTeX-intelligent-newline-" env))) |
194 | 837 (progn |
838 (message | |
839 (cond | |
840 (YaTeX-japan "%s ‚ÅŽŸ‚Ìs‚Ì“ü—Í‚Éi‚Ý‚Ü‚·B") | |
841 (t "`%s' produces the next line's template.")) | |
842 (key-description | |
843 (car (where-is-internal 'YaTeX-intelligent-newline)))))) | |
64 | 844 (YaTeX-indent-line)) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
845 (YaTeX-package-auto-usepackage env 'env) |
5 | 846 (if YaTeX-current-position-register |
69 | 847 (point-to-register YaTeX-current-position-register)))) |
0 | 848 |
849 (defun YaTeX-make-begin-end (arg) | |
850 "Make LaTeX environment command of \\begin{env.} ... \\end{env.} | |
851 by completing read. | |
852 If you invoke this command with universal argument, | |
5 | 853 \(key binding for universal-argument is \\[universal-argument]\) |
0 | 854 you can put REGION into that environment between \\begin and \\end." |
855 (interactive "P") | |
856 (let* | |
857 ((mode (if arg " region" "")) | |
858 (env | |
5 | 859 (YaTeX-read-environment |
72 | 860 (format "Begin environment%s(default %s): " mode YaTeX-env-name)))) |
0 | 861 (if (string= env "") |
72 | 862 (setq env YaTeX-env-name)) |
863 (setq YaTeX-env-name env) | |
7 | 864 (YaTeX-update-table |
72 | 865 (list YaTeX-env-name) 'env-table 'user-env-table 'tmp-env-table) |
866 (YaTeX-insert-begin-end YaTeX-env-name arg))) | |
0 | 867 |
868 (defun YaTeX-make-begin-end-region () | |
869 "Call YaTeX-make-begin-end with ARG to specify region mode." | |
870 (interactive) | |
69 | 871 (YaTeX-make-begin-end t)) |
0 | 872 |
72 | 873 (defun YaTeX-guess-section-type () |
874 (if (eq major-mode 'yatex-mode) | |
875 (save-excursion | |
876 (cond | |
877 ((save-excursion (not (search-backward YaTeX-ec nil t))) | |
878 (if YaTeX-use-LaTeX2e "documentclass" "documentstyle")) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
879 ((progn |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
880 (if (= (char-after (1- (point))) ?~) (forward-char -1)) |
82 | 881 (forward-char -1) (looking-at "•\\\|}\\|Ž®\\|‘æ")) |
72 | 882 "ref") |
883 ((and (looking-at "[a-z \t]") | |
884 (progn (skip-chars-backward "a-z \t") | |
314
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
885 (looking-at "table\\|figure\\|formula\\|eq\\(\\.\\|uation\\)"))) |
72 | 886 "ref") |
887 ((save-excursion | |
888 (skip-chars-backward "[^ƒA-ƒ“]") | |
889 (looking-at "ƒvƒƒOƒ‰ƒ€\\|ƒŠƒXƒg")) | |
890 "ref") | |
891 ((YaTeX-re-search-active-backward | |
892 (concat YaTeX-ec-regexp "begin{\\([^}]+\\)}") | |
893 (regexp-quote YaTeX-comment-prefix) | |
894 (save-excursion (forward-line -1) (point)) | |
895 t) | |
896 (let ((env (YaTeX-match-string 1))) | |
897 (cdr (assoc env | |
898 '(("table" . "caption")))))) | |
899 )))) | |
900 | |
46 | 901 (defun YaTeX-make-section (arg &optional beg end cmd) |
0 | 902 "Make LaTeX \\section{} type command with completing read. |
13 | 903 With numeric ARG, you can specify the number of arguments of |
0 | 904 LaTeX command. |
905 For example, if you want to produce LaTeX command | |
906 | |
907 \\addtolength{\\topmargin}{8mm} | |
908 | |
5 | 909 which has two arguments. You can produce that sequence by typing... |
0 | 910 ESC 2 C-c s add SPC RET \\topm SPC RET 8mm RET |
911 \(by default\) | |
13 | 912 Then yatex will automatically complete `addtolength' with two arguments |
6 | 913 next time. |
14 | 914 You can complete symbol at LaTeX command and the 1st argument. |
915 | |
916 If the optional 2nd and 3rd argument BEG END are specified, enclose | |
46 | 917 the region from BEG to END into the first argument of the LaTeX sequence. |
918 Optional 4th arg CMD is LaTeX command name, for non-interactive use." | |
6 | 919 (interactive "P") |
7 | 920 (setq YaTeX-current-completion-type 'section) |
68 | 921 (if (equal arg '(4)) (setq beg (region-beginning) end (region-end))) |
14 | 922 (unwind-protect |
923 (let* | |
22 | 924 ((source-window (selected-window)) |
72 | 925 guess |
22 | 926 (section |
46 | 927 (or cmd |
72 | 928 (progn |
929 (setq guess | |
930 (or (YaTeX-guess-section-type) YaTeX-section-name)) | |
931 (YaTeX-read-section | |
932 (if YaTeX-simple-messages | |
933 (format "Section-type (default %s): " guess) | |
934 (if (> (minibuffer-depth) 0) | |
935 (format "%s???{} (default %s)%s: " | |
936 YaTeX-ec guess | |
937 (format "[level:%d]" (minibuffer-depth))) | |
938 (format "(C-v for view-section) %s???{%s} (default %s): " | |
939 YaTeX-ec (if beg "region" "") guess))) | |
940 nil)))) | |
941 (section (if (string= section "") guess section)) | |
14 | 942 (numarg ;; The number of section-type command's argument |
68 | 943 (or (and (numberp arg) arg) |
51 | 944 (nth 1 (YaTeX-lookup-table section 'section)) |
14 | 945 1)) |
946 (arg-reader (intern-soft (concat "YaTeX::" section))) | |
947 (addin-args (and arg-reader (fboundp arg-reader))) | |
948 (title "") | |
54 | 949 (j 1) |
72 | 950 (after-change-functions nil) ;inhibit font-locking temporarily |
82 | 951 (enable-recursive-minibuffers t) |
952 (mkarg-func | |
953 (function | |
954 (lambda (n) | |
955 (while (<= j n) | |
216
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
956 (unwind-protect |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
957 (setq title |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
958 (cond |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
959 (addin-args (funcall arg-reader j)) |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
960 (YaTeX-skip-default-reader "") |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
961 (t |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
962 (read-string |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
963 (format "Argument %d of %s: " j section))))) |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
964 (insert |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
965 (concat ;to allow nil return value |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
966 "{" title "}"))) |
82 | 967 (setq j (1+ j)))))) |
968 );;let | |
72 | 969 (setq YaTeX-section-name section) |
14 | 970 (if beg |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
971 (let*((e (make-marker)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
972 (ar2 (intern-soft (concat "YaTeX::" section "-region"))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
973 (arp (and ar2 (fboundp ar2)))) |
14 | 974 (goto-char end) |
975 (insert "}") | |
976 (set-marker e (point)) | |
977 (goto-char beg) | |
216
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
978 (unwind-protect |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
979 (progn |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
980 (insert YaTeX-ec YaTeX-section-name |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
981 (YaTeX-addin YaTeX-section-name)) |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
982 (if (> numarg 1) (funcall mkarg-func (1- numarg)))) |
c1edf0fbab32
Leave `{}' after C-g at section-type completion.
yuuji@gentei.org
parents:
215
diff
changeset
|
983 (insert "{")) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
984 (if arp (funcall ar2 (point) e)) |
68 | 985 (goto-char e) |
986 (set-marker e nil)) | |
14 | 987 (use-global-map YaTeX-recursive-map) |
72 | 988 (if (= numarg 0) (YaTeX-make-singlecmd YaTeX-section-name) |
989 (progn (insert YaTeX-ec YaTeX-section-name) | |
990 (insert (YaTeX-addin YaTeX-section-name)))) | |
82 | 991 ;;read arguments with add-in |
992 (funcall mkarg-func numarg)) | |
14 | 993 (YaTeX-update-table |
994 (if (/= numarg 1) (list section numarg) | |
995 (list section)) | |
996 'section-table 'user-section-table 'tmp-section-table) | |
997 (if YaTeX-current-position-register | |
998 (point-to-register YaTeX-current-position-register)) | |
165 | 999 (if (string= (YaTeX-buffer-substring (- (point) 2) (point)) |
1000 "{}") | |
1001 (forward-char -1)) | |
1002 (while (string= (YaTeX-buffer-substring (- (point) 3) (1- (point))) | |
1003 "{}") | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1004 (forward-char -2)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1005 (YaTeX-package-auto-usepackage section 'section)) |
72 | 1006 (if (<= (minibuffer-depth) 0) (use-global-map global-map)) |
1007 (insert ""))) ;insert dummy string to fontify(Emacs20) | |
0 | 1008 |
14 | 1009 (defun YaTeX-make-section-region (args beg end) |
1010 "Call YaTeX-make-section with arguments to specify region mode." | |
1011 (interactive "P\nr") | |
69 | 1012 (YaTeX-make-section args beg end)) |
0 | 1013 |
54 | 1014 (defun YaTeX-make-fontsize (arg &optional fontsize) |
0 | 1015 "Make completion like {\\large ...} or {\\slant ...} in minibuffer. |
1016 If you invoke this command with universal argument, you can put region | |
1017 into {\\xxx } braces. | |
5 | 1018 \(key binding for universal-argument is \\[universal-argument]\)" |
0 | 1019 (interactive "P") |
49 | 1020 (YaTeX-sync-local-table 'tmp-fontsize-table) |
0 | 1021 (let* ((mode (if arg "region" "")) |
1022 (fontsize | |
54 | 1023 (or fontsize |
1024 (YaTeX-read-fontsize | |
1025 (if YaTeX-simple-messages | |
72 | 1026 (format "Font or size (default %s): " YaTeX-fontsize-name) |
1027 (format "{\\??? %s} (default %s)%s: " mode YaTeX-fontsize-name | |
54 | 1028 (if (> (minibuffer-depth) 0) |
1029 (format "[level:%d]" (minibuffer-depth)) ""))) | |
1030 nil nil)))) | |
0 | 1031 (if (string= fontsize "") |
72 | 1032 (setq fontsize YaTeX-fontsize-name)) |
68 | 1033 (setq YaTeX-current-completion-type 'large) |
72 | 1034 (setq YaTeX-fontsize-name fontsize) |
6 | 1035 (YaTeX-update-table |
72 | 1036 (list YaTeX-fontsize-name) |
6 | 1037 'fontsize-table 'user-fontsize-table 'tmp-fontsize-table) |
70 | 1038 (and YaTeX-use-LaTeX2e |
1039 (YaTeX-latex2e-p) | |
72 | 1040 (setq fontsize |
1041 (cdr (assoc YaTeX-fontsize-name LaTeX2e-fontstyle-alist))) | |
1042 (setq YaTeX-fontsize-name fontsize)) | |
0 | 1043 (if arg |
1044 (save-excursion | |
1045 (if (> (point) (mark)) (exchange-point-and-mark)) | |
72 | 1046 (insert "{\\" YaTeX-fontsize-name " ") |
0 | 1047 (exchange-point-and-mark) |
1048 (insert "}")) | |
72 | 1049 (insert (concat "{\\" YaTeX-fontsize-name " }")) |
1050 (forward-char -1) | |
5 | 1051 (if YaTeX-current-position-register |
1052 (point-to-register YaTeX-current-position-register)) | |
68 | 1053 (save-excursion |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1054 (insert (YaTeX-addin YaTeX-fontsize-name))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1055 (YaTeX-package-auto-usepackage YaTeX-fontsize-name 'large)))) |
0 | 1056 |
1057 (defun YaTeX-make-fontsize-region () | |
5 | 1058 "Call function:YaTeX-make-fontsize with ARG to specify region mode." |
0 | 1059 (interactive) |
69 | 1060 (YaTeX-make-fontsize t)) |
0 | 1061 |
52 | 1062 (defvar YaTeX-singlecmd-suffix "" "*Suffix for maketitle-type commands.") |
51 | 1063 (defvar YaTeX-read-singlecmd-history nil "Holds maketitle-type history.") |
1064 (put 'YaTeX-read-singlecmd-history 'no-default t) | |
0 | 1065 (defun YaTeX-make-singlecmd (single) |
1066 (interactive | |
49 | 1067 (list (YaTeX-cplread-with-learning |
54 | 1068 (if YaTeX-simple-messages |
72 | 1069 (format "maketitle-type (default %s): " YaTeX-single-command) |
1070 (format "%s??? (default %s)%s: " YaTeX-ec YaTeX-single-command | |
54 | 1071 (if (> (minibuffer-depth) 0) |
1072 (format "[level:%d]" (minibuffer-depth)) ""))) | |
49 | 1073 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table |
51 | 1074 nil nil nil 'YaTeX-read-singlecmd-history))) |
0 | 1075 (if (string= single "") |
72 | 1076 (setq single YaTeX-single-command)) |
1077 (setq YaTeX-single-command single) | |
7 | 1078 (setq YaTeX-current-completion-type 'maketitle) |
54 | 1079 (let ((dollar (and (not (YaTeX-in-math-mode-p)) |
72 | 1080 (YaTeX-math-member-p YaTeX-single-command))) |
54 | 1081 p q) |
1082 (if dollar (insert "$")) | |
72 | 1083 (insert YaTeX-ec YaTeX-single-command) |
52 | 1084 (setq p (point)) |
1085 (insert (YaTeX-addin single) YaTeX-singlecmd-suffix) | |
54 | 1086 (if dollar (insert "$")) |
52 | 1087 (setq q (point)) |
1088 (goto-char p) | |
1089 (forward-char -2) | |
1090 (if (looking-at "\\[\\]") (forward-char 1) (goto-char q))) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1091 (YaTeX-package-auto-usepackage YaTeX-single-command 'maketitle) |
5 | 1092 (if YaTeX-current-position-register |
69 | 1093 (point-to-register YaTeX-current-position-register))) |
0 | 1094 |
1095 (defvar YaTeX-completion-begin-regexp "[{\\]" | |
51 | 1096 "Regular expression of limit where LaTeX command's completion begins.") |
0 | 1097 |
1098 (defun YaTeX-do-completion () | |
1099 "Try completion on LaTeX command preceding point." | |
1100 (interactive) | |
1101 (if | |
1102 (or (eq (preceding-char) ? ) | |
1103 (eq (preceding-char) ?\t) | |
1104 (eq (preceding-char) ?\n) | |
1105 (bobp)) | |
1106 (message "Nothing to complete.") ;Do not complete | |
1107 (let* ((end (point)) | |
6 | 1108 (limit (point-beginning-of-line)) |
0 | 1109 (completion-begin |
6 | 1110 (progn (re-search-backward "[ \t\n]" limit 1) (point))) |
0 | 1111 (begin (progn |
1112 (goto-char end) | |
1113 (if (re-search-backward YaTeX-completion-begin-regexp | |
1114 completion-begin t) | |
1115 (1+ (point)) | |
1116 nil)))) | |
1117 (goto-char end) | |
1118 (cond | |
1119 ((null begin) | |
13 | 1120 (message "I think it is not a LaTeX sequence.")) |
0 | 1121 (t |
49 | 1122 (mapcar 'YaTeX-sync-local-table |
18 | 1123 '(tmp-section-table tmp-env-table tmp-singlecmd-table)) |
165 | 1124 (let*((pattern (YaTeX-buffer-substring begin end)) |
6 | 1125 (all-table |
1126 (append | |
1127 section-table user-section-table tmp-section-table | |
1128 env-table user-env-table tmp-env-table | |
1129 singlecmd-table user-singlecmd-table tmp-singlecmd-table)) | |
1130 ;; First, | |
1131 ;; search completion without backslash. | |
1132 (completion (try-completion pattern all-table))) | |
0 | 1133 (if |
1134 (eq completion nil) | |
1135 ;; Next, | |
1136 ;; search completion with backslash | |
1137 (setq completion | |
165 | 1138 (try-completion |
1139 (YaTeX-buffer-substring (1- begin) end) | |
1140 all-table nil) | |
0 | 1141 begin (1- begin))) |
1142 (cond | |
1143 ((null completion) | |
1144 (message (concat "Can't find completion for '" pattern "'")) | |
1145 (ding)) | |
1146 ((eq completion t) (message "Sole completion.")) | |
1147 ((not (string= completion pattern)) | |
82 | 1148 (delete-region begin end) |
0 | 1149 (insert completion) |
1150 ) | |
1151 (t | |
1152 (message "Making completion list...") | |
1153 (with-output-to-temp-buffer "*Help*" | |
1154 (display-completion-list | |
69 | 1155 (all-completions pattern all-table))))))))))) |
0 | 1156 |
12 | 1157 (defun YaTeX-toggle-modify-mode (&optional arg) |
1158 (interactive "P") | |
1159 (or (memq 'YaTeX-modify-mode mode-line-format) | |
1160 (setq mode-line-format | |
1161 (append (list "" 'YaTeX-modify-mode) mode-line-format))) | |
11 | 1162 (if (or arg (null YaTeX-modify-mode)) |
1163 (progn | |
12 | 1164 (setq YaTeX-modify-mode "*m*") |
11 | 1165 (message "Modify mode")) |
1166 (setq YaTeX-modify-mode nil) | |
1167 (message "Cancel modify mode.")) | |
69 | 1168 (set-buffer-modified-p (buffer-modified-p))) ;redraw mode-line |
11 | 1169 |
46 | 1170 (defun YaTeX-switch-mode-menu (arg &optional char) |
11 | 1171 (interactive "P") |
22 | 1172 (message "Toggle: (M)odify-mode ma(T)h-mode") |
46 | 1173 (let ((c (or char (read-char)))) |
11 | 1174 (cond |
1175 ((= c ?m) (YaTeX-toggle-modify-mode arg)) | |
22 | 1176 ((or (= c ?$) (= c ?t)) |
1177 (if YaTeX-auto-math-mode | |
1178 (message "Makes no sense in YaTeX-auto-math-mode.") | |
69 | 1179 (YaTeX-toggle-math-mode arg)))))) |
11 | 1180 |
0 | 1181 (defun YaTeX-insert-quote () |
1182 (interactive) | |
1183 (insert | |
1184 (cond | |
49 | 1185 ((YaTeX-literal-p) ?\") |
0 | 1186 ((= (preceding-char) ?\\ ) ?\") |
57 | 1187 ;((= (preceding-char) ?\( ) ?\") |
22 | 1188 ((or (= (preceding-char) 32) |
1189 (= (preceding-char) 9) | |
1190 (= (preceding-char) ?\n) | |
1191 (bobp) | |
1192 (string-match | |
57 | 1193 (regexp-quote (char-to-string (preceding-char))) |
1194 "ABCDHIuvwxyz()")) | |
22 | 1195 "``") |
69 | 1196 (t "''")))) |
22 | 1197 |
1198 (defun YaTeX-closable-p () | |
1199 (and (not YaTeX-modify-mode) | |
54 | 1200 (not (eq YaTeX-close-paren-always 'never)) |
22 | 1201 (or YaTeX-close-paren-always (eolp)) |
1202 (not (input-pending-p)) | |
49 | 1203 (not (YaTeX-literal-p))) |
22 | 1204 ;;(or YaTeX-modify-mode |
1205 ;; (and (not YaTeX-close-paren-always) (not (eolp))) | |
1206 ;; (input-pending-p) | |
1207 ;; (YaTeX-quick-in-environment-p "verbatim")) | |
69 | 1208 ) |
0 | 1209 |
5 | 1210 (defun YaTeX-insert-braces-region (beg end &optional open close) |
0 | 1211 (interactive "r") |
1212 (save-excursion | |
1213 (goto-char end) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1214 (YaTeX-insert-inherit (or close "}")) |
0 | 1215 (goto-char beg) |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1216 (YaTeX-insert-inherit (or open "{")))) |
0 | 1217 |
194 | 1218 (defun YaTeX-get-macro-at-point (&optional p) |
1219 "Get (La)TeX macro around point P." | |
1220 (interactive "d") | |
1221 (save-excursion | |
1222 (goto-char (setq p (or p (point)))) | |
198
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1223 (let ((token (substring (substring YaTeX-TeX-token-regexp 1) 0 -2)) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1224 bsend) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1225 (and (not (bobp)) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1226 (or (looking-at YaTeX-TeX-token-regexp) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1227 (string-match |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1228 YaTeX-TeX-token-regexp (char-to-string (preceding-char)))) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1229 (progn |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1230 (skip-chars-backward token) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1231 (equal (preceding-char) ?\\)) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1232 (save-excursion |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1233 (setq bsend (point)) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1234 (skip-chars-backward "\\\\") ;emacs18 doesn't return distance |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1235 (/= (% (- bsend (point)) 2) 0)) ;consider \\ |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1236 (looking-at YaTeX-TeX-token-regexp) |
768ff443ef84
More accurate check for YaTeX-get-macro-at-point.
yuuji@gentei.org
parents:
197
diff
changeset
|
1237 (YaTeX-match-string 0))))) |
194 | 1238 |
49 | 1239 (defun YaTeX-insert-braces (arg &optional open close) |
1240 (interactive "p") | |
194 | 1241 (let ((begend-guide |
1242 (function | |
1243 (lambda () | |
1244 (if (equal (get 'YaTeX-insert-braces 'begend-guide) 2) | |
1245 nil ;if triggered thrice, do nothing | |
1246 (momentary-string-display | |
1247 (format | |
1248 (cond | |
196
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1249 (YaTeX-japan "begin/end“ü—Í‚É‚Í %s ‚ðŽg‚¢‚Ü‚µ‚傤") |
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1250 (t "You don't understand Zen of `%s'!")) |
194 | 1251 (key-description |
1252 (car (where-is-internal 'YaTeX-make-begin-end)))) | |
1253 (point)) | |
1254 (put 'YaTeX-insert-braces 'begend-guide | |
1255 (+ 1 (string-to-int ;increment counter of beg-end guidance | |
1256 (prin1-to-string | |
1257 (get 'YaTeX-insert-braces 'begend-guide))))))))) | |
196
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1258 env macro not-literal b e) |
22 | 1259 (cond |
51 | 1260 ((YaTeX-jmode) (YaTeX-self-insert arg)) |
49 | 1261 ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1262 ((save-excursion |
59 | 1263 (and (> (- (point) (point-min)) 6) |
1264 (condition-case () (forward-char -6) (error nil))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1265 (looking-at "\\\\left\\\\")) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1266 (insert "{\\right\\}") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1267 (forward-char -8)) |
193 | 1268 ((save-excursion ;from matsu<at>math.s.chiba-u.ac.jp |
69 | 1269 (and (> (- (point) (point-min)) 6) (forward-char -6)) |
1270 (looking-at "\\\\[bB]igl\\\\")) | |
1271 (insert | |
1272 (concat | |
1273 "{" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\}")) | |
1274 (forward-char -7)) | |
1275 ((save-excursion | |
1276 (and (> (- (point) (point-min)) 7) | |
1277 (condition-case () (forward-char -7) (error nil))) | |
1278 (looking-at "\\\\[bB]iggl\\\\")) | |
1279 (insert | |
1280 (concat | |
1281 "{" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\}")) | |
1282 (forward-char -8)) | |
1283 ((= (preceding-char) ?\\ ) | |
1284 (insert "{\\}") | |
1285 (forward-char -2)) ;matsu's hack ends here | |
194 | 1286 ((and (setq not-literal (not (YaTeX-literal-p))) |
1287 (equal "end" (setq macro (YaTeX-get-macro-at-point))) | |
22 | 1288 (setq env (YaTeX-inner-environment))) |
194 | 1289 (funcall begend-guide) |
196
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1290 (insert "{" env "}")) |
194 | 1291 ((and not-literal (equal "begin" macro)) |
196
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1292 (insert "{") |
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1293 (save-excursion |
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1294 (indent-to (prog1 (- (current-column) 7) (insert "}\n"))) |
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1295 (insert "\\end{}") |
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1296 (setq e (point))) |
194 | 1297 (setq env |
1298 (YaTeX-read-environment | |
1299 (format "Begin environment(default %s): " YaTeX-env-name))) | |
1300 (if (string= "" env) (setq env YaTeX-env-name)) | |
1301 (setq YaTeX-env-name env) | |
1302 (funcall begend-guide) | |
196
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1303 (delete-region (- (point) 7) e) |
194 | 1304 (YaTeX-insert-begin-end env nil)) |
22 | 1305 (t |
47 | 1306 (insert (or open "{") (or close "}")) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1307 (forward-char -1) |
196
701d87b607e0
The indentation of automatically inserted \end, fixed.
yuuji@gentei.org
parents:
195
diff
changeset
|
1308 (if (and (eq (char-after (point)) ?\}) ;; the case `\\{}' |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1309 (eq (char-after (- (point) 2)) ?\\ )) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1310 (progn (insert "\\") (forward-char -1))) |
69 | 1311 )))) |
22 | 1312 |
1313 (defun YaTeX-jmode () | |
1314 (or (and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) | |
179 | 1315 (and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*) |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1316 (and (boundp 'skk-mode) skk-mode (not skk-latin-mode)) |
179 | 1317 (and (boundp 'default-input-method) default-input-method |
1318 current-input-method))) | |
52 | 1319 |
59 | 1320 (defun YaTeX-jmode-off () |
179 | 1321 (if (cond |
1322 ((and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) | |
1323 (canna-toggle-japanese-mode) t) | |
1324 ((and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*) | |
1325 (egg:toggle-egg-mode-on-off) t) | |
1326 ((and (fboundp 'skk-mode) (boundp 'skk-mode) skk-mode) | |
1327 (cond | |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1328 ((fboundp 'skk-latin-mode) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1329 (or (and (boundp 'skk-henkan-mode) skk-henkan-mode) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1330 (and (boundp 'skk-henkan-on) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1331 (or skk-henkan-mode skk-henkan-active)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1332 (and (boundp 'j-henkan-on) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1333 (or j-henkan-on j-henkan-active)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1334 ;; Deactivate jmode if henkan-mode is not running. |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1335 ;; Suggested by tt.tetsuo.tsukamoto. |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1336 (progn |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1337 (put 'YaTeX-jmode-on 'skkkata skk-katakana) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1338 (skk-latin-mode t)))) |
179 | 1339 ((fboundp 'skk-mode-off) (skk-mode-off)) |
1340 (t (j-mode-off))) | |
1341 t) | |
1342 ((and (fboundp 'toggle-input-method) current-input-method) | |
1343 (toggle-input-method) t) | |
1344 ((and (fboundp 'fep-force-off) (fep-force-off)))) | |
1345 (put 'YaTeX-jmode 'jmode t))) | |
1346 | |
1347 (defun YaTeX-jmode-on () | |
59 | 1348 (cond |
179 | 1349 ((boundp 'canna:*japanese-mode*) |
1350 (if (not canna:*japanese-mode*) (canna-toggle-japanese-mode))) | |
1351 ((boundp 'egg:*mode-on*) | |
1352 (and (not egg:*mode-on*) (not egg:*input-mode*) | |
1353 (egg:toggle-egg-mode-on-off))) | |
1354 ((and (fboundp 'skk-mode) (boundp 'skk-mode)) | |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1355 (if (get 'YaTeX-jmode-on 'skkkata) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1356 (skk-j-mode-on t) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1357 (skk-mode 1)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1358 (put 'YaTeX-jmode-on 'skkkata nil)) |
179 | 1359 ((fboundp 'toggle-input-method) |
1360 (if (not current-input-method) (toggle-input-method))) | |
1361 ((and (fboundp 'fep-force-on) (fep-force-on))))) | |
1362 | |
1363 (defun YaTeX-jmode-back () | |
1364 (if (get 'YaTeX-jmode 'jmode) | |
1365 (YaTeX-jmode-on)) | |
1366 (setplist 'YaTeX-jmode nil)) | |
59 | 1367 |
22 | 1368 (defun YaTeX-self-insert (arg) |
290
1a4332ecc58b
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents:
288
diff
changeset
|
1369 (call-interactively (global-key-binding (char-to-string (YaTeX-last-key))))) |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1370 (defun YaTeX-insert-inherit (&rest args) |
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1371 (apply (if (fboundp 'insert-and-inherit) 'insert-and-inherit 'insert) |
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1372 args)) |
52 | 1373 |
22 | 1374 (defun YaTeX-insert-brackets (arg) |
1375 "Insert Kagi-kakko or \\ [ \\] pair or simply \[." | |
1376 (interactive "p") | |
1377 (let ((col (1- (current-column)))) | |
1378 (cond | |
1379 ((YaTeX-jmode) (YaTeX-self-insert arg)) | |
1380 ((not (YaTeX-closable-p)) | |
1381 (YaTeX-self-insert arg)) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1382 ((save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1383 (and (> (- (point) (point-min)) 5) (forward-char -5)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1384 (looking-at "\\\\left")) |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1385 (YaTeX-insert-inherit "[\\right]") |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1386 (forward-char -7)) |
193 | 1387 ((save-excursion ;from matsu<at>math.s.chiba-u.ac.jp |
69 | 1388 (and (> (- (point) (point-min)) 5) (forward-char -5)) |
1389 (looking-at "\\\\[bB]igl")) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1390 (YaTeX-insert-inherit |
69 | 1391 (concat |
1392 "[" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r]")) | |
1393 (forward-char -6)) | |
1394 ((save-excursion | |
1395 (and (> (- (point) (point-min)) 6) (forward-char -6)) | |
1396 (looking-at "\\\\[bB]iggl")) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1397 (YaTeX-insert-inherit |
69 | 1398 (concat |
1399 "[" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r]")) | |
1400 (forward-char -7)) ;matsu's hack ends here | |
36 | 1401 ((and (= (preceding-char) ?\\ ) |
1402 (/= (char-after (- (point) 2)) ?\\ ) | |
1403 (not (YaTeX-in-math-mode-p))) | |
290
1a4332ecc58b
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents:
288
diff
changeset
|
1404 (YaTeX-insert-inherit (YaTeX-last-key) "\n") |
22 | 1405 (indent-to (max 0 col)) |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1406 (YaTeX-insert-inherit "\\]") |
22 | 1407 (beginning-of-line) |
1408 (open-line 1) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1409 (delete-region (point) (progn (beginning-of-line) (point))) |
22 | 1410 (indent-to (+ YaTeX-environment-indent (max 0 col))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1411 (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1))) |
22 | 1412 ((YaTeX-closable-p) |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1413 (YaTeX-insert-inherit "[]") |
22 | 1414 (backward-char 1)) |
69 | 1415 (t (YaTeX-self-insert arg))))) |
0 | 1416 |
5 | 1417 (defun YaTeX-insert-brackets-region (beg end) |
1418 (interactive "r") | |
69 | 1419 (YaTeX-insert-braces-region beg end "[" "]")) |
5 | 1420 |
22 | 1421 (defun YaTeX-insert-parens (arg) |
1422 "Insert parenthesis pair." | |
1423 (interactive "p") | |
1424 (cond | |
1425 ((YaTeX-jmode) (YaTeX-self-insert arg)) | |
1426 ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1427 ((save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1428 (and (> (- (point) (point-min)) 5) (forward-char -5)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1429 (looking-at "\\\\left")) |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1430 (YaTeX-insert-inherit "(\\right)") |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1431 (forward-char -7)) |
193 | 1432 ((save-excursion ;from matsu<at>math.s.chiba-u.ac.jp |
69 | 1433 (and (> (- (point) (point-min)) 5) (forward-char -5)) |
1434 (looking-at "\\\\[bB]igl")) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1435 (YaTeX-insert-inherit |
69 | 1436 (concat |
1437 "(" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r)")) | |
1438 (forward-char -6)) | |
1439 ((save-excursion | |
1440 (and (> (- (point) (point-min)) 6) (forward-char -6)) | |
1441 (looking-at "\\\\[bB]iggl")) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1442 (YaTeX-insert-inherit |
69 | 1443 (concat |
1444 "(" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r)")) | |
1445 (forward-char -7)) | |
1446 ((= (preceding-char) ?\\ ) ;matsu's hack ends here | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1447 (YaTeX-insert-inherit "(\\)") |
22 | 1448 (backward-char 2)) |
1449 ((YaTeX-closable-p) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1450 (YaTeX-insert-inherit "()") |
22 | 1451 (backward-char 1)) |
69 | 1452 (t (YaTeX-self-insert arg)))) |
22 | 1453 |
11 | 1454 (defun YaTeX-insert-parens-region (beg end) |
1455 (interactive "r") | |
69 | 1456 (YaTeX-insert-braces-region beg end "(" ")")) |
1457 | |
1458 (defun YaTeX-insert-bar (arg) | |
1459 "Insert bar pair." | |
1460 (interactive "p") | |
1461 (cond | |
1462 ((YaTeX-jmode) (YaTeX-self-insert arg)) | |
1463 ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) | |
1464 ((save-excursion | |
1465 (and (> (- (point) (point-min)) 5) (forward-char -5)) | |
1466 (looking-at "\\\\left")) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1467 (YaTeX-insert-inherit "|\\right|") |
69 | 1468 (forward-char -7)) |
193 | 1469 ((save-excursion ;from matsu<at>math.s.chiba-u.ac.jp |
69 | 1470 (and (> (- (point) (point-min)) 5) (forward-char -5)) |
1471 (looking-at "\\\\[bB]igl")) | |
1472 (insert | |
1473 (concat | |
1474 "|" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r|")) | |
1475 (forward-char -6)) | |
1476 ((save-excursion | |
1477 (and (> (- (point) (point-min)) 6) (forward-char -6)) | |
1478 (looking-at "\\\\[bB]iggl")) | |
1479 (insert | |
1480 (concat | |
1481 "|" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r|")) | |
1482 (forward-char -7)) | |
193 | 1483 ((save-excursion ; added by Jin <MAF01011<at>nifty.ne.jp> |
69 | 1484 (and (> (- (point) (point-min)) 6) (forward-char -6)) |
1485 (looking-at "\\\\left\\\\")) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1486 (YaTeX-insert-inherit "|\\right\\|") |
69 | 1487 (forward-char -8)) |
1488 ((save-excursion | |
1489 (and (> (- (point) (point-min)) 6) (forward-char -6)) | |
1490 (looking-at "\\\\[bB]igl\\\\")) | |
1491 (insert | |
1492 (concat | |
1493 "|" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\|")) | |
1494 (forward-char -7)) | |
1495 ((save-excursion | |
1496 (and (> (- (point) (point-min)) 7) (forward-char -7)) | |
1497 (looking-at "\\\\[bB]iggl\\\\")) | |
1498 (insert | |
1499 (concat | |
1500 "|" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\|")) | |
1501 (forward-char -8)) ; added by Jin up to here. | |
1502 ((= (preceding-char) ?\\ ) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1503 (YaTeX-insert-inherit "|\\|") |
69 | 1504 (backward-char 2)) |
1505 ; ((and (YaTeX-closable-p) | |
1506 ; (/= (preceding-char) ?|) | |
1507 ; (/= (following-char) ?|)) | |
184
bdc00b25045d
The text-property for math-mode should be front-sticky and rear-nonsticky.
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
181
diff
changeset
|
1508 ; (YaTeX-insert-inherit "||") |
69 | 1509 ; (backward-char 1)) |
1510 (t (YaTeX-self-insert arg)))) | |
11 | 1511 |
285
032d08cdcca2
Activate YaTeX-use-jmode-hook only if using canna.
HIROSE Yuuji <yuuji@gentei.org>
parents:
282
diff
changeset
|
1512 (defvar YaTeX-use-jmode-hook |
032d08cdcca2
Activate YaTeX-use-jmode-hook only if using canna.
HIROSE Yuuji <yuuji@gentei.org>
parents:
282
diff
changeset
|
1513 (and (featurep 'canna) (boundp 'canna:*initialized*) canna:*initialized*) |
032d08cdcca2
Activate YaTeX-use-jmode-hook only if using canna.
HIROSE Yuuji <yuuji@gentei.org>
parents:
282
diff
changeset
|
1514 ;; (not (and (fboundp 'skk-mode) (boundp 'skk-mode))) |
197 | 1515 "*Non-nil means activate automatic jmode switcher within/out math mode. |
1516 Hopefully, change default to t in the next version of 1.75.") | |
179 | 1517 (defun YaTeX-jmode-hook (old new) |
1518 "A hook controling jmode on/off." | |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1519 ;; This function is called via point-entered/leave hook, so that |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1520 ;; codes in it is evaluated on such emacsen as having text-properties. |
179 | 1521 (let ((inhibit-point-motion-hooks t) |
1522 (oldp (plist-get (text-properties-at old) 'point-left)) | |
1523 (newp (plist-get (text-properties-at new) 'point-left)) | |
1524 (lnew (plist-get (text-properties-at new) 'last-new)) | |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1525 (mjmode (plist-get (text-properties-at new) 'mjmode)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1526 (bmp (buffer-modified-p)) |
179 | 1527 (jm (YaTeX-jmode)) b e) |
181
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1528 (unwind-protect |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1529 (cond |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1530 ((eq lnew new) nil) ;Do nothing if continuous entry |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1531 ((and (not (eq newp 'YaTeX-jmode-hook)) |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1532 (eq oldp 'YaTeX-jmode-hook) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1533 (plist-get (text-properties-at old) 'entered)) |
181
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1534 ;; leave |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1535 (remove-text-properties |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1536 (setq b (1+ (or (previous-single-property-change old 'point-left) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1537 (1- (point))))) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1538 (setq e (1- (or (next-single-property-change old 'point-left) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1539 (1+ (point))))) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1540 (list 'last-new nil 'entered nil)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1541 (add-text-properties b e (list 'mjmode jm)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1542 (if (boundp 'skk-katakana) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1543 (put 'YaTeX-jmode-on 'skkkata skk-katakana)) |
181
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1544 (if (plist-get (text-properties-at old) 'jmode) |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1545 (YaTeX-jmode-on))) |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1546 ((and (not (eq oldp 'YaTeX-jmode-hook)) |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1547 (eq newp 'YaTeX-jmode-hook) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1548 (not (plist-get (text-properties-at new) 'entered))) |
181
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1549 ;; enter |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1550 (add-text-properties |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1551 (1+ (or (previous-single-property-change new 'point-left) |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1552 (1- (point)))) |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1553 (1- (or (next-single-property-change new 'point-left) |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1554 (1+ (point)))) |
186
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1555 (list 'jmode jm 'last-new new 'entered t)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1556 (if (boundp 'skk-katakana) ;care for skk katakana mode |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1557 (put 'YaTeX-jmode-on 'skkkata skk-katakana)) |
61996cd55816
Ensure point-entered/point-left hook should not run continuously.
yuuji@gentei.org
parents:
185
diff
changeset
|
1558 (if mjmode (YaTeX-jmode-on) (YaTeX-jmode-off)))) |
181
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1559 ;;unwind job |
ab7cd5129797
Keep buffer-modified-p in YaTeX-jmode-hook().
yuuji@gentei.org
parents:
179
diff
changeset
|
1560 (set-buffer-modified-p bmp)))) |
179 | 1561 |
0 | 1562 (defun YaTeX-insert-dollar () |
1563 (interactive) | |
22 | 1564 (if (or (not (YaTeX-closable-p)) |
57 | 1565 (= (preceding-char) 92) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1566 (and (YaTeX-in-math-mode-p) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1567 (or (/= (preceding-char) ?$) (/= (following-char) ?$)))) |
7 | 1568 (insert "$") |
1569 (insert "$$") | |
22 | 1570 (forward-char -1) |
197 | 1571 (and YaTeX-use-jmode-hook |
1572 (fboundp 'add-text-properties) | |
1573 (add-text-properties | |
1574 (1- (point)) (1+ (point)) | |
1575 (list 'point-left 'YaTeX-jmode-hook | |
1576 'point-entered 'YaTeX-jmode-hook | |
1577 'front-sticky t | |
1578 'rear-nonsticky t | |
1579 'mjmode nil | |
1580 'jmode (YaTeX-jmode)))) | |
59 | 1581 (YaTeX-jmode-off) |
69 | 1582 (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1)))) |
0 | 1583 |
11 | 1584 (defun YaTeX-insert-dollars-region (beg end) |
1585 (interactive "r") | |
69 | 1586 (YaTeX-insert-braces-region beg end "$" "$")) |
11 | 1587 |
57 | 1588 (defun YaTeX-insert-amper () |
1589 (interactive) | |
1590 (if (or (string-match YaTeX-array-env-regexp | |
1591 (or (YaTeX-inner-environment t) "document")) | |
1592 (= (preceding-char) 92) | |
77 | 1593 (YaTeX-literal-p) |
1594 (YaTeX-in-math-mode-p)) | |
57 | 1595 (insert "&") |
69 | 1596 (insert "\\&"))) |
57 | 1597 |
0 | 1598 (defun YaTeX-version () |
1599 "Return string of the version of running YaTeX." | |
1600 (interactive) | |
1601 (message | |
5 | 1602 (concat "Yet Another tex-mode " |
55 | 1603 (if YaTeX-japan "u–ì’¹v" "`Wild Bird'") |
7 | 1604 " Revision " |
69 | 1605 YaTeX-revision-number))) |
0 | 1606 |
46 | 1607 (defun YaTeX-typeset-menu (arg &optional char) |
1608 "Typeset, preview, visit error and miscellaneous convenient menu. | |
1609 Optional second argument CHAR is for non-interactive call from menu." | |
5 | 1610 (interactive "P") |
7 | 1611 (message |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
129
diff
changeset
|
1612 (concat "J)latex R)egion E)nv B)ibtex mk(I)dx " |
123 | 1613 "latex+p(D)f " |
1614 (if (fboundp 'start-process) "K)ill ") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1615 "P)review " |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1616 (and (boundp 'window-system) window-system "S)earch ") |
123 | 1617 "V)iewErr L)pr")) |
46 | 1618 (let ((sw (selected-window)) (c (or char (read-char)))) |
32
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
1619 (require 'yatexprc) ;for Nemacs's bug |
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
1620 (select-window sw) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1621 (cond |
5 | 1622 ((= c ?j) (YaTeX-typeset-buffer)) |
1623 ((= c ?r) (YaTeX-typeset-region)) | |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
129
diff
changeset
|
1624 ((= c ?e) (YaTeX-typeset-environment)) |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
218
diff
changeset
|
1625 ((= c ?b) (YaTeX-call-builtin-on-file |
227
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
1626 "BIBTEX" bibtex-command arg)) |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
218
diff
changeset
|
1627 ((= c ?i) (YaTeX-call-builtin-on-file |
227
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
1628 "MAKEINDEX" makeindex-command arg)) |
7 | 1629 ((= c ?k) (YaTeX-kill-typeset-process YaTeX-typeset-process)) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1630 ((= c ?p) (call-interactively 'YaTeX-preview)) |
7 | 1631 ((= c ?q) (YaTeX-system "lpq" "*Printer queue*")) |
288
dffc0d979ae0
Use %#DVIPDF on `[prefix] t d'.
HIROSE Yuuji <yuuji@gentei.org>
parents:
286
diff
changeset
|
1632 ((= c ?d) (YaTeX-typeset-buffer |
dffc0d979ae0
Use %#DVIPDF on `[prefix] t d'.
HIROSE Yuuji <yuuji@gentei.org>
parents:
286
diff
changeset
|
1633 (or (YaTeX-get-builtin "DVIPDF") YaTeX-dvipdf-command))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1634 ((= c ?v) (YaTeX-view-error)) |
5 | 1635 ((= c ?l) (YaTeX-lpr arg)) |
13 | 1636 ((= c ?m) (YaTeX-switch-mode-menu arg)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1637 ((= c ?b) (YaTeX-insert-string "\\")) |
69 | 1638 ((= c ?s) (YaTeX-xdvi-remote-search arg))))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1639 |
72 | 1640 (if (fboundp 'wrap-function-to-control-ime) |
1641 (wrap-function-to-control-ime 'YaTeX-typeset-menu t "P")) | |
1642 | |
1643 | |
46 | 1644 (defun YaTeX-%-menu (&optional beg end char) |
13 | 1645 "Operate %# notation." |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
1646 ;;Do not use interactive"r" for the functions which require no mark |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
1647 (interactive) |
231 | 1648 (message "!)Edit-%%#! B)EGIN-END-region P)review L)Edit-%%#LPR make(I)ndex B)ibtex") |
46 | 1649 (let ((c (or char (read-char))) (string "") key |
13 | 1650 (b (make-marker)) (e (make-marker))) |
1651 (save-excursion | |
1652 (cond | |
231 | 1653 ((rindex "!plib" c) ;Edit %#xxx |
227
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
1654 (setq key (cdr (assq c '((?! . "!") |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
1655 (?p . "PREVIEW") |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
1656 (?l . "LPR") |
231 | 1657 (?i . "MAKEINDEX") |
227
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
1658 (?b . "BIBTEX"))))) |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
1659 (YaTeX-getset-builtin key t)) |
13 | 1660 |
1661 ((= c ?b) ;%#BEGIN %#END region | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
1662 (or end (setq beg (min (point) (mark)) end (max (point) (mark)))) |
13 | 1663 (set-marker b beg) |
1664 (set-marker e end) | |
1665 (goto-char (point-min)) | |
1666 (while (re-search-forward "^%#\\(BEGIN\\)\\|\\(END\\)$" nil t) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1667 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1668 (delete-region (point) (progn (forward-line 1) (point)))) |
68 | 1669 (goto-char b) |
13 | 1670 (open-line 1) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1671 (delete-region (point) (progn (beginning-of-line)(point)));for 19 :-< |
13 | 1672 (insert "%#BEGIN") |
68 | 1673 (goto-char e) |
1674 (insert "%#END\n") | |
1675 (set-marker b nil) | |
1676 (set-marker e nil)) | |
69 | 1677 )))) |
13 | 1678 |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1679 (defvar YaTeX-refcommand-def-regexp-default |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1680 "label\\|bibitem") |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1681 (defvar YaTeX-refcommand-def-regexp-private nil |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1682 "*Regexp of defining label commands") |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1683 (defvar YaTeX-refcommand-def-regexp |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1684 (concat (if YaTeX-refcommand-def-regexp-private |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1685 (concat YaTeX-refcommand-def-regexp-private "\\|")) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1686 YaTeX-refcommand-def-regexp-default)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1687 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1688 (defvar YaTeX-refcommand-ref-regexp-default |
314
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
1689 "\\(page\\|eq\\|fig\\)?ref\\|cite" |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
1690 "Regexp of LaTeX's label-referring macros. |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
1691 Searching for this will be done without `\\\\'. |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
1692 So you need not add patterns if new referring macro ends with \"ref\".") |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1693 (defvar YaTeX-refcommand-ref-regexp-private nil |
314
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
1694 "*Regexp of referring label commands. |
fae84a98372c
("crefrange") ("cpageref") ("labelcref") ("labelcpageref") for cleveref
HIROSE Yuuji <yuuji@gentei.org>
parents:
313
diff
changeset
|
1695 See documentation of `YaTeX-refcommand-ref-regexp-default'.") |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1696 (defvar YaTeX-refcommand-ref-regexp |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1697 (concat (if YaTeX-refcommand-ref-regexp-private |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1698 (concat YaTeX-refcommand-ref-regexp-private "\\|")) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1699 YaTeX-refcommand-ref-regexp-default)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1700 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1701 (defvar YaTeX-refcommand-regexp |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1702 (concat YaTeX-refcommand-def-regexp |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1703 "\\|" YaTeX-refcommand-ref-regexp) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1704 "Regexp of label defining/referring command name.") |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1705 |
51 | 1706 (defun YaTeX-goto-corresponding-label (reverse &optional otherwin) |
48 | 1707 "Jump to corresponding \\label{} and \\ref{} or \\cite and \\bibitem. |
1708 The default search direction depends on the command at the cursor position. | |
1709 When the cursor is on \\ref(\\cite), YaTeX will try to search the | |
1710 corresponding \\label(\\bibitem) backward, | |
1711 and if it fails search forward again. And when the cursor is | |
1712 on \\label(\\bibitem), YaTeX will search the corresponding \\ref(\\cite) | |
1713 forward at first and secondary backward. | |
1714 Argument REVERSE non-nil makes the default | |
1715 direction rule reverse. Since Search string is automatically set in | |
13 | 1716 search-last-string, you can repeat search the same label/ref by typing |
51 | 1717 \\[isearch-forward] or \\[isearch-backward]. |
1718 If optional second argument OTHERWIN is non-nil, move to other window." | |
13 | 1719 |
51 | 1720 (let ((scmd "") label direc string blist (p (point)) (cb (current-buffer)) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
166
diff
changeset
|
1721 (refcommands YaTeX-refcommand-regexp) |
82 | 1722 (foundmsg (format "Type %s %c to return to original position." |
1723 (key-description | |
1724 (car | |
1725 (or (where-is-internal 'register-to-point) | |
1726 (where-is-internal 'jump-to-register)))) | |
1727 YaTeX-current-position-register)) | |
48 | 1728 (func (function (lambda (string sfunc) |
1729 (or | |
1730 (funcall sfunc string nil t) | |
68 | 1731 (funcall (if (eq sfunc 're-search-forward) |
1732 're-search-backward 're-search-forward) | |
48 | 1733 string nil t)))))) |
7 | 1734 (cond |
48 | 1735 ((YaTeX-on-section-command-p refcommands) |
82 | 1736 (setq scmd |
1737 (cdr | |
1738 (assoc | |
1739 (YaTeX-match-string 1) | |
1740 '(("label" . "\\\\\\(page\\|eq\\)?ref{%k}") | |
1741 ("ref" . "\\\\label{%k}") | |
1742 ("eqref" . "\\\\label{%k}") | |
1743 ("pageref" . "\\\\label{%k}") | |
1744 ("cite" . | |
1745 "\\\\bibitem\\(\\[[^]]+\\]\\)?{%k}\\|^\\s *@[a-z]+{%k,") | |
1746 ("bibitem" . "\\\\cite\\(\\[[^]]+\\]\\)?"))))) | |
7 | 1747 (goto-char (match-end 0)) |
165 | 1748 (let ((label (YaTeX-buffer-substring |
82 | 1749 (1- (point)) (progn (backward-list 1) (1+ (point))))) |
1750 (fp (make-marker))fl fn | |
1751 (goother (function (lambda (buffer point) | |
1752 (goto-char point) | |
1753 (if (one-window-p) | |
1754 (split-window-calculate-height | |
1755 YaTeX-default-pop-window-height)) | |
1756 (select-window (get-lru-window)) | |
1757 (switch-to-buffer buffer))))) | |
68 | 1758 ;(setq string (concat "\\" scmd "{" label "}")) |
82 | 1759 ;(setq string (concat "\\\\" scmd "{" (regexp-quote label) "}")) |
1760 (setq string (YaTeX-replace-format scmd "k" (regexp-quote label))) | |
48 | 1761 (setq direc (if (string-match "ref\\|cite" scmd) |
68 | 1762 're-search-forward 're-search-backward)) |
48 | 1763 (if YaTeX-current-position-register |
1764 (point-to-register YaTeX-current-position-register)) | |
68 | 1765 (if reverse (setq direc (if (eq direc 're-search-forward) |
1766 're-search-backward 're-search-forward))) | |
48 | 1767 (if (funcall func string direc) ;label/ref found! |
13 | 1768 (progn |
82 | 1769 (if otherwin (funcall goother cb p)) |
13 | 1770 (goto-char (match-beginning 0)) |
51 | 1771 (push-mark p)) |
1772 ;;if label/ref not found, search through all yatex buffers. | |
1773 (goto-char p) ;resume position of current buffer | |
48 | 1774 (catch 'found |
82 | 1775 (setq blist (YaTeX-yatex-buffer-list)) |
48 | 1776 (while blist |
82 | 1777 ;; search for corresponding keyword |
48 | 1778 (set-buffer (car blist)) |
1779 (if (YaTeX-on-section-command-p refcommands) | |
1780 (goto-char (match-beginning 0))) | |
82 | 1781 (cond |
1782 ; cond1 | |
1783 ((funcall func string direc) | |
1784 (cond | |
1785 (otherwin | |
1786 (set-buffer cb) | |
1787 (funcall goother (car blist) p)) | |
1788 ((or (get-buffer-window (car blist)) | |
1789 (and YaTeX-emacs-19 | |
1790 (get-buffer-window (car blist) t))) | |
1791 (goto-buffer-window (car blist))) | |
1792 (t | |
1793 (switch-to-buffer (car blist)) | |
1794 (message foundmsg))) | |
1795 (goto-char (match-beginning 0)) | |
1796 (throw 'found t)) | |
1797 ; cond2 | |
1798 ((and | |
1799 (string-match "bibitem" scmd) | |
1800 (catch 'found2 | |
1801 (save-excursion | |
1802 (goto-char (point-min)) | |
1803 (while (YaTeX-re-search-active-forward | |
1804 "\\\\bibliography{\\([^}]*\\)}" "%" nil t) | |
1805 (setq fl (YaTeX-split-string (YaTeX-match-string 1) ",")) | |
1806 (while fl | |
1807 (if (or (file-exists-p (setq fn (car fl))) | |
1808 (file-exists-p (setq fn (concat fn ".bib")))) | |
1809 (progn | |
1810 (set-buffer (find-file-noselect fn)) | |
1811 (save-excursion | |
1812 (goto-char (point-min)) | |
1813 (if (YaTeX-re-search-active-forward | |
1814 string "%" nil t) | |
1815 (throw 'found2 | |
1816 (set-marker fp (point))))))) | |
1817 (setq fl (cdr fl))))))) | |
1818 (if otherwin | |
1819 (funcall goother (marker-buffer fp) fp) | |
1820 (switch-to-buffer (marker-buffer fp)) | |
1821 (goto-char fp)) | |
1822 (set-marker fp nil) | |
1823 (message foundmsg) | |
1824 (throw 'found t))) | |
1825 (setq blist (cdr blist))) | |
1826 ;; search for bibliography | |
1827 ))) | |
48 | 1828 (if YaTeX-emacs-19 |
68 | 1829 (setq regexp-search-ring |
1830 (cons string (delete string regexp-search-ring))) | |
1831 (setq search-last-regexp string))) | |
69 | 1832 (t nil)))) |
5 | 1833 |
73 | 1834 ;;YaTeX-goto-corresponding-environment was moved to yatexlib |
5 | 1835 |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1836 (defun YaTeX-goto-corresponding-file (&optional other) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1837 "Visit or switch buffer of corresponding file, |
176 | 1838 looking at \\input or \\include or \\includeonly on current line." |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1839 (if (not (YaTeX-on-includes-p)) nil |
70 | 1840 (let ((parent buffer-file-name) input-file b) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1841 (save-excursion |
86 | 1842 (if (and (re-search-forward "[{%]" (point-end-of-line) t) |
1843 (= ?{ (char-after (match-beginning 0)))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1844 nil |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1845 (skip-chars-backward "^,{")) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1846 (setq input-file |
165 | 1847 (YaTeX-buffer-substring |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1848 (point) (progn (skip-chars-forward "^ ,}") (point)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1849 (if (not (string-match "\\.\\(tex\\|sty\\)$" input-file)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1850 (setq input-file (concat input-file ".tex")))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1851 (cond |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1852 (other (YaTeX-switch-to-buffer-other-window input-file)) |
70 | 1853 ((setq b (YaTeX-get-file-buffer input-file)) |
1854 (goto-buffer-window b)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1855 (t (YaTeX-switch-to-buffer input-file))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1856 (or (YaTeX-get-builtin "!") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1857 YaTeX-parent-file |
69 | 1858 (setq YaTeX-parent-file parent))))) |
5 | 1859 |
1860 (defun YaTeX-goto-corresponding-BEGIN-END () | |
1861 (if (not (YaTeX-on-BEGIN-END-p)) nil | |
1862 (if (cond | |
1863 ((equal (match-beginning 0) (match-beginning 1)) ;if on %#BEGIN | |
1864 (not (search-forward "%#END" nil t))) | |
1865 (t ; if on %#END | |
1866 (not (search-backward "%#BEGIN" nil t)))) | |
7 | 1867 (error "Corresponding %%#BEGIN/END not found.")) |
5 | 1868 (beginning-of-line) |
69 | 1869 t)) |
5 | 1870 |
59 | 1871 (defvar YaTeX-processed-file-regexp-alist nil |
1872 "Alist of regexp of processed file regexp vs. its file name part; | |
1873 For example, if you include image file with `\\epsfile{file=FILE}' where | |
1874 `FILE' is processed file. You might want to view FILE with other previewer | |
1875 such as ghostview, or want to preview its source which was drawn with | |
1876 other drawing tool, tgif for example. Then you should set entire regexp | |
1877 of including expression and enclose its file name part with \\\\( and \\\\). | |
1878 | |
1879 Ex. (\"\\\\\\\\epsfile{[^}]*file=\\\\([^,} ]+\\\\)\\\\(\\\\.e?ps\\\\)?[^}]*}\" 1) | |
1880 | |
1881 Where the first group surrounded by \\\\( and \\\\) is the file name part | |
1882 of expression. So you should set 1 to second element. And the first | |
1883 matching group is sent to (image) processor defined by the variable | |
1884 YaTeX-file-processor-alist. See also the documentation of | |
1885 YaTeX-file-processor-alist. | |
1886 | |
1887 ª‚¶‚á—Ç‚‚í‚©‚ñ‚È‚¢‚·‚ËB—Ⴆ‚Î tgif hoge.obj ‚µ‚Ä hoge.eps ‚ð | |
1888 \\epsfile{file=hoge.eps} ‚ŃCƒ“ƒNƒ‹[ƒh‚µ‚Ä‚¢‚é‚Æ‚µ‚悤B‚»‚Ìs‚Å | |
1889 \[prefix\] g ‚ð‰Ÿ‚µ‚½Žž‚É tgif ‚ð‹N“®‚µ‚Ä—~‚µ‚©‚Á‚½‚çA‚Ü‚¸ã‚̂悤‚È | |
1890 ³‹K•\Œ»‚ðÝ’è‚·‚éB\\\\(‚Æ\\\\)‚ň͂ñ‚¾‚Æ‚±‚낪ƒtƒ@ƒCƒ‹–¼‚É‚È‚é‚悤‚É | |
1891 ’ˆÓ‚·‚éB‚Ńtƒ@ƒCƒ‹–¼•”•ª‚ª‰½”Ô–Ú‚Ì\\\\(\\\\)‚É‚È‚é‚©‚ðƒŠƒXƒg‚Ì2”Ô–Ú‚É‘‚B | |
1892 ‚·‚é‚ÆA‚»‚Ì•”•ª‚ª•Ï” YaTeX-file-processor-alist ‚Å’è‹`‚³‚ꂽ | |
1893 ˆ—ƒvƒƒOƒ‰ƒ€‚É“n‚³‚ê‚éB‚Æ‚¢‚¤‚킯B | |
1894 ‚ñ`‚â‚Á‚Ï‚è‚Þ‚¸‚©‚µ‚¢‚ËB•ª‚©‚ç‚È‚¢Žž‚Í—×‚Ì Lisper ‚É•·‚‚©A | |
1895 fj–ì’¹‚̉ï‚Å•·‚±‚¤! | |
1896 ") | |
1897 | |
1898 (defvar YaTeX-processed-file-regexp-alist-default | |
64 | 1899 '(("\\\\epsfile\\(\\[[^]]+\\]\\)?{[^},]*file=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 2) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1900 ("\\\\epsfig{[^},]*fi\\(le\\|gure\\)=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 2) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1901 ("\\\\postscriptbox{[^}]*}{[^}]*}{\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 1) |
274
27aaf7d5e513
Candidate: change default file processor.
HIROSE Yuuji <yuuji@gentei.org>
parents:
271
diff
changeset
|
1902 ("\\\\\\(epsfbox\\|epsfig\\)\\*?{\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 2) ;\epsfbox{hoge.ps} |
275
45350f20793d
Fix regexp for \includegraphics
HIROSE Yuuji <yuuji@koeki-u.ac.jp>
parents:
274
diff
changeset
|
1903 ("\\\\includegraphics\\*?\\(.*\\]\\|\\s \\)?{\\(.*\\)\\(\\.ai\\|\\.pdf\\|\\.svg\\|\\.png\\|\\.jpe?g\\|\\.e?ps\\)}" 2) ;\includegraphics[options...]{hoge.eps} |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1904 ("\\\\\\(psbox\\)\\(\\[[^]]+\\]\\)?{\\(\\([^,} ]*/\\)?[^} ]+\\)\\(\\.e?ps\\)}" 3) ;\psbox[options...]{hoge.eps} (97/1/11) |
68 | 1905 ("\\\\input{\\([^} ]+\\)\\(\\.tps\\)}" 1) ;tgif2tex (1998/9/16) |
59 | 1906 ) |
69 | 1907 "See the documentation of YaTeX-processed-file-regexp-alist.") |
59 | 1908 |
1909 (defvar YaTeX-file-processor-alist nil | |
1910 "*Alist of files' processor vs. its extension; | |
69 | 1911 See also the documentation of YaTeX-processed-file-regexp-alist.") |
274
27aaf7d5e513
Candidate: change default file processor.
HIROSE Yuuji <yuuji@gentei.org>
parents:
271
diff
changeset
|
1912 |
59 | 1913 (defvar YaTeX-file-processor-alist-default |
1914 '(("tgif" . ".obj") | |
274
27aaf7d5e513
Candidate: change default file processor.
HIROSE Yuuji <yuuji@gentei.org>
parents:
271
diff
changeset
|
1915 ("gimp" . ".xcf") ("gimp" . ".xcf.gz") ("gimp" . ".xcf.bz2") |
27aaf7d5e513
Candidate: change default file processor.
HIROSE Yuuji <yuuji@gentei.org>
parents:
271
diff
changeset
|
1916 ("inkscape" . ".svg") ("inkscape" . ".svgz") ("inkscape" . ".ai") |
276
6188dcbf8d2f
Command name of StarOffice derivatives set to soffice
HIROSE Yuuji <yuuji@gentei.org>
parents:
275
diff
changeset
|
1917 ("soffice" . ".odg") |
274
27aaf7d5e513
Candidate: change default file processor.
HIROSE Yuuji <yuuji@gentei.org>
parents:
271
diff
changeset
|
1918 ("gimp" . ".jpeg") ("gimp" . ".jpg") ("gimp" . ".png") |
27aaf7d5e513
Candidate: change default file processor.
HIROSE Yuuji <yuuji@gentei.org>
parents:
271
diff
changeset
|
1919 ("evince" . ".ps") |
27aaf7d5e513
Candidate: change default file processor.
HIROSE Yuuji <yuuji@gentei.org>
parents:
271
diff
changeset
|
1920 ("evince" . ".eps") |
276
6188dcbf8d2f
Command name of StarOffice derivatives set to soffice
HIROSE Yuuji <yuuji@gentei.org>
parents:
275
diff
changeset
|
1921 ("soffice" . ".pdf") |
59 | 1922 (t . ".tex") |
1923 (t . ".sty") | |
1924 (t . "")) | |
69 | 1925 "See the documentation of YaTeX-file-processor-alist.") |
59 | 1926 |
1927 (defun YaTeX-goto-corresponding-file-processor (&optional other) | |
1928 "Execute corresponding file processor." | |
1929 (save-excursion | |
1930 (or (looking-at YaTeX-ec-regexp) | |
1931 (skip-chars-backward (concat "^" YaTeX-ec) (point-beginning-of-line))) | |
1932 (let ((list (append YaTeX-processed-file-regexp-alist | |
1933 YaTeX-processed-file-regexp-alist-default)) | |
1934 (p (point)) flist file | |
70 | 1935 (peol (point-end-of-line)) |
1936 (basedir | |
1937 (if YaTeX-search-file-from-top-directory | |
1938 (save-excursion (YaTeX-visit-main t) default-directory) | |
1939 "."))) | |
59 | 1940 (setq flist (catch 'found |
70 | 1941 (while list |
1942 (goto-char p) | |
1943 (if (re-search-forward (car (car list)) peol t) | |
1944 (progn | |
1945 (setq file (YaTeX-match-string | |
1946 (car (cdr (car list))))) | |
1947 (throw 'found (cdr (car list))))) | |
1948 (setq list (cdr list))))) | |
59 | 1949 (if flist ;if pattern and file name found |
1950 (let*((plist (append YaTeX-file-processor-alist | |
1951 YaTeX-file-processor-alist-default)) | |
1952 (plist0 plist) | |
1953 ext cmd src buf (alt (car (cdr flist)))) | |
1954 (if (and (re-search-forward | |
1955 (concat YaTeX-comment-prefix "\\s *\\(.*\\)$") peol t) | |
1956 (assoc (setq cmd (YaTeX-match-string 1)) | |
1957 YaTeX-file-processor-alist)) | |
1958 (setq src ;if processor is specified | |
1959 (concat file | |
1960 (cdr (assoc cmd YaTeX-file-processor-alist)))) | |
1961 (while plist ;if processor is not specified | |
1962 (setq ext (cdr (car plist))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1963 (if (and (string< "" (concat file ext)) |
70 | 1964 (file-exists-p |
1965 (expand-file-name (concat file ext) basedir))) | |
1966 (setq cmd (car (car plist)) | |
1967 src (concat file ext) plist nil)) | |
59 | 1968 (setq plist (cdr plist))) |
1969 (if (and (null src) alt YaTeX-create-file-prefix-g) | |
1970 (setq cmd alt | |
1971 src (concat file (cdr (assoc alt plist0)))))) | |
70 | 1972 (if src ;if processor and src file found |
1973 (let ((default-directory basedir)) | |
59 | 1974 (cond |
70 | 1975 ((stringp cmd) |
1976 (let ((buf (concat "* " cmd " " src " *"))) | |
1977 (YaTeX-system (concat cmd " " src) buf) | |
1978 t)) | |
1979 ((eq t cmd) | |
1980 (let ((parent buffer-file-name)) | |
1981 (funcall | |
1982 (cond | |
1983 (other 'YaTeX-switch-to-buffer-other-window) | |
1984 ((get-file-buffer src) 'goto-buffer-window) | |
1985 (t 'YaTeX-switch-to-buffer)) | |
1986 src) | |
1987 (or (YaTeX-get-builtin "!") | |
1988 YaTeX-parent-file | |
1989 (setq YaTeX-parent-file parent)) | |
1990 t)) | |
1991 ((symbolp cmd) | |
1992 (cond | |
1993 ((symbol-function cmd) | |
1994 (funcall cmd src other))) | |
1995 t))))))))) | |
59 | 1996 |
14 | 1997 (defun YaTeX-on-section-command-p (command) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1998 "Check if point is on the LaTeX command: COMMAND(regexp). |
49 | 1999 Return nil if point is not on it. Otherwise return the |
2000 number of argument position. | |
82 | 2001 Section command name is stored in match-data #1. |
2002 Parsing information is stored to plist. | |
2003 Macros name stored to propname 'command. | |
2004 Macro's argument number stored to propname 'argc." | |
2005 (let ((p (point)) md (parg 0) (argc 1) word (grouping 0) (i 0) | |
2006 (ec+command (concat YaTeX-ec-regexp "\\(" command "\\)"))) | |
2007 (setplist 'YaTeX-on-section-command-p nil) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2008 (while (setq i (string-match "\\\\(" command i)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2009 (setq grouping (1+ grouping) i (+ i 2))) |
7 | 2010 (save-excursion |
82 | 2011 (if (looking-at ec+command) nil |
49 | 2012 (catch 'found ;caught value has no meaning |
77 | 2013 ;;(1) looking at current position |
82 | 2014 (and (looking-at command) |
2015 (save-excursion | |
2016 (while (and (not (bobp)) (looking-at command)) | |
2017 (forward-char -1)) | |
2018 (looking-at ec+command)) | |
2019 (goto-char (match-beginning 0)) | |
2020 (throw 'found t)) | |
245
8ad85ce1ee98
YaTeX-on-section-command-p tries to escape parentheses.
yuuji@gentei.org
parents:
240
diff
changeset
|
2021 ;;If inside of parentheses, try to escape. |
8ad85ce1ee98
YaTeX-on-section-command-p tries to escape parentheses.
yuuji@gentei.org
parents:
240
diff
changeset
|
2022 (while (condition-case err |
8ad85ce1ee98
YaTeX-on-section-command-p tries to escape parentheses.
yuuji@gentei.org
parents:
240
diff
changeset
|
2023 (progn (up-list -1) t) |
8ad85ce1ee98
YaTeX-on-section-command-p tries to escape parentheses.
yuuji@gentei.org
parents:
240
diff
changeset
|
2024 (error nil))) |
8ad85ce1ee98
YaTeX-on-section-command-p tries to escape parentheses.
yuuji@gentei.org
parents:
240
diff
changeset
|
2025 (while (equal (preceding-char) ?\]) (backward-list)) |
77 | 2026 ;;(2) search command directly |
2027 (skip-chars-forward "^{}[]") | |
2028 (and (YaTeX-re-search-active-backward | |
82 | 2029 ec+command |
2030 YaTeX-comment-prefix nil t) | |
77 | 2031 (>= p (match-beginning 0)) |
2032 (throw 'found (goto-char (match-beginning 0)))) | |
2033 ;;(3) search token | |
2034 (goto-char p) | |
49 | 2035 (while t |
2036 (if (bobp) (throw 'found nil)) | |
2037 (cond | |
2038 ((looking-at YaTeX-ec-regexp) (throw 'found t)) | |
2039 ((looking-at "[[{]") nil) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2040 ((looking-at "[]}]")(condition-case nil (up-list -1) (error nil))) |
49 | 2041 (t (skip-chars-backward " \t\r\n"))) |
2042 (skip-chars-backward (concat "^ \t\r\n{}[]" YaTeX-ec-regexp)) | |
51 | 2043 (or (bobp) (forward-char -1))))) |
2044 (if (and | |
82 | 2045 (looking-at (concat ec+command |
2046 "\\(\\(\\[[^]]+\\]\\|([0-9,]+)\\)*\\)" ;optional arg | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2047 ;"[ \t\n\r]*{[^}]+}")) ;arg braces |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2048 "[ \t\n\r]*{[^}]*}")) ;arg braces |
51 | 2049 (not (YaTeX-lookup-table |
2050 (setq word (YaTeX-match-string 1)) 'singlecmd))) | |
46 | 2051 (progn |
49 | 2052 (setq md (match-data)) |
2053 (skip-chars-forward "^{") | |
2054 (if (<= (point) p) (setq parg (1+ parg))) | |
2055 (setq argc | |
51 | 2056 (or (car (cdr (YaTeX-lookup-table word 'section))) |
49 | 2057 argc)) |
82 | 2058 (put 'YaTeX-on-section-command-p 'argc argc) |
2059 (put 'YaTeX-on-section-command-p 'command argc) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2060 (while (and (>= (setq argc (1- argc)) 0) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2061 (progn (skip-chars-forward " \t\n\r") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2062 (looking-at "{"))) |
49 | 2063 (forward-list 1) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2064 (if (<= (point) p) (setq parg (1+ parg)))) |
49 | 2065 (store-match-data md) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2066 (setq i (+ 2 grouping)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2067 (if (and (match-beginning i) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2068 (>= p (match-beginning i)) (< p (match-end i))) |
49 | 2069 -1 ;return -1 if point is on optional arg |
2070 (if (< p (point)) parg)) | |
69 | 2071 ))))) |
5 | 2072 |
52 | 2073 (defun YaTeX-on-maketitle-p () |
2074 "Check if point is on maketitle type commands. | |
2075 Call this function after YaTeX-on-section-command-p." | |
2076 (let ((p (point))) | |
2077 (save-excursion | |
2078 (or (= (char-after (point)) ?\\ ) | |
2079 (progn | |
2080 (skip-chars-backward | |
2081 (concat "^" YaTeX-ec-regexp) (point-beginning-of-line)) | |
2082 (or (bobp) (bolp) (backward-char 1)))) | |
2083 (and (looking-at (concat YaTeX-ec-regexp YaTeX-TeX-token-regexp)) | |
2084 (<= (match-beginning 0) p) | |
2085 (> (match-end 0) p))))) | |
2086 | |
5 | 2087 (defun YaTeX-on-begin-end-p () |
2088 (save-excursion | |
77 | 2089 (if (and (boundp 'in-leftright-p) in-leftright-p) |
2090 ;; Dirty workaround for YaTeX-goto-corresponding-leftright 2003/3/28 | |
2091 (let ((md (match-data))) ; for safety | |
2092 (if (looking-at YaTeX-ec-regexp) | |
2093 nil ; stay here | |
2094 (cond | |
2095 ((looking-at "\\w") (skip-chars-backward "A-Za-z")) | |
2096 ((looking-at "\\.()\\[\\]|") (forward-char -1))) | |
2097 (if (equal (char-after (1- (point))) | |
2098 (string-to-char YaTeX-ec)) | |
2099 (forward-char -1)))) | |
82 | 2100 ;(beginning-of-line) |
2101 (if (equal (char-after (point)) ?\\) nil ;stay here | |
2102 (skip-chars-backward "^\n\\\\") | |
2103 (or (bolp) (forward-char -1)))) | |
5 | 2104 (re-search-forward |
13 | 2105 ;;"\\\\begin{\\([^}]+\\)}\\|\\\\end{\\([^}]+\\)}" |
2106 (concat | |
2107 (YaTeX-replace-format-args | |
2108 (regexp-quote YaTeX-struct-begin) | |
2109 (concat "\\(" YaTeX-struct-name-regexp "\\)") "" "" "") | |
2110 "\\|" | |
2111 (YaTeX-replace-format-args | |
2112 (regexp-quote YaTeX-struct-end) | |
70 | 2113 (concat "\\(" YaTeX-struct-name-regexp "\\)") "" "" "") |
2114 "\\|\\(" | |
2115 YaTeX-ec-regexp ;;"[][()]\\)" | |
2116 "[][]\\)" | |
2117 ) | |
69 | 2118 (point-end-of-line) t))) |
6 | 2119 |
5 | 2120 (defun YaTeX-on-includes-p () |
2121 (save-excursion | |
2122 (beginning-of-line) | |
86 | 2123 (re-search-forward "\\(\\(include[^}]*\\)\\|\\(input\\)\\){[^}]*}" |
69 | 2124 (point-end-of-line) t))) |
6 | 2125 |
7 | 2126 (defun YaTeX-on-comment-p (&optional sw) |
22 | 2127 "Return t if current line is commented out. |
2128 Optional argument SW t to treat all `%' lines as comment, | |
7 | 2129 even if on `%#' notation." |
2130 (save-excursion | |
2131 (beginning-of-line) | |
22 | 2132 (skip-chars-forward "\\s ") |
69 | 2133 (looking-at (if sw "%" "%[^#]")))) |
7 | 2134 |
5 | 2135 (defun YaTeX-on-BEGIN-END-p () |
2136 (save-excursion | |
7 | 2137 (let ((case-fold-search nil)) |
5 | 2138 (beginning-of-line) |
69 | 2139 (re-search-forward |
2140 "\\(%#BEGIN\\)\\|\\(%#END\\)" (point-end-of-line) t)))) | |
6 | 2141 |
7 | 2142 (defun YaTeX-goto-corresponding-* (arg) |
5 | 2143 "Parse current line and call suitable function." |
7 | 2144 (interactive "P") |
77 | 2145 (let (mm) |
2146 (cond | |
2147 ((YaTeX-goto-corresponding-label arg)) | |
2148 ((YaTeX-goto-corresponding-environment)) | |
2149 ((YaTeX-goto-corresponding-file-processor arg)) | |
2150 ((YaTeX-goto-corresponding-file arg)) | |
2151 ((YaTeX-goto-corresponding-BEGIN-END)) | |
2152 ((and (setq mm (YaTeX-in-math-mode-p)) | |
2153 (YaTeX-goto-corresponding-leftright))) | |
82 | 2154 ((and ;;mm YaTeX-use-AMS-LaTeX |
77 | 2155 (YaTeX-goto-corresponding-paren))) |
2156 ;;((and (string-match | |
2157 ;; YaTeX-equation-env-regexp ;to delay loading | |
2158 ;; (or (YaTeX-inner-environment t) "document")) | |
2159 ;; (YaTeX-goto-corresponding-leftright))) | |
2160 (t (message "I don't know where to go."))))) | |
5 | 2161 |
51 | 2162 (defun YaTeX-goto-corresponding-*-other-window (arg) |
2163 "Parse current line and call suitable function." | |
2164 (interactive "P") | |
2165 (cond | |
2166 ((YaTeX-goto-corresponding-label arg t)) | |
2167 ;;((YaTeX-goto-corresponding-environment)) | |
2168 ((YaTeX-goto-corresponding-file t)) | |
2169 ;;((YaTeX-goto-corresponding-BEGIN-END)) | |
69 | 2170 (t (message "I don't know where to go.")))) |
51 | 2171 |
5 | 2172 (defun YaTeX-comment-region (alt-prefix) |
22 | 2173 "Comment out region by '%'. |
2174 If you call this function on the 'begin{}' or 'end{}' line, | |
2175 it comments out whole environment" | |
5 | 2176 (interactive "P") |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2177 (if (not (YaTeX-on-begin-end-p)) |
49 | 2178 (comment-out-region |
5 | 2179 (if alt-prefix |
2180 (read-string "Insert prefix: ") | |
2181 YaTeX-comment-prefix)) | |
69 | 2182 (YaTeX-comment-uncomment-env 'comment-out-region))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2183 |
5 | 2184 (defun YaTeX-uncomment-region (alt-prefix) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2185 "Uncomment out region by '%'." |
5 | 2186 (interactive "P") |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2187 (if (not (YaTeX-on-begin-end-p)) |
77 | 2188 (uncomment-out-region |
5 | 2189 (if alt-prefix (read-string "Remove prefix: ") |
11 | 2190 YaTeX-comment-prefix) |
49 | 2191 (region-beginning) (region-end) YaTeX-uncomment-once) |
77 | 2192 (YaTeX-comment-uncomment-env 'uncomment-out-region))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2193 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2194 (defun YaTeX-comment-uncomment-env (func) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2195 "Comment or uncomment out one LaTeX environment switching function by FUNC." |
49 | 2196 (let (beg (p (point))) |
2197 (save-excursion | |
2198 (beginning-of-line) | |
2199 (setq beg (point)) | |
2200 (YaTeX-goto-corresponding-environment) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2201 (beginning-of-line) |
49 | 2202 (if (> p (point)) (setq beg (1+ beg)) (forward-char 1)) |
2203 (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) | |
45 | 2204 (message "%sommented out current environment." |
69 | 2205 (if (eq func 'comment-out-region) "C" "Un-c"))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2206 |
3 | 2207 (defun YaTeX-comment-paragraph () |
2208 "Comment out current paragraph." | |
2209 (interactive) | |
2210 (save-excursion | |
7 | 2211 (cond |
2212 ((YaTeX-on-begin-end-p) | |
2213 (beginning-of-line) | |
2214 (insert YaTeX-comment-prefix) | |
2215 (YaTeX-goto-corresponding-environment) | |
2216 (beginning-of-line) | |
2217 (insert YaTeX-comment-prefix)) | |
2218 ((YaTeX-on-comment-p) | |
2219 (message "Already commented out.")) | |
2220 (t | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2221 (mark-paragraph) |
7 | 2222 (if (looking-at paragraph-separate) (forward-line 1)) |
69 | 2223 (comment-out-region "%"))))) |
3 | 2224 |
2225 (defun YaTeX-uncomment-paragraph () | |
2226 "Uncomment current paragraph." | |
2227 (interactive) | |
2228 (save-excursion | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2229 (if (YaTeX-on-begin-end-p) |
68 | 2230 (let ((p (point-marker))) |
22 | 2231 (YaTeX-goto-corresponding-environment) |
11 | 2232 (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once) |
68 | 2233 (goto-char p) |
2234 (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once) | |
2235 (set-marker p nil)) | |
7 | 2236 (if (YaTeX-on-comment-p) |
2237 (let*((fill-prefix "") | |
2238 ;;append `^%' to head of paragraph delimiter. | |
2239 (paragraph-start | |
2240 (concat | |
61 | 2241 "^$\\|^%\\(" YaTeX-paragraph-separate "\\)")) |
49 | 2242 (paragraph-separate paragraph-start)) |
7 | 2243 (mark-paragraph) |
2244 (if (not (bobp)) (forward-line 1)) | |
77 | 2245 (uncomment-out-region "%" nil nil YaTeX-uncomment-once)) |
69 | 2246 (message "This line is not a comment line."))))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2247 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2248 (defun YaTeX-remove-prefix (prefix &optional once) |
7 | 2249 "Remove prefix on current line as far as prefix detected. But |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2250 optional argument ONCE makes deletion once." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2251 (interactive "sPrefix:") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2252 (beginning-of-line) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2253 (while (re-search-forward (concat "^" prefix) (point-end-of-line) t) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
2254 (replace-match "") |
69 | 2255 (if once (end-of-line)))) |
3 | 2256 |
22 | 2257 (defun YaTeX-kill-some-pairs (predicate gofunc kill-contents) |
2258 "Kill some matching pair. | |
64 | 2259 This function assumes that pairs occupy whole of each line where they resid." |
7 | 2260 (if (not (funcall predicate)) nil |
64 | 2261 (let ((b1 (match-beginning 0)) (e1 (match-end 0)) |
2262 b2 e2) | |
7 | 2263 (save-excursion |
2264 (funcall gofunc) | |
64 | 2265 (funcall predicate) ;get match data |
2266 (if (< (point) e1) ;if currently on begin-line | |
2267 (progn | |
2268 (setq b2 b1 e2 e1 | |
2269 b1 (match-beginning 0) e1 (match-end 0)) | |
2270 (goto-char e2)) ;goto end-line's end | |
2271 (setq b2 (match-beginning 0) | |
2272 e2 (match-end 0)) | |
2273 (goto-char e2)) ;now e2 has surely end-line's end | |
2274 (skip-chars-forward " \t") | |
2275 (and (eolp) | |
2276 (not (eobp)) | |
2277 (setq e2 (1+ (point)))) | |
2278 (if (not kill-contents) | |
2279 (kill-region | |
2280 (progn | |
2281 (goto-char b2) | |
68 | 2282 (skip-chars-backward " \t%") |
64 | 2283 (if (bolp) (point) b2)) |
2284 e2)) | |
2285 (goto-char b1) | |
68 | 2286 (skip-chars-backward " \t%") |
64 | 2287 (if (not kill-contents) |
2288 (progn | |
2289 (kill-append | |
2290 (buffer-substring | |
2291 (setq b1 (if (bolp) (point) b1)) | |
2292 (setq e1 | |
2293 (progn | |
2294 (goto-char e1) | |
2295 (while (looking-at "{\\| \t") | |
2296 (forward-list 1)) | |
2297 (skip-chars-forward " \t") | |
2298 (if (and (eolp) (not (eobp))) | |
2299 (1+ (point)) | |
2300 (point))))) | |
2301 t) | |
2302 (delete-region b1 e1)) | |
2303 (kill-region | |
2304 (if (bolp) (point) b1) | |
2305 e2))) | |
69 | 2306 t))) |
5 | 2307 |
22 | 2308 (defun YaTeX-kill-section-command (point kill-all) |
82 | 2309 "Kill section-type command at POINT leaving its last argument. |
2310 Non-nil for the second argument kill its last argument too." | |
2311 (let ((cmd (get 'YaTeX-on-section-command-p 'command)) | |
2312 (argc (get 'YaTeX-on-section-command-p 'argc)) | |
2313 beg (end (make-marker))) | |
14 | 2314 (save-excursion |
22 | 2315 (goto-char point) |
2316 (or (looking-at YaTeX-ec-regexp) | |
2317 (progn | |
2318 (skip-chars-backward (concat "^" YaTeX-ec-regexp)) | |
2319 (forward-char -1))) | |
2320 (setq beg (point)) | |
2321 (skip-chars-forward "^{") | |
82 | 2322 (while (> (setq argc (1- argc)) 0) |
2323 (skip-chars-forward "^{") | |
2324 (forward-list 1)) | |
2325 (kill-region beg (point)) | |
22 | 2326 (forward-list 1) |
2327 (set-marker end (point)) | |
82 | 2328 (if kill-all |
2329 (progn | |
2330 (kill-append (buffer-substring beg end) nil) | |
2331 (delete-region beg end)) | |
22 | 2332 (goto-char beg) |
82 | 2333 (kill-append |
2334 (buffer-substring | |
2335 (point) (progn (skip-chars-forward "^{" end) (1+ (point)))) | |
2336 nil) | |
2337 (delete-region beg (1+ (point))) | |
22 | 2338 (goto-char end) |
68 | 2339 (set-marker end nil) |
2340 (kill-append (buffer-substring (point) (1- (point))) nil) | |
69 | 2341 (delete-backward-char 1))))) |
14 | 2342 |
22 | 2343 (defun YaTeX-kill-paren (kill-contents) |
2344 "Kill parentheses leaving its contents. | |
2345 But kill its contents if the argument KILL-CONTENTS is non-nil." | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2346 (interactive "P") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2347 (let (p bsl (backslash-syntax (char-to-string (char-syntax ?\\))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2348 (md (match-data))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2349 (unwind-protect |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2350 (save-excursion |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2351 (modify-syntax-entry ?\\ " ") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2352 (if (looking-at "\\s(\\|\\(\\s)\\)") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2353 (progn |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2354 (if (match-beginning 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2355 (up-list -1)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2356 (if (and (> (point) (point-min)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2357 (= (char-after (1- (point))) ?\\ )) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2358 (setq p (1- (point)) bsl t) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2359 (setq p (point))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2360 (forward-list 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2361 ;(YaTeX-goto-open-paren t) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2362 (if kill-contents (delete-region p (point)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2363 (backward-delete-char 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2364 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2365 ((save-excursion |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2366 (forward-char -2) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2367 (looking-at (concat YaTeX-ec-regexp "/"))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2368 (backward-delete-char 2)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2369 ((= (char-after (1- (point))) ?\\) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2370 (backward-delete-char 1))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2371 (goto-char p) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2372 (if (looking-at |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2373 (concat "{" YaTeX-ec-regexp |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2374 YaTeX-command-token-regexp "+" |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2375 "\\s +")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2376 (delete-region (point) (match-end 0)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2377 (delete-char 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2378 (if bsl (delete-char 1)))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2379 t))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2380 (modify-syntax-entry ?\\ backslash-syntax) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2381 (store-match-data md)))) |
14 | 2382 |
22 | 2383 (defvar YaTeX-read-environment-history nil "Holds history of environments.") |
2384 (put 'YaTeX-read-environment-history 'no-default t) | |
2385 (defun YaTeX-read-environment (prompt &optional predicate must-match initial) | |
2386 "Read a LaTeX environment name with completion." | |
49 | 2387 (YaTeX-sync-local-table 'tmp-env-table) |
51 | 2388 (completing-read-with-history |
2389 prompt | |
2390 (append tmp-env-table user-env-table env-table) | |
2391 predicate must-match initial | |
69 | 2392 'YaTeX-read-environment-history)) |
22 | 2393 |
2394 (defvar YaTeX-read-section-history nil "Holds history of section-types.") | |
2395 (put 'YaTeX-read-section-history 'no-default t) | |
2396 (defun YaTeX-read-section (prompt &optional predicate initial) | |
2397 "Read a LaTeX section-type command with completion." | |
49 | 2398 (YaTeX-sync-local-table 'tmp-section-table) |
51 | 2399 (let ((minibuffer-completion-table |
22 | 2400 (append tmp-section-table user-section-table section-table))) |
51 | 2401 (read-from-minibuffer-with-history |
2402 prompt initial YaTeX-section-completion-map nil | |
69 | 2403 'YaTeX-read-section-history))) |
22 | 2404 |
2405 (defun YaTeX-read-section-with-overview () | |
2406 "Read sectioning command with overview. | |
119
34096706b634
Bind local variable source-window for YaTeX-read-section-with-overview
yuuji@gentei.org
parents:
107
diff
changeset
|
2407 This function refers a local variable `source-window' in YaTeX-make-section, |
34096706b634
Bind local variable source-window for YaTeX-read-section-with-overview
yuuji@gentei.org
parents:
107
diff
changeset
|
2408 because this function is called with no argument." |
22 | 2409 (interactive) |
52 | 2410 (require 'yatexsec) ;some case needs this |
22 | 2411 (if (> (minibuffer-depth) 1) |
2412 (error "Too many minibuffer levels for overview.")) | |
64 | 2413 (let ((sw (selected-window)) |
2414 (minibuffer-max-depth nil) ; for XEmacs20 | |
2415 (enable-recursive-minibuffers t) sect) | |
22 | 2416 (unwind-protect |
2417 (progn | |
2418 (select-window source-window) | |
2419 (setq sect (YaTeX-read-section-in-minibuffer | |
2420 "Sectioning(Up=C-p, Down=C-n, Help=?): " | |
2421 YaTeX-sectioning-level (YaTeX-section-overview)))) | |
2422 (select-window sw)) | |
72 | 2423 (YaTeX-minibuffer-erase) |
22 | 2424 (insert sect) |
69 | 2425 (exit-minibuffer))) |
22 | 2426 |
51 | 2427 (defvar YaTeX-read-fontsize-history nil "Holds history of font designator.") |
2428 (put 'YaTeX-read-fontsize-history 'no-default t) | |
22 | 2429 (defun YaTeX-read-fontsize (prompt &optional predicate must-match initial) |
2430 "Read a LaTeX font changing command with completion." | |
49 | 2431 (YaTeX-sync-local-table 'tmp-fontsize-table) |
51 | 2432 (completing-read-with-history |
22 | 2433 prompt (append tmp-fontsize-table user-fontsize-table fontsize-table) |
69 | 2434 predicate must-match initial 'YaTeX-read-fontsize-history)) |
5 | 2435 |
2436 (defun YaTeX-change-environment () | |
2437 "Change the name of environment." | |
2438 (interactive) | |
2439 (if (not (YaTeX-on-begin-end-p)) nil | |
2440 (save-excursion | |
179 | 2441 (let (p env newenv (m1 (match-beginning 1)) (m2 (match-beginning 2))) |
165 | 2442 (setq env (if m1 (YaTeX-buffer-substring m1 (match-end 1)) |
2443 (YaTeX-buffer-substring m2 (match-end 2)))) | |
11 | 2444 (goto-char (match-beginning 0)) |
5 | 2445 (set-mark-command nil) |
2446 (YaTeX-goto-corresponding-environment) | |
2447 (setq newenv (YaTeX-read-environment | |
2448 (format "Change environment `%s' to: " env))) | |
13 | 2449 (cond |
2450 ((string= newenv "") (message "Change environment cancelled.")) | |
2451 ((string= newenv env) (message "No need to change.")) | |
2452 (t | |
5 | 2453 (search-forward (concat "{" env) (point-end-of-line) t) |
68 | 2454 (replace-match (concat "{" newenv) t) |
5 | 2455 (exchange-point-and-mark) |
2456 (search-forward (concat "{" env) (point-end-of-line) t) | |
68 | 2457 (replace-match (concat "{" newenv) t))) |
69 | 2458 t)))) |
5 | 2459 |
22 | 2460 (defun YaTeX-change-section () |
2461 "Change section-type command." | |
5 | 2462 (interactive) |
49 | 2463 (let*((where (YaTeX-on-section-command-p YaTeX-command-token-regexp)) |
70 | 2464 (p (point)) (cmd (YaTeX-match-string 1)) |
2465 (beg (make-marker)) (end (make-marker)) old new) | |
49 | 2466 (if (null where) nil |
70 | 2467 (unwind-protect |
119
34096706b634
Bind local variable source-window for YaTeX-read-section-with-overview
yuuji@gentei.org
parents:
107
diff
changeset
|
2468 (let ((source-window (selected-window))) |
70 | 2469 (cond |
2470 ((equal where 0);;if point is on section command | |
2471 (set-marker beg (match-beginning 1)) | |
2472 (set-marker end (match-end 1)) | |
2473 (goto-char beg) ;beginning of the command | |
2474 (setq new (YaTeX-read-section | |
169
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2475 (format "Change `%s' to: " cmd) nil) |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2476 old cmd)) |
49 | 2477 |
70 | 2478 ((= where -1);;if point is on a optional parameter |
2479 (set-marker beg (match-beginning 2)) | |
2480 (skip-chars-forward "^{") | |
2481 (set-marker end (point)) | |
2482 (goto-char p) | |
2483 (setq new | |
2484 (if (fboundp (intern-soft (concat YaTeX-addin-prefix cmd))) | |
2485 (YaTeX-addin cmd) | |
2486 (concat "[" | |
169
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2487 (read-string |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2488 (format "Change `%s' to: " |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2489 (setq old (YaTeX-buffer-substring |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2490 (1+ beg) (1- end))))) |
70 | 2491 "]")))) |
49 | 2492 |
70 | 2493 ((> where 0);;if point is in arguments' braces |
2494 (or (looking-at "{") | |
2495 (progn (skip-chars-backward "^{") (forward-char -1))) | |
2496 (set-marker beg (1+ (point))) | |
2497 (forward-list 1) | |
2498 (forward-char -1) | |
2499 (set-marker end (point)) | |
165 | 2500 (setq old (YaTeX-buffer-substring beg end)) |
70 | 2501 (goto-char p) |
2502 (if (> (length old) 40) | |
2503 (setq old (concat (substring old 0 12) "..." | |
2504 (substring old -12)))) | |
2505 (setq new | |
2506 (if (intern-soft (concat "YaTeX::" cmd)) | |
2507 (funcall (intern-soft (concat "YaTeX::" cmd)) where) | |
2508 (read-string (format "Change `%s' to: " old))))) | |
2509 ) ;cond | |
169
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2510 (if (string= old new) |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2511 nil ;do not replace |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2512 (delete-region beg end) |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2513 (goto-char beg) |
0cb6c6a78e9e
YaTeX-change-section: If new string equals to old one, do not change text.
yuuji@gentei.org
parents:
168
diff
changeset
|
2514 (insert-before-markers new))) |
70 | 2515 (set-marker beg nil) |
2516 (set-marker end nil)) | |
49 | 2517 ;;(goto-char (marker-position p)) |
69 | 2518 new))) |
49 | 2519 |
2520 (defun YaTeX-change-fontsize () | |
2521 "Change large-type command." | |
2522 (let ((lt (append tmp-fontsize-table user-fontsize-table fontsize-table)) | |
2523 (p (point)) large old new beg end) | |
2524 ;;(and (looking-at "}") (up-list -1)) | |
2525 ;;(and (looking-at "{") (forward-char 1)) | |
2526 ;;Is above convenient? | |
2527 (save-excursion | |
2528 (or (looking-at YaTeX-ec-regexp) | |
2529 (progn | |
2530 (skip-chars-backward (concat "^" YaTeX-ec-regexp)) | |
2531 (forward-char -1))) | |
2532 (cond | |
2533 ((and | |
2534 (looking-at | |
2535 (concat YaTeX-ec-regexp "\\(" YaTeX-TeX-token-regexp "\\)")) | |
2536 (< p (match-end 0)) | |
2537 (assoc (setq old (YaTeX-match-string 1)) lt)) | |
2538 (goto-char p) | |
2539 (setq beg (match-beginning 1) end (match-end 1) ;save match position | |
2540 new (completing-read | |
2541 (format "Change font/size `%s' to : " old) lt)) | |
22 | 2542 (delete-region beg end) |
49 | 2543 (goto-char beg) |
22 | 2544 (insert-before-markers new) |
49 | 2545 new) |
2546 (t nil) | |
69 | 2547 )))) |
22 | 2548 |
52 | 2549 (defun YaTeX-change-math-image () |
2550 "Change with image completion." | |
2551 (let (maketitle memberp beg end) | |
2552 (if (and (YaTeX-on-maketitle-p) | |
2553 (progn | |
2554 (setq maketitle (substring (YaTeX-match-string 0) 1)) | |
2555 (setq memberp (YaTeX-math-member-p maketitle)))) | |
291
027c4e8d98ce
Set last-command-event locally too.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
2556 (let*((last-command-char (string-to-char (car memberp))) |
027c4e8d98ce
Set last-command-event locally too.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
2557 (last-command-event last-command-char)) |
52 | 2558 (setq beg (match-beginning 0) end (match-end 0)) |
2559 (delete-region beg end) | |
2560 (YaTeX-math-insert-sequence t (cdr memberp)))))) | |
2561 | |
22 | 2562 (defun YaTeX-kill-* (&optional arg) |
2563 "Parse current line and call suitable function. | |
2564 Non-nil for ARG kills its contents too." | |
2565 (interactive "P") | |
5 | 2566 (cond |
2567 ((YaTeX-kill-some-pairs 'YaTeX-on-begin-end-p | |
22 | 2568 'YaTeX-goto-corresponding-environment arg)) |
5 | 2569 ((YaTeX-kill-some-pairs 'YaTeX-on-BEGIN-END-p |
22 | 2570 'YaTeX-goto-corresponding-BEGIN-END arg)) |
32
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
2571 ((YaTeX-on-section-command-p YaTeX-command-token-regexp);on any command |
22 | 2572 (YaTeX-kill-section-command (match-beginning 0) arg)) |
2573 ((YaTeX-kill-paren arg)) | |
69 | 2574 (t (message "I don't know what to kill.")))) |
5 | 2575 |
2576 (defun YaTeX-change-* () | |
2577 "Parse current line and call suitable function." | |
2578 (interactive) | |
2579 (cond | |
82 | 2580 ((YaTeX-change-parentheses)) |
5 | 2581 ((YaTeX-change-environment)) |
22 | 2582 ((YaTeX-change-section)) |
49 | 2583 ((YaTeX-change-fontsize)) |
52 | 2584 ((YaTeX-change-math-image)) |
69 | 2585 (t (message "I don't know what to change.")))) |
5 | 2586 |
7 | 2587 ;;; |
48 | 2588 ;Check availability of add-in functions |
7 | 2589 ;;; |
2590 (cond | |
48 | 2591 ((featurep 'yatexadd) nil) ;Already provided. |
2592 ((progn (load "yatexadd" t) (featurep 'yatexadd)) nil) | |
7 | 2593 (t (message "YaTeX add-in functions not supplied."))) |
2594 | |
5 | 2595 (defun YaTeX-addin (name) |
2596 "Check availability of addin function and call it if exists." | |
7 | 2597 (if (and (not (get 'YaTeX-generate 'disabled)) |
57 | 2598 (intern-soft (concat YaTeX-addin-prefix name)) |
2599 (fboundp (intern-soft (concat YaTeX-addin-prefix name)))) | |
2600 (let ((s (funcall (intern (concat YaTeX-addin-prefix name))))) | |
7 | 2601 (if (stringp s) s "")) |
69 | 2602 "")) ;Add in function is not bound. |
2603 | |
7 | 2604 |
22 | 2605 (defun YaTeX-on-item-p (&optional point) |
2606 "Return t if POINT (default is (point)) is on \\item." | |
2607 (let ((p (or point (point)))) | |
2608 (save-excursion | |
2609 (goto-char p) | |
2610 (end-of-line) | |
2611 (setq p (point)) | |
2612 (re-search-backward YaTeX-paragraph-delimiter nil t) | |
69 | 2613 (re-search-forward YaTeX-item-regexp p t)))) |
22 | 2614 |
49 | 2615 (defun YaTeX-in-verb-p (&optional point) |
2616 "Check if POINT is in verb or verb*. Default of POINT is (point)." | |
2617 (setq point (or point (point))) | |
7 | 2618 (save-excursion |
70 | 2619 (let ((md (match-data))) |
2620 (goto-char point) | |
2621 (unwind-protect | |
2622 (if (not (re-search-backward | |
2623 (concat YaTeX-ec-regexp | |
2624 "\\(" YaTeX-verb-regexp "\\)" | |
2625 "\\([^-A-Za-z_*]\\)") | |
2626 (point-beginning-of-line) t)) | |
2627 nil | |
2628 (goto-char (match-end 2)) | |
2629 (skip-chars-forward | |
165 | 2630 (concat "^" (YaTeX-buffer-substring |
2631 (match-beginning 2) (match-end 2)))) | |
70 | 2632 (and (< (match-beginning 2) point) (< (1- point) (point)))) |
2633 (store-match-data md))))) | |
49 | 2634 |
2635 (defun YaTeX-literal-p (&optional point) | |
2636 "Check if POINT is in verb or verb* or verbatime environment family. | |
2637 Default of POINT is (point)." | |
70 | 2638 (let ((md (match-data))) |
2639 (unwind-protect | |
2640 (cond | |
2641 ((equal YaTeX-ec "\\") ;maybe LaTeX | |
2642 (save-excursion | |
2643 (and point (goto-char point)) | |
2644 (or (YaTeX-in-verb-p (point)) | |
2645 (and (not (looking-at "\\\\end{verb")) | |
2646 (YaTeX-quick-in-environment-p | |
2647 YaTeX-verbatim-environments)))))) | |
2648 (store-match-data md)))) | |
5 | 2649 |
2650 (defun YaTeX-in-environment-p (env) | |
7 | 2651 "Return if current LaTeX environment is ENV. |
2652 ENV is given in the form of environment's name or its list." | |
22 | 2653 (let ((md (match-data)) (nest 0) p envrx) |
5 | 2654 (cond |
22 | 2655 ((atom env) |
2656 (setq envrx | |
2657 (concat "\\(" | |
2658 (regexp-quote | |
2659 (YaTeX-replace-format-args | |
2660 YaTeX-struct-begin env "" "")) | |
2661 "\\)\\|\\(" | |
2662 (regexp-quote | |
2663 (YaTeX-replace-format-args | |
2664 YaTeX-struct-end env "" "")) | |
2665 "\\)")) | |
2666 (save-excursion | |
2667 (setq p (catch 'open | |
2668 (while (YaTeX-re-search-active-backward | |
2669 envrx YaTeX-comment-prefix nil t) | |
2670 (if (match-beginning 2) | |
2671 (setq nest (1+ nest)) | |
2672 (setq nest (1- nest))) | |
129
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2673 (if (< nest 0) |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2674 (throw 'open (cons env (match-beginning 0))))))))) |
5 | 2675 ((listp env) |
49 | 2676 (setq p |
2677 (or (YaTeX-in-environment-p (car env)) | |
2678 (and (cdr env) (YaTeX-in-environment-p (cdr env))))))) | |
7 | 2679 (store-match-data md) |
49 | 2680 p;(or p (YaTeX-in-verb-p (match-beginning 0))) |
69 | 2681 )) |
5 | 2682 |
2683 (defun YaTeX-quick-in-environment-p (env) | |
7 | 2684 "Check quickly but unsure if current environment is ENV. |
22 | 2685 ENV is given in the form of environment's name or its list. |
49 | 2686 This function returns correct result only if ENV is NOT nested." |
7 | 2687 (save-excursion |
129
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2688 (let ((md (match-data)) m0 (p (point)) rc clfound) |
7 | 2689 (cond |
2690 ((listp env) | |
49 | 2691 (or (YaTeX-quick-in-environment-p (car env)) |
2692 (and (cdr env) (YaTeX-quick-in-environment-p (cdr env))))) | |
7 | 2693 (t |
129
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2694 (unwind-protect |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2695 (if (prog1 |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2696 (YaTeX-search-active-backward |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2697 (YaTeX-replace-format-args YaTeX-struct-begin env "" "") |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2698 YaTeX-comment-prefix nil t) |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2699 (setq m0 (match-beginning 0))) |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2700 (if (YaTeX-search-active-forward |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2701 (YaTeX-replace-format-args |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2702 YaTeX-struct-end env) |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2703 YaTeX-comment-prefix p t nil) |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2704 nil ;if \end{env} found, return nil |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2705 (cons env m0))) ;else, return meaningful values |
b11d6271207e
YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint
yuuji@gentei.org
parents:
123
diff
changeset
|
2706 (store-match-data md))))))) |
5 | 2707 |
22 | 2708 ;; Filling \item |
46 | 2709 (defun YaTeX-remove-trailing-comment (start end) |
2710 "Remove trailing comment from START to end." | |
2711 (save-excursion | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2712 (let ((trcom (concat YaTeX-comment-prefix "$"))) |
46 | 2713 (goto-char start) |
2714 (while (re-search-forward trcom end t) | |
54 | 2715 (if (/= (char-after (1- (match-beginning 0))) ?\\ ) |
69 | 2716 (replace-match "\\1")))))) |
5 | 2717 |
82 | 2718 (defvar YaTeX-itemize-withlabel-max-indent-depth 8) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2719 (defun YaTeX-get-item-info (&optional recent thisenv) |
51 | 2720 "Return the list of the beginning of \\item and column of its item. |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2721 If it seems to be outside of itemizing environment, just return nil. |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2722 Non-nil for optional argument RECENT refers recent \\item. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2723 Optional second argument THISENV omits calling YaTeX-inner-environment." |
22 | 2724 (save-excursion |
82 | 2725 (let* ((p (point)) env e0 c cc md |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2726 (bndry (and (setq env (or thisenv (YaTeX-inner-environment t))) |
82 | 2727 (get 'YaTeX-inner-environment 'point)))) |
22 | 2728 (end-of-line) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2729 (if (if recent |
82 | 2730 (catch 'found |
2731 (while (YaTeX-re-search-active-backward | |
2732 YaTeX-item-regexp YaTeX-comment-prefix bndry t) | |
2733 (setq md (match-data)) | |
2734 (YaTeX-inner-environment t) | |
2735 (store-match-data md) | |
2736 (if (= bndry (get 'YaTeX-inner-environment 'point)) | |
2737 (throw 'found t)))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2738 (goto-char bndry) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2739 (YaTeX-re-search-active-forward |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2740 YaTeX-item-regexp YaTeX-comment-prefix p t)) |
51 | 2741 (progn |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2742 (goto-char (match-end 0)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2743 ;(setq c (current-column)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2744 (if (string-match "desc" env) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2745 (setq c 6) |
82 | 2746 (setq cc (current-column)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2747 (if (equal (following-char) ?\[) (forward-list 1)) |
82 | 2748 (if (< (- (current-column) cc) |
2749 YaTeX-itemize-withlabel-max-indent-depth) | |
2750 (setq c 0) | |
2751 (move-to-column cc) | |
2752 (setq c YaTeX-itemize-withlabel-max-indent-depth))) | |
51 | 2753 (skip-chars-forward " \t" (point-end-of-line)) |
69 | 2754 (list (point-beginning-of-line) (+ c (current-column)))))))) |
22 | 2755 |
5 | 2756 (defun YaTeX-fill-item () |
2757 "Fill item in itemize environment." | |
2758 (interactive) | |
2759 (save-excursion | |
51 | 2760 (let* ((p (point)) |
2761 (item-term (concat | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2762 "\\(^[ \t]*$\\)\\|" YaTeX-item-regexp "\\|\\(" |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2763 YaTeX-ec-regexp "\\(begin\\|end\\)\\)")) |
51 | 2764 ;;This value depends on LaTeX. |
2765 fill-prefix start col | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2766 (info (YaTeX-get-item-info t))) |
55 | 2767 (if (null info) nil ;not on \item, do nothing |
22 | 2768 (setq start (car info) |
2769 col (car (cdr info))) | |
55 | 2770 (save-excursion |
2771 (if (re-search-backward "^\\s *$" start t) | |
2772 ;;if separated from \item line, isolate this block | |
2773 (progn | |
2774 (setq start (1+ (match-end 0))) | |
2775 (goto-char start) | |
2776 (skip-chars-forward " \t") | |
2777 (delete-region (point) start) ;is this your favor??? | |
2778 (indent-to col)))) | |
46 | 2779 (beginning-of-line) |
2780 (if (<= (save-excursion | |
2781 (re-search-forward | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2782 (concat "\\\\end{\\|\\\\begin{\\|^[ \t]*$") nil t) |
46 | 2783 (match-beginning 0)) |
2784 p) | |
51 | 2785 (progn (message "Not on itemize.") nil) |
2786 (end-of-line) | |
2787 (newline) | |
2788 (indent-to col) | |
2789 (setq fill-prefix | |
165 | 2790 (YaTeX-buffer-substring (point-beginning-of-line)(point))) |
51 | 2791 (beginning-of-line) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2792 (delete-region (point) (progn (forward-line 1) (point))) |
51 | 2793 (re-search-forward item-term nil 1) |
2794 (YaTeX-remove-trailing-comment start (point)) | |
2795 (beginning-of-line) | |
2796 (push-mark (point) t) | |
2797 (goto-char start) | |
2798 (forward-line 1) | |
2799 (while (< (point) (mark)) | |
2800 (delete-region (point) (progn (skip-chars-forward " \t") (point))) | |
2801 (forward-line 1)) | |
2802 (fill-region-as-paragraph start (mark)) | |
2803 (if NTT-jTeX | |
2804 (while (progn(forward-line -1)(end-of-line) (> (point) start)) | |
2805 (insert ?%))) | |
69 | 2806 (pop-mark)))))) |
5 | 2807 |
51 | 2808 (defun YaTeX-fill-paragraph (arg) |
2809 "YaTeX adjustment function for fill-paragraph. | |
2810 *Protect \\verb from unexpected broken up." | |
2811 (interactive "P") | |
2812 (cond | |
2813 ((not (eq major-mode 'yatex-mode)) (fill-paragraph arg)) | |
2814 ((YaTeX-quick-in-environment-p YaTeX-fill-inhibit-environments) nil) | |
68 | 2815 ((YaTeX-in-math-mode-p) nil) |
51 | 2816 (t |
2817 (save-excursion | |
82 | 2818 (let*((verbrex (concat YaTeX-ec-regexp |
51 | 2819 "\\(" YaTeX-verb-regexp "\\)" ;match#1 |
2820 "\\(.\\).*\\(\\2\\)")) ;match #2 and #3 | |
82 | 2821 (tilderex (concat "\\(" |
2822 YaTeX-kanji-regexp "~" | |
2823 "\\)" YaTeX-ec-regexp | |
2824 "\\|\\(" | |
2825 "~" YaTeX-kanji-regexp | |
2826 "\\)")) | |
2827 (p (point)) ii end poslist spacelist lenlist b e n | |
2828 (fill-prefix fill-prefix) | |
2829 (inenv (or (YaTeX-inner-environment t) "document")) | |
2830 (border (get 'YaTeX-inner-environment 'point))) | |
52 | 2831 (cond |
2832 ((save-excursion (beginning-of-line) ;if point is on the first | |
2833 (setq end (point)) ;non-whitespace char | |
2834 (skip-chars-forward " \t") | |
2835 (equal (point) p)) | |
165 | 2836 (setq fill-prefix (YaTeX-buffer-substring p end))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2837 ((and ;;(not YaTeX-emacs-19) |
82 | 2838 (string-match YaTeX-itemizing-env-regexp inenv) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2839 (setq ii (YaTeX-get-item-info))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2840 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2841 (beginning-of-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2842 (indent-to-column (car (cdr ii))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2843 (setq fill-prefix |
165 | 2844 (YaTeX-buffer-substring (point) (point-beginning-of-line))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2845 (delete-region (point) (progn (beginning-of-line) (point)))))) |
82 | 2846 (cond |
2847 ((string-match "tabular" inenv) | |
2848 (let ((b (point-beginning-of-line)) | |
2849 (e (point-end-of-line))) | |
2850 (if (re-search-backward | |
2851 "&\\|\\\\\\\\\\|\\\\\\(begin\\|end\\){" border t) | |
2852 (setq b (if (match-beginning 1) | |
2853 (progn (forward-line 1) (point)) | |
2854 (point-beginning-of-line)))) | |
2855 (goto-char p) | |
2856 (if (re-search-forward | |
2857 "&\\|\\\\\\\\\\|\\\\\\(end\\|begin\\){" nil t) | |
2858 (setq e (if (match-beginning 1) | |
2859 (progn (forward-line -1) | |
2860 (point-end-of-line)) | |
2861 (match-beginning 0)))) | |
2862 (set-mark e) | |
2863 (goto-char b))) | |
2864 (t | |
2865 (mark-paragraph))) | |
51 | 2866 (save-restriction |
2867 (narrow-to-region (region-beginning) (region-end)) | |
52 | 2868 (YaTeX-remove-trailing-comment (point-min) (point-max)) |
82 | 2869 ;; First, replace spaces in verb to _ temporarily. |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2870 (goto-char (point-min)) |
51 | 2871 (while (YaTeX-re-search-active-forward |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2872 verbrex YaTeX-comment-prefix (point-max) t) |
51 | 2873 (setq end (match-beginning 3)) |
2874 (goto-char (match-beginning 2)) | |
2875 (while (re-search-forward "\\s " end t) | |
2876 (setq poslist (cons (make-marker) poslist) | |
82 | 2877 spacelist (cons (preceding-char) spacelist) |
2878 lenlist (cons 1 lenlist)) | |
51 | 2879 (replace-match "_") |
2880 (set-marker (car poslist) (match-beginning 0)))) | |
82 | 2881 ;; Second, replace "•\~\ref{...}" to "\\\ref{...}" |
2882 (goto-char (point-min)) | |
2883 (while (YaTeX-re-search-active-forward | |
2884 tilderex YaTeX-comment-prefix (point-max) t) | |
2885 (if (match-beginning 1) | |
2886 (setq b (match-beginning 1) e (match-end 1) n 1) | |
2887 (setq b (match-beginning 2) e (match-end 2) n 2)) | |
2888 (setq poslist (cons (make-marker) poslist) | |
2889 spacelist (cons (YaTeX-match-string n) spacelist) | |
2890 lenlist (cons 2 lenlist)) | |
2891 (goto-char (match-beginning 0)) | |
2892 (delete-region (point) e) | |
2893 (insert YaTeX-ec YaTeX-ec) ;set-marker should be here | |
2894 (set-marker (car poslist) b)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2895 ;;(fill-paragraph arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2896 (fill-region-as-paragraph (point-min) (point-max) arg) |
51 | 2897 (while spacelist |
68 | 2898 (goto-char (car poslist)) |
2899 (set-marker (car poslist) nil) | |
82 | 2900 (and (eolp) (skip-chars-forward "\n\t ")) |
2901 (delete-char (car lenlist)) | |
51 | 2902 (insert (car spacelist)) |
82 | 2903 (setq spacelist (cdr spacelist) |
2904 poslist (cdr poslist) | |
2905 lenlist (cdr lenlist))) | |
52 | 2906 (goto-char (point-min)) |
2907 (forward-word 1) | |
2908 (beginning-of-line) | |
82 | 2909 (while (re-search-forward "\\\\\\([a-z]*ref\\|cite\\){" nil t) |
59 | 2910 (if (< (point-end-of-line) |
2911 (save-excursion (forward-char -1) (forward-list 1) (point))) | |
73 | 2912 (progn (end-of-line) |
2913 (if (save-excursion | |
2914 (backward-word 1) | |
2915 (looking-at "[^0-9A-z!-)]")) | |
2916 (insert YaTeX-comment-prefix))))) | |
82 | 2917 ;; Nonbreak space `~' |
2918 (goto-char (point-min)) | |
2919 (while (YaTeX-re-search-active-forward | |
2920 "~\\(\\s *\\)$" YaTeX-comment-prefix (point-max) t) | |
2921 (delete-region (match-beginning 1) (match-end 1)) | |
2922 (insert YaTeX-comment-prefix)) | |
59 | 2923 (goto-char (point-min)) |
73 | 2924 (if (and NTT-jTeX (looking-at "[ \t]\\|^$")) |
52 | 2925 (progn |
2926 (goto-char (point-min)) | |
2927 (while (not (eobp)) | |
2928 (end-of-line) | |
2929 (or (bolp) | |
2930 (save-excursion | |
2931 (backward-word 1) | |
73 | 2932 (looking-at "[0-9A-z!-)]")) ;is not japanese string |
59 | 2933 (progn (setq p (point)) (insert YaTeX-comment-prefix))) |
52 | 2934 (forward-line 1)) |
2935 (goto-char p) | |
61 | 2936 (if (looking-at "%") (delete-char 1)) ;remove last inserted `%' |
69 | 2937 )))))))) |
51 | 2938 |
52 | 2939 (if (fboundp 'YaTeX-saved-indent-new-comment-line) nil |
2940 (fset 'YaTeX-saved-indent-new-comment-line | |
2941 (symbol-function 'indent-new-comment-line)) | |
2942 (fset 'indent-new-comment-line 'YaTeX-indent-new-comment-line)) | |
2943 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2944 (defun YaTeX-indent-new-comment-line (&optional soft) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2945 "Tuned `indent-new-comment-line' function for yatex. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2946 See the documentation of `YaTeX-saved-indent-new-comment-line'." |
69 | 2947 (interactive) |
52 | 2948 (cond |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2949 ((or (not (memq major-mode '(yatex-mode yahtml-mode))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2950 (string-match |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2951 "document" |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2952 (or (and (boundp 'inenv) inenv) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2953 (or (YaTeX-inner-environment t) "document")))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2954 (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft)))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2955 ; ((and (eq major-mode 'yahtml-mode) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2956 ; (string-match |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2957 ; "^[Pp][Rr][Ee]" (yahtml-inner-environment-but "^[Aa]\\b" t))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2958 ; (yahtml-indent-new-commnet-line)) |
61 | 2959 ((and (eq major-mode 'yatex-mode) ;1997/2/4 |
2960 (YaTeX-in-math-mode-p)) nil) ;1996/12/30 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2961 (t (let (fill-prefix) |
69 | 2962 (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft))))))) |
51 | 2963 |
5 | 2964 (defun YaTeX-fill-* () |
2965 "Fill paragraph according to its condition." | |
2966 (interactive) | |
2967 (cond | |
2968 ((YaTeX-fill-item)) | |
69 | 2969 )) |
5 | 2970 |
22 | 2971 ;; Accent completion |
5 | 2972 (defun YaTeX-read-accent-char (x) |
2973 "Read char in accent braces." | |
2974 (let ((c (read-char))) | |
2975 (concat | |
2976 (if (and (or (= c ?i) (= c ?j)) | |
2977 (not (string-match (regexp-quote x) "cdb"))) | |
2978 "\\" "") | |
69 | 2979 (char-to-string c)))) |
5 | 2980 |
2981 (defun YaTeX-make-accent () | |
2982 "Make accent usage." | |
2983 (interactive) | |
2984 (message "1:` 2:' 3:^ 4:\" 5:~ 6:= 7:. u v H t c d b") | |
2985 (let ((c (read-char))(case-fold-search nil)) | |
2986 (setq c (cond ((and (> c ?0) (< c ?8)) | |
2987 (substring "`'^\"~=." (1- (- c ?0)) (- c ?0))) | |
2988 ((= c ?h) "H") | |
2989 (t (char-to-string c)))) | |
2990 (if (not (string-match c "`'^\"~=.uvHtcdb")) nil | |
2991 (insert "\\" c "{}") | |
2992 (backward-char 1) | |
2993 (insert (YaTeX-read-accent-char c)) | |
2994 (if (string= c "t") (insert (YaTeX-read-accent-char c))) | |
69 | 2995 (forward-char 1)))) |
5 | 2996 |
22 | 2997 ;; Indentation |
2998 (defun YaTeX-current-indentation () | |
2999 "Return the indentation of current environment." | |
3000 (save-excursion | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3001 ;;(beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3002 (if (YaTeX-beginning-of-environment t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3003 (goto-char (get 'YaTeX-inner-environment 'point)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3004 (forward-line -1) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3005 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3006 (skip-chars-forward " \t")) |
69 | 3007 (current-column))) |
22 | 3008 |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3009 (defun YaTeX-previous-line-indentation () |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3010 (save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3011 (forward-line -1) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3012 (skip-chars-forward " \t") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3013 (current-column))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3014 |
82 | 3015 (defvar YaTeX-noindent-env-regexp "verbatim\\*?\\|alltt" |
3016 "*Regexp of environment names that should begin with no indentation. | |
3017 All verbatime-like environment name should match with.") | |
22 | 3018 (defun YaTeX-indent-line () |
3019 "Indent corrent line referrin current environment." | |
3020 (interactive) | |
48 | 3021 (let ((indent-relative |
3022 (function | |
51 | 3023 (lambda (&optional additional) |
48 | 3024 (YaTeX-reindent |
51 | 3025 (+ (YaTeX-current-indentation) |
3026 (or additional 0) | |
3027 YaTeX-environment-indent))))) | |
82 | 3028 sect depth iteminfo (p (point)) pp (peol (point-end-of-line)) begend |
52 | 3029 ;;inenv below is sometimes defined in YaTeX-indent-new-comment-line |
3030 (inenv (or (and (boundp 'inenv) inenv) (YaTeX-inner-environment t)))) | |
3031 ;;(if NTT-jTeX ;;Do you need this section? | |
3032 ;; (save-excursion | |
3033 ;; (end-of-line) | |
3034 ;; (let ((p (point))) | |
3035 ;; (forward-line -1) | |
3036 ;; (end-of-line) | |
3037 ;; (or (= p (point)) | |
3038 ;; (progn (backward-char (length YaTeX-comment-prefix)) | |
3039 ;; (not (looking-at (regexp-quote YaTeX-comment-prefix)))) | |
3040 ;; (progn | |
3041 ;; (skip-chars-backward YaTeX-comment-prefix) | |
3042 ;; (kill-line)))))) | |
3043 (or inenv (setq inenv "document")) ;is the default environment | |
48 | 3044 (cond |
82 | 3045 ((and |
3046 (prog1 (YaTeX-on-begin-end-p) | |
3047 (setq begend (match-beginning 0))) | |
3048 (or (match-beginning 2) ;if \end | |
3049 (and (match-beginning 3) ;if \) \] | |
3050 (= (char-syntax (char-after (1+ (match-beginning 3)))) ?\))))) | |
70 | 3051 (YaTeX-reindent |
3052 (save-excursion | |
3053 (YaTeX-goto-corresponding-environment) | |
3054 (current-column)))) | |
82 | 3055 ;; on the begining of verbatime line, remove all indentation |
3056 ((and begend ;; match-beginning 0 of \begin | |
3057 YaTeX-noindent-env-regexp | |
3058 (stringp YaTeX-noindent-env-regexp) | |
3059 (save-excursion | |
3060 (and ;; if the \begin is the first declaration of this line | |
3061 (progn (beginning-of-line) (skip-chars-forward " \t") | |
3062 (= begend (point))) | |
3063 (progn | |
3064 (goto-char begend) | |
3065 (looking-at | |
3066 (concat YaTeX-ec-regexp | |
3067 "begin{\\(" YaTeX-noindent-env-regexp "\\)}")))))) | |
3068 (save-excursion | |
3069 (goto-char begend) | |
3070 (delete-region (point) (point-beginning-of-line)))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3071 ((string-match YaTeX-equation-env-regexp inenv) |
68 | 3072 (YaTeX-indent-line-equation)) ;autoload-ed from yatexenv |
52 | 3073 (;(YaTeX-in-environment-p '("itemize" "enumerate" "description" "list")) |
3074 (string-match YaTeX-itemizing-env-regexp inenv) | |
3075 ;;(YaTeX-on-item-p) ?? | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3076 ;;(setq iteminfo (YaTeX-get-item-info t)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3077 (if (save-excursion |
51 | 3078 (beginning-of-line) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3079 (re-search-forward YaTeX-item-regexp peol t)) |
68 | 3080 (progn |
3081 (save-excursion | |
3082 (goto-char (1+ (match-beginning 0))) | |
3083 (setq depth | |
3084 (* YaTeX-environment-indent | |
3085 (cond | |
3086 ((looking-at "subsubsub") 3) | |
3087 ((looking-at "subsub") 2) | |
3088 ((looking-at "sub") 1) | |
3089 (t 0))))) | |
51 | 3090 (funcall indent-relative depth)) |
82 | 3091 (YaTeX-reindent (or (car (cdr (YaTeX-get-item-info t inenv))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3092 (+ (save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3093 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3094 (YaTeX-current-indentation)) |
52 | 3095 YaTeX-environment-indent)))) |
48 | 3096 ) |
49 | 3097 ((YaTeX-literal-p) ;verbatims |
48 | 3098 (tab-to-tab-stop)) |
82 | 3099 ((string-match "\\(tabular\\|array\\)" inenv) ;1.73 |
3100 (let ((n 1)) | |
3101 (condition-case err | |
3102 (save-excursion | |
3103 (beginning-of-line) | |
3104 (skip-chars-forward "[ \t]") | |
3105 ;;(if (looking-at "&") (forward-char 1)) | |
3106 (require 'yatexenv) | |
3107 (setq n (car (YaTeX-array-what-column-internal)))) | |
3108 (error nil)) | |
3109 (YaTeX-reindent | |
3110 (+ (YaTeX-current-indentation) | |
3111 YaTeX-environment-indent | |
3112 (* (1- n) YaTeX-tabular-indentation))))) | |
52 | 3113 ((and inenv (not (equal "document" inenv))) |
48 | 3114 (funcall indent-relative)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3115 ((YaTeX-on-section-command-p YaTeX-sectioning-regexp) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3116 (require 'yatexsec) ;to know YaTeX-sectioning-level |
68 | 3117 (setq sect (YaTeX-match-string 1)) |
3118 (if (string-match "\\*$" sect) | |
3119 (setq sect (substring sect 0 -1))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3120 (YaTeX-reindent |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3121 (* (max |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3122 (1- ;I want chapter to have indentation 0 |
68 | 3123 (or (cdr (assoc sect YaTeX-sectioning-level)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3124 0)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3125 0) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3126 YaTeX-environment-indent))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3127 ;;Default movement |
48 | 3128 ((and (bolp) fill-prefix) (insert fill-prefix)) |
3129 (t (save-excursion | |
3130 (beginning-of-line) | |
64 | 3131 (if fill-prefix |
3132 (progn | |
3133 (delete-region (point) | |
3134 (progn (skip-chars-forward " \t") | |
3135 (point))) | |
3136 (insert fill-prefix)) | |
3137 (skip-chars-forward " \t") | |
82 | 3138 (if (bobp) |
3139 nil | |
3140 (indent-relative-maybe)))) | |
52 | 3141 (skip-chars-forward " \t"))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3142 ;;if current line is \begin, re-indent \end too |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3143 (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3144 (save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3145 ;;(beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3146 ;;(search-forward "\\begin") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3147 (goto-char (match-beginning 0)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3148 (setq depth (current-column)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3149 (YaTeX-goto-corresponding-environment) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3150 (YaTeX-reindent depth))) |
59 | 3151 (if (or |
3152 (and NTT-jTeX | |
3153 (save-excursion (beginning-of-line) (looking-at "[ \t]"))) | |
3154 (save-excursion | |
3155 (beginning-of-line) | |
3156 (and | |
82 | 3157 (not (bobp)) |
3158 (progn | |
3159 (backward-char 1) | |
3160 (re-search-backward | |
3161 "\\\\\\(\\(page\\)?ref\\|cite\\){" (point-beginning-of-line) t)) | |
59 | 3162 (goto-char (1- (match-end 0))) |
3163 (> (save-excursion | |
3164 (condition-case () | |
3165 (progn (forward-list 1) (point)) | |
3166 (error (point-max)))) | |
3167 (point-end-of-line))))) | |
52 | 3168 (save-excursion |
3169 (end-of-line) | |
3170 (let ((p (point))) | |
3171 (forward-line -1) | |
3172 (end-of-line) | |
3173 (or (= p (point)) | |
3174 (looking-at (regexp-quote YaTeX-comment-prefix)) | |
3175 (bobp) (bolp) | |
3176 (save-excursion | |
3177 (backward-word 1) | |
3178 (looking-at "\\sw+")) ;is not japanese string | |
69 | 3179 (insert YaTeX-comment-prefix))))))) |
22 | 3180 |
77 | 3181 (defun YaTeX-comment-line-break (&optional soft) |
3182 "Call comment-indent-new-line and YaTeX-indent-line" | |
3183 (comment-indent-new-line soft) | |
3184 (YaTeX-indent-line)) | |
3185 | |
70 | 3186 (defun YaTeX-latex2e-p () |
3187 (let ((b (current-buffer)) | |
3188 (ptn (concat YaTeX-ec "documentclass"))) | |
3189 (unwind-protect | |
3190 (or (save-excursion (search-backward ptn nil t)) | |
3191 (progn | |
3192 (YaTeX-visit-main t) | |
3193 (save-excursion (search-backward ptn nil t)))) | |
3194 (set-buffer b)))) | |
3195 | |
7 | 3196 (provide 'yatex) |
3197 (defvar yatex-mode-load-hook nil | |
3198 "*List of functions to be called when yatex.el is loaded.") | |
72 | 3199 (if (and YaTeX-emacs-19 YaTeX-display-color-p (not (featurep 'yatex19))) |
55 | 3200 (load "yatex19")) |
51 | 3201 (load "yatexhks" t) |
3202 | |
3203 ;;-------------------- Final hook jobs -------------------- | |
3204 (substitute-all-key-definition | |
3205 'fill-paragraph 'YaTeX-fill-paragraph YaTeX-mode-map) | |
72 | 3206 (substitute-all-key-definition |
73 | 3207 'kill-buffer 'YaTeX-kill-buffer YaTeX-mode-map) |
7 | 3208 (run-hooks 'yatex-mode-load-hook) |
51 | 3209 |
3210 ;; `History' was moved to ChangeLog | |
0 | 3211 ;----------------------------- End of yatex.el ----------------------------- |
72 | 3212 |
82 | 3213 ; Local variables: |
3214 ; coding: sjis | |
3215 ; End: |