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