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