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