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