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