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