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