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