Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatex.el @ 61:b9f753846b6b
Bug fix release
author | yuuji |
---|---|
date | Mon, 07 Apr 1997 20:07:48 +0000 |
parents | 9e08ed569d80 |
children | 36a48185b95a |
rev | line source |
---|---|
0 | 1 ;;; -*- Emacs-Lisp -*- |
2 ;;; Yet Another tex-mode for emacs. | |
61 | 3 ;;; yatex.el rev. 1.64 |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
4 ;;; (c )1991-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] |
61 | 5 ;;; Last modified Tue Apr 8 05:07:31 1997 on crx |
11 | 6 ;;; $Id$ |
5 | 7 |
13 | 8 ;; This program is free software; you can redistribute it and/or modify |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
0 | 12 |
13 | 13 ;; This program is distributed in the hope that it will be useful, |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
19 ;; along with this program; see the file COPYING. If not, write to | |
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
5 | 21 |
3 | 22 (require 'comment) |
61 | 23 (defconst YaTeX-revision-number "1.64" |
0 | 24 "Revision number of running yatex.el" |
25 ) | |
26 | |
27 ;---------- Local variables ---------- | |
28 ;;; | |
29 ;; Initialize local variable for yatex-mode. | |
30 ;; Preserving user preferred definitions. | |
31 ;; ** Check all of these defvar-ed values ** | |
32 ;; ** and setq other values more suitable ** | |
5 | 33 ;; ** for your site, if needed. ** |
0 | 34 ;;; |
22 | 35 (defvar YaTeX-prefix "\C-c" |
59 | 36 "*Prefix key to call YaTeX functions. |
0 | 37 You can select favorite prefix key by setq in your ~/.emacs." |
38 ) | |
11 | 39 (defvar YaTeX-environment-indent 1 |
40 "*Indentation depth at column width in LaTeX environments." | |
41 ) | |
1 | 42 (defvar YaTeX-fill-prefix "" |
5 | 43 "*fill-prefix used for auto-fill-mode. |
13 | 44 The default value is null string." |
5 | 45 ) |
46 (defvar YaTeX-fill-column 72 | |
47 "*fill-column used for auto-fill-mode." | |
0 | 48 ) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
49 (defvar YaTeX-comment-prefix "%" |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
50 "TeX comment prefix." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
51 ) |
5 | 52 (defvar YaTeX-current-position-register ?3 |
22 | 53 "*Position register to keep where the last completion was done. |
54 All of YaTeX completing input store the current position into | |
5 | 55 the register YaTeX-current-position-register. So every time you |
52 | 56 make a trip to any other part of text other than you are writing, you can |
13 | 57 return to the editing paragraph by calling register-to-point with argument |
5 | 58 YaTeX-current-position-register." |
59 ) | |
13 | 60 (defvar YaTeX-dos (eq system-type 'ms-dos)) |
45 | 61 (defvar YaTeX-emacs-19 (string= "19" (substring emacs-version 0 2))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
62 (defvar YaTeX-user-completion-table |
13 | 63 (if YaTeX-dos "~/_yatexrc" "~/.yatexrc") |
5 | 64 "*Default filename in which user completion table is saved." |
0 | 65 ) |
18 | 66 ;;(defvar YaTeX-tmp-dic-unit 'main-file |
67 ;; "*Default switching unit of temporary dictionary. | |
68 ;;There are two switching unit: | |
69 ;;'main-file : switch tmp-dic according to main-file directory. | |
70 ;;'directory : switch tmp-dic dir by dir." | |
71 ;;) | |
7 | 72 (defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE)) |
73 "Whether yatex mode is running on Japanese environment or not." | |
74 ) | |
75 (defvar tex-command (if YaTeX-japan "jlatex" "latex") | |
76 "*Default command for typesetting LaTeX text." | |
77 ) | |
78 (defvar bibtex-command (if YaTeX-japan "jbibtex" "bibtex") | |
79 "*Default command of BibTeX." | |
0 | 80 ) |
81 (defvar dvi2-command ;previewer command for your site | |
52 | 82 (if YaTeX-dos "dviout -wait=0" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
83 "xdvi -geo +0+0 -s 4") |
5 | 84 "*Default previewer command including its option. |
7 | 85 This default value is for X window system." |
0 | 86 ) |
13 | 87 (defvar makeindex-command (if YaTeX-dos "makeind" "makeindex") |
11 | 88 "*Default makeindex command." |
89 ) | |
5 | 90 (defvar dviprint-command-format |
13 | 91 (if YaTeX-dos "dviprt %s %f%t" |
5 | 92 "dvi2ps %f %t %s | lpr") |
22 | 93 "*Command line string to print out current file. |
94 Format string %s will be replaced by the filename. Do not forget to | |
95 specify the `from usage' and `to usage' with their option by format string | |
96 %f and %t. | |
97 See also documentation of dviprint-from-format and dviprint-to-format." | |
5 | 98 ) |
99 (defvar dviprint-from-format | |
13 | 100 (if YaTeX-dos "%b-" "-f %b") |
7 | 101 "*`From' page format of dvi filter. %b will turn to beginning page number." |
5 | 102 ) |
103 (defvar dviprint-to-format | |
13 | 104 (if YaTeX-dos "%e" "-t %e") |
7 | 105 "*`To' page format of dvi filter. %e will turn to end page number." |
5 | 106 ) |
107 (defvar YaTeX-default-document-style | |
108 (concat (if YaTeX-japan "j") "article") | |
109 "*Default LaTeX Documentstyle for YaTeX-typeset-region." | |
110 ) | |
111 (defvar YaTeX-need-nonstop nil | |
45 | 112 "*T for adding `\\nonstopmode{}' to text before invoking latex command." |
5 | 113 ) |
0 | 114 (defvar latex-warning-regexp "line.* [0-9]*" |
5 | 115 "*Regular expression of line number of warning message by latex command." |
0 | 116 ) |
117 (defvar latex-error-regexp "l\\.[1-9][0-9]*" | |
22 | 118 "*Regular expression of line number of latex error. |
119 Perhaps your latex command stops at this error message with line number of | |
120 LaTeX source text." | |
0 | 121 ) |
1 | 122 (defvar latex-dos-emergency-message |
3 | 123 "Emergency stop" ;<- for Micro tex, ASCII-pTeX 1.6 |
22 | 124 "Message pattern of emergency stop of typesetting. |
125 Because Demacs (GNU Emacs on DOS) cannot have concurrent process, the | |
0 | 126 latex command which is stopping on a LaTeX error, is terminated by Demacs. |
13 | 127 Many latex command on DOS display some messages when it is terminated by |
128 other process, user or OS. Define to this variable a message string of your | |
129 latex command on DOS shown at abnormal termination. | |
0 | 130 Remember Demacs's call-process function is not oriented for interactive |
131 process." | |
132 ) | |
5 | 133 (defvar latex-message-kanji-code 2 |
134 "*Kanji coding system latex command types out. | |
135 1 = Shift JIS, 2 = JIS, 3 = EUC." | |
136 ) | |
22 | 137 (defvar YaTeX-inhibit-prefix-letter nil |
138 "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter." | |
139 ) | |
5 | 140 (defvar NTT-jTeX nil |
141 "*Use NTT-jTeX for latex command." | |
142 ) | |
11 | 143 (defvar YaTeX-item-regexp (concat (regexp-quote "\\") "\\(sub\\)*item") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
144 "*Regular expression of item command." |
6 | 145 ) |
18 | 146 (defvar YaTeX-nervous t |
147 "*If you are nervous about maintenance of yatexrc, set this value to T. | |
148 And you will have the local dictionary." | |
6 | 149 ) |
7 | 150 (defvar YaTeX-sectioning-regexp |
52 | 151 "\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\*?\\)\\b" |
7 | 152 "*LaTeX sectioning commands regexp." |
153 ) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
154 (defvar YaTeX-paragraph-start |
59 | 155 (concat "^[ \t]*%\\|^[ \t]*$\\|\\'\\|^\C-l\\|\\\\\\\\$\\|^[ \t]*\\\\\\(" |
13 | 156 YaTeX-sectioning-regexp ;sectioning commands |
7 | 157 "\\|[A-z]*item\\|begin{\\|end{" ;special declaration |
59 | 158 "\\|newpage\\b\\|vspace\\b" |
7 | 159 "\\)") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
160 "*Paragraph starting regexp of common LaTeX source. Use this value |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
161 for YaTeX-uncomment-paragraph." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
162 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
163 (defvar YaTeX-paragraph-separate |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
164 (concat "^[ \t]*%\\|^[ \t]*$\\|^\C-l\\|\\\\\\\\$\\|^[ \t]*\\\\\\(" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
165 YaTeX-sectioning-regexp ;sectioning commands |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
166 "\\|begin{\\|end{" ;special declaration |
59 | 167 "\\|newpage\\b\\|vspace\\b" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
168 "\\)") |
7 | 169 "*Paragraph delimiter regexp of common LaTeX source. Use this value |
170 for YaTeX-uncomment-paragraph." | |
171 ) | |
49 | 172 (defvar YaTeX-verbatim-environments |
173 '("verbatim" "verbatim*") | |
174 "*Assume these environments of this variable disable LaTeX commands.") | |
51 | 175 (defvar YaTeX-verb-regexp "verb\\*?\\|path" |
176 "*Regexp of verb family. Do not contain preceding \\\\ nor \\(\\).") | |
49 | 177 (defvar YaTeX-fill-inhibit-environments |
178 (append '("tabular" "tabular*" "array" "picture" "eqnarray" "eqnarray*" | |
179 "equation" "math" "displaymath") | |
180 YaTeX-verbatim-environments) | |
13 | 181 "*In these environments, YaTeX inhibits fill-paragraph from formatting. |
11 | 182 Define those environments as a form of list." |
183 ) | |
52 | 184 (defvar YaTeX-itemizing-env-regexp |
185 "itemize\\|enumerate\\|description\\|list" | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
186 "*Regexp of itemizing environments") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
187 (defvar YaTeX-equation-env-regexp |
54 | 188 "array\\*?\\|equation\\*?" |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
189 "*Regexp of environments for equations") |
57 | 190 (defvar YaTeX-array-env-regexp |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
191 (concat |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
192 "array\\*?\\|eqnarray\\*?\\|tabbing\\|tabular\\*?\\|" ;LaTeX |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
193 "align\\*?\\|split\\*?\\|aligned\\*?\\|alignat\\*?\\|" ;AMS-LaTeX |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
194 "xalignat\\*?\\|xxalignat\\*?") ;AMS-LaTeX |
57 | 195 "*Regexp of environments where `&' becomes field delimiter.") |
11 | 196 (defvar YaTeX-uncomment-once t |
22 | 197 "*T for removing all continuous commenting character(%). |
198 Nil for removing only one commenting character at the beginning-of-line." | |
199 ) | |
200 (defvar YaTeX-default-pop-window-height 10 | |
201 "Default typesetting buffer height. | |
202 If integer, sets the window-height of typesetting buffer. | |
203 If string, sets the percentage of it. | |
204 If nil, use default pop-to-buffer." | |
205 ) | |
206 (defvar YaTeX-close-paren-always t | |
207 "Close parenthesis always when YaTeX-modify-mode is nil." | |
208 ) | |
209 (defvar YaTeX-no-begend-shortcut nil | |
210 "*T for disabling shortcut of begin-type completion, [prefix] b d, etc." | |
211 ) | |
212 (defvar YaTeX-greek-by-maketitle-completion nil | |
213 "*T for greek letters completion by maketitle-type completion." | |
11 | 214 ) |
22 | 215 (defvar YaTeX-auto-math-mode t |
216 "*T for changing YaTeX-math mode automatically.") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
217 (defvar YaTeX-use-AMS-LaTeX nil |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
218 "*T for using AMS-LaTeX" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
219 ) |
22 | 220 (defvar yatex-mode-hook nil |
221 "*List of functions to be called at the end of yatex-mode initializations." | |
11 | 222 ) |
22 | 223 ;;-- Math mode values -- |
224 | |
225 (defvar YaTeX-math-key-list-default | |
226 '((";" . YaTeX-math-sign-alist) | |
52 | 227 (":" . YaTeX-greek-key-alist)) |
22 | 228 "Default key sequence to invoke math-mode's image completion." |
11 | 229 ) |
22 | 230 (defvar YaTeX-math-key-list-private nil |
51 | 231 "*User defined alist, math-mode-prefix vs completion alist." |
22 | 232 ) |
233 (defvar YaTeX-math-key-list | |
234 (append YaTeX-math-key-list-private YaTeX-math-key-list-default) | |
235 "Key sequence to invoke math-mode's image completion." | |
236 ) | |
52 | 237 (defvar YaTeX-create-file-prefix-g nil |
54 | 238 "*Non-nil creates new file when [prefix] g on \\include{foo}." |
239 ) | |
240 (defvar YaTeX-skip-default-reader nil | |
241 "Non-nil skips default argument reader of section-type completion." | |
242 ) | |
243 (defvar YaTeX-simple-messages nil | |
244 "Non-nil makes minibuffer messages simpler." | |
245 ) | |
57 | 246 (defvar YaTeX-addin-prefix "YaTeX:") |
0 | 247 ;------------ Completion table ------------ |
248 ; Set tex-section-like command possible completion | |
22 | 249 (defvar section-table |
49 | 250 '(("part") ("chapter") ("section") ("subsection") |
251 ("subsubsection") ("paragraph") ("subparagraph") | |
22 | 252 ("author") ("thanks") ("documentstyle") ("pagestyle") |
49 | 253 ("title") ("underline") ("label") ("makebox") |
254 ("footnote") ("footnotetext") | |
48 | 255 ("hspace*") ("vspace*") ("bibliography") ("bibitem") ("cite") |
49 | 256 ("input") ("include") ("includeonly") ("mbox") ("hbox") ("caption") |
22 | 257 ("newlength") ("setlength" 2) ("addtolength" 2) ("settowidth" 2) |
258 ("setcounter" 2) ("addtocounter" 2) ("stepcounter" 2) | |
259 ("newcommand" 2) ("renewcommand" 2) | |
260 ("setcounter" 2) ("newenvironment" 3) ("newtheorem" 2) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
261 ("cline") ("framebox") ("savebox" 2) ("date") ("put") ("ref") |
22 | 262 ("frac" 2) ("multicolumn" 3) ("shortstack") |
263 ) | |
264 "Default completion table for section-type completion." | |
265 ) | |
0 | 266 (defvar user-section-table nil) |
6 | 267 (defvar tmp-section-table nil) |
0 | 268 |
269 ; Set tex-environment possible completion | |
22 | 270 (defvar env-table |
271 '(("quote") ("quotation") ("center") ("verse") ("document") | |
272 ("verbatim") ("itemize") ("enumerate") ("description") | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
273 ("list") ("tabular") ("tabular*") ("table") ("tabbing") ("titlepage") |
22 | 274 ("sloppypar") ("quotation") ("picture") ("displaymath") |
275 ("eqnarray") ("figure") ("equation") ("abstract") ("array") | |
276 ("thebibliography") ("theindex") ("flushleft") ("flushright") | |
277 ("minipage") | |
278 ) | |
279 "Default completion table for begin-type completion." | |
280 ) | |
0 | 281 (defvar user-env-table nil) |
6 | 282 (defvar tmp-env-table nil) |
0 | 283 |
13 | 284 ; Set {\Large }-like completion |
22 | 285 (defvar fontsize-table |
286 '(("rm") ("em") ("bf") ("boldmath") ("it") ("sl") ("sf") ("sc") ("tt") | |
287 ("dg") ("dm") | |
288 ("tiny") ("scriptsize") ("footnotesize") ("small")("normalsize") | |
289 ("large") ("Large") ("LARGE") ("huge") ("Huge") | |
290 ) | |
291 "Default completion table for large-type completion." | |
292 ) | |
0 | 293 (defvar user-fontsize-table nil) |
6 | 294 (defvar tmp-fontsize-table nil) |
0 | 295 |
22 | 296 (defvar singlecmd-table |
51 | 297 (append |
298 '(("maketitle") ("sloppy") ("protect") | |
299 ("LaTeX") ("TeX") ("item") ("item[]") ("appendix") ("hline") | |
54 | 300 ;;("rightarrow") ("Rightarrow") ("leftarrow") ("Leftarrow") |
51 | 301 ("pagebreak") ("newpage") ("clearpage") ("cleardoublepage") |
302 ("footnotemark") ("verb") ("verb*") | |
59 | 303 ("linebreak") ("pagebreak") ("noindent") ("indent") |
51 | 304 ("left") ("right") |
305 ) | |
306 (if YaTeX-greek-by-maketitle-completion | |
307 '(("alpha") ("beta") ("gamma") ("delta") ("epsilon") | |
308 ("varepsilon") ("zeta") ("eta") ("theta")("vartheta") | |
309 ("iota") ("kappa") ("lambda") ("mu") ("nu") ("xi") ("pi") | |
310 ("varpi") ("rho") ("varrho") ("sigma") ("varsigma") ("tau") | |
311 ("upsilon") ("phi") ("varphi") ("chi") ("psi") ("omega") | |
312 ("Gamma") ("Delta") ("Theta") ("Lambda")("Xi") ("Pi") | |
313 ("Sigma") ("Upsilon") ("Phi") ("Psi") ("Omega")))) | |
22 | 314 "Default completion table for maketitle-type completion." |
315 ) | |
0 | 316 (defvar user-singlecmd-table nil) |
6 | 317 (defvar tmp-singlecmd-table nil) |
0 | 318 |
319 ;---------- Key mode map ---------- | |
320 ;;; | |
321 ;; Create new key map: YaTeX-mode-map | |
322 ;; Do not change this section. | |
323 ;;; | |
324 (defvar YaTeX-mode-map nil | |
54 | 325 "Keymap used in YaTeX mode" |
0 | 326 ) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
327 (defvar YaTeX-typesetting-mode-map nil |
54 | 328 "Keymap used in YaTeX typesetting buffer" |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
329 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
330 (defvar YaTeX-prefix-map nil |
54 | 331 "Keymap used when YaTeX-prefix key pushed" |
0 | 332 ) |
54 | 333 (defvar YaTeX-user-extensional-map (make-sparse-keymap) |
334 "*Keymap used for the user's customization") | |
7 | 335 (defvar YaTeX-current-completion-type nil |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
336 "Has current completion type. This may be used in YaTeX addin functions." |
7 | 337 ) |
22 | 338 (defvar YaTeX-modify-mode nil |
51 | 339 "*Current editing mode. |
340 When non-nil, each opening parentheses only opens, | |
341 nil enters both open/close parentheses when opening parentheses key pressed." | |
22 | 342 ) |
343 (defvar YaTeX-math-mode nil | |
344 "Holds whether current mode is math-mode." | |
345 ) | |
13 | 346 ;---------- Define default key bindings on YaTeX mode map ---------- |
57 | 347 (defun YaTeX-define-key (key binding &optional map) |
51 | 348 "Define key on YaTeX-prefix-map." |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
349 (if YaTeX-inhibit-prefix-letter |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
350 (let ((c (aref key 0))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
351 (cond |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
352 ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a)))) |
14 | 353 ((and (>= c ?A) (<= c ?Z) (numberp YaTeX-inhibit-prefix-letter)) |
354 (aset key 0 (1+ (- c ?A)))) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
355 (t nil)))) |
57 | 356 (define-key (or map YaTeX-prefix-map) key binding) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
357 ) |
57 | 358 (defun YaTeX-define-begend-key-normal (key env &optional map) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
359 "Define short cut YaTeX-make-begin-end key." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
360 (YaTeX-define-key |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
361 key |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
362 (list 'lambda '(arg) '(interactive "P") |
57 | 363 (list 'YaTeX-insert-begin-end env 'arg)) |
364 map) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
365 ) |
57 | 366 (defun YaTeX-define-begend-region-key (key env &optional map) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
367 "Define short cut YaTeX-make-begin-end-region key." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
368 (YaTeX-define-key key (list 'lambda nil '(interactive) |
57 | 369 (list 'YaTeX-insert-begin-end env t)) map) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
370 ) |
57 | 371 (defun YaTeX-define-begend-key (key env &optional map) |
7 | 372 "Define short cut key for begin type completion both for normal |
373 and region mode. To customize YaTeX, user should use this function." | |
57 | 374 (YaTeX-define-begend-key-normal key env map) |
7 | 375 (if YaTeX-inhibit-prefix-letter nil |
376 (YaTeX-define-begend-region-key | |
377 (concat (upcase (substring key 0 1)) (substring key 1)) env)) | |
378 ) | |
0 | 379 ;;; |
380 ;; Define key table | |
381 ;;; | |
382 (if YaTeX-mode-map | |
383 nil | |
384 (setq YaTeX-mode-map (make-sparse-keymap)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
385 (setq YaTeX-prefix-map (make-sparse-keymap)) |
0 | 386 (define-key YaTeX-mode-map "\"" 'YaTeX-insert-quote) |
5 | 387 (define-key YaTeX-mode-map "{" 'YaTeX-insert-braces) |
22 | 388 (define-key YaTeX-mode-map "(" 'YaTeX-insert-parens) |
7 | 389 (define-key YaTeX-mode-map "$" 'YaTeX-insert-dollar) |
57 | 390 (define-key YaTeX-mode-map "&" 'YaTeX-insert-amper) |
22 | 391 (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
|
392 (define-key YaTeX-mode-map YaTeX-prefix YaTeX-prefix-map) |
22 | 393 (define-key YaTeX-mode-map "\M-\C-@" 'YaTeX-mark-environment) |
394 (define-key YaTeX-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment) | |
395 (define-key YaTeX-mode-map "\M-\C-e" 'YaTeX-end-of-environment) | |
396 (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
|
397 (define-key YaTeX-mode-map "\C-i" 'YaTeX-indent-line) |
13 | 398 (YaTeX-define-key "%" 'YaTeX-%-menu) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
399 (YaTeX-define-key "t" 'YaTeX-typeset-menu) |
11 | 400 (YaTeX-define-key "w" 'YaTeX-switch-mode-menu) |
5 | 401 (YaTeX-define-key "'" 'YaTeX-prev-error) |
402 (YaTeX-define-key "^" 'YaTeX-visit-main) | |
403 (YaTeX-define-key "4^" 'YaTeX-visit-main-other-window) | |
51 | 404 (YaTeX-define-key "4g" 'YaTeX-goto-corresponding-*-other-window) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
405 (YaTeX-define-key "44" 'YaTeX-switch-to-window) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
406 (and YaTeX-emacs-19 window-system |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
407 (progn |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
408 (YaTeX-define-key "5^" 'YaTeX-visit-main-other-frame) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
409 (YaTeX-define-key "5g" 'YaTeX-goto-corresponding-*-other-frame) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
410 (YaTeX-define-key "55" 'YaTeX-switch-to-window))) |
5 | 411 (YaTeX-define-key " " 'YaTeX-do-completion) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
412 (YaTeX-define-key "v" 'YaTeX-version) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
413 |
5 | 414 (YaTeX-define-key "}" 'YaTeX-insert-braces-region) |
415 (YaTeX-define-key "]" 'YaTeX-insert-brackets-region) | |
11 | 416 (YaTeX-define-key ")" 'YaTeX-insert-parens-region) |
417 (YaTeX-define-key "$" 'YaTeX-insert-dollars-region) | |
5 | 418 (YaTeX-define-key "i" 'YaTeX-fill-item) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
419 (YaTeX-define-key |
7 | 420 "\\" '(lambda () (interactive) (insert "$\\backslash$"))) |
22 | 421 (if YaTeX-no-begend-shortcut |
422 (progn | |
423 (YaTeX-define-key "B" 'YaTeX-make-begin-end-region) | |
424 (YaTeX-define-key "b" 'YaTeX-make-begin-end)) | |
425 (YaTeX-define-begend-key "bc" "center") | |
426 (YaTeX-define-begend-key "bd" "document") | |
427 (YaTeX-define-begend-key "bD" "description") | |
428 (YaTeX-define-begend-key "be" "enumerate") | |
429 (YaTeX-define-begend-key "bE" "equation") | |
430 (YaTeX-define-begend-key "bi" "itemize") | |
431 (YaTeX-define-begend-key "bl" "flushleft") | |
432 (YaTeX-define-begend-key "bm" "minipage") | |
433 (YaTeX-define-begend-key "bt" "tabbing") | |
434 (YaTeX-define-begend-key "bT" "tabular") | |
435 (YaTeX-define-begend-key "b\^t" "table") | |
436 (YaTeX-define-begend-key "bp" "picture") | |
437 (YaTeX-define-begend-key "bq" "quote") | |
438 (YaTeX-define-begend-key "bQ" "quotation") | |
439 (YaTeX-define-begend-key "br" "flushright") | |
440 (YaTeX-define-begend-key "bv" "verbatim") | |
441 (YaTeX-define-begend-key "bV" "verse") | |
442 (YaTeX-define-key "B " 'YaTeX-make-begin-end-region) | |
443 (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
|
444 (YaTeX-define-key "e" 'YaTeX-end-environment) |
14 | 445 (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
|
446 (YaTeX-define-key "s" 'YaTeX-make-section) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
447 (YaTeX-define-key "L" 'YaTeX-make-fontsize-region) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
448 (YaTeX-define-key "l" 'YaTeX-make-fontsize) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
449 (YaTeX-define-key "m" 'YaTeX-make-singlecmd) |
22 | 450 (YaTeX-define-key "." 'YaTeX-comment-paragraph) |
451 (YaTeX-define-key "," 'YaTeX-uncomment-paragraph) | |
452 (YaTeX-define-key ">" 'YaTeX-comment-region) | |
453 (YaTeX-define-key "<" 'YaTeX-uncomment-region) | |
5 | 454 (YaTeX-define-key "g" 'YaTeX-goto-corresponding-*) |
455 (YaTeX-define-key "k" 'YaTeX-kill-*) | |
456 (YaTeX-define-key "c" 'YaTeX-change-*) | |
457 (YaTeX-define-key "a" 'YaTeX-make-accent) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
458 (YaTeX-define-key "?" 'YaTeX-help) |
22 | 459 (YaTeX-define-key "/" 'YaTeX-apropos) |
460 (YaTeX-define-key "&" 'YaTeX-what-column) | |
52 | 461 (YaTeX-define-key "d" 'YaTeX-display-hierarchy) |
54 | 462 (YaTeX-define-key "x" YaTeX-user-extensional-map) |
5 | 463 (YaTeX-define-key "n" |
7 | 464 '(lambda () (interactive) (insert "\\\\"))) |
13 | 465 (if YaTeX-dos |
7 | 466 (define-key YaTeX-prefix-map "\C-r" |
0 | 467 '(lambda () (interactive) |
3 | 468 (set-screen-height YaTeX-saved-screen-height) (recenter)))) |
22 | 469 (mapcar |
470 (function | |
471 (lambda (key) | |
472 (define-key YaTeX-mode-map (car key) 'YaTeX-math-insert-sequence))) | |
473 YaTeX-math-key-list) | |
0 | 474 ) |
475 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
476 (if YaTeX-typesetting-mode-map nil |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
477 (setq YaTeX-typesetting-mode-map (make-keymap)) |
7 | 478 ;(suppress-keymap YaTeX-typesetting-mode-map t) |
479 (define-key YaTeX-typesetting-mode-map " " 'YaTeX-jump-error-line) | |
480 (define-key YaTeX-typesetting-mode-map "\C-m" 'YaTeX-send-string) | |
61 | 481 (define-key YaTeX-typesetting-mode-map "1" 'delete-other-windows) |
482 (define-key YaTeX-typesetting-mode-map "0" 'delete-window) | |
483 (define-key YaTeX-typesetting-mode-map "q" 'delete-window) | |
0 | 484 ) |
485 | |
49 | 486 (defvar YaTeX-section-completion-map nil |
22 | 487 "*Key map used at YaTeX completion in the minibuffer.") |
49 | 488 (if YaTeX-section-completion-map nil |
489 (setq YaTeX-section-completion-map | |
22 | 490 (copy-keymap (or (and (boundp 'gmhist-completion-map) |
491 gmhist-completion-map) | |
492 minibuffer-local-completion-map))) | |
49 | 493 (define-key YaTeX-section-completion-map |
22 | 494 " " 'YaTeX-minibuffer-complete) |
49 | 495 (define-key YaTeX-section-completion-map |
22 | 496 "\C-i" 'YaTeX-minibuffer-complete) |
49 | 497 (define-key YaTeX-section-completion-map |
22 | 498 "\C-v" 'YaTeX-read-section-with-overview)) |
499 | |
14 | 500 (defvar YaTeX-recursive-map nil |
22 | 501 "*Key map used at YaTeX reading arguments in the minibuffer.") |
14 | 502 (if YaTeX-recursive-map nil |
503 (setq YaTeX-recursive-map (copy-keymap global-map)) | |
504 (define-key YaTeX-recursive-map YaTeX-prefix YaTeX-prefix-map)) | |
505 | |
506 ;; (define-key YaTeX-recursive-map | |
507 ;; (concat YaTeX-prefix (if YaTeX-inhibit-prefix-letter "\C-s" "s")) | |
508 ;; 'YaTeX-make-section) | |
509 ;; (define-key map | |
510 ;; (concat YaTeX-prefix (if YaTeX-inhibit-prefix-letter "\C-m" "m")) | |
511 ;; 'YaTeX-make-singlecmd) | |
512 ;; (define-key map | |
513 ;; (concat YaTeX-prefix (if YaTeX-inhibit-prefix-letter "\C-l" "l")) | |
514 ;; 'YaTeX-make-fontsize) | |
515 | |
516 | |
0 | 517 ;---------- Define other variable ---------- |
22 | 518 (defvar env-name "document" "*Initial tex-environment completion") |
519 (defvar section-name "documentstyle" "*Initial tex-section completion") | |
520 (defvar fontsize-name "large" "*Initial fontsize completion") | |
521 (defvar single-command "maketitle" "*Initial LaTeX single command") | |
51 | 522 (defvar YaTeX-user-table-is-read nil |
5 | 523 "Flag that means whether user completion table has been read or not." |
0 | 524 ) |
22 | 525 (defvar YaTeX-kanji-code-alist nil |
526 "Kanji-code expression translation table." | |
5 | 527 ) |
13 | 528 (if (boundp 'MULE) |
22 | 529 (setq YaTeX-kanji-code-alist |
530 (list (cons | |
531 1 | |
532 (if YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos) | |
533 *sjis*)) | |
534 '(2 . *junet*) '(3 . *euc-japan*)) | |
13 | 535 )) |
536 (defvar YaTeX-kanji-code (if YaTeX-dos 1 2) | |
5 | 537 "*File kanji code used by Japanese TeX." |
538 ) | |
22 | 539 (defvar YaTeX-coding-system nil "File coding system used by Japanese TeX.") |
540 (defvar YaTeX-latex-message-code "Process coding system for LaTeX.") | |
5 | 541 (cond |
542 ((boundp 'MULE) | |
22 | 543 (setq YaTeX-coding-system |
544 (symbol-value (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))) | |
13 | 545 (if (not YaTeX-dos) |
22 | 546 (setq YaTeX-latex-message-code *autoconv*))) |
5 | 547 ((boundp 'NEMACS) |
22 | 548 (setq YaTeX-latex-message-code latex-message-kanji-code)) |
5 | 549 ) |
14 | 550 (defvar YaTeX-parent-file nil |
551 "*Main LaTeX source file name used when %#! expression doesn't exist.") | |
52 | 552 (make-variable-buffer-local 'YaTeX-parent-file) |
553 | |
14 | 554 ;---------- Provide YaTeX-mode ---------- |
0 | 555 ;;; |
556 ;; Major mode definition | |
557 ;;; | |
558 (defun yatex-mode () | |
7 | 559 " Yet Another LaTeX mode: Major mode for editing input files of LaTeX. |
13 | 560 -You can invoke processes concerning LaTeX typesetting by |
7 | 561 \\[YaTeX-typeset-menu] |
22 | 562 -Complete LaTeX environment form of `\\begin{env} ... \\end{env}' by |
7 | 563 \\[YaTeX-make-begin-end] |
564 -Enclose region into some environment by | |
565 \\[universal-argument] \\[YaTeX-make-begin-end] | |
566 -Complete LaTeX command which takes argument like `\\section{}' by | |
567 \\[YaTeX-make-section] | |
568 -Put LaTeX command which takes no arguments like `\\maketitle' by | |
569 \\[YaTeX-make-singlecmd] | |
570 -Complete font or character size descriptor like `{\\large }' by | |
571 \\[YaTeX-make-fontsize] | |
22 | 572 -Enclose region into those descriptors above by |
7 | 573 \\[universal-argument] \\[YaTeX-make-fontsize] |
54 | 574 -Enter European accent notations by |
7 | 575 \\[YaTeX-make-accent] |
13 | 576 -Toggle various modes of YaTeX by |
577 \\[YaTeX-switch-mode-menu] | |
22 | 578 -Change environt name (on the begin/end line) by |
579 \\[YaTeX-change-*] | |
580 -Kill LaTeX command/environment sequences by | |
581 \\[YaTeX-kill-*] | |
582 -Kill LaTeX command/environment with its contents | |
583 \\[universal-argument] \\[YaTeX-kill-*] | |
584 -Go to corresponding object (begin/end, file, labels) by | |
54 | 585 \\[YaTeX-goto-corresponding-*] or |
586 \\[YaTeX-goto-corresponding-*-other-window] (in other window) | |
587 \\[YaTeX-goto-corresponding-*-other-frame] (in other frame) | |
22 | 588 -Go to main LaTeX source text by |
54 | 589 \\[YaTeX-visit-main] or |
590 \\[YaTeX-visit-main-other-window] (in other window) | |
591 \\[YaTeX-visit-main-other-frame] (in other frame) | |
22 | 592 -Comment out or uncomment region by |
593 \\[YaTeX-comment-region] or \\[YaTeX-uncomment-region] | |
594 -Comment out or uncomment paragraph by | |
595 \\[YaTeX-comment-paragraph] or \\[YaTeX-uncomment-paragraph] | |
596 -Make an \\item entry hang-indented by | |
597 \\[YaTeX-fill-item] | |
598 -Enclose the region with parentheses by | |
599 \\[YaTeX-insert-parens-region] | |
600 \\[YaTeX-insert-braces-region] | |
601 \\[YaTeX-insert-brackets-region] | |
602 \\[YaTeX-insert-dollars-region] | |
603 -Look up the corresponding column header of tabular environment by | |
604 \\[YaTeX-what-column] | |
54 | 605 -Enter a newline and an entry suitable for environment by |
606 \\[YaTeX-intelligent-newline] | |
607 -View the structure of file inclusion by | |
608 \\[YaTeX-display-hierarchy] | |
22 | 609 -Refer the online help of popular LaTeX commands by |
54 | 610 \\[YaTeX-help] (help) |
611 \\[YaTeX-apropos] (apropos) | |
13 | 612 -Edit `%# notation' by |
613 \\[YaTeX-%-menu] | |
7 | 614 |
615 Those are enough for fastening your editing of LaTeX source. But further | |
22 | 616 more features are available and they are documented in the manual. |
617 " | |
0 | 618 (interactive) |
619 (kill-all-local-variables) | |
7 | 620 (setq major-mode 'yatex-mode) |
55 | 621 (setq mode-name (if YaTeX-japan "‚â‚Ä‚Ó" "YaTeX")) |
18 | 622 (mapcar 'make-local-variable |
52 | 623 '(dvi2-command fill-column fill-prefix |
18 | 624 tmp-env-table tmp-section-table tmp-fontsize-table |
52 | 625 tmp-singlecmd-table paragraph-start paragraph-separate |
626 YaTeX-math-mode indent-line-function | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
627 comment-start comment-start-skip |
22 | 628 )) |
14 | 629 (cond ((boundp 'MULE) |
5 | 630 (set-file-coding-system YaTeX-coding-system)) |
631 ((boundp 'NEMACS) | |
632 (make-local-variable 'kanji-fileio-code) | |
633 (setq kanji-fileio-code YaTeX-kanji-code))) | |
634 (setq fill-column YaTeX-fill-column | |
7 | 635 fill-prefix YaTeX-fill-prefix |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
636 paragraph-start YaTeX-paragraph-start |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
637 paragraph-separate YaTeX-paragraph-separate |
52 | 638 indent-line-function 'YaTeX-indent-line |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
639 comment-start YaTeX-comment-prefix |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
640 comment-end "" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
641 ;;comment-start-skip "[^\\\\]%+[ \t]*" |
22 | 642 ) |
0 | 643 (use-local-map YaTeX-mode-map) |
13 | 644 (if YaTeX-dos (setq YaTeX-saved-screen-height (screen-height))) |
6 | 645 (YaTeX-read-user-completion-table) |
54 | 646 (and (fboundp 'YaTeX-19-collect-macros) (YaTeX-19-collect-macros)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
647 (turn-on-auto-fill) ;1.63 |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
648 (run-hooks 'text-mode-hook 'yatex-mode-hook) |
5 | 649 ) |
650 | |
0 | 651 ;---------- Define YaTeX-mode functions ---------- |
13 | 652 (defvar YaTeX-ec "\\" "Escape character of current mark-up language.") |
22 | 653 (defvar YaTeX-ec-regexp (regexp-quote YaTeX-ec)) |
13 | 654 (defvar YaTeX-struct-begin |
655 (concat YaTeX-ec "begin{%1}%2") | |
656 "Keyword to begin environment.") | |
657 (defvar YaTeX-struct-end (concat YaTeX-ec "end{%1}") | |
658 "Keyword to end environment.") | |
659 (defvar YaTeX-struct-name-regexp "[^}]+" | |
660 "Environment name regexp.") | |
22 | 661 (defvar YaTeX-TeX-token-regexp |
55 | 662 (cond (YaTeX-japan "[A-Za-z*‚ -‚ñˆŸ-êž]+") |
22 | 663 (t "[A-Za-z*]+")) |
664 "Regexp of characters which can be a member of TeX command's name.") | |
32
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
665 (defvar YaTeX-command-token-regexp YaTeX-TeX-token-regexp |
51 | 666 "Regexp of characters which can be a member of current mark up language's command name.") |
49 | 667 |
13 | 668 ;;(defvar YaTeX-struct-section |
669 ;; (concat YaTeX-ec "%1{%2}") | |
670 ;; "Keyword to make section.") | |
671 | |
0 | 672 ;;; |
22 | 673 ;; autoload section |
674 ;;; | |
51 | 675 ;;autoload from yatexlib(general functions). |
22 | 676 (autoload 'YaTeX-showup-buffer "yatexlib" "YaTeX library" t) |
677 (autoload 'YaTeX-window-list "yatexlib" "YaTeX library" t) | |
678 (autoload 'YaTeX-search-active-forward "yatexlib" "YaTeX library" t) | |
679 (autoload 'YaTeX-search-active-backward "yatexlib" "YaTeX library" t) | |
680 (autoload 'substitute-all-key-definition "yatexlib" "YaTeX library" t) | |
681 (autoload 'YaTeX-switch-to-buffer "yatexlib" "YaTeX library" t) | |
682 (autoload 'YaTeX-switch-to-buffer-other-window "yatexlib" "YaTeX library" t) | |
683 (autoload 'YaTeX-replace-format "yatexlib" "YaTeX library" t) | |
684 (autoload 'YaTeX-replace-format-args "yatexlib" "YaTeX library" t) | |
685 (autoload 'rindex "yatexlib" "YaTeX library" t) | |
686 (autoload 'YaTeX-match-string "yatexlib" "YaTeX library" t) | |
687 (autoload 'YaTeX-minibuffer-complete "yatexlib" "YaTeX library" t) | |
51 | 688 (autoload 'goto-buffer-window "yatexlib" "YaTeX library" t) |
689 (autoload 'split-window-calculate-height "yatexlib" "YaTeX library" t) | |
690 (autoload 'read-string-with-history "yatexlib" "YaTeX library" t) | |
691 (autoload 'read-from-minibuffer-with-history "yatexlib" "YaTeX library" t) | |
692 (autoload 'completing-read-with-history "yatexlib" "YaTeX library" t) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
693 (autoload 'YaTeX-switch-to-window "yatexlib" "For windows.el" t) |
22 | 694 |
695 ;;autoload from yatexprc.el | |
696 (autoload 'YaTeX-visit-main "yatexprc" "Visit main LaTeX file." t) | |
697 (autoload 'YaTeX-visit-main-other-window "yatexprc" | |
52 | 698 "Visit main other window." t) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
699 (autoload 'YaTeX-main-file-p "yatexprc" "Check if the file is main." t) |
51 | 700 (autoload 'YaTeX-get-builtin "yatexprc" "Get %# built-in." t) |
59 | 701 (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
|
702 (autoload 'YaTeX-save-buffers "yatexprc" "Save buffers of same major mode" t) |
22 | 703 |
704 ;;autoload from yatexmth.el | |
705 (autoload 'YaTeX-math-insert-sequence "yatexmth" "Image input." t) | |
706 (autoload 'YaTeX-in-math-mode-p "yatexmth" "Check if in math-env." t) | |
707 (autoload 'YaTeX-toggle-math-mode "yatexmth" "YaTeX math-mode interfaces." t) | |
52 | 708 (autoload 'YaTeX-math-member-p "yatexmth" "Check if a word is math command." t) |
22 | 709 |
710 ;;autoload from yatexhlp.el | |
711 (autoload 'YaTeX-help "yatexhlp" "YaTeX helper with LaTeX commands." t) | |
712 (autoload 'YaTeX-apropos "yatexhlp" "Apropos for (La)TeX commands." t) | |
713 | |
714 ;;autoload from yatexgen.el | |
715 (autoload 'YaTeX-generate "yatexgen" "YaTeX add-in function generator." t) | |
716 (autoload 'YaTeX-generate-simple "yatexgen" "YaTeX add-in support." t) | |
717 | |
718 ;;autoload from yatexsec.el | |
719 (autoload 'YaTeX-read-section-in-minibuffer "yatexsec" "YaTeX sectioning" t) | |
720 (autoload 'YaTeX-make-section-with-overview "yatexsec" "YaTeX sectioning" t) | |
721 | |
722 ;;autoload from yatexenv.el | |
723 (autoload 'YaTeX-what-column "yatexenv" "YaTeX env. specific funcs" t) | |
724 (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
|
725 (autoload 'YaTeX-indent-line-equation "yatexenv" "Indent equation lines." t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
726 (autoload 'YaTeX-goto-corresponding-leftright "yatexenv" "\left\right jumps" t) |
22 | 727 |
52 | 728 ;;autoload from yatexhie.el |
729 (autoload 'YaTeX-display-hierarchy "yatexhie" | |
730 "YaTeX document hierarchy browser" t) | |
61 | 731 (autoload 'YaTeX-display-hierarchy-directly "yatexhie" |
732 "Same as YaTeX-display-hierarchy. Call from mouse." t) | |
52 | 733 |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
734 ;; autoload from yahtml.el |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
735 (autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
736 |
22 | 737 ;;; |
0 | 738 ;; YaTeX-mode functions |
739 ;;; | |
22 | 740 (defun YaTeX-insert-begin-end (env region-mode) |
45 | 741 "Insert \\begin{mode-name} and \\end{mode-name}. |
22 | 742 This works also for other defined begin/end tokens to define the structure." |
7 | 743 (setq YaTeX-current-completion-type 'begin) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
744 (let*((ccol (current-column)) beg beg2 exchange |
22 | 745 (arg region-mode) ;for old compatibility |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
746 (indent-column (+ ccol YaTeX-environment-indent))(i 1) func) |
22 | 747 (if (and region-mode (> (point) (mark))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
748 (progn (exchange-point-and-mark) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
749 (setq exchange t |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
750 ccol (current-column) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
751 indent-column (+ ccol YaTeX-environment-indent)))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
752 ;;VER2 (insert "\\begin{" env "}" (YaTeX-addin env)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
753 (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
754 (YaTeX-insert-struc 'begin env) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
755 (setq beg2 (point)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
756 (insert "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
757 (indent-to indent-column) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
758 (save-excursion |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
759 ;;indent optional argument of \begin{env}, if any |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
760 (while (> (point-beginning-of-line) beg) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
761 (skip-chars-forward "\\s " (point-end-of-line)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
762 (indent-to indent-column) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
763 (forward-line -1))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
764 (require 'yatexenv) |
22 | 765 (if region-mode |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
766 ;;if region-mode, indent all text in the region |
7 | 767 (save-excursion |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
768 (if (fboundp (intern-soft (concat "YaTeX-enclose-" env))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
769 (funcall (intern-soft (concat "YaTeX-enclose-" env)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
770 (point) (mark)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
771 (while (< (progn (forward-line 1) (point)) (mark)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
772 (if (eolp) nil |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
773 (skip-chars-forward " \t\n") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
774 (indent-to indent-column)))))) |
22 | 775 (if region-mode (exchange-point-and-mark)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
776 (indent-to ccol) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
777 ;;VER2 (insert "\\end{" env "}\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
778 (YaTeX-insert-struc 'end env) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
779 (YaTeX-reindent ccol) |
22 | 780 (if region-mode |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
781 (progn |
54 | 782 (insert "\n") |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
783 (or exchange (exchange-point-and-mark))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
784 (goto-char beg2) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
785 (YaTeX-intelligent-newline nil)) |
5 | 786 (if YaTeX-current-position-register |
787 (point-to-register YaTeX-current-position-register))) | |
0 | 788 ) |
789 | |
790 (defun YaTeX-make-begin-end (arg) | |
791 "Make LaTeX environment command of \\begin{env.} ... \\end{env.} | |
792 by completing read. | |
793 If you invoke this command with universal argument, | |
5 | 794 \(key binding for universal-argument is \\[universal-argument]\) |
0 | 795 you can put REGION into that environment between \\begin and \\end." |
796 (interactive "P") | |
797 (let* | |
798 ((mode (if arg " region" "")) | |
799 (env | |
5 | 800 (YaTeX-read-environment |
801 (format "Begin environment%s(default %s): " mode env-name)))) | |
0 | 802 (if (string= env "") |
803 (setq env env-name)) | |
804 (setq env-name env) | |
7 | 805 (YaTeX-update-table |
806 (list env-name) 'env-table 'user-env-table 'tmp-env-table) | |
0 | 807 (YaTeX-insert-begin-end env-name arg)) |
808 ) | |
809 | |
810 (defun YaTeX-make-begin-end-region () | |
811 "Call YaTeX-make-begin-end with ARG to specify region mode." | |
812 (interactive) | |
813 (YaTeX-make-begin-end t) | |
814 ) | |
815 | |
22 | 816 (defun YaTeX-inner-environment (&optional quick) |
817 "Return current inner-most environment. | |
818 Non-nil for optional argument QUICK restricts search bound to most | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
819 recent sectioning command. Matching point is stored to property 'point |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
820 of 'YaTeX-inner-environment, which can be referred by |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
821 (get 'YaTeX-inner-environment 'point)." |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
822 (let*((nest 0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
823 (beg (YaTeX-replace-format-args |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
824 (regexp-quote YaTeX-struct-begin) |
59 | 825 YaTeX-struct-name-regexp |
826 (if (eq major-mode 'yahtml-mode) "\\s *.*" "") | |
827 "")) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
828 (end (YaTeX-replace-format-args |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
829 (regexp-quote YaTeX-struct-end) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
830 YaTeX-struct-name-regexp "" "")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
831 (begend (concat "\\(" beg "\\)\\|\\(" end "\\)")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
832 bound m0 |
54 | 833 (open |
834 (concat "^" (or (cdr (assq major-mode '((yahtml-mode . "<")))) "{"))) | |
835 (close | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
836 (concat "^" |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
837 (or (cdr(assq major-mode '((yahtml-mode . "\n\t >")))) "}")))) |
22 | 838 (save-excursion |
839 (if quick | |
840 (setq bound | |
841 (save-excursion | |
842 (YaTeX-re-search-active-backward | |
52 | 843 (concat YaTeX-ec-regexp |
844 "\\(" YaTeX-sectioning-regexp "\\)\\*?\\{") | |
22 | 845 YaTeX-comment-prefix nil 1) |
52 | 846 (or (bobp) (end-of-line)) |
847 (point)))) | |
22 | 848 (if (catch 'begin |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
849 (if (and (numberp bound) (< (point) bound)) (throw 'begin nil)) |
22 | 850 (while (YaTeX-re-search-active-backward |
851 begend YaTeX-comment-prefix bound t) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
852 (setq m0 (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
853 (if (looking-at end) ;;(match-beginning 2) |
22 | 854 (setq nest (1+ nest)) |
855 (setq nest (1- nest))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
856 (if (< nest 0) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
857 (progn |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
858 (put 'YaTeX-inner-environment 'point m0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
859 (goto-char m0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
860 (put 'YaTeX-inner-environment 'indent (current-column)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
861 (throw 'begin t))))) |
22 | 862 (buffer-substring |
54 | 863 (progn (skip-chars-forward open) (1+ (point))) |
864 (progn (skip-chars-forward close) (point)))))) | |
5 | 865 ) |
866 | |
867 (defun YaTeX-end-environment () | |
868 "Close opening environment" | |
869 (interactive) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
870 (let ((env (YaTeX-inner-environment))) |
5 | 871 (if (not env) (error "No premature environment") |
3 | 872 (save-excursion |
22 | 873 (if (YaTeX-search-active-forward |
874 (YaTeX-replace-format-args YaTeX-struct-end env "" "") | |
875 YaTeX-comment-prefix nil t) | |
3 | 876 (if (y-or-n-p |
877 (concat "Environment `" env | |
13 | 878 "' may be already closed. Force close?")) |
3 | 879 nil |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
880 (error "end environment aborted.")))) |
3 | 881 (message "") ;Erase (y or n) message. |
13 | 882 (YaTeX-insert-struc 'end env) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
883 (save-excursion |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
884 (goto-char (or (get 'YaTeX-inner-environment 'point) (match-end 0))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
885 (if (pos-visible-in-window-p) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
886 (sit-for (if YaTeX-dos 2 1)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
887 (message "Matches with %s at line %d" |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
888 (YaTeX-replace-format-args YaTeX-struct-begin env "" "") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
889 (count-lines (point-min) (point))))))) |
3 | 890 ) |
891 | |
13 | 892 ;;;VER2 |
893 (defun YaTeX-insert-struc (what env) | |
894 (cond | |
895 ((eq what 'begin) | |
896 (insert (YaTeX-replace-format-args | |
897 YaTeX-struct-begin env (YaTeX-addin env)))) | |
898 ((eq what 'end) | |
899 (insert (YaTeX-replace-format-args YaTeX-struct-end env))) | |
900 (t nil)) | |
901 ) | |
902 | |
46 | 903 (defun YaTeX-make-section (arg &optional beg end cmd) |
0 | 904 "Make LaTeX \\section{} type command with completing read. |
13 | 905 With numeric ARG, you can specify the number of arguments of |
0 | 906 LaTeX command. |
907 For example, if you want to produce LaTeX command | |
908 | |
909 \\addtolength{\\topmargin}{8mm} | |
910 | |
5 | 911 which has two arguments. You can produce that sequence by typing... |
0 | 912 ESC 2 C-c s add SPC RET \\topm SPC RET 8mm RET |
913 \(by default\) | |
13 | 914 Then yatex will automatically complete `addtolength' with two arguments |
6 | 915 next time. |
14 | 916 You can complete symbol at LaTeX command and the 1st argument. |
917 | |
918 If the optional 2nd and 3rd argument BEG END are specified, enclose | |
46 | 919 the region from BEG to END into the first argument of the LaTeX sequence. |
920 Optional 4th arg CMD is LaTeX command name, for non-interactive use." | |
6 | 921 (interactive "P") |
7 | 922 (setq YaTeX-current-completion-type 'section) |
14 | 923 (unwind-protect |
924 (let* | |
22 | 925 ((source-window (selected-window)) |
926 (section | |
46 | 927 (or cmd |
928 (YaTeX-read-section | |
54 | 929 (if YaTeX-simple-messages |
930 (format "Section-type (default %s): " section-name) | |
931 (if (> (minibuffer-depth) 0) | |
932 (format "%s???{} (default %s)%s: " YaTeX-ec section-name | |
933 (format "[level:%d]" (minibuffer-depth))) | |
934 (format "(C-v for view-section) %s???{} (default %s): " | |
935 YaTeX-ec section-name))) | |
46 | 936 nil))) |
14 | 937 (section (if (string= section "") section-name section)) |
938 (numarg ;; The number of section-type command's argument | |
939 (or arg | |
51 | 940 (nth 1 (YaTeX-lookup-table section 'section)) |
14 | 941 1)) |
942 (arg-reader (intern-soft (concat "YaTeX::" section))) | |
943 (addin-args (and arg-reader (fboundp arg-reader))) | |
944 (title "") | |
54 | 945 (j 1) |
14 | 946 (enable-recursive-minibuffers t));;let |
947 (setq section-name section) | |
948 (if beg | |
949 (let ((e (make-marker))) | |
950 (goto-char end) | |
951 (insert "}") | |
952 (set-marker e (point)) | |
953 (goto-char beg) | |
954 (insert YaTeX-ec section-name "{") | |
955 (goto-char (marker-position e))) | |
956 (use-global-map YaTeX-recursive-map) | |
54 | 957 (if (= numarg 0) (YaTeX-make-singlecmd section-name) |
55 | 958 (insert YaTeX-ec section-name (YaTeX-addin section-name))) |
54 | 959 (while (<= j numarg) |
960 (insert | |
961 "{" | |
962 (setq title | |
963 (cond | |
964 (addin-args (funcall arg-reader j)) | |
965 (YaTeX-skip-default-reader "") | |
966 (t | |
967 (read-string (format "Argument %d of %s: " j section))))) | |
968 "}") | |
969 (setq j (1+ j)))) | |
14 | 970 (YaTeX-update-table |
971 (if (/= numarg 1) (list section numarg) | |
972 (list section)) | |
973 'section-table 'user-section-table 'tmp-section-table) | |
974 (if YaTeX-current-position-register | |
975 (point-to-register YaTeX-current-position-register)) | |
976 (if (string= (buffer-substring (- (point) 2) (point)) "{}") | |
54 | 977 (forward-char -1)) |
978 (while (string= (buffer-substring (- (point) 3) (1- (point))) "{}") | |
979 (forward-char -2))) | |
14 | 980 (if (<= (minibuffer-depth) 0) (use-global-map global-map))) |
0 | 981 ) |
982 | |
14 | 983 (defun YaTeX-make-section-region (args beg end) |
984 "Call YaTeX-make-section with arguments to specify region mode." | |
985 (interactive "P\nr") | |
986 (YaTeX-make-section args beg end) | |
987 ) | |
0 | 988 |
54 | 989 (defun YaTeX-make-fontsize (arg &optional fontsize) |
0 | 990 "Make completion like {\\large ...} or {\\slant ...} in minibuffer. |
991 If you invoke this command with universal argument, you can put region | |
992 into {\\xxx } braces. | |
5 | 993 \(key binding for universal-argument is \\[universal-argument]\)" |
0 | 994 (interactive "P") |
49 | 995 (YaTeX-sync-local-table 'tmp-fontsize-table) |
0 | 996 (let* ((mode (if arg "region" "")) |
997 (fontsize | |
54 | 998 (or fontsize |
999 (YaTeX-read-fontsize | |
1000 (if YaTeX-simple-messages | |
1001 (format "Font or size (default %s): " fontsize-name) | |
1002 (format "{\\??? %s} (default %s)%s: " mode fontsize-name | |
1003 (if (> (minibuffer-depth) 0) | |
1004 (format "[level:%d]" (minibuffer-depth)) ""))) | |
1005 nil nil)))) | |
0 | 1006 (if (string= fontsize "") |
1007 (setq fontsize fontsize-name)) | |
1008 (setq fontsize-name fontsize) | |
6 | 1009 (YaTeX-update-table |
1010 (list fontsize-name) | |
1011 'fontsize-table 'user-fontsize-table 'tmp-fontsize-table) | |
0 | 1012 (if arg |
1013 (save-excursion | |
1014 (if (> (point) (mark)) (exchange-point-and-mark)) | |
1015 (insert "{\\" fontsize-name " ") | |
1016 (exchange-point-and-mark) | |
1017 (insert "}")) | |
1018 (insert "{\\" fontsize-name " }") | |
5 | 1019 (if YaTeX-current-position-register |
1020 (point-to-register YaTeX-current-position-register)) | |
0 | 1021 (forward-char -1))) |
1022 ) | |
1023 | |
1024 (defun YaTeX-make-fontsize-region () | |
5 | 1025 "Call function:YaTeX-make-fontsize with ARG to specify region mode." |
0 | 1026 (interactive) |
1027 (YaTeX-make-fontsize t) | |
1028 ) | |
1029 | |
52 | 1030 (defvar YaTeX-singlecmd-suffix "" "*Suffix for maketitle-type commands.") |
51 | 1031 (defvar YaTeX-read-singlecmd-history nil "Holds maketitle-type history.") |
1032 (put 'YaTeX-read-singlecmd-history 'no-default t) | |
0 | 1033 (defun YaTeX-make-singlecmd (single) |
1034 (interactive | |
49 | 1035 (list (YaTeX-cplread-with-learning |
54 | 1036 (if YaTeX-simple-messages |
1037 (format "maketitle-type (default %s): " single-command) | |
1038 (format "%s??? (default %s)%s: " YaTeX-ec single-command | |
1039 (if (> (minibuffer-depth) 0) | |
1040 (format "[level:%d]" (minibuffer-depth)) ""))) | |
49 | 1041 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table |
51 | 1042 nil nil nil 'YaTeX-read-singlecmd-history))) |
0 | 1043 (if (string= single "") |
1044 (setq single single-command)) | |
1045 (setq single-command single) | |
7 | 1046 (setq YaTeX-current-completion-type 'maketitle) |
54 | 1047 (let ((dollar (and (not (YaTeX-in-math-mode-p)) |
1048 (YaTeX-math-member-p single-command))) | |
1049 p q) | |
1050 (if dollar (insert "$")) | |
52 | 1051 (insert YaTeX-ec single-command) |
1052 (setq p (point)) | |
1053 (insert (YaTeX-addin single) YaTeX-singlecmd-suffix) | |
54 | 1054 (if dollar (insert "$")) |
52 | 1055 (setq q (point)) |
1056 (goto-char p) | |
1057 (forward-char -2) | |
1058 (if (looking-at "\\[\\]") (forward-char 1) (goto-char q))) | |
5 | 1059 (if YaTeX-current-position-register |
1060 (point-to-register YaTeX-current-position-register)) | |
0 | 1061 ) |
1062 | |
1063 (defvar YaTeX-completion-begin-regexp "[{\\]" | |
51 | 1064 "Regular expression of limit where LaTeX command's completion begins.") |
0 | 1065 |
1066 (defun YaTeX-do-completion () | |
1067 "Try completion on LaTeX command preceding point." | |
1068 (interactive) | |
1069 (if | |
1070 (or (eq (preceding-char) ? ) | |
1071 (eq (preceding-char) ?\t) | |
1072 (eq (preceding-char) ?\n) | |
1073 (bobp)) | |
1074 (message "Nothing to complete.") ;Do not complete | |
1075 (let* ((end (point)) | |
6 | 1076 (limit (point-beginning-of-line)) |
0 | 1077 (completion-begin |
6 | 1078 (progn (re-search-backward "[ \t\n]" limit 1) (point))) |
0 | 1079 (begin (progn |
1080 (goto-char end) | |
1081 (if (re-search-backward YaTeX-completion-begin-regexp | |
1082 completion-begin t) | |
1083 (1+ (point)) | |
1084 nil)))) | |
1085 (goto-char end) | |
1086 (cond | |
1087 ((null begin) | |
13 | 1088 (message "I think it is not a LaTeX sequence.")) |
0 | 1089 (t |
49 | 1090 (mapcar 'YaTeX-sync-local-table |
18 | 1091 '(tmp-section-table tmp-env-table tmp-singlecmd-table)) |
6 | 1092 (let*((pattern (buffer-substring begin end)) |
1093 (all-table | |
1094 (append | |
1095 section-table user-section-table tmp-section-table | |
1096 env-table user-env-table tmp-env-table | |
1097 singlecmd-table user-singlecmd-table tmp-singlecmd-table)) | |
1098 ;; First, | |
1099 ;; search completion without backslash. | |
1100 (completion (try-completion pattern all-table))) | |
0 | 1101 (if |
1102 (eq completion nil) | |
1103 ;; Next, | |
1104 ;; search completion with backslash | |
1105 (setq completion | |
1106 (try-completion (buffer-substring (1- begin) end) | |
1107 all-table nil) | |
1108 begin (1- begin))) | |
1109 (cond | |
1110 ((null completion) | |
1111 (message (concat "Can't find completion for '" pattern "'")) | |
1112 (ding)) | |
1113 ((eq completion t) (message "Sole completion.")) | |
1114 ((not (string= completion pattern)) | |
1115 (kill-region begin end) | |
1116 (insert completion) | |
1117 ) | |
1118 (t | |
1119 (message "Making completion list...") | |
1120 (with-output-to-temp-buffer "*Help*" | |
1121 (display-completion-list | |
6 | 1122 (all-completions pattern all-table)))))))))) |
0 | 1123 ) |
1124 | |
12 | 1125 (defun YaTeX-toggle-modify-mode (&optional arg) |
1126 (interactive "P") | |
1127 (or (memq 'YaTeX-modify-mode mode-line-format) | |
1128 (setq mode-line-format | |
1129 (append (list "" 'YaTeX-modify-mode) mode-line-format))) | |
11 | 1130 (if (or arg (null YaTeX-modify-mode)) |
1131 (progn | |
12 | 1132 (setq YaTeX-modify-mode "*m*") |
11 | 1133 (message "Modify mode")) |
1134 (setq YaTeX-modify-mode nil) | |
1135 (message "Cancel modify mode.")) | |
1136 (set-buffer-modified-p (buffer-modified-p)) ;redraw mode-line | |
1137 ) | |
1138 | |
46 | 1139 (defun YaTeX-switch-mode-menu (arg &optional char) |
11 | 1140 (interactive "P") |
22 | 1141 (message "Toggle: (M)odify-mode ma(T)h-mode") |
46 | 1142 (let ((c (or char (read-char)))) |
11 | 1143 (cond |
1144 ((= c ?m) (YaTeX-toggle-modify-mode arg)) | |
22 | 1145 ((or (= c ?$) (= c ?t)) |
1146 (if YaTeX-auto-math-mode | |
1147 (message "Makes no sense in YaTeX-auto-math-mode.") | |
1148 (YaTeX-toggle-math-mode arg))))) | |
11 | 1149 ) |
1150 | |
0 | 1151 (defun YaTeX-insert-quote () |
1152 (interactive) | |
1153 (insert | |
1154 (cond | |
49 | 1155 ((YaTeX-literal-p) ?\") |
0 | 1156 ((= (preceding-char) ?\\ ) ?\") |
57 | 1157 ;((= (preceding-char) ?\( ) ?\") |
22 | 1158 ((or (= (preceding-char) 32) |
1159 (= (preceding-char) 9) | |
1160 (= (preceding-char) ?\n) | |
1161 (bobp) | |
1162 (string-match | |
57 | 1163 (regexp-quote (char-to-string (preceding-char))) |
1164 "ABCDHIuvwxyz()")) | |
22 | 1165 "``") |
1166 (t "''"))) | |
1167 ) | |
1168 | |
1169 (defun YaTeX-closable-p () | |
1170 (and (not YaTeX-modify-mode) | |
54 | 1171 (not (eq YaTeX-close-paren-always 'never)) |
22 | 1172 (or YaTeX-close-paren-always (eolp)) |
1173 (not (input-pending-p)) | |
49 | 1174 (not (YaTeX-literal-p))) |
22 | 1175 ;;(or YaTeX-modify-mode |
1176 ;; (and (not YaTeX-close-paren-always) (not (eolp))) | |
1177 ;; (input-pending-p) | |
1178 ;; (YaTeX-quick-in-environment-p "verbatim")) | |
1179 ) | |
0 | 1180 |
5 | 1181 (defun YaTeX-insert-braces-region (beg end &optional open close) |
0 | 1182 (interactive "r") |
1183 (save-excursion | |
1184 (goto-char end) | |
5 | 1185 (insert (or close "}")) |
0 | 1186 (goto-char beg) |
5 | 1187 (insert (or open "{"))) |
0 | 1188 ) |
1189 | |
49 | 1190 (defun YaTeX-insert-braces (arg &optional open close) |
1191 (interactive "p") | |
22 | 1192 (let (env) |
1193 (cond | |
51 | 1194 ((YaTeX-jmode) (YaTeX-self-insert arg)) |
49 | 1195 ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1196 ((save-excursion |
59 | 1197 (and (> (- (point) (point-min)) 6) |
1198 (condition-case () (forward-char -6) (error nil))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1199 (looking-at "\\\\left\\\\")) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1200 (insert "{\\right\\}") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1201 (forward-char -8)) |
48 | 1202 ((and (> (point) (+ (point-min) 4)) |
1203 (save-excursion (backward-char 4) (looking-at "\\\\end")) | |
49 | 1204 (not (YaTeX-literal-p)) |
22 | 1205 (setq env (YaTeX-inner-environment))) |
1206 (momentary-string-display | |
1207 (concat | |
48 | 1208 "{" |
22 | 1209 (cond |
1210 (YaTeX-japan | |
55 | 1211 (format "¡“x‚©‚ç‚Í‚¿‚á‚ñ‚Æ %s b ‚ðŽg‚¢‚Ü‚µ‚傤" YaTeX-prefix)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1212 (t (format "You don't understand Zen of `%s b':p" YaTeX-prefix))) |
22 | 1213 "}") |
1214 (point)) | |
47 | 1215 (insert (or open "{") env (or close "}"))) |
22 | 1216 (t |
47 | 1217 (insert (or open "{") (or close "}")) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1218 (forward-char -1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1219 (if (and (eq (char-after (point)) ?\}) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1220 (eq (char-after (- (point) 2)) ?\\ )) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1221 (progn (insert "\\") (forward-char -1))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1222 ))) |
22 | 1223 ) |
1224 | |
1225 (defun YaTeX-jmode () | |
1226 (or (and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1227 (and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*)) |
22 | 1228 ) |
52 | 1229 |
59 | 1230 (defun YaTeX-jmode-off () |
1231 (cond | |
1232 ((and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) | |
1233 (canna-toggle-japanese-mode)) | |
1234 ((and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*) | |
1235 (egg:toggle-egg-mode-on-off)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1236 ((and (fboundp 'skk-mode) (boundp 'skk-mode) skk-mode) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1237 (if (fboundp 'skk-mode-off) (skk-mode-off) (j-mode-off))) |
59 | 1238 ((and (fboundp 'fep-force-off) (fep-force-off)))) |
1239 ) | |
1240 | |
22 | 1241 (defun YaTeX-self-insert (arg) |
52 | 1242 (call-interactively (global-key-binding (char-to-string last-command-char)))) |
1243 | |
22 | 1244 (defun YaTeX-insert-brackets (arg) |
1245 "Insert Kagi-kakko or \\ [ \\] pair or simply \[." | |
1246 (interactive "p") | |
1247 (let ((col (1- (current-column)))) | |
1248 (cond | |
1249 ((YaTeX-jmode) (YaTeX-self-insert arg)) | |
1250 ((not (YaTeX-closable-p)) | |
1251 (YaTeX-self-insert arg)) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1252 ((save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1253 (and (> (- (point) (point-min)) 5) (forward-char -5)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1254 (looking-at "\\\\left")) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1255 (insert "[\\right]") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1256 (forward-char -7)) |
36 | 1257 ((and (= (preceding-char) ?\\ ) |
1258 (/= (char-after (- (point) 2)) ?\\ ) | |
1259 (not (YaTeX-in-math-mode-p))) | |
22 | 1260 (insert last-command-char "\n") |
1261 (indent-to (max 0 col)) | |
1262 (insert "\\]") | |
1263 (beginning-of-line) | |
1264 (open-line 1) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1265 (delete-region (point) (progn (beginning-of-line) (point))) |
22 | 1266 (indent-to (+ YaTeX-environment-indent (max 0 col))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1267 (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1))) |
22 | 1268 ((YaTeX-closable-p) |
1269 (insert "[]") | |
1270 (backward-char 1)) | |
1271 (t (YaTeX-self-insert arg))) | |
1272 ) | |
0 | 1273 ) |
1274 | |
5 | 1275 (defun YaTeX-insert-brackets-region (beg end) |
1276 (interactive "r") | |
7 | 1277 (YaTeX-insert-braces-region beg end "[" "]") |
5 | 1278 ) |
1279 | |
22 | 1280 (defun YaTeX-insert-parens (arg) |
1281 "Insert parenthesis pair." | |
1282 (interactive "p") | |
1283 (cond | |
1284 ((YaTeX-jmode) (YaTeX-self-insert arg)) | |
1285 ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1286 ((save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1287 (and (> (- (point) (point-min)) 5) (forward-char -5)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1288 (looking-at "\\\\left")) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1289 (insert "(\\right)") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1290 (forward-char -7)) |
22 | 1291 ((and (= (preceding-char) ?\\ ) (not (YaTeX-in-math-mode-p))) |
1292 (insert "(\\)") | |
1293 (backward-char 2)) | |
1294 ((YaTeX-closable-p) | |
1295 (insert "()") | |
1296 (backward-char 1)) | |
1297 (t (YaTeX-self-insert arg))) | |
1298 ) | |
1299 | |
11 | 1300 (defun YaTeX-insert-parens-region (beg end) |
1301 (interactive "r") | |
1302 (YaTeX-insert-braces-region beg end "(" ")") | |
1303 ) | |
1304 | |
0 | 1305 (defun YaTeX-insert-dollar () |
1306 (interactive) | |
22 | 1307 (if (or (not (YaTeX-closable-p)) |
57 | 1308 (= (preceding-char) 92) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1309 (and (YaTeX-in-math-mode-p) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1310 (or (/= (preceding-char) ?$) (/= (following-char) ?$)))) |
7 | 1311 (insert "$") |
1312 (insert "$$") | |
22 | 1313 (forward-char -1) |
59 | 1314 (YaTeX-jmode-off) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1315 (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1))) |
0 | 1316 ) |
1317 | |
11 | 1318 (defun YaTeX-insert-dollars-region (beg end) |
1319 (interactive "r") | |
1320 (YaTeX-insert-braces-region beg end "$" "$") | |
1321 ) | |
1322 | |
57 | 1323 (defun YaTeX-insert-amper () |
1324 (interactive) | |
1325 (if (or (string-match YaTeX-array-env-regexp | |
1326 (or (YaTeX-inner-environment t) "document")) | |
1327 (= (preceding-char) 92) | |
1328 (YaTeX-literal-p)) | |
1329 (insert "&") | |
1330 (insert "\\&")) | |
1331 ) | |
1332 | |
0 | 1333 (defun YaTeX-version () |
1334 "Return string of the version of running YaTeX." | |
1335 (interactive) | |
1336 (message | |
5 | 1337 (concat "Yet Another tex-mode " |
55 | 1338 (if YaTeX-japan "u–ì’¹v" "`Wild Bird'") |
7 | 1339 " Revision " |
0 | 1340 YaTeX-revision-number)) |
1341 ) | |
1342 | |
46 | 1343 (defun YaTeX-typeset-menu (arg &optional char) |
1344 "Typeset, preview, visit error and miscellaneous convenient menu. | |
1345 Optional second argument CHAR is for non-interactive call from menu." | |
5 | 1346 (interactive "P") |
7 | 1347 (message |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1348 (concat "J)latex R)egion B)ibtex mk(I)ndex " |
59 | 1349 (if (not YaTeX-dos) "K)ill-latex ") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1350 "P)review " |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1351 (and (boundp 'window-system) window-system "S)earch ") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1352 "V)iewerr L)pr")) |
46 | 1353 (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
|
1354 (require 'yatexprc) ;for Nemacs's bug |
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
1355 (select-window sw) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1356 (cond |
5 | 1357 ((= c ?j) (YaTeX-typeset-buffer)) |
1358 ((= c ?r) (YaTeX-typeset-region)) | |
11 | 1359 ((= c ?b) (YaTeX-call-command-on-file |
1360 bibtex-command "*YaTeX-bibtex*")) | |
13 | 1361 ((= c ?i) (YaTeX-call-command-on-file |
11 | 1362 makeindex-command "*YaTeX-makeindex*")) |
7 | 1363 ((= 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
|
1364 ((= c ?p) (call-interactively 'YaTeX-preview)) |
7 | 1365 ((= c ?q) (YaTeX-system "lpq" "*Printer queue*")) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1366 ((= c ?v) (YaTeX-view-error)) |
5 | 1367 ((= c ?l) (YaTeX-lpr arg)) |
13 | 1368 ((= c ?m) (YaTeX-switch-mode-menu arg)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1369 ((= c ?b) (YaTeX-insert-string "\\")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1370 ((= c ?s) (YaTeX-xdvi-remote-search arg)))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1371 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1372 |
46 | 1373 (defun YaTeX-%-menu (&optional beg end char) |
13 | 1374 "Operate %# notation." |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
1375 ;;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
|
1376 (interactive) |
13 | 1377 (message "!)Edit-%%#! B)EGIN-END-region L)Edit-%%#LPR") |
46 | 1378 (let ((c (or char (read-char))) (string "") key |
13 | 1379 (b (make-marker)) (e (make-marker))) |
1380 (save-excursion | |
1381 (cond | |
1382 ((or (= c ?!) (= c ?l)) ;Edit `%#!' | |
1383 (goto-char (point-min)) | |
1384 (setq key (cond ((= c ?!) "%#!") | |
1385 ((= c ?l) "%#LPR"))) | |
1386 (if (re-search-forward key nil t) | |
1387 (progn | |
1388 (setq string (buffer-substring (point) (point-end-of-line))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1389 (delete-region (point) (progn (end-of-line) (point)))) |
13 | 1390 (open-line 1) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1391 (delete-region (point) (progn (beginning-of-line)(point)));for 19 :-< |
13 | 1392 (insert key)) |
1393 (unwind-protect | |
1394 (setq string (read-string (concat key ": ") string)) | |
1395 (insert string))) | |
1396 | |
1397 ((= c ?b) ;%#BEGIN %#END region | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
15
diff
changeset
|
1398 (or end (setq beg (min (point) (mark)) end (max (point) (mark)))) |
13 | 1399 (set-marker b beg) |
1400 (set-marker e end) | |
1401 (goto-char (point-min)) | |
1402 (while (re-search-forward "^%#\\(BEGIN\\)\\|\\(END\\)$" nil t) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1403 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1404 (delete-region (point) (progn (forward-line 1) (point)))) |
13 | 1405 (goto-char (marker-position b)) |
1406 (open-line 1) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1407 (delete-region (point) (progn (beginning-of-line)(point)));for 19 :-< |
13 | 1408 (insert "%#BEGIN") |
1409 (goto-char (marker-position e)) | |
1410 (insert "%#END\n")) | |
1411 ))) | |
1412 ) | |
1413 | |
51 | 1414 (defun YaTeX-goto-corresponding-label (reverse &optional otherwin) |
48 | 1415 "Jump to corresponding \\label{} and \\ref{} or \\cite and \\bibitem. |
1416 The default search direction depends on the command at the cursor position. | |
1417 When the cursor is on \\ref(\\cite), YaTeX will try to search the | |
1418 corresponding \\label(\\bibitem) backward, | |
1419 and if it fails search forward again. And when the cursor is | |
1420 on \\label(\\bibitem), YaTeX will search the corresponding \\ref(\\cite) | |
1421 forward at first and secondary backward. | |
1422 Argument REVERSE non-nil makes the default | |
1423 direction rule reverse. Since Search string is automatically set in | |
13 | 1424 search-last-string, you can repeat search the same label/ref by typing |
51 | 1425 \\[isearch-forward] or \\[isearch-backward]. |
1426 If optional second argument OTHERWIN is non-nil, move to other window." | |
13 | 1427 |
51 | 1428 (let ((scmd "") label direc string blist (p (point)) (cb (current-buffer)) |
48 | 1429 (refcommands "label\\|ref\\|cite\\|bibitem") |
1430 (func (function (lambda (string sfunc) | |
1431 (or | |
1432 (funcall sfunc string nil t) | |
1433 (funcall (if (eq sfunc 'search-forward) | |
1434 'search-backward 'search-forward) | |
1435 string nil t)))))) | |
7 | 1436 (cond |
48 | 1437 ((YaTeX-on-section-command-p refcommands) |
1438 (setq scmd (cdr (assoc (YaTeX-match-string 1) | |
1439 '(("label" . "ref") ("ref" . "label") | |
1440 ("cite" . "bibitem") ("bibitem" . "cite"))))) | |
7 | 1441 (goto-char (match-end 0)) |
1442 (let ((label (buffer-substring | |
1443 (1- (point)) (progn (backward-list 1) (1+ (point)))))) | |
48 | 1444 (setq string (concat "\\" scmd "{" label "}")) |
1445 (setq direc (if (string-match "ref\\|cite" scmd) | |
1446 'search-forward 'search-backward)) | |
1447 (if YaTeX-current-position-register | |
1448 (point-to-register YaTeX-current-position-register)) | |
7 | 1449 (if reverse (setq direc (if (eq direc 'search-forward) |
1450 'search-backward 'search-forward))) | |
48 | 1451 (if (funcall func string direc) ;label/ref found! |
13 | 1452 (progn |
51 | 1453 (if otherwin |
1454 (progn | |
1455 (goto-char p) | |
1456 (if (one-window-p) | |
1457 (split-window-calculate-height | |
1458 YaTeX-default-pop-window-height)) | |
1459 (select-window (get-lru-window)) | |
1460 (switch-to-buffer cb))) | |
13 | 1461 (goto-char (match-beginning 0)) |
51 | 1462 (push-mark p)) |
1463 ;;if label/ref not found, search through all yatex buffers. | |
1464 (goto-char p) ;resume position of current buffer | |
48 | 1465 (setq blist (YaTeX-yatex-buffer-list)) |
1466 (catch 'found | |
1467 (while blist | |
1468 (set-buffer (car blist)) | |
1469 (if (YaTeX-on-section-command-p refcommands) | |
1470 (goto-char (match-beginning 0))) | |
1471 (if (funcall func string direc) | |
1472 (progn | |
51 | 1473 (cond |
1474 (otherwin | |
1475 (set-buffer cb) | |
1476 (goto-char p) | |
1477 (if (one-window-p) | |
1478 (split-window-calculate-height | |
1479 YaTeX-default-pop-window-height)) | |
1480 (select-window (get-lru-window)) | |
1481 (switch-to-buffer (car blist))) | |
1482 ((or (get-buffer-window (car blist)) | |
1483 (and YaTeX-emacs-19 | |
1484 (get-buffer-window (car blist) t))) | |
1485 (goto-buffer-window (car blist))) | |
1486 (t | |
49 | 1487 (switch-to-buffer (car blist)) |
1488 (message | |
1489 (format "Type %s %c to return to original position." | |
1490 (key-description | |
1491 (car | |
1492 (or (where-is-internal 'register-to-point) | |
1493 (where-is-internal 'jump-to-register)))) | |
51 | 1494 YaTeX-current-position-register)))) |
48 | 1495 (goto-char (match-beginning 0)) |
1496 (throw 'found t))) | |
1497 (setq blist (cdr blist))))) | |
1498 ) | |
1499 (if YaTeX-emacs-19 | |
1500 (setq search-ring (cons string search-ring)) | |
1501 (setq search-last-string string))) | |
7 | 1502 (t nil))) |
5 | 1503 ) |
1504 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1505 (defun YaTeX-goto-corresponding-environment (&optional allow-mismatch noerr) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1506 "Go to corresponding begin/end enclosure. |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1507 Optional argument ALLOW-MISMATCH allows mismatch open/clese. Use this |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1508 for \left(, \right). |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1509 Optional third argument NOERR causes no error for unballanced environment." |
3 | 1510 (interactive) |
5 | 1511 (if (not (YaTeX-on-begin-end-p)) nil |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1512 (let ((p (match-end 0)) b0 b1 env (nest 0) regexp re-s (op (point)) |
7 | 1513 (m0 (match-beginning 0)) ;whole matching |
1514 (m1 (match-beginning 1)) ;environment in \begin{} | |
1515 (m2 (match-beginning 2))) ;environment in \end{} | |
1516 ;(setq env (regexp-quote (buffer-substring p (match-beginning 0)))) | |
5 | 1517 (if (cond |
7 | 1518 (m1 ;if begin{xxx} |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1519 (setq env |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1520 (if allow-mismatch YaTeX-struct-name-regexp |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1521 (regexp-quote (buffer-substring m1 (match-end 1))))) |
13 | 1522 ; (setq regexp (concat "\\(\\\\end{" env "}\\)\\|" |
1523 ; "\\(\\\\begin{" env "}\\)")) | |
1524 (setq regexp | |
1525 (concat | |
1526 "\\(" | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1527 (YaTeX-replace-format-args |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1528 (regexp-quote YaTeX-struct-end) env "" "") |
13 | 1529 "\\)\\|\\(" |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1530 (YaTeX-replace-format-args |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1531 (regexp-quote YaTeX-struct-begin) env "" "") |
13 | 1532 "\\)")) |
46 | 1533 (setq re-s 're-search-forward)) |
7 | 1534 (m2 ;if end{xxx} |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1535 (setq env |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1536 (if allow-mismatch YaTeX-struct-name-regexp |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1537 (regexp-quote (buffer-substring m2 (match-end 2))))) |
13 | 1538 ; (setq regexp (concat "\\(\\\\begin{" env "}\\)\\|" |
1539 ; "\\(\\\\end{" env "}\\)")) | |
1540 (setq regexp | |
1541 (concat | |
1542 "\\(" | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1543 (YaTeX-replace-format-args |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1544 (regexp-quote YaTeX-struct-begin) env "" "") |
13 | 1545 "\\)\\|\\(" |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1546 (YaTeX-replace-format-args |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1547 (regexp-quote YaTeX-struct-end) env "" "") |
13 | 1548 "\\)")) |
46 | 1549 (setq re-s 're-search-backward)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1550 (t (if noerr nil (error "Corresponding environment not found.")))) |
7 | 1551 (progn |
1552 (while (and (>= nest 0) (funcall re-s regexp nil t)) | |
1553 (setq b0 (match-beginning 0) b1 (match-beginning 1)) | |
1554 (if (or (equal b0 m0) | |
49 | 1555 (YaTeX-literal-p b0)) |
7 | 1556 nil |
1557 (setq nest (if (equal b0 b1) | |
1558 (1- nest) (1+ nest))))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1559 (if (< nest 0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1560 (goto-char (match-beginning 0)) ;found. |
7 | 1561 (goto-char op) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1562 (funcall |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1563 (if noerr 'message 'error) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1564 "Corresponding environment `%s' not found." env) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1565 (sit-for 1) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1566 nil))))) |
5 | 1567 ) |
1568 | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1569 (defun YaTeX-goto-corresponding-file (&optional other) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1570 "Visit or switch buffer of corresponding file, |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1571 looking at \\input or \\include or \includeonly on current line." |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1572 (if (not (YaTeX-on-includes-p)) nil |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1573 (let ((parent buffer-file-name) input-file) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1574 (save-excursion |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1575 (if (search-forward "{" (point-end-of-line) t) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1576 nil |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1577 (skip-chars-backward "^,{")) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1578 (setq input-file |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1579 (buffer-substring |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1580 (point) (progn (skip-chars-forward "^ ,}") (point)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1581 (if (not (string-match "\\.\\(tex\\|sty\\)$" input-file)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1582 (setq input-file (concat input-file ".tex")))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1583 (cond |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1584 (other (YaTeX-switch-to-buffer-other-window input-file)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1585 ((get-file-buffer input-file) (goto-buffer-window input-file)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1586 (t (YaTeX-switch-to-buffer input-file))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1587 (or (YaTeX-get-builtin "!") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1588 YaTeX-parent-file |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1589 (setq YaTeX-parent-file parent)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1590 ) |
5 | 1591 |
1592 (defun YaTeX-goto-corresponding-BEGIN-END () | |
1593 (if (not (YaTeX-on-BEGIN-END-p)) nil | |
1594 (if (cond | |
1595 ((equal (match-beginning 0) (match-beginning 1)) ;if on %#BEGIN | |
1596 (not (search-forward "%#END" nil t))) | |
1597 (t ; if on %#END | |
1598 (not (search-backward "%#BEGIN" nil t)))) | |
7 | 1599 (error "Corresponding %%#BEGIN/END not found.")) |
5 | 1600 (beginning-of-line) |
1601 t) | |
1602 ) | |
1603 | |
59 | 1604 (defvar YaTeX-processed-file-regexp-alist nil |
1605 "Alist of regexp of processed file regexp vs. its file name part; | |
1606 For example, if you include image file with `\\epsfile{file=FILE}' where | |
1607 `FILE' is processed file. You might want to view FILE with other previewer | |
1608 such as ghostview, or want to preview its source which was drawn with | |
1609 other drawing tool, tgif for example. Then you should set entire regexp | |
1610 of including expression and enclose its file name part with \\\\( and \\\\). | |
1611 | |
1612 Ex. (\"\\\\\\\\epsfile{[^}]*file=\\\\([^,} ]+\\\\)\\\\(\\\\.e?ps\\\\)?[^}]*}\" 1) | |
1613 | |
1614 Where the first group surrounded by \\\\( and \\\\) is the file name part | |
1615 of expression. So you should set 1 to second element. And the first | |
1616 matching group is sent to (image) processor defined by the variable | |
1617 YaTeX-file-processor-alist. See also the documentation of | |
1618 YaTeX-file-processor-alist. | |
1619 | |
1620 ª‚¶‚á—Ç‚‚í‚©‚ñ‚È‚¢‚·‚ËB—Ⴆ‚Î tgif hoge.obj ‚µ‚Ä hoge.eps ‚ð | |
1621 \\epsfile{file=hoge.eps} ‚ŃCƒ“ƒNƒ‹[ƒh‚µ‚Ä‚¢‚é‚Æ‚µ‚悤B‚»‚Ìs‚Å | |
1622 \[prefix\] g ‚ð‰Ÿ‚µ‚½Žž‚É tgif ‚ð‹N“®‚µ‚Ä—~‚µ‚©‚Á‚½‚çA‚Ü‚¸ã‚̂悤‚È | |
1623 ³‹K•\Œ»‚ðÝ’è‚·‚éB\\\\(‚Æ\\\\)‚ň͂ñ‚¾‚Æ‚±‚낪ƒtƒ@ƒCƒ‹–¼‚É‚È‚é‚悤‚É | |
1624 ’ˆÓ‚·‚éB‚Ńtƒ@ƒCƒ‹–¼•”•ª‚ª‰½”Ô–Ú‚Ì\\\\(\\\\)‚É‚È‚é‚©‚ðƒŠƒXƒg‚Ì2”Ô–Ú‚É‘‚B | |
1625 ‚·‚é‚ÆA‚»‚Ì•”•ª‚ª•Ï” YaTeX-file-processor-alist ‚Å’è‹`‚³‚ꂽ | |
1626 ˆ—ƒvƒƒOƒ‰ƒ€‚É“n‚³‚ê‚éB‚Æ‚¢‚¤‚킯B | |
1627 ‚ñ`‚â‚Á‚Ï‚è‚Þ‚¸‚©‚µ‚¢‚ËB•ª‚©‚ç‚È‚¢Žž‚Í—×‚Ì Lisper ‚É•·‚‚©A | |
1628 fj–ì’¹‚̉ï‚Å•·‚±‚¤! | |
1629 ") | |
1630 | |
1631 (defvar YaTeX-processed-file-regexp-alist-default | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1632 '(("\\\\epsfile{[^},]*file=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1633 ("\\\\epsfig{[^},]*fi\\(le\\|gure\\)=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 2) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1634 ("\\\\postscriptbox{[^}]*}{[^}]*}{\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 1) |
61 | 1635 ("\\\\\\(epsfbox\\|includegraphics\\){\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 2) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1636 ("\\\\\\(psbox\\)\\(\\[[^]]+\\]\\)?{\\(\\([^,} ]*/\\)?[^} ]+\\)\\(\\.e?ps\\)}" 3) ;\psbox[options...]{hoge.eps} (97/1/11) |
59 | 1637 ) |
1638 "See the documentation of YaTeX-processed-file-regexp-alist." | |
1639 ) | |
1640 | |
1641 (defvar YaTeX-file-processor-alist nil | |
1642 "*Alist of files' processor vs. its extension; | |
1643 See also the documentation of YaTeX-processed-file-regexp-alist." | |
1644 ) | |
1645 (defvar YaTeX-file-processor-alist-default | |
1646 '(("tgif" . ".obj") | |
1647 ("ghostview" . ".ps") | |
1648 ("ghostview" . ".eps") | |
1649 (t . ".tex") | |
1650 (t . ".sty") | |
1651 (t . "")) | |
1652 "See the documentation of YaTeX-file-processor-alist." | |
1653 ) | |
1654 | |
1655 (defun YaTeX-goto-corresponding-file-processor (&optional other) | |
1656 "Execute corresponding file processor." | |
1657 (save-excursion | |
1658 (or (looking-at YaTeX-ec-regexp) | |
1659 (skip-chars-backward (concat "^" YaTeX-ec) (point-beginning-of-line))) | |
1660 (let ((list (append YaTeX-processed-file-regexp-alist | |
1661 YaTeX-processed-file-regexp-alist-default)) | |
1662 (p (point)) flist file | |
1663 (peol (point-end-of-line))) | |
1664 (setq flist (catch 'found | |
1665 (while list | |
1666 (goto-char p) | |
1667 (if (re-search-forward (car (car list)) peol t) | |
1668 (progn | |
1669 (setq file (YaTeX-match-string | |
1670 (car (cdr (car list))))) | |
1671 (throw 'found (cdr (car list))))) | |
1672 (setq list (cdr list))))) | |
1673 (if flist ;if pattern and file name found | |
1674 (let*((plist (append YaTeX-file-processor-alist | |
1675 YaTeX-file-processor-alist-default)) | |
1676 (plist0 plist) | |
1677 ext cmd src buf (alt (car (cdr flist)))) | |
1678 (if (and (re-search-forward | |
1679 (concat YaTeX-comment-prefix "\\s *\\(.*\\)$") peol t) | |
1680 (assoc (setq cmd (YaTeX-match-string 1)) | |
1681 YaTeX-file-processor-alist)) | |
1682 (setq src ;if processor is specified | |
1683 (concat file | |
1684 (cdr (assoc cmd YaTeX-file-processor-alist)))) | |
1685 (while plist ;if processor is not specified | |
1686 (setq ext (cdr (car plist))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1687 (if (and (string< "" (concat file ext)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1688 (file-exists-p (concat file ext))) |
59 | 1689 (setq cmd (car (car plist)) |
1690 src (concat file ext) plist nil)) | |
1691 (setq plist (cdr plist))) | |
1692 (if (and (null src) alt YaTeX-create-file-prefix-g) | |
1693 (setq cmd alt | |
1694 src (concat file (cdr (assoc alt plist0)))))) | |
1695 (if src ;if processor and src file found | |
1696 (cond | |
1697 ((stringp cmd) | |
1698 (let ((buf (concat "* " cmd " " src " *"))) | |
1699 (YaTeX-system (concat cmd " " src) buf) | |
1700 t)) | |
1701 ((eq t cmd) | |
1702 (let ((parent buffer-file-name)) | |
1703 (funcall | |
1704 (cond | |
1705 (other 'YaTeX-switch-to-buffer-other-window) | |
1706 ((get-file-buffer src) 'goto-buffer-window) | |
1707 (t 'YaTeX-switch-to-buffer)) | |
1708 src) | |
1709 (or (YaTeX-get-builtin "!") | |
1710 YaTeX-parent-file | |
1711 (setq YaTeX-parent-file parent)) | |
1712 t)) | |
1713 ((symbolp cmd) | |
1714 (cond | |
1715 ((symbol-function cmd) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1716 (funcall cmd src other))) |
59 | 1717 t))))))) |
1718 ) | |
1719 | |
14 | 1720 (defun YaTeX-on-section-command-p (command) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1721 "Check if point is on the LaTeX command: COMMAND(regexp). |
49 | 1722 Return nil if point is not on it. Otherwise return the |
1723 number of argument position. | |
48 | 1724 Section command name is stored in match-data #1." |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1725 (let ((p (point)) md (parg 0) (argc 1) word (grouping 0) (i 0)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1726 (while (setq i (string-match "\\\\(" command i)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1727 (setq grouping (1+ grouping) i (+ i 2))) |
7 | 1728 (save-excursion |
49 | 1729 (if (looking-at YaTeX-ec-regexp) nil |
1730 (catch 'found ;caught value has no meaning | |
1731 (while t | |
1732 (if (bobp) (throw 'found nil)) | |
1733 (cond | |
1734 ((looking-at YaTeX-ec-regexp) (throw 'found t)) | |
1735 ((looking-at "[[{]") nil) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1736 ((looking-at "[]}]")(condition-case nil (up-list -1) (error nil))) |
49 | 1737 (t (skip-chars-backward " \t\r\n"))) |
1738 (skip-chars-backward (concat "^ \t\r\n{}[]" YaTeX-ec-regexp)) | |
51 | 1739 (or (bobp) (forward-char -1))))) |
1740 (if (and | |
1741 (looking-at (concat YaTeX-ec-regexp "\\(" command "\\)" | |
1742 "\\(\\(\\[[^]]+\\]\\)*\\)" ;optional arg | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1743 ;"[ \t\n\r]*{[^}]+}")) ;arg braces |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1744 "[ \t\n\r]*{[^}]*}")) ;arg braces |
51 | 1745 (not (YaTeX-lookup-table |
1746 (setq word (YaTeX-match-string 1)) 'singlecmd))) | |
46 | 1747 (progn |
49 | 1748 (setq md (match-data)) |
1749 (skip-chars-forward "^{") | |
1750 (if (<= (point) p) (setq parg (1+ parg))) | |
1751 (setq argc | |
51 | 1752 (or (car (cdr (YaTeX-lookup-table word 'section))) |
49 | 1753 argc)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1754 (while (and (>= (setq argc (1- argc)) 0) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1755 (progn (skip-chars-forward " \t\n\r") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1756 (looking-at "{"))) |
49 | 1757 (forward-list 1) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1758 (if (<= (point) p) (setq parg (1+ parg)))) |
49 | 1759 (store-match-data md) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1760 (setq i (+ 2 grouping)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1761 (if (and (match-beginning i) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1762 (>= p (match-beginning i)) (< p (match-end i))) |
49 | 1763 -1 ;return -1 if point is on optional arg |
1764 (if (< p (point)) parg)) | |
1765 )))) | |
5 | 1766 ) |
1767 | |
52 | 1768 (defun YaTeX-on-maketitle-p () |
1769 "Check if point is on maketitle type commands. | |
1770 Call this function after YaTeX-on-section-command-p." | |
1771 (let ((p (point))) | |
1772 (save-excursion | |
1773 (or (= (char-after (point)) ?\\ ) | |
1774 (progn | |
1775 (skip-chars-backward | |
1776 (concat "^" YaTeX-ec-regexp) (point-beginning-of-line)) | |
1777 (or (bobp) (bolp) (backward-char 1)))) | |
1778 (and (looking-at (concat YaTeX-ec-regexp YaTeX-TeX-token-regexp)) | |
1779 (<= (match-beginning 0) p) | |
1780 (> (match-end 0) p))))) | |
1781 | |
5 | 1782 (defun YaTeX-on-begin-end-p () |
1783 (save-excursion | |
1784 (beginning-of-line) | |
1785 (re-search-forward | |
13 | 1786 ;;"\\\\begin{\\([^}]+\\)}\\|\\\\end{\\([^}]+\\)}" |
1787 (concat | |
1788 (YaTeX-replace-format-args | |
1789 (regexp-quote YaTeX-struct-begin) | |
1790 (concat "\\(" YaTeX-struct-name-regexp "\\)") "" "" "") | |
1791 "\\|" | |
1792 (YaTeX-replace-format-args | |
1793 (regexp-quote YaTeX-struct-end) | |
1794 (concat "\\(" YaTeX-struct-name-regexp "\\)") "" "" "")) | |
1795 (point-end-of-line) t)) | |
5 | 1796 ) |
6 | 1797 |
5 | 1798 (defun YaTeX-on-includes-p () |
1799 (save-excursion | |
1800 (beginning-of-line) | |
1801 (re-search-forward "\\(\\(include.*\\)\\|\\(input\\)\\){.*}" | |
1802 (point-end-of-line) t)) | |
1803 ) | |
6 | 1804 |
7 | 1805 (defun YaTeX-on-comment-p (&optional sw) |
22 | 1806 "Return t if current line is commented out. |
1807 Optional argument SW t to treat all `%' lines as comment, | |
7 | 1808 even if on `%#' notation." |
1809 (save-excursion | |
1810 (beginning-of-line) | |
22 | 1811 (skip-chars-forward "\\s ") |
1812 (looking-at (if sw "%" "%[^#]"))) | |
7 | 1813 ) |
1814 | |
5 | 1815 (defun YaTeX-on-BEGIN-END-p () |
1816 (save-excursion | |
7 | 1817 (let ((case-fold-search nil)) |
5 | 1818 (beginning-of-line) |
1819 (re-search-forward "\\(%#BEGIN\\)\\|\\(%#END\\)" (point-end-of-line) t))) | |
1820 ) | |
6 | 1821 |
7 | 1822 (defun YaTeX-goto-corresponding-* (arg) |
5 | 1823 "Parse current line and call suitable function." |
7 | 1824 (interactive "P") |
5 | 1825 (cond |
7 | 1826 ((YaTeX-goto-corresponding-label arg)) |
5 | 1827 ((YaTeX-goto-corresponding-environment)) |
61 | 1828 ((YaTeX-goto-corresponding-file-processor arg)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1829 ((YaTeX-goto-corresponding-file arg)) |
5 | 1830 ((YaTeX-goto-corresponding-BEGIN-END)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1831 ((and (string-match |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1832 YaTeX-equation-env-regexp ;to delay loading |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1833 (or (YaTeX-inner-environment t) "document")) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1834 (YaTeX-goto-corresponding-leftright))) |
5 | 1835 (t (message "I don't know where to go."))) |
1836 ) | |
1837 | |
51 | 1838 (defun YaTeX-goto-corresponding-*-other-window (arg) |
1839 "Parse current line and call suitable function." | |
1840 (interactive "P") | |
1841 (cond | |
1842 ((YaTeX-goto-corresponding-label arg t)) | |
1843 ;;((YaTeX-goto-corresponding-environment)) | |
1844 ((YaTeX-goto-corresponding-file t)) | |
1845 ;;((YaTeX-goto-corresponding-BEGIN-END)) | |
1846 (t (message "I don't know where to go."))) | |
1847 ) | |
1848 | |
5 | 1849 (defun YaTeX-comment-region (alt-prefix) |
22 | 1850 "Comment out region by '%'. |
1851 If you call this function on the 'begin{}' or 'end{}' line, | |
1852 it comments out whole environment" | |
5 | 1853 (interactive "P") |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1854 (if (not (YaTeX-on-begin-end-p)) |
49 | 1855 (comment-out-region |
5 | 1856 (if alt-prefix |
1857 (read-string "Insert prefix: ") | |
1858 YaTeX-comment-prefix)) | |
49 | 1859 (YaTeX-comment-uncomment-env 'comment-out-region)) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1860 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1861 |
5 | 1862 (defun YaTeX-uncomment-region (alt-prefix) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1863 "Uncomment out region by '%'." |
5 | 1864 (interactive "P") |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1865 (if (not (YaTeX-on-begin-end-p)) |
5 | 1866 (uncomment-region |
1867 (if alt-prefix (read-string "Remove prefix: ") | |
11 | 1868 YaTeX-comment-prefix) |
49 | 1869 (region-beginning) (region-end) YaTeX-uncomment-once) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1870 (YaTeX-comment-uncomment-env 'uncomment-region)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1871 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1872 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1873 (defun YaTeX-comment-uncomment-env (func) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1874 "Comment or uncomment out one LaTeX environment switching function by FUNC." |
49 | 1875 (let (beg (p (point))) |
1876 (save-excursion | |
1877 (beginning-of-line) | |
1878 (setq beg (point)) | |
1879 (YaTeX-goto-corresponding-environment) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1880 (beginning-of-line) |
49 | 1881 (if (> p (point)) (setq beg (1+ beg)) (forward-char 1)) |
1882 (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) | |
45 | 1883 (message "%sommented out current environment." |
1884 (if (eq func 'comment-region) "C" "Un-c")) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1885 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1886 |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1887 (defun YaTeX-beginning-of-environment (&optional limit-search-bound end) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1888 "Goto the beginning of the current environment. |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1889 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound to |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1890 most recent sectioning command. Non-nil for optional third argument END |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1891 goes to end of environment." |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1892 (interactive) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1893 (let ((op (point))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1894 (if (YaTeX-inner-environment limit-search-bound) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1895 (progn |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1896 (goto-char (get 'YaTeX-inner-environment 'point)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1897 (and end (YaTeX-goto-corresponding-environment)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1898 (if (interactive-p) (push-mark op)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1899 t))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1900 ) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1901 |
22 | 1902 (defun YaTeX-end-of-environment (&optional limit-search-bound) |
1903 "Goto the end of the current environment. | |
1904 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound | |
1905 to most recent sectioning command." | |
1906 (interactive) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1907 (YaTeX-beginning-of-environment limit-search-bound t) |
22 | 1908 ) |
1909 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1910 (defun YaTeX-mark-environment () |
13 | 1911 "Mark current position and move point to end of environment." |
1912 (interactive) | |
1913 (let ((curp (point))) | |
22 | 1914 (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin |
1915 (forward-line 1) | |
1916 (beginning-of-line)) | |
1917 (if (not (YaTeX-end-of-environment)) ;arg1 turns to match-beginning 1 | |
13 | 1918 (progn |
1919 (goto-char curp) | |
1920 (error "Cannot found the end of current environment.")) | |
1921 (YaTeX-goto-corresponding-environment) | |
1922 (beginning-of-line) ;for confirmation | |
1923 (if (< curp (point)) | |
22 | 1924 (progn |
1925 (message "Mark this environment?(y or n): ") | |
1926 (if (= (read-char) ?y) nil | |
1927 (goto-char curp) | |
1928 (error "Abort. Please call again at more proper position.")))) | |
13 | 1929 (set-mark-command nil) |
1930 (YaTeX-goto-corresponding-environment) | |
1931 (end-of-line) | |
1932 (if (eobp) nil (forward-char 1)))) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1933 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1934 |
3 | 1935 (defun YaTeX-comment-paragraph () |
1936 "Comment out current paragraph." | |
1937 (interactive) | |
1938 (save-excursion | |
7 | 1939 (cond |
1940 ((YaTeX-on-begin-end-p) | |
1941 (beginning-of-line) | |
1942 (insert YaTeX-comment-prefix) | |
1943 (YaTeX-goto-corresponding-environment) | |
1944 (beginning-of-line) | |
1945 (insert YaTeX-comment-prefix)) | |
1946 ((YaTeX-on-comment-p) | |
1947 (message "Already commented out.")) | |
1948 (t | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1949 (mark-paragraph) |
7 | 1950 (if (looking-at paragraph-separate) (forward-line 1)) |
49 | 1951 (comment-out-region "%")))) |
3 | 1952 ) |
1953 | |
1954 (defun YaTeX-uncomment-paragraph () | |
1955 "Uncomment current paragraph." | |
1956 (interactive) | |
1957 (save-excursion | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1958 (if (YaTeX-on-begin-end-p) |
22 | 1959 (let ((p (make-marker))) |
1960 (set-marker p (point)) | |
1961 (YaTeX-goto-corresponding-environment) | |
11 | 1962 (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once) |
22 | 1963 (goto-char (marker-position p)) |
11 | 1964 (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once)) |
7 | 1965 (if (YaTeX-on-comment-p) |
1966 (let*((fill-prefix "") | |
1967 ;;append `^%' to head of paragraph delimiter. | |
1968 (paragraph-start | |
1969 (concat | |
61 | 1970 "^$\\|^%\\(" YaTeX-paragraph-separate "\\)")) |
49 | 1971 (paragraph-separate paragraph-start)) |
7 | 1972 (mark-paragraph) |
1973 (if (not (bobp)) (forward-line 1)) | |
49 | 1974 (uncomment-region "%" nil nil YaTeX-uncomment-once)) |
7 | 1975 (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
|
1976 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1977 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1978 (defun YaTeX-remove-prefix (prefix &optional once) |
7 | 1979 "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
|
1980 optional argument ONCE makes deletion once." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1981 (interactive "sPrefix:") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1982 (beginning-of-line) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1983 (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
|
1984 (replace-match "") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1985 (if once (end-of-line))) |
3 | 1986 ) |
1987 | |
7 | 1988 (defun YaTeX-kill-option-string () |
1989 (if (and (eq predicate 'YaTeX-on-begin-end-p) | |
1990 (looking-at "\\(\\[.*\\]\\)*\\({.*}\\)*")) | |
1991 (delete-region (match-beginning 0) (match-end 0))) | |
1992 ) | |
1993 | |
22 | 1994 (defun YaTeX-kill-some-pairs (predicate gofunc kill-contents) |
1995 "Kill some matching pair. | |
1996 This function assumes that pairs occupy each line where they resid." | |
1997 ;;(interactive) | |
7 | 1998 (if (not (funcall predicate)) nil |
22 | 1999 (let ((beg (make-marker)) (end (make-marker)) (p (make-marker))) |
7 | 2000 (set-marker end (match-end 0)) |
2001 (if (match-beginning 2) | |
2002 (set-marker beg (match-beginning 2)) | |
2003 (set-marker beg (match-beginning 1)) | |
2004 (goto-char (match-end 0)) | |
2005 (YaTeX-kill-option-string)) | |
2006 (save-excursion | |
2007 (funcall gofunc) | |
2008 (delete-region (point-beginning-of-line) (match-end 0)) | |
2009 (YaTeX-kill-option-string) | |
52 | 2010 (if (and (eolp) (not (eobp))) (delete-char 1)) |
22 | 2011 (set-marker p (point)) |
2012 (goto-char beg) | |
2013 (delete-region (point-beginning-of-line) end) | |
52 | 2014 (if (and (eolp) (not (eobp))) (delete-char 1)) |
22 | 2015 (if kill-contents (delete-region p (point)))) |
2016 t)) | |
5 | 2017 ) |
2018 | |
22 | 2019 (defun YaTeX-kill-section-command (point kill-all) |
2020 "Kill section-type command at POINT leaving its argument. | |
2021 Non-nil for the second argument kill its argument too." | |
2022 (let (beg (end (make-marker))) | |
14 | 2023 (save-excursion |
22 | 2024 (goto-char point) |
2025 (or (looking-at YaTeX-ec-regexp) | |
2026 (progn | |
2027 (skip-chars-backward (concat "^" YaTeX-ec-regexp)) | |
2028 (forward-char -1))) | |
2029 (setq beg (point)) | |
2030 (skip-chars-forward "^{") | |
2031 (forward-list 1) | |
2032 (set-marker end (point)) | |
2033 (if kill-all (delete-region beg end) | |
2034 (goto-char beg) | |
2035 (delete-region | |
2036 (point) (progn (skip-chars-forward "^{" end) (1+ (point)))) | |
2037 (goto-char end) | |
2038 (backward-delete-char 1)))) | |
14 | 2039 ) |
2040 | |
22 | 2041 (defun YaTeX-kill-paren (kill-contents) |
2042 "Kill parentheses leaving its contents. | |
2043 But kill its contents if the argument KILL-CONTENTS is non-nil." | |
14 | 2044 (save-excursion |
2045 (let (p) | |
2046 (if (looking-at "\\s(\\|\\(\\s)\\)") | |
2047 (progn | |
2048 (if (match-beginning 1) | |
2049 (up-list -1)) | |
2050 (setq p (point)) | |
2051 (forward-list 1) | |
22 | 2052 (if kill-contents (delete-region p (point)) |
2053 (backward-delete-char 1) | |
2054 (goto-char p) | |
2055 (if (looking-at | |
2056 (concat "{" YaTeX-ec-regexp | |
32
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
2057 YaTeX-command-token-regexp "+" |
22 | 2058 "\\s +")) |
2059 (delete-region | |
2060 (point) | |
2061 (progn (re-search-forward "\\s +" nil t) (point))) | |
2062 (delete-char 1))) | |
14 | 2063 t)))) |
2064 ) | |
2065 | |
22 | 2066 (defvar YaTeX-read-environment-history nil "Holds history of environments.") |
2067 (put 'YaTeX-read-environment-history 'no-default t) | |
2068 (defun YaTeX-read-environment (prompt &optional predicate must-match initial) | |
2069 "Read a LaTeX environment name with completion." | |
49 | 2070 (YaTeX-sync-local-table 'tmp-env-table) |
51 | 2071 (completing-read-with-history |
2072 prompt | |
2073 (append tmp-env-table user-env-table env-table) | |
2074 predicate must-match initial | |
2075 'YaTeX-read-environment-history) | |
22 | 2076 ) |
2077 | |
2078 (defvar YaTeX-read-section-history nil "Holds history of section-types.") | |
2079 (put 'YaTeX-read-section-history 'no-default t) | |
2080 (defun YaTeX-read-section (prompt &optional predicate initial) | |
2081 "Read a LaTeX section-type command with completion." | |
49 | 2082 (YaTeX-sync-local-table 'tmp-section-table) |
51 | 2083 (let ((minibuffer-completion-table |
22 | 2084 (append tmp-section-table user-section-table section-table))) |
51 | 2085 (read-from-minibuffer-with-history |
2086 prompt initial YaTeX-section-completion-map nil | |
2087 'YaTeX-read-section-history)) | |
22 | 2088 ) |
2089 | |
2090 (defun YaTeX-read-section-with-overview () | |
2091 "Read sectioning command with overview. | |
2092 This function refers a local variable `source-window' in YaTeX-make-section" | |
2093 (interactive) | |
52 | 2094 (require 'yatexsec) ;some case needs this |
22 | 2095 (if (> (minibuffer-depth) 1) |
2096 (error "Too many minibuffer levels for overview.")) | |
2097 (let ((sw (selected-window))(enable-recursive-minibuffers t) sect) | |
2098 (unwind-protect | |
2099 (progn | |
2100 (select-window source-window) | |
2101 (setq sect (YaTeX-read-section-in-minibuffer | |
2102 "Sectioning(Up=C-p, Down=C-n, Help=?): " | |
2103 YaTeX-sectioning-level (YaTeX-section-overview)))) | |
2104 (select-window sw)) | |
2105 (if (eq (selected-window) (minibuffer-window)) | |
2106 (erase-buffer)) | |
2107 (insert sect) | |
2108 (exit-minibuffer) | |
2109 ) | |
2110 ) | |
2111 | |
51 | 2112 (defvar YaTeX-read-fontsize-history nil "Holds history of font designator.") |
2113 (put 'YaTeX-read-fontsize-history 'no-default t) | |
22 | 2114 (defun YaTeX-read-fontsize (prompt &optional predicate must-match initial) |
2115 "Read a LaTeX font changing command with completion." | |
49 | 2116 (YaTeX-sync-local-table 'tmp-fontsize-table) |
51 | 2117 (completing-read-with-history |
22 | 2118 prompt (append tmp-fontsize-table user-fontsize-table fontsize-table) |
51 | 2119 predicate must-match initial 'YaTeX-read-fontsize-history) |
5 | 2120 ) |
2121 | |
2122 (defun YaTeX-change-environment () | |
2123 "Change the name of environment." | |
2124 (interactive) | |
2125 (if (not (YaTeX-on-begin-end-p)) nil | |
2126 (save-excursion | |
7 | 2127 (let (p env (m1 (match-beginning 1)) (m2 (match-beginning 2))) |
2128 (setq env (if m1 (buffer-substring m1 (match-end 1)) | |
2129 (buffer-substring m2 (match-end 2)))) | |
11 | 2130 (goto-char (match-beginning 0)) |
5 | 2131 (set-mark-command nil) |
2132 (YaTeX-goto-corresponding-environment) | |
2133 (setq newenv (YaTeX-read-environment | |
2134 (format "Change environment `%s' to: " env))) | |
13 | 2135 (cond |
2136 ((string= newenv "") (message "Change environment cancelled.")) | |
2137 ((string= newenv env) (message "No need to change.")) | |
2138 (t | |
5 | 2139 (search-forward (concat "{" env) (point-end-of-line) t) |
2140 (replace-match (concat "{" newenv)) | |
2141 (exchange-point-and-mark) | |
2142 (search-forward (concat "{" env) (point-end-of-line) t) | |
13 | 2143 (replace-match (concat "{" newenv)))) |
5 | 2144 t))) |
2145 ) | |
2146 | |
22 | 2147 (defun YaTeX-change-section () |
2148 "Change section-type command." | |
5 | 2149 (interactive) |
49 | 2150 (let*((where (YaTeX-on-section-command-p YaTeX-command-token-regexp)) |
2151 (p (point)) (cmd (YaTeX-match-string 1)) beg end old new) | |
2152 (if (null where) nil | |
2153 (cond | |
2154 | |
2155 ((equal where 0);;if point is on section command | |
2156 (setq beg (match-beginning 1) | |
2157 end (match-end 1)) | |
2158 (goto-char beg) ;beginning of the command | |
2159 (setq new (YaTeX-read-section (format "Change `%s' to: " cmd) nil))) | |
2160 | |
2161 ((= where -1);;if point is on a optional parameter | |
2162 (setq beg (match-beginning 2)) | |
2163 (skip-chars-forward "^{") | |
2164 (setq end (point)) | |
2165 (goto-char p) | |
2166 (setq new | |
57 | 2167 (if (fboundp (intern-soft (concat YaTeX-addin-prefix cmd))) |
49 | 2168 (YaTeX-addin cmd) |
2169 (concat "[" | |
2170 (read-string (format "Change `%s' to: " | |
2171 (buffer-substring | |
2172 (1+ beg) (1- end)))) | |
2173 "]")))) | |
2174 | |
2175 ((> where 0);;if point is in arguments' braces | |
2176 (or (looking-at "{") | |
2177 (progn (skip-chars-backward "^{") (forward-char -1))) | |
2178 (setq beg (1+ (point))) | |
2179 (forward-list 1) | |
2180 (forward-char -1) | |
2181 (setq end (point) | |
2182 old (buffer-substring beg end)) | |
2183 (goto-char p) | |
2184 (if (> (length old) 40) | |
2185 (setq old (concat (substring old 0 12) "..." (substring old -12)))) | |
2186 (setq new | |
2187 (if (intern-soft (concat "YaTeX::" cmd)) | |
2188 (funcall (intern-soft (concat "YaTeX::" cmd)) where) | |
2189 (read-string (format "Change `%s' to: " old))))) | |
2190 );cond | |
2191 (delete-region beg end) | |
2192 (goto-char beg) | |
2193 (insert-before-markers new) | |
2194 ;;(goto-char (marker-position p)) | |
2195 new)) | |
2196 ) | |
2197 | |
2198 (defun YaTeX-change-fontsize () | |
2199 "Change large-type command." | |
2200 (let ((lt (append tmp-fontsize-table user-fontsize-table fontsize-table)) | |
2201 (p (point)) large old new beg end) | |
2202 ;;(and (looking-at "}") (up-list -1)) | |
2203 ;;(and (looking-at "{") (forward-char 1)) | |
2204 ;;Is above convenient? | |
2205 (save-excursion | |
2206 (or (looking-at YaTeX-ec-regexp) | |
2207 (progn | |
2208 (skip-chars-backward (concat "^" YaTeX-ec-regexp)) | |
2209 (forward-char -1))) | |
2210 (cond | |
2211 ((and | |
2212 (looking-at | |
2213 (concat YaTeX-ec-regexp "\\(" YaTeX-TeX-token-regexp "\\)")) | |
2214 (< p (match-end 0)) | |
2215 (assoc (setq old (YaTeX-match-string 1)) lt)) | |
2216 (goto-char p) | |
2217 (setq beg (match-beginning 1) end (match-end 1) ;save match position | |
2218 new (completing-read | |
2219 (format "Change font/size `%s' to : " old) lt)) | |
22 | 2220 (delete-region beg end) |
49 | 2221 (goto-char beg) |
22 | 2222 (insert-before-markers new) |
49 | 2223 new) |
2224 (t nil) | |
2225 ))) | |
22 | 2226 ) |
2227 | |
52 | 2228 (defun YaTeX-change-math-image () |
2229 "Change with image completion." | |
2230 (let (maketitle memberp beg end) | |
2231 (if (and (YaTeX-on-maketitle-p) | |
2232 (progn | |
2233 (setq maketitle (substring (YaTeX-match-string 0) 1)) | |
2234 (setq memberp (YaTeX-math-member-p maketitle)))) | |
2235 (let ((last-command-char (string-to-char (car memberp)))) | |
2236 (setq beg (match-beginning 0) end (match-end 0)) | |
2237 (delete-region beg end) | |
2238 (YaTeX-math-insert-sequence t (cdr memberp)))))) | |
2239 | |
22 | 2240 (defun YaTeX-kill-* (&optional arg) |
2241 "Parse current line and call suitable function. | |
2242 Non-nil for ARG kills its contents too." | |
2243 (interactive "P") | |
5 | 2244 (cond |
2245 ((YaTeX-kill-some-pairs 'YaTeX-on-begin-end-p | |
22 | 2246 'YaTeX-goto-corresponding-environment arg)) |
5 | 2247 ((YaTeX-kill-some-pairs 'YaTeX-on-BEGIN-END-p |
22 | 2248 'YaTeX-goto-corresponding-BEGIN-END arg)) |
32
546c4baad92f
The first typesetting splits window into 3 on Nemacs. Fixed.
yuuji
parents:
22
diff
changeset
|
2249 ((YaTeX-on-section-command-p YaTeX-command-token-regexp);on any command |
22 | 2250 (YaTeX-kill-section-command (match-beginning 0) arg)) |
2251 ((YaTeX-kill-paren arg)) | |
5 | 2252 (t (message "I don't know what to kill."))) |
2253 ) | |
2254 | |
2255 (defun YaTeX-change-* () | |
2256 "Parse current line and call suitable function." | |
2257 (interactive) | |
2258 (cond | |
2259 ((YaTeX-change-environment)) | |
22 | 2260 ((YaTeX-change-section)) |
49 | 2261 ((YaTeX-change-fontsize)) |
52 | 2262 ((YaTeX-change-math-image)) |
5 | 2263 (t (message "I don't know what to change."))) |
2264 ) | |
2265 | |
7 | 2266 ;;; |
48 | 2267 ;Check availability of add-in functions |
7 | 2268 ;;; |
2269 (cond | |
48 | 2270 ((featurep 'yatexadd) nil) ;Already provided. |
2271 ((progn (load "yatexadd" t) (featurep 'yatexadd)) nil) | |
7 | 2272 (t (message "YaTeX add-in functions not supplied."))) |
2273 | |
5 | 2274 (defun YaTeX-addin (name) |
2275 "Check availability of addin function and call it if exists." | |
7 | 2276 (if (and (not (get 'YaTeX-generate 'disabled)) |
57 | 2277 (intern-soft (concat YaTeX-addin-prefix name)) |
2278 (fboundp (intern-soft (concat YaTeX-addin-prefix name)))) | |
2279 (let ((s (funcall (intern (concat YaTeX-addin-prefix name))))) | |
7 | 2280 (if (stringp s) s "")) |
2281 "") ;Add in function is not bound. | |
2282 ) | |
2283 | |
22 | 2284 (defun YaTeX-on-item-p (&optional point) |
2285 "Return t if POINT (default is (point)) is on \\item." | |
2286 (let ((p (or point (point)))) | |
2287 (save-excursion | |
2288 (goto-char p) | |
2289 (end-of-line) | |
2290 (setq p (point)) | |
2291 (re-search-backward YaTeX-paragraph-delimiter nil t) | |
2292 (re-search-forward YaTeX-item-regexp p t))) | |
2293 ) | |
2294 | |
49 | 2295 (defun YaTeX-in-verb-p (&optional point) |
2296 "Check if POINT is in verb or verb*. Default of POINT is (point)." | |
2297 (setq point (or point (point))) | |
7 | 2298 (save-excursion |
49 | 2299 (goto-char point) |
51 | 2300 (if (not (re-search-backward |
2301 (concat YaTeX-ec-regexp | |
2302 "\\(" YaTeX-verb-regexp "\\)" | |
2303 "\\([^-A-Za-z_*]\\)") | |
2304 (point-beginning-of-line) t)) | |
7 | 2305 nil |
51 | 2306 (goto-char (match-end 2)) |
7 | 2307 (skip-chars-forward |
51 | 2308 (concat "^" (buffer-substring (match-beginning 2) (match-end 2)))) |
2309 (and (< (match-beginning 2) point) (< (1- point) (point))))) | |
49 | 2310 ) |
2311 | |
2312 (defun YaTeX-literal-p (&optional point) | |
2313 "Check if POINT is in verb or verb* or verbatime environment family. | |
2314 Default of POINT is (point)." | |
2315 (cond | |
2316 ((equal YaTeX-ec "\\") ;maybe LaTeX | |
2317 (save-excursion | |
2318 (and point (goto-char point)) | |
2319 (or (YaTeX-in-verb-p (point)) | |
59 | 2320 (and (not (looking-at "\\\\end{verb")) |
2321 (YaTeX-quick-in-environment-p YaTeX-verbatim-environments)))))) | |
5 | 2322 ) |
2323 | |
2324 (defun YaTeX-in-environment-p (env) | |
7 | 2325 "Return if current LaTeX environment is ENV. |
2326 ENV is given in the form of environment's name or its list." | |
22 | 2327 (let ((md (match-data)) (nest 0) p envrx) |
5 | 2328 (cond |
22 | 2329 ((atom env) |
2330 (setq envrx | |
2331 (concat "\\(" | |
2332 (regexp-quote | |
2333 (YaTeX-replace-format-args | |
2334 YaTeX-struct-begin env "" "")) | |
2335 "\\)\\|\\(" | |
2336 (regexp-quote | |
2337 (YaTeX-replace-format-args | |
2338 YaTeX-struct-end env "" "")) | |
2339 "\\)")) | |
2340 (save-excursion | |
2341 (setq p (catch 'open | |
2342 (while (YaTeX-re-search-active-backward | |
2343 envrx YaTeX-comment-prefix nil t) | |
2344 (if (match-beginning 2) | |
2345 (setq nest (1+ nest)) | |
2346 (setq nest (1- nest))) | |
2347 (if (< nest 0) (throw 'open t))))))) | |
5 | 2348 ((listp env) |
49 | 2349 (setq p |
2350 (or (YaTeX-in-environment-p (car env)) | |
2351 (and (cdr env) (YaTeX-in-environment-p (cdr env))))))) | |
7 | 2352 (store-match-data md) |
49 | 2353 p;(or p (YaTeX-in-verb-p (match-beginning 0))) |
2354 ) | |
5 | 2355 ) |
2356 | |
2357 (defun YaTeX-quick-in-environment-p (env) | |
7 | 2358 "Check quickly but unsure if current environment is ENV. |
22 | 2359 ENV is given in the form of environment's name or its list. |
49 | 2360 This function returns correct result only if ENV is NOT nested." |
7 | 2361 (save-excursion |
49 | 2362 (let ((md (match-data)) (p (point)) rc clfound) |
7 | 2363 (cond |
2364 ((listp env) | |
49 | 2365 (or (YaTeX-quick-in-environment-p (car env)) |
2366 (and (cdr env) (YaTeX-quick-in-environment-p (cdr env))))) | |
7 | 2367 (t |
22 | 2368 (if (YaTeX-search-active-backward |
2369 (YaTeX-replace-format-args YaTeX-struct-begin env "" "") | |
2370 YaTeX-comment-prefix nil t) | |
49 | 2371 (setq rc (not (YaTeX-search-active-forward |
2372 (YaTeX-replace-format-args | |
2373 YaTeX-struct-end env) | |
2374 YaTeX-comment-prefix p t nil)))) | |
7 | 2375 (store-match-data md) |
22 | 2376 rc)))) |
5 | 2377 ) |
2378 | |
22 | 2379 ;; Filling \item |
46 | 2380 (defun YaTeX-remove-trailing-comment (start end) |
2381 "Remove trailing comment from START to end." | |
2382 (save-excursion | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2383 (let ((trcom (concat YaTeX-comment-prefix "$"))) |
46 | 2384 (goto-char start) |
2385 (while (re-search-forward trcom end t) | |
54 | 2386 (if (/= (char-after (1- (match-beginning 0))) ?\\ ) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2387 (replace-match "\\1"))))) |
5 | 2388 ) |
2389 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2390 (defun YaTeX-get-item-info (&optional recent thisenv) |
51 | 2391 "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
|
2392 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
|
2393 Non-nil for optional argument RECENT refers recent \\item. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2394 Optional second argument THISENV omits calling YaTeX-inner-environment." |
22 | 2395 (save-excursion |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2396 (let* ((p (point)) env e0 c |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2397 (bndry (and (setq env (or thisenv (YaTeX-inner-environment t))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2398 (get 'YaTeX-inner-environment 'point) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2399 ))) |
22 | 2400 (end-of-line) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2401 (if (if recent |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2402 (YaTeX-re-search-active-backward |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2403 YaTeX-item-regexp YaTeX-comment-prefix bndry t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2404 (goto-char bndry) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2405 (YaTeX-re-search-active-forward |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2406 YaTeX-item-regexp YaTeX-comment-prefix p t)) |
51 | 2407 (progn |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2408 (goto-char (match-end 0)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2409 ;(setq c (current-column)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2410 (if (string-match "desc" env) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2411 (setq c 6) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2412 (if (equal (following-char) ?\[) (forward-list 1)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2413 (setq c 0)) |
51 | 2414 (skip-chars-forward " \t" (point-end-of-line)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2415 (list (point-beginning-of-line) (+ c (current-column))))))) |
22 | 2416 ) |
2417 | |
5 | 2418 (defun YaTeX-fill-item () |
2419 "Fill item in itemize environment." | |
2420 (interactive) | |
2421 (save-excursion | |
51 | 2422 (let* ((p (point)) |
2423 (item-term (concat | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2424 "\\(^[ \t]*$\\)\\|" YaTeX-item-regexp "\\|\\(" |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2425 YaTeX-ec-regexp "\\(begin\\|end\\)\\)")) |
51 | 2426 ;;This value depends on LaTeX. |
2427 fill-prefix start col | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2428 (info (YaTeX-get-item-info t))) |
55 | 2429 (if (null info) nil ;not on \item, do nothing |
22 | 2430 (setq start (car info) |
2431 col (car (cdr info))) | |
55 | 2432 (save-excursion |
2433 (if (re-search-backward "^\\s *$" start t) | |
2434 ;;if separated from \item line, isolate this block | |
2435 (progn | |
2436 (setq start (1+ (match-end 0))) | |
2437 (goto-char start) | |
2438 (skip-chars-forward " \t") | |
2439 (delete-region (point) start) ;is this your favor??? | |
2440 (indent-to col)))) | |
46 | 2441 (beginning-of-line) |
2442 (if (<= (save-excursion | |
2443 (re-search-forward | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2444 (concat "\\\\end{\\|\\\\begin{\\|^[ \t]*$") nil t) |
46 | 2445 (match-beginning 0)) |
2446 p) | |
51 | 2447 (progn (message "Not on itemize.") nil) |
2448 (end-of-line) | |
2449 (newline) | |
2450 (indent-to col) | |
2451 (setq fill-prefix | |
2452 (buffer-substring (point-beginning-of-line)(point))) | |
2453 (beginning-of-line) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2454 (delete-region (point) (progn (forward-line 1) (point))) |
51 | 2455 (re-search-forward item-term nil 1) |
2456 (YaTeX-remove-trailing-comment start (point)) | |
2457 (beginning-of-line) | |
2458 (push-mark (point) t) | |
2459 (goto-char start) | |
2460 (forward-line 1) | |
2461 (while (< (point) (mark)) | |
2462 (delete-region (point) (progn (skip-chars-forward " \t") (point))) | |
2463 (forward-line 1)) | |
2464 (fill-region-as-paragraph start (mark)) | |
2465 (if NTT-jTeX | |
2466 (while (progn(forward-line -1)(end-of-line) (> (point) start)) | |
2467 (insert ?%))) | |
2468 (pop-mark))))) | |
5 | 2469 ) |
2470 | |
51 | 2471 (defun YaTeX-fill-paragraph (arg) |
2472 "YaTeX adjustment function for fill-paragraph. | |
2473 *Protect \\verb from unexpected broken up." | |
2474 (interactive "P") | |
2475 (cond | |
2476 ((not (eq major-mode 'yatex-mode)) (fill-paragraph arg)) | |
2477 ((YaTeX-quick-in-environment-p YaTeX-fill-inhibit-environments) nil) | |
2478 (t | |
2479 (save-excursion | |
2480 (let ((verbrex (concat YaTeX-ec-regexp | |
2481 "\\(" YaTeX-verb-regexp "\\)" ;match#1 | |
2482 "\\(.\\).*\\(\\2\\)")) ;match #2 and #3 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2483 (p (point)) ii end poslist spacelist (fill-prefix fill-prefix)) |
52 | 2484 (cond |
2485 ((save-excursion (beginning-of-line) ;if point is on the first | |
2486 (setq end (point)) ;non-whitespace char | |
2487 (skip-chars-forward " \t") | |
2488 (equal (point) p)) | |
2489 (setq fill-prefix (buffer-substring p end))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2490 ((and ;;(not YaTeX-emacs-19) |
52 | 2491 (string-match YaTeX-itemizing-env-regexp |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2492 (or (YaTeX-inner-environment t) "document")) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2493 (setq ii (YaTeX-get-item-info))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2494 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2495 (beginning-of-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2496 (indent-to-column (car (cdr ii))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2497 (setq fill-prefix |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2498 (buffer-substring (point) (point-beginning-of-line))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2499 (delete-region (point) (progn (beginning-of-line) (point)))))) |
51 | 2500 (mark-paragraph) |
2501 (save-restriction | |
2502 (narrow-to-region (region-beginning) (region-end)) | |
52 | 2503 (YaTeX-remove-trailing-comment (point-min) (point-max)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2504 (goto-char (point-min)) |
51 | 2505 (while (YaTeX-re-search-active-forward |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2506 verbrex YaTeX-comment-prefix (point-max) t) |
51 | 2507 (setq end (match-beginning 3)) |
2508 (goto-char (match-beginning 2)) | |
2509 (while (re-search-forward "\\s " end t) | |
2510 (setq poslist (cons (make-marker) poslist) | |
2511 spacelist (cons (preceding-char) spacelist)) | |
2512 (replace-match "_") | |
2513 (set-marker (car poslist) (match-beginning 0)))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2514 ;;(fill-paragraph arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2515 (fill-region-as-paragraph (point-min) (point-max) arg) |
51 | 2516 (while spacelist |
2517 (goto-char (marker-position (car poslist))) | |
2518 (delete-char 1) | |
2519 (insert (car spacelist)) | |
52 | 2520 (setq spacelist (cdr spacelist) poslist (cdr poslist))) |
2521 (goto-char (point-min)) | |
2522 (forward-word 1) | |
2523 (beginning-of-line) | |
59 | 2524 (while (re-search-forward "\\\\\\(\\(page\\)?ref\\|cite\\){" nil t) |
2525 (if (< (point-end-of-line) | |
2526 (save-excursion (forward-char -1) (forward-list 1) (point))) | |
2527 (progn (end-of-line) (insert YaTeX-comment-prefix)))) | |
2528 (goto-char (point-min)) | |
52 | 2529 (if (and NTT-jTeX (looking-at "[ \t]")) |
2530 (progn | |
2531 (goto-char (point-min)) | |
2532 (while (not (eobp)) | |
2533 (end-of-line) | |
2534 (or (bolp) | |
2535 (save-excursion | |
2536 (backward-word 1) | |
2537 (looking-at "\\sw+")) ;is not japanese string | |
59 | 2538 (progn (setq p (point)) (insert YaTeX-comment-prefix))) |
52 | 2539 (forward-line 1)) |
2540 (goto-char p) | |
61 | 2541 (if (looking-at "%") (delete-char 1)) ;remove last inserted `%' |
52 | 2542 ))))))) |
51 | 2543 ) |
2544 | |
52 | 2545 (if (fboundp 'YaTeX-saved-indent-new-comment-line) nil |
2546 (fset 'YaTeX-saved-indent-new-comment-line | |
2547 (symbol-function 'indent-new-comment-line)) | |
2548 (fset 'indent-new-comment-line 'YaTeX-indent-new-comment-line)) | |
2549 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2550 (defun YaTeX-indent-new-comment-line (&optional soft) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2551 "Tuned `indent-new-comment-line' function for yatex. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2552 See the documentation of `YaTeX-saved-indent-new-comment-line'." |
52 | 2553 (cond |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2554 ((or (not (memq major-mode '(yatex-mode yahtml-mode))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2555 (string-match |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2556 "document" |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2557 (or (and (boundp 'inenv) inenv) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2558 (or (YaTeX-inner-environment t) "document")))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2559 (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
|
2560 ; ((and (eq major-mode 'yahtml-mode) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2561 ; (string-match |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2562 ; "^[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
|
2563 ; (yahtml-indent-new-commnet-line)) |
61 | 2564 ((and (eq major-mode 'yatex-mode) ;1997/2/4 |
2565 (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
|
2566 (t (let (fill-prefix) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2567 (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft)))))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2568 ) |
51 | 2569 |
5 | 2570 (defun YaTeX-fill-* () |
2571 "Fill paragraph according to its condition." | |
2572 (interactive) | |
2573 (cond | |
2574 ((YaTeX-fill-item)) | |
2575 ) | |
2576 ) | |
2577 | |
22 | 2578 ;; Accent completion |
5 | 2579 (defun YaTeX-read-accent-char (x) |
2580 "Read char in accent braces." | |
2581 (let ((c (read-char))) | |
2582 (concat | |
2583 (if (and (or (= c ?i) (= c ?j)) | |
2584 (not (string-match (regexp-quote x) "cdb"))) | |
2585 "\\" "") | |
2586 (char-to-string c))) | |
2587 ) | |
2588 | |
2589 (defun YaTeX-make-accent () | |
2590 "Make accent usage." | |
2591 (interactive) | |
2592 (message "1:` 2:' 3:^ 4:\" 5:~ 6:= 7:. u v H t c d b") | |
2593 (let ((c (read-char))(case-fold-search nil)) | |
2594 (setq c (cond ((and (> c ?0) (< c ?8)) | |
2595 (substring "`'^\"~=." (1- (- c ?0)) (- c ?0))) | |
2596 ((= c ?h) "H") | |
2597 (t (char-to-string c)))) | |
2598 (if (not (string-match c "`'^\"~=.uvHtcdb")) nil | |
2599 (insert "\\" c "{}") | |
2600 (backward-char 1) | |
2601 (insert (YaTeX-read-accent-char c)) | |
2602 (if (string= c "t") (insert (YaTeX-read-accent-char c))) | |
2603 (forward-char 1))) | |
2604 ) | |
2605 | |
22 | 2606 ;; Indentation |
2607 (defun YaTeX-current-indentation () | |
2608 "Return the indentation of current environment." | |
2609 (save-excursion | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2610 ;;(beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2611 (if (YaTeX-beginning-of-environment t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2612 (goto-char (get 'YaTeX-inner-environment 'point)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2613 (forward-line -1) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2614 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2615 (skip-chars-forward " \t")) |
22 | 2616 (current-column)) |
2617 ) | |
2618 | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2619 (defun YaTeX-previous-line-indentation () |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2620 (save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2621 (forward-line -1) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2622 (skip-chars-forward " \t") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2623 (current-column))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2624 |
22 | 2625 (defun YaTeX-reindent (col) |
2626 "Remove current indentation and reindento to COL column." | |
2627 (save-excursion | |
2628 (beginning-of-line) | |
2629 (skip-chars-forward " \t") | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2630 (if (/= col (current-column)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2631 (progn |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2632 (delete-region (point) (progn (beginning-of-line) (point))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2633 (indent-to col)))) |
22 | 2634 (skip-chars-forward " \t" (point-end-of-line))) |
2635 | |
2636 (defun YaTeX-indent-line () | |
2637 "Indent corrent line referrin current environment." | |
2638 (interactive) | |
48 | 2639 (let ((indent-relative |
2640 (function | |
51 | 2641 (lambda (&optional additional) |
48 | 2642 (YaTeX-reindent |
51 | 2643 (+ (YaTeX-current-indentation) |
2644 (or additional 0) | |
2645 YaTeX-environment-indent))))) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2646 depth iteminfo (p (point)) pp (peol (point-end-of-line)) |
52 | 2647 ;;inenv below is sometimes defined in YaTeX-indent-new-comment-line |
2648 (inenv (or (and (boundp 'inenv) inenv) (YaTeX-inner-environment t)))) | |
2649 ;;(if NTT-jTeX ;;Do you need this section? | |
2650 ;; (save-excursion | |
2651 ;; (end-of-line) | |
2652 ;; (let ((p (point))) | |
2653 ;; (forward-line -1) | |
2654 ;; (end-of-line) | |
2655 ;; (or (= p (point)) | |
2656 ;; (progn (backward-char (length YaTeX-comment-prefix)) | |
2657 ;; (not (looking-at (regexp-quote YaTeX-comment-prefix)))) | |
2658 ;; (progn | |
2659 ;; (skip-chars-backward YaTeX-comment-prefix) | |
2660 ;; (kill-line)))))) | |
2661 (or inenv (setq inenv "document")) ;is the default environment | |
48 | 2662 (cond |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2663 ((and (YaTeX-on-begin-end-p) (match-beginning 2)) ;if \end |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2664 (save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2665 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2666 (YaTeX-reindent (YaTeX-current-indentation)))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2667 ((string-match YaTeX-equation-env-regexp inenv) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2668 (YaTeX-indent-line-equation)) ;autoload-ed from yatex.env |
52 | 2669 (;(YaTeX-in-environment-p '("itemize" "enumerate" "description" "list")) |
2670 (string-match YaTeX-itemizing-env-regexp inenv) | |
2671 ;;(YaTeX-on-item-p) ?? | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2672 ;;(setq iteminfo (YaTeX-get-item-info t)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2673 (if (save-excursion |
51 | 2674 (beginning-of-line) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2675 (re-search-forward YaTeX-item-regexp peol t)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2676 (save-excursion |
51 | 2677 (goto-char (1+ (match-beginning 0))) |
2678 (setq depth | |
2679 (* YaTeX-environment-indent | |
2680 (cond | |
2681 ((looking-at "subsubsub") 3) | |
2682 ((looking-at "subsub") 2) | |
2683 ((looking-at "sub") 1) | |
2684 (t 0)))) | |
2685 (funcall indent-relative depth)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2686 (YaTeX-reindent (or (car (cdr (YaTeX-get-item-info nil inenv))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2687 (+ (save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2688 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2689 (YaTeX-current-indentation)) |
52 | 2690 YaTeX-environment-indent)))) |
48 | 2691 ) |
49 | 2692 ((YaTeX-literal-p) ;verbatims |
48 | 2693 (tab-to-tab-stop)) |
52 | 2694 ((and inenv (not (equal "document" inenv))) |
48 | 2695 (funcall indent-relative)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2696 ((YaTeX-on-section-command-p YaTeX-sectioning-regexp) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2697 (require 'yatexsec) ;to know YaTeX-sectioning-level |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2698 (YaTeX-reindent |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2699 (* (max |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2700 (1- ;I want chapter to have indentation 0 |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2701 (or (cdr (assoc (YaTeX-match-string 1) YaTeX-sectioning-level)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2702 0)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2703 0) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2704 YaTeX-environment-indent))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2705 ;;Default movement |
48 | 2706 ((and (bolp) fill-prefix) (insert fill-prefix)) |
2707 (t (save-excursion | |
2708 (beginning-of-line) | |
2709 (skip-chars-forward " \t") | |
2710 (indent-relative-maybe)) | |
52 | 2711 (skip-chars-forward " \t"))) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2712 ;;if current line is \begin, re-indent \end too |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2713 (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2714 (save-excursion |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2715 ;;(beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2716 ;;(search-forward "\\begin") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2717 (goto-char (match-beginning 0)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2718 (setq depth (current-column)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2719 (YaTeX-goto-corresponding-environment) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2720 (YaTeX-reindent depth))) |
59 | 2721 (if (or |
2722 (and NTT-jTeX | |
2723 (save-excursion (beginning-of-line) (looking-at "[ \t]"))) | |
2724 (save-excursion | |
2725 (beginning-of-line) | |
2726 (backward-char 1) | |
2727 (and | |
2728 (re-search-backward | |
2729 "\\\\\\(\\(page\\)?ref\\|cite\\){" (point-beginning-of-line) t) | |
2730 (goto-char (1- (match-end 0))) | |
2731 (> (save-excursion | |
2732 (condition-case () | |
2733 (progn (forward-list 1) (point)) | |
2734 (error (point-max)))) | |
2735 (point-end-of-line))))) | |
52 | 2736 (save-excursion |
2737 (end-of-line) | |
2738 (let ((p (point))) | |
2739 (forward-line -1) | |
2740 (end-of-line) | |
2741 (or (= p (point)) | |
2742 (looking-at (regexp-quote YaTeX-comment-prefix)) | |
2743 (bobp) (bolp) | |
2744 (save-excursion | |
2745 (backward-word 1) | |
2746 (looking-at "\\sw+")) ;is not japanese string | |
2747 (insert YaTeX-comment-prefix)))))) | |
22 | 2748 ) |
2749 | |
49 | 2750 (defun YaTeX-local-table-symbol (symbol) |
36 | 2751 "Return the lisp symbol which keeps local completion table of SYMBOL." |
18 | 2752 (intern (concat "YaTeX$" |
2753 default-directory | |
2754 (symbol-name symbol))) | |
2755 ) | |
2756 | |
49 | 2757 (defun YaTeX-sync-local-table (symbol) |
22 | 2758 "Synchronize local variable SYMBOL. |
2759 Copy its corresponding directory dependent completion table to SYMBOL." | |
49 | 2760 (if (boundp (YaTeX-local-table-symbol symbol)) |
2761 (set symbol (symbol-value (YaTeX-local-table-symbol symbol)))) | |
18 | 2762 ) |
2763 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2764 (defun YaTeX-read-user-completion-table (&optional forcetoread) |
18 | 2765 "Append user completion table of LaTeX macros" |
2766 (let*((user-table (expand-file-name YaTeX-user-completion-table)) | |
49 | 2767 (local-table (expand-file-name (file-name-nondirectory user-table))) |
2768 var localvar localbuf (curbuf (current-buffer)) sexp) | |
51 | 2769 (if YaTeX-user-table-is-read nil |
49 | 2770 (message "Loading user completion table") |
6 | 2771 (if (file-exists-p user-table) (load-file user-table) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2772 (message "Welcome to the field of YaTeX. I'm glad to see you!"))) |
51 | 2773 (setq YaTeX-user-table-is-read t) |
22 | 2774 (cond |
49 | 2775 ((file-exists-p local-table) |
51 | 2776 (set-buffer (setq localbuf (find-file-noselect local-table))) |
49 | 2777 (widen) |
2778 (goto-char (point-min)) | |
2779 (while (re-search-forward "(setq \\([^ ]+\\)" nil t) | |
2780 (setq var (intern (buffer-substring | |
2781 (match-beginning 1) (match-end 1))) | |
2782 localvar (YaTeX-local-table-symbol var)) | |
2783 (goto-char (match-beginning 0)) | |
2784 (setq sexp (buffer-substring (point) | |
2785 (progn (forward-sexp) (point)))) | |
2786 (set-buffer curbuf) | |
2787 (or (assq var (buffer-local-variables)) (make-local-variable var)) | |
2788 (eval (read sexp)) | |
2789 (or (and (boundp localvar) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2790 (symbol-value localvar) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2791 (not forcetoread)) |
49 | 2792 (set localvar (symbol-value var))) |
2793 (set-buffer localbuf)) | |
51 | 2794 (kill-buffer localbuf))) |
2795 (set-buffer curbuf)) | |
6 | 2796 ) |
2797 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2798 (defun YaTeX-reload-dictionary () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2799 "Reload local dictionary. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2800 Use this function after editing ./.yatexrc." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2801 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2802 (let ((YaTeX-user-table-is-read nil)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2803 (YaTeX-read-user-completion-table t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2804 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2805 |
51 | 2806 (defun YaTeX-lookup-table (word type) |
2807 "Lookup WORD in completion table whose type is TYPE. | |
2808 This function refers the symbol tmp-TYPE-table, user-TYPE-table, TYPE-table. | |
2809 Typically, TYPE is one of 'env, 'section, 'fontsize, 'singlecmd." | |
2810 (if (symbolp type) (setq type (symbol-name type))) | |
2811 (or (assoc word (symbol-value (intern (concat "tmp-" type "-table")))) | |
2812 (assoc word (symbol-value (intern (concat "user-" type "-table")))) | |
2813 (assoc word (symbol-value (intern (concat type "-table")))))) | |
2814 | |
49 | 2815 (defun YaTeX-update-table (vallist default-table user-table local-table) |
6 | 2816 "Update completion table if the car of VALLIST is not in current tables. |
2817 Second argument DEFAULT-TABLE is the quoted symbol of default completion | |
2818 table, third argument USER-TABLE is user table which will be saved in | |
49 | 2819 YaTeX-user-completion-table, fourth argument LOCAL-TABLE should have the |
6 | 2820 completion which is valid during current Emacs's session. If you |
49 | 2821 want to make LOCAL-TABLE valid longer span (but restrict in this directory) |
6 | 2822 create the file in current directory which has the same name with |
2823 YaTeX-user-completion-table." | |
2824 (let ((car-v (car vallist)) key answer | |
2825 (file (file-name-nondirectory YaTeX-user-completion-table))) | |
2826 (cond | |
2827 ((assoc car-v (symbol-value default-table)) | |
2828 nil) ;Nothing to do | |
2829 ((setq key (assoc car-v (symbol-value user-table))) | |
2830 (if (equal (cdr vallist) (cdr key)) nil | |
2831 ;; if association hits, but contents differ. | |
2832 (message | |
2833 "%s's attributes turned into %s" (car vallist) (cdr vallist)) | |
2834 (set user-table (delq key (symbol-value user-table))) | |
2835 (set user-table (cons vallist (symbol-value user-table))) | |
49 | 2836 (YaTeX-update-dictionary |
2837 YaTeX-user-completion-table user-table "user"))) | |
2838 ((setq key (assoc car-v (symbol-value local-table))) | |
6 | 2839 (if (equal (cdr vallist) (cdr key)) nil |
2840 (message | |
2841 "%s's attributes turned into %s" (car vallist) (cdr vallist)) | |
49 | 2842 (set local-table (delq key (symbol-value local-table))) |
2843 (set local-table (cons vallist (symbol-value local-table))) | |
2844 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) | |
2845 (YaTeX-update-dictionary file local-table))) | |
13 | 2846 ;; All of above cases, there are some completion in tables. |
6 | 2847 ;; Then update tables. |
2848 (t | |
2849 (if (not YaTeX-nervous) | |
51 | 2850 (setq answer "u") |
6 | 2851 (message |
51 | 2852 "`%s' is not in table. Register into: U)serDic L)ocalDic N)one D)iscard" |
6 | 2853 (car vallist)) |
49 | 2854 (setq answer (char-to-string (read-char)))) |
6 | 2855 (cond |
49 | 2856 ((string-match answer "uy") |
6 | 2857 (set user-table (cons vallist (symbol-value user-table))) |
49 | 2858 (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user") |
2859 ) | |
2860 ((string-match answer "tl") | |
2861 (set local-table (cons vallist (symbol-value local-table))) | |
2862 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) | |
2863 (YaTeX-update-dictionary file local-table)) | |
51 | 2864 ((string-match answer "d") nil) ;discard it |
2865 (t (set default-table | |
2866 (cons vallist (symbol-value default-table)))))))) | |
6 | 2867 ) |
2868 | |
49 | 2869 (defun YaTeX-cplread-with-learning |
2870 (prom default-table user-table local-table | |
51 | 2871 &optional pred reqmatch init hsym) |
49 | 2872 "Completing read with learning. |
2873 Do a completing read with prompt PROM. Completion table is what | |
2874 DEFAULT-TABLE, USER-TABLE, LOCAL table are appended in reverse order. | |
2875 Note that these tables are passed by the symbol. | |
2876 Optional arguments PRED, REQMATH and INIT are passed to completing-read | |
2877 as its arguments PREDICATE, REQUIRE-MATCH and INITIAL-INPUT respectively. | |
51 | 2878 If optional 8th argument HSYM, history symbol, is passed, use it as |
2879 history list variable." | |
49 | 2880 (YaTeX-sync-local-table local-table) |
2881 (let*((table (append (symbol-value local-table) | |
2882 (symbol-value user-table) | |
2883 (symbol-value default-table))) | |
51 | 2884 (word (completing-read-with-history |
2885 prom table pred reqmatch init hsym))) | |
49 | 2886 (if (and (string< "" word) (not (assoc word table))) |
2887 (YaTeX-update-table (list word) default-table user-table local-table)) | |
2888 word) | |
6 | 2889 ) |
0 | 2890 |
49 | 2891 (defun YaTeX-update-dictionary (file symbol &optional type) |
2892 (let ((local-table-buf (find-file-noselect file)) | |
2893 (name (symbol-name symbol)) | |
2894 (value (symbol-value symbol))) | |
2895 (save-excursion | |
2896 (message "Updating %s dictionary..." (or type "local")) | |
2897 (set-buffer local-table-buf) | |
2898 (goto-char (point-max)) | |
2899 (search-backward (concat "(setq " name) nil t) | |
2900 (delete-region (point) (progn (forward-sexp) (point))) | |
2901 (delete-blank-lines) | |
2902 (insert "(setq " name " '(\n") | |
2903 (mapcar '(lambda (s) | |
2904 (insert (format "%s\n" (prin1-to-string s)))) | |
2905 value) | |
2906 (insert "))\n\n") | |
2907 (delete-blank-lines) | |
2908 (basic-save-buffer) | |
2909 (kill-buffer local-table-buf) | |
2910 (message "Updating %s dictionary...Done" (or type "local")))) | |
0 | 2911 ) |
2912 | |
3 | 2913 ;; --------------- General sub functions --------------- |
6 | 2914 (defun point-beginning-of-line () |
2915 (save-excursion (beginning-of-line)(point)) | |
2916 ) | |
2917 | |
2918 (defun point-end-of-line () | |
2919 (save-excursion (end-of-line)(point)) | |
2920 ) | |
3 | 2921 |
7 | 2922 |
2923 (provide 'yatex) | |
2924 (defvar yatex-mode-load-hook nil | |
2925 "*List of functions to be called when yatex.el is loaded.") | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
2926 (if (and YaTeX-emacs-19 window-system (not (featurep 'yatex19))) |
55 | 2927 (load "yatex19")) |
51 | 2928 (load "yatexhks" t) |
2929 | |
2930 ;;-------------------- Final hook jobs -------------------- | |
2931 (substitute-all-key-definition | |
2932 'fill-paragraph 'YaTeX-fill-paragraph YaTeX-mode-map) | |
7 | 2933 (run-hooks 'yatex-mode-load-hook) |
51 | 2934 |
2935 ;; `History' was moved to ChangeLog | |
0 | 2936 ;----------------------------- End of yatex.el ----------------------------- |