Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatex.el @ 4:78dfe28b6a35
Provide service function to define begin/end insert key-bind.
Support environment wide commenting/de-commenting.
Revise YaTeX-end-environment.
Add YaTeX-inhibit-prefix-alphabet to avoid "C-c letter".
author | yuuji |
---|---|
date | Mon, 30 Nov 1992 07:29:11 +0000 |
parents | 191610912c8b |
children | 370a391533fd |
rev | line source |
---|---|
0 | 1 ;;; -*- Emacs-Lisp -*- |
2 ;;; Yet Another tex-mode for emacs. | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
3 ;;; yatex.el rev.1.33 |
0 | 4 ;;; (c)1991 by Hirose Yuuji.[yuuji@ae.keio.ac.jp] |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
5 ;;; Last modified Sun Nov 29 16:04:57 1992 on 98fa |
0 | 6 |
7 (provide 'yatex-mode) | |
3 | 8 (require 'comment) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
9 (defconst YaTeX-revision-number "1.33" |
0 | 10 "Revision number of running yatex.el" |
11 ) | |
12 | |
13 ;---------- Local variables ---------- | |
14 ;;; | |
15 ;; Initialize local variable for yatex-mode. | |
16 ;; Preserving user preferred definitions. | |
17 ;; ** Check all of these defvar-ed values ** | |
18 ;; ** and setq other values more suitable ** | |
19 ;; ** for your site, if nedded. ** | |
20 ;;; | |
21 (defvar YaTeX-prefix "\^C" | |
22 "Prefix key to trigger YaTeX functions. | |
23 You can select favorite prefix key by setq in your ~/.emacs." | |
24 ) | |
25 (defvar YaTeX-open-lines 1 | |
26 "Blank lines between text and \??{??}" | |
27 ) | |
1 | 28 (defvar YaTeX-fill-prefix "" |
0 | 29 "fill-prefix used for auto-fill-mode. |
30 The defalut value is single TAB." | |
31 ) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
32 (defvar YaTeX-comment-prefix "%" |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
33 "TeX comment prefix." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
34 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
35 (defvar YaTeX-user-completion-table |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
36 (if (eq system-type 'ms-dos) "~/_yatexrc" |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
37 "~/.yatexrc") |
0 | 38 "Default filename in which user completion table is saved." |
39 ) | |
40 (defvar tex-command "jlatex" | |
41 "Default command for compiling LaTeX text." | |
42 ) | |
43 (defvar dvi2-command ;previewer command for your site | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
44 (if (eq system-type 'ms-dos) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
45 "dviout" |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
46 (concat |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
47 "xdvi -geo +0+0 -s 4 -display " |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
48 (getenv "DISPLAY"))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
49 "Default previewer command including its option. |
0 | 50 This default value is for X window system. If you want to use this |
51 default, you have to make sure the environment variable DISPLAY is | |
52 correctly set." | |
53 ) | |
54 (defvar latex-warning-regexp "line.* [0-9]*" | |
55 "Regular expression of line number of warning message by latex command." | |
56 ) | |
57 (defvar latex-error-regexp "l\\.[1-9][0-9]*" | |
58 "Regular expression of line number of latex error. Perhaps your latex | |
59 command stops at this error message with line number of LaTeX source text." | |
60 ) | |
1 | 61 (defvar latex-dos-emergency-message |
3 | 62 "Emergency stop" ;<- for Micro tex, ASCII-pTeX 1.6 |
0 | 63 "Because Demacs (GNU Emacs on DOS) cannot have pararell process, the |
64 latex command which is stopping on a LaTeX error, is terminated by Demacs. | |
65 Many latex command on DOS display some message when it is terminated by | |
66 other process, user or OS. Define this variable a message string of your | |
67 latex command on DOS shows at abnormal termination. | |
68 Remember Demacs's call-process function is not oriented for interactive | |
69 process." | |
70 ) | |
71 | |
72 ;------------ Completion table ------------ | |
73 ; Set tex-section-like command possible completion | |
74 (setq section-table | |
75 '(("part") ("section") ("subsection") ("subsubsection") | |
76 ("author") ("documentstyle") ("pagestyle") | |
77 ("documentstyle[10pt]") ("documentstyle[11pt]") | |
78 ("documentstyle[12pt]") | |
3 | 79 ("title") ("chapter") ("part") ("paragraph") |
0 | 80 ("subparagraph") ("underline") ("label") ("footnote") |
81 ("hspace*") ("vspace*") ("bibliography") ("bibitem[]") ("cite[]") | |
82 ("nocite") ("input") ("include") ("includeonly") ("mbox") ("hbox") | |
83 ("caption") ("newcommand") ("setlength") ("addtolength") | |
84 ("newenvironment") ("newtheorem") | |
85 )) | |
86 (defvar user-section-table nil) | |
87 | |
88 ; Set style possible completion | |
89 (setq article-table | |
90 '(("article") ("jarticle") ("report") ("jreport") ("jbook") | |
91 ("4em") ("2ex") | |
92 ("empty") ("headings") ("\\textwidth") | |
93 ("\\oddsidemargin") ("\\evensidemargin") | |
94 ("\\textheight") ("\\topmargin") | |
95 ("\\bottommargin") ("\\footskip") ("\\footheight") | |
96 )) | |
97 (defvar user-article-table nil) | |
98 | |
99 ; Set tex-environment possible completion | |
100 (setq env-table | |
101 '(("quote") ("quotation") ("center") ("verse") ("document") | |
102 ("verbatim") ("itemize") ("enumerate") ("description") | |
103 ("list{}") ("tabular") ("table") ("titlepage") | |
104 ("sloppypar") ("ref") ("quotation") ("quote") ("picture") | |
105 ("eqnarray") ("figure") ("equation") ("abstract") ("array") | |
106 ("thebibliography") ("theindex") | |
107 )) | |
108 (defvar user-env-table nil) | |
109 | |
110 ; Set {\Large }-like comletion | |
111 (setq fontsize-table | |
112 '(("rm") ("em") ("bf") ("boldmath") ("it") ("sl") ("sf") ("sc") ("tt") | |
113 ("dg") ("dm") | |
114 ("tiny") ("scriptsize") ("footnotesize") ("small")("normalsize") | |
115 ("large") ("Large") ("LARGE") ("huge") ("Huge") | |
116 )) | |
117 (defvar user-fontsize-table nil) | |
118 | |
119 (setq singlecmd-table | |
120 '(("maketitle") ("sloppy") | |
121 ("alpha") ("beta") ("gamma") ("delta") ("epsilon") ("varepsilon") | |
122 ("zeta") ("eta") ("theta")("vartheta") ("iota") ("kappa") | |
123 ("lambda") ("mu") ("nu") ("xi") ("pi") ("varpi") ("rho") ("varrho") | |
124 ("sigma") ("varsigma") ("tau") ("upsilon") ("phi") ("varphi") | |
125 ("chi") ("psi") ("omega") ("Gamma") ("Delta") ("Theta") ("Lambda") | |
126 ("Xi") ("Pi") ("Sigma") ("Upsilon") ("Phi") ("Psi") ("Omega") | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
127 ("LaTeX") ("TeX") ("item[]") |
0 | 128 )) |
129 (defvar user-singlecmd-table nil) | |
130 | |
131 ;---------- Key mode map ---------- | |
132 ;;; | |
133 ;; Create new key map: YaTeX-mode-map | |
134 ;; Do not change this section. | |
135 ;;; | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
136 (defvar YaTeX-inhibit-prefix-letter nil |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
137 "Switch which determin whether inhibit yatex.el from defining |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
138 key sequence \"C-c letter\" or not." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
139 ) |
0 | 140 (defvar YaTeX-mode-map nil |
141 "Keymap used in YaTeX mode." | |
142 ) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
143 (defvar YaTeX-typesetting-mode-map nil |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
144 "Keymap userd in YaTeX typesetting buffer." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
145 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
146 (defvar YaTeX-prefix-map nil |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
147 "Keymap used when YaTeX-prefix key pushed." |
0 | 148 ) |
149 | |
150 ;---------- Define deafult key bindings on YaTeX mode map ---------- | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
151 (defun YaTeX-define-key (key binding) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
152 "Define key on YaTeX-prefix-map" |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
153 (if YaTeX-inhibit-prefix-letter |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
154 (let ((c (aref key 0))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
155 (cond |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
156 ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a)))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
157 ((and (>= c ?A) (<= c ?Z)) (aset key 0 (1+ (- c ?A)))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
158 (t nil)))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
159 (define-key YaTeX-prefix-map key binding) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
160 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
161 (defun YaTeX-define-begend-key (key env) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
162 "Define short cut YaTeX-make-begin-end key." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
163 (YaTeX-define-key |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
164 key |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
165 (list 'lambda '(arg) '(interactive "P") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
166 (list 'YaTeX-insert-begin-end env 'arg))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
167 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
168 (defun YaTeX-define-begend-region-key (key env) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
169 "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
|
170 (YaTeX-define-key key (list 'lambda nil '(interactive) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
171 (list 'YaTeX-insert-begin-end env t))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
172 ) |
0 | 173 ;;; |
174 ;; Define key table | |
175 ;;; | |
176 (if YaTeX-mode-map | |
177 nil | |
178 (setq YaTeX-mode-map (make-sparse-keymap)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
179 (setq YaTeX-prefix-map (make-sparse-keymap)) |
0 | 180 (define-key YaTeX-mode-map "\"" 'YaTeX-insert-quote) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
181 (define-key YaTeX-mode-map YaTeX-prefix YaTeX-prefix-map) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
182 (YaTeX-define-key "t" 'YaTeX-typeset-menu) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
183 (define-key YaTeX-prefix-map "'" 'YaTeX-prev-error) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
184 (define-key YaTeX-prefix-map " " 'YaTeX-do-completion) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
185 (YaTeX-define-key "v" 'YaTeX-version) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
186 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
187 (define-key YaTeX-prefix-map "{" 'YaTeX-insert-braces) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
188 (define-key YaTeX-prefix-map "}" 'YaTeX-insert-braces-region) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
189 (YaTeX-define-key "d" 'YaTeX-insert-dollar) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
190 (YaTeX-define-key |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
191 "\\" '(lambda () (interactive) (YaTeX-insert-string "$\\backslash$"))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
192 (YaTeX-define-begend-region-key "Bd" "document") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
193 (YaTeX-define-begend-key "bd" "document") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
194 (YaTeX-define-begend-region-key "BD" "description") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
195 (YaTeX-define-begend-key "bD" "description") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
196 (YaTeX-define-begend-region-key "Be" "enumerate") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
197 (YaTeX-define-begend-key "be" "enumerate") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
198 (YaTeX-define-begend-region-key "Bi" "itemize") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
199 (YaTeX-define-begend-key "bi" "itemize") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
200 (YaTeX-define-begend-region-key "Bt" "tabbing") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
201 (YaTeX-define-begend-key "bt" "tabbing") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
202 (YaTeX-define-begend-region-key "BT" "tabular") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
203 (YaTeX-define-begend-key "bT" "tabular") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
204 (YaTeX-define-begend-region-key "Bq" "quote") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
205 (YaTeX-define-begend-key "bq" "quote") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
206 (YaTeX-define-begend-region-key "BQ" "quotation") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
207 (YaTeX-define-begend-key "bQ" "quotation") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
208 (YaTeX-define-key "." 'YaTeX-comment-paragraph) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
209 (YaTeX-define-key "," 'YaTeX-uncomment-paragraph) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
210 (YaTeX-define-key ">" 'YaTeX-comment-region) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
211 (YaTeX-define-key "<" 'YaTeX-uncomment-region) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
212 (YaTeX-define-key "B " 'YaTeX-make-begin-end-region) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
213 (YaTeX-define-key "b " 'YaTeX-make-begin-end) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
214 (YaTeX-define-key "e" 'YaTeX-end-environment) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
215 (YaTeX-define-key "s" 'YaTeX-make-section) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
216 (YaTeX-define-key "L" 'YaTeX-make-fontsize-region) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
217 (YaTeX-define-key "l" 'YaTeX-make-fontsize) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
218 (YaTeX-define-key "m" 'YaTeX-make-singlecmd) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
219 (YaTeX-define-key "g" 'YaTeX-goto-corresponding-environment) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
220 (YaTeX-define-key "\C-m" |
0 | 221 '(lambda () (interactive) (YaTeX-insert-string "\\\\"))) |
222 (if (eq system-type 'ms-dos) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
223 (define-key YaTeX-prefix-map "\^L" |
0 | 224 '(lambda () (interactive) |
3 | 225 (set-screen-height YaTeX-saved-screen-height) (recenter)))) |
0 | 226 ) |
227 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
228 (if YaTeX-typesetting-mode-map nil |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
229 (setq YaTeX-typesetting-mode-map (make-keymap)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
230 (suppress-keymap YaTeX-typesetting-mode-map t) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
231 (define-key YaTeX-typesetting-mode-map " " |
0 | 232 'YaTeX-jump-error-line) |
233 ) | |
234 | |
235 ;---------- Customize as you like above ---------- | |
236 | |
237 ;---------- Define other variable ---------- | |
238 (defvar env-name "document") ;Initial tex-environment completion | |
239 (defvar section-name "documentstyle[12pt]") ;Initial tex-section completion | |
240 (defvar fontsize-name "large") ;Initial fontsize completion | |
241 (defvar single-command "maketitle") ;Initial LaTeX single command | |
242 (defvar YaTeX-user-table-has-read nil | |
243 "Flag that means whether user completion table has read or not." | |
244 ) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
245 (defvar YaTeX-user-table-modified nil |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
246 "Flag that means whether user completion table has modified or not." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
247 ) |
0 | 248 (defvar yatex-mode-hook nil |
249 "List of functions to be called after .tex file is read | |
250 and yatex-mode starts.") | |
251 | |
252 ;---------- Produce YaTeX-mode ---------- | |
253 ;;; | |
254 ;; Major mode definition | |
255 ;;; | |
256 (defun yatex-mode () | |
257 (interactive) | |
258 (kill-all-local-variables) | |
259 (setq major-mode 'YaTeX-mode) | |
1 | 260 (setq mode-name "‚â‚Ä‚Ó‚à[‚Ç") |
0 | 261 (turn-on-auto-fill) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
262 (make-local-variable 'dvi2-command) |
1 | 263 (make-local-variable 'kanji-display-code) |
264 (make-local-variable 'kanji-fileio-code) | |
265 (if (eq system-type 'ms-dos) | |
266 (setq YaTeX-kanji-code 1) | |
267 (defvar YaTeX-kanji-code 2)) | |
268 (setq kanji-display-code YaTeX-kanji-code | |
269 kanji-fileio-code YaTeX-kanji-code) | |
0 | 270 (make-local-variable 'fill-column) |
271 (make-local-variable 'fill-prefix) | |
272 (setq fill-column 72 | |
273 fill-prefix YaTeX-fill-prefix) | |
274 (use-local-map YaTeX-mode-map) | |
275 (if (eq system-type 'ms-dos) | |
3 | 276 (setq YaTeX-saved-screen-height (screen-height))) |
0 | 277 (if YaTeX-user-table-has-read nil |
278 (YaTeX-read-user-completion-table) | |
279 (setq YaTeX-user-table-has-read t)) | |
280 (run-hooks 'yatex-mode-hook) | |
281 ) | |
282 | |
283 ;---------- Define YaTeX-mode functions ---------- | |
284 ;;; | |
285 ;; YaTeX-mode functions | |
286 ;;; | |
287 (defun YaTeX-insert-begin-end (env arg) | |
288 "Insert \begin{mode-name} and \end{mode-name}." | |
289 (if arg | |
290 (save-excursion | |
291 (if (> (point) (mark)) (exchange-point-and-mark)) | |
292 (insert "\\begin{" env "}\n") | |
293 (exchange-point-and-mark) | |
294 (insert "\\end{" env "}\n")) | |
295 (delete-blank-lines) | |
296 (insert "\\begin{" env "}\n") | |
297 (newline (1+ (* 2 YaTeX-open-lines))) | |
298 (insert "\\end{" env "}\n") | |
299 (previous-line (+ 2 YaTeX-open-lines))) | |
300 ) | |
301 | |
302 (defun YaTeX-make-begin-end (arg) | |
303 "Make LaTeX environment command of \\begin{env.} ... \\end{env.} | |
304 by completing read. | |
305 If you invoke this command with universal argument, | |
306 \(C-u or ESC-1 is typical prefix to invoke commands with ARG.\) | |
307 you can put REGION into that environment between \\begin and \\end." | |
308 (interactive "P") | |
309 (let* | |
310 ((mode (if arg " region" "")) | |
311 (env | |
312 (completing-read | |
313 (format "Begin environment%s(default %s): " mode env-name) | |
314 (append user-env-table env-table) nil nil))) | |
315 (if (string= env "") | |
316 (setq env env-name)) | |
317 (setq env-name env) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
318 (if (not (assoc env-name (append user-env-table env-table))) ;if not exist |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
319 (setq user-env-table (cons (list env-name) user-env-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
320 YaTeX-user-table-modified t)) |
0 | 321 (YaTeX-insert-begin-end env-name arg)) |
322 ) | |
323 | |
324 (defun YaTeX-make-begin-end-region () | |
325 "Call YaTeX-make-begin-end with ARG to specify region mode." | |
326 (interactive) | |
327 (YaTeX-make-begin-end t) | |
328 ) | |
329 | |
3 | 330 (defun YaTeX-end-environment () |
331 "Close opening environment" | |
332 (interactive) | |
333 (let ((curp (point)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
334 s env (nest 0)) |
3 | 335 (save-excursion |
336 (while | |
337 (and | |
338 (>= nest 0) | |
339 (re-search-backward | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
340 "\\(\\\\begin{\\).*}\\|\\(\\\\end{\\).*}" (point-min) t)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
341 (if (re-search-backward "^[ ]*%" (point-beginning-of-line) t) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
342 nil ;ignore TeX comment usage. |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
343 (setq nest (if (eq (match-beginning 0) (match-beginning 1)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
344 (1- nest) (1+ nest))))) |
3 | 345 (if (>= nest 0) |
346 (message "No premature environment") | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
347 (goto-char (match-end 1)) |
3 | 348 (setq s (point)) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
349 (skip-chars-forward "^}") |
3 | 350 (setq env (buffer-substring s (point))) |
351 ;;(recursive-edit) | |
352 )) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
353 (if (not env) nil |
3 | 354 (save-excursion |
355 (if (and (re-search-forward "^[^\\%]*\\\\end{.*}" (point-max) t) | |
356 (progn (goto-char (match-beginning 0)) | |
357 (re-search-forward env (match-end 0) t))) | |
358 (if (y-or-n-p | |
359 (concat "Environment `" env | |
360 "' was already closed. Force close?")) | |
361 nil | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
362 (error "end environment aborted.")))) |
3 | 363 (message "") ;Erase (y or n) message. |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
364 (insert "\\end{" env "}") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
365 (setq curp (point)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
366 (goto-char s) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
367 (if (pos-visible-in-window-p) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
368 (sit-for 1) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
369 (message (concat "Matches \\begin{" env |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
370 (format "} at line %d" |
3 | 371 (count-lines (point-min) s))))) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
372 (goto-char curp)) |
3 | 373 ) |
374 ) | |
375 | |
0 | 376 (defun YaTeX-make-section (arg) |
377 "Make LaTeX \\section{} type command with completing read. | |
378 With ARG of numeric, you can specify the number of argument of | |
379 LaTeX command. | |
380 For example, if you want to produce LaTeX command | |
381 | |
382 \\addtolength{\\topmargin}{8mm} | |
383 | |
384 which has two argument. You can produce that sequence by typing... | |
385 ESC 2 C-c s add SPC RET \\topm SPC RET 8mm RET | |
386 \(by default\) | |
387 You can complete symbol at LaTeX command and 1st argument." | |
388 (interactive "p") | |
389 (let* | |
390 ((section | |
391 (completing-read | |
392 (format "\\???{} (default %s): " section-name) | |
393 (append user-section-table section-table) | |
394 nil nil)) | |
395 (section (if (string= section "") section-name section)) | |
396 (title | |
397 (completing-read (concat "\\" section "{???}: ") | |
398 (append user-article-table article-table) | |
399 nil nil))) | |
400 (setq section-name section) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
401 (if (not (assoc section-name (append user-section-table section-table))) |
0 | 402 (setq user-section-table |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
403 (cons (list section-name) user-section-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
404 YaTeX-user-table-modified t)) |
0 | 405 (insert "\\" section-name "{" title "}") |
406 (let ((j 2)) | |
407 (while (<= j arg) | |
408 (insert (concat "{" (read-string (format "Argument %d: " j)))) | |
409 (insert "}") | |
410 (setq j (1+ j))) | |
411 ) | |
412 (if (string= title "") (forward-char -1) | |
413 nil)) | |
414 ) | |
415 | |
416 ;(defun YaTeX-make-section-region () | |
417 ; "Call YaTeX-make-section with ARG to specify region mode." | |
418 ; (interactive) | |
419 ; (YaTeX-make-section t) | |
420 ;) | |
421 | |
422 (defun YaTeX-make-fontsize (arg) | |
423 "Make completion like {\\large ...} or {\\slant ...} in minibuffer. | |
424 If you invoke this command with universal argument, you can put region | |
425 into {\\xxx } braces. | |
426 \(C-u or ESC-1 are default key bindings of universal-argument.\)" | |
427 (interactive "P") | |
428 (let* ((mode (if arg "region" "")) | |
429 (fontsize | |
430 (completing-read | |
431 (format "{\\??? %s} (default %s): " mode fontsize-name) | |
432 (append user-fontsize-table fontsize-table) | |
433 nil nil ))) | |
434 (if (string= fontsize "") | |
435 (setq fontsize fontsize-name)) | |
436 (setq fontsize-name fontsize) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
437 (if (not (assoc fontsize-name (append user-fontsize-table fontsize-table))) |
0 | 438 (setq user-fontsize-table |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
439 (cons (list fontsize-name) user-fontsize-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
440 YaTeX-user-table-modified t)) |
0 | 441 (if arg |
442 (save-excursion | |
443 (if (> (point) (mark)) (exchange-point-and-mark)) | |
444 (insert "{\\" fontsize-name " ") | |
445 (exchange-point-and-mark) | |
446 (insert "}")) | |
447 (insert "{\\" fontsize-name " }") | |
448 (forward-char -1))) | |
449 ) | |
450 | |
451 (defun YaTeX-make-fontsize-region () | |
452 "Call functino:YaTeX-make-fontsize with ARG to specify region mode." | |
453 (interactive) | |
454 (YaTeX-make-fontsize t) | |
455 ) | |
456 | |
457 (defun YaTeX-make-singlecmd (single) | |
458 (interactive | |
459 (list (completing-read | |
460 (format "\\??? (default %s): " single-command) | |
461 (append user-singlecmd-table singlecmd-table) | |
462 nil nil ))) | |
463 (if (string= single "") | |
464 (setq single single-command)) | |
465 (setq single-command single) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
466 (if (not (assoc single-command |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
467 (append user-singlecmd-table singlecmd-table))) |
0 | 468 (setq user-singlecmd-table |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
469 (cons (list single-command) user-singlecmd-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
470 YaTeX-user-table-modified t)) |
0 | 471 (insert "\\" single-command " ") |
472 ) | |
473 | |
474 (defvar YaTeX-completion-begin-regexp "[{\\]" | |
475 "Regular expression of limit where LaTeX command's | |
476 completion begins.") | |
477 | |
478 (defun YaTeX-do-completion () | |
479 "Try completion on LaTeX command preceding point." | |
480 (interactive) | |
481 (if | |
482 (or (eq (preceding-char) ? ) | |
483 (eq (preceding-char) ?\t) | |
484 (eq (preceding-char) ?\n) | |
485 (bobp)) | |
486 (message "Nothing to complete.") ;Do not complete | |
487 (let* ((end (point)) | |
488 (limit (save-excursion (beginning-of-line) (point))) | |
489 (completion-begin | |
490 (progn (re-search-backward "[ \t\n]" limit 1) | |
491 (point))) | |
492 (begin (progn | |
493 (goto-char end) | |
494 (if (re-search-backward YaTeX-completion-begin-regexp | |
495 completion-begin t) | |
496 (1+ (point)) | |
497 nil)))) | |
498 (goto-char end) | |
499 (cond | |
500 ((null begin) | |
501 (message "I think it is not LaTeX sequence.")) | |
502 (t | |
503 (let* ((pattern (buffer-substring begin end)) | |
504 (all-table (append section-table user-section-table | |
505 article-table user-article-table | |
506 env-table user-env-table | |
507 singlecmd-table user-singlecmd-table)) | |
508 ;; First, | |
509 ;; search completion without backslash. | |
510 (completion (try-completion pattern all-table nil))) | |
511 (if | |
512 (eq completion nil) | |
513 ;; Next, | |
514 ;; search completion with backslash | |
515 (setq completion | |
516 (try-completion (buffer-substring (1- begin) end) | |
517 all-table nil) | |
518 begin (1- begin))) | |
519 (cond | |
520 ((null completion) | |
521 (message (concat "Can't find completion for '" pattern "'")) | |
522 (ding)) | |
523 ((eq completion t) (message "Sole completion.")) | |
524 ((not (string= completion pattern)) | |
525 (kill-region begin end) | |
526 (insert completion) | |
527 ) | |
528 (t | |
529 (message "Making completion list...") | |
530 (with-output-to-temp-buffer "*Help*" | |
531 (display-completion-list | |
532 (all-completions pattern all-table))) ) | |
533 )))))) | |
534 ) | |
535 | |
536 (defun YaTeX-insert-quote () | |
537 (interactive) | |
538 (insert | |
539 (cond | |
540 ((= (preceding-char) ?\\ ) ?\") | |
541 ((= (preceding-char) ?\( ) ?\") | |
542 ((= (preceding-char) 32) "``") | |
543 ((= (preceding-char) 9) "``") | |
544 ((= (preceding-char) ?\n) "``") | |
545 ((bobp) "``") | |
546 (t "''") | |
547 ))) | |
548 | |
549 | |
550 (defun YaTeX-insert-braces-region (beg end) | |
551 (interactive "r") | |
552 (save-excursion | |
553 (goto-char end) | |
554 (insert "}") | |
555 (goto-char beg) | |
556 (insert "{")) | |
557 ) | |
558 | |
559 (defun YaTeX-insert-braces () | |
560 (interactive) | |
561 (insert "{}") | |
562 (forward-char -1) | |
563 ) | |
564 | |
565 (defun YaTeX-insert-dollar () | |
566 (interactive) | |
567 (insert "$$") | |
568 (forward-char -1) | |
569 ) | |
570 | |
571 (defun YaTeX-insert-string (s) | |
572 (insert s) | |
573 ) | |
574 | |
575 (defun YaTeX-version () | |
576 "Return string of the version of running YaTeX." | |
577 (interactive) | |
578 (message | |
1 | 579 (concat "Yet Another TeX mode u–ì’¹v Revision " |
0 | 580 YaTeX-revision-number)) |
581 ) | |
582 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
583 (defun YaTeX-typeset-sentinel (proc mes) |
0 | 584 (cond ((null (buffer-name (process-buffer proc))) |
585 ;; buffer killed | |
586 (set-process-buffer proc nil)) | |
587 ((memq (process-status proc) '(signal exit)) | |
588 (let* ((obuf (current-buffer))) | |
589 ;; save-excursion isn't the right thing if | |
590 ;; process-buffer is current-buffer | |
591 (unwind-protect | |
592 (progn | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
593 ;; Write something in *typesetting* and hack its mode line |
0 | 594 (set-buffer (process-buffer proc)) |
595 (goto-char (point-max)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
596 (insert ?\n "jlatex typesetting " mes) |
0 | 597 (forward-char -1) |
598 (insert " at " | |
599 (substring (current-time-string) 0 -5)) | |
600 (insert "\n * Hit any key to return * ") | |
601 (forward-char 1) | |
602 (setq mode-line-process | |
603 (concat ": " | |
604 (symbol-name (process-status proc)))) | |
605 ;; If buffer and mode line will show that the process | |
606 ;; is dead, we can delete it now. Otherwise it | |
607 ;; will stay around until M-x list-processes. | |
608 (delete-process proc) | |
609 ) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
610 (setq YaTeX-typesetting-process nil) |
0 | 611 ;; Force mode line redisplay soon |
612 (set-buffer-modified-p (buffer-modified-p)) | |
613 ) | |
614 (set-buffer obuf) | |
615 ))) | |
616 ) | |
617 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
618 (defvar YaTeX-typesetting-process nil |
0 | 619 "Process identifier for jlatex" |
620 ) | |
621 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
622 (defun YaTeX-typeset () |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
623 "Execute jlatex (or other) to LaTeX typeset." |
0 | 624 (interactive) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
625 (if YaTeX-typesetting-process |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
626 (if (eq (process-status YaTeX-typesetting-process) 'run) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
627 (progn (interrupt-process YaTeX-typesetting-process) |
0 | 628 (sit-for 1) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
629 (delete-process YaTeX-typesetting-process)) |
0 | 630 nil) nil) |
631 ; (compile1 (concat tex-command " " (buffer-name)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
632 ; "TeX error" "*TeX typesetting*") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
633 (setq YaTeX-typesetting-process nil) |
0 | 634 (if (eq system-type 'ms-dos) ;if MS-DOS |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
635 (with-output-to-temp-buffer "*YaTeX-typesetting*" |
0 | 636 (message (concat "Compiling " (buffer-name) "...")) |
1 | 637 (YaTeX-put-nonstopmode) |
638 (basic-save-buffer) | |
639 (call-process shell-file-name | |
640 nil | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
641 "*YaTeX-typesetting*" nil |
1 | 642 "/c" (YaTeX-get-latex-command)) |
643 (YaTeX-remove-nonstopmode)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
644 (setq YaTeX-typesetting-process ;if UNIX |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
645 (with-output-to-temp-buffer "*YaTeX-typesetting*" |
1 | 646 (basic-save-buffer) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
647 (start-process "LaTeX" "*YaTeX-typesetting*" shell-file-name "-c" |
1 | 648 (YaTeX-get-latex-command)) |
0 | 649 )) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
650 (set-process-sentinel YaTeX-typesetting-process 'YaTeX-typeset-sentinel)) |
0 | 651 (setq current-TeX-buffer (buffer-name)) |
652 (other-window 1) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
653 (use-local-map YaTeX-typesetting-mode-map) |
0 | 654 (set-kanji-process-code YaTeX-kanji-code) |
655 (message "Type SPC to continue.") | |
656 (goto-char (point-max)) | |
657 (sit-for 30) | |
658 (read-char) ;hit any key | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
659 (if (not (= (window-start) (point-min))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
660 (while (eq (point) (point-max)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
661 (scroll-down 1))) |
0 | 662 (other-window -1) |
663 ) | |
664 | |
665 (defun YaTeX-preview (preview-command preview-file) | |
666 "Execute xdvi (or other) to tex-preview." | |
667 (interactive | |
668 (list (read-string "Preview command: " dvi2-command) | |
669 (read-string "Prefiew file[.dvi]: " | |
3 | 670 ;;(substring (buffer-name) 0 -4) |
671 (YaTeX-get-preview-file-name) ;ver 1.31 | |
0 | 672 ))) |
673 (setq dvi2-command preview-command) | |
674 (with-output-to-temp-buffer "*dvi-preview*" | |
675 (if (eq system-type 'ms-dos) | |
676 (progn (send-string-to-terminal "\e[2J") ;if MS-DOS | |
677 (call-process shell-file-name "con" "*dvi-preview*" nil | |
678 "/c " dvi2-command preview-file) | |
679 (redraw-display)) | |
680 (start-process "xdvi" "*dvi-preview*" shell-file-name "-c" | |
681 (concat dvi2-command " " preview-file)) ;if UNIX | |
682 (message (concat "Starting " dvi2-command " to preview " preview-file))) | |
683 ) | |
684 ) | |
685 | |
686 (defun YaTeX-prev-error () | |
687 "Visit previous error. The reason why not NEXT-error is to | |
688 avoid make confliction of line numbers by editing." | |
689 (interactive) | |
690 (setq cur-buf (buffer-name) | |
691 YaTeX-error-line nil) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
692 (if (null (get-buffer "*YaTeX-typesetting*")) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
693 (message "There is no output buffer of typesetting.") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
694 (pop-to-buffer "*YaTeX-typesetting*") |
0 | 695 (if (eq system-type 'ms-dos) |
696 (if (search-backward latex-dos-emergency-message nil t) | |
697 (progn (goto-char (point-max)) | |
698 (setq error-regexp latex-error-regexp)) | |
699 (beginning-of-line) | |
700 (forward-char -1) | |
701 (setq error-regexp latex-warning-regexp)) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
702 (if YaTeX-typesetting-process ; if jlatex on UNIX |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
703 (if (eq (process-status YaTeX-typesetting-process) 'run) |
0 | 704 (progn |
705 (goto-char (point-max)) | |
706 (setq error-regexp latex-error-regexp))) | |
707 (beginning-of-line) | |
708 (setq error-regexp latex-warning-regexp))) | |
709 (if (re-search-backward error-regexp nil t) | |
710 (save-restriction | |
711 (set-mark-command nil) | |
712 (end-of-line) | |
713 (narrow-to-region (point) (mark)) | |
714 (goto-char (point-min)) | |
715 (re-search-forward "[0-9]") | |
716 (forward-char -1) | |
717 (set-mark (point)) | |
1 | 718 (skip-chars-forward "0-9") |
0 | 719 (narrow-to-region (point) (mark)) |
720 (goto-char (point-min)) | |
721 (setq YaTeX-error-line (read (current-buffer)))) | |
722 (message "No more error on %s" cur-buf) | |
723 (ding) | |
724 ) | |
725 (other-window -1) | |
726 (switch-to-buffer cur-buf) | |
727 (if (null YaTeX-error-line) | |
728 nil | |
729 (goto-line YaTeX-error-line) | |
730 (message "latex error or warning at line: %d" YaTeX-error-line) | |
731 (other-window 1) | |
732 (skip-chars-backward "[0-9]") | |
733 (recenter (/ (window-height) 2)) | |
734 (sit-for 3) | |
735 (forward-line -1) | |
736 (other-window -1) | |
737 )) | |
738 ) | |
739 | |
740 (defun YaTeX-jump-error-line () | |
741 "Jump corresponding line on latex command's error message." | |
742 (interactive) | |
743 (let ((end (progn (end-of-line) (point))) | |
744 (begin (progn (beginning-of-line)(point)))) | |
745 (if (null (re-search-forward "l[ ines]*\\.*[1-9][0-9]*" end t)) | |
746 (message "No line number expression") | |
747 (goto-char (match-beginning 0)) | |
748 (re-search-forward "[1-9][0-9]*" end t) | |
749 (save-restriction | |
750 (narrow-to-region (match-beginning 0) (match-end 0)) | |
751 (goto-char (point-min)) | |
752 (let ((error-line (read (current-buffer)))) | |
753 (other-window -1) | |
754 (switch-to-buffer current-TeX-buffer) | |
755 (goto-line error-line))))) | |
756 ) | |
757 | |
758 (defun YaTeX-view-error () | |
759 (interactive) | |
760 (other-window 1) | |
761 (goto-char (point-max)) | |
762 (other-window -1) | |
763 ) | |
764 | |
1 | 765 (defun YaTeX-put-nonstopmode () |
766 (if (boundp 'YaTeX-need-nonstop) | |
767 (if (re-search-backward "\\nonstopmode{}" (point-min) t) | |
768 nil ;if already written in text then do nothing | |
769 (save-excursion | |
770 (goto-char (point-min)) | |
771 (insert "\\nonstopmode{}%_YaTeX_%\n"))) | |
772 ) | |
773 ) | |
774 | |
775 (defun YaTeX-remove-nonstopmode () | |
776 (if (boundp 'YaTeX-need-nonstop) ;for speed | |
777 (save-excursion | |
778 (goto-char (point-min)) | |
779 (forward-line 1) | |
780 (narrow-to-region (point-min) (point)) | |
781 (goto-char (point-min)) | |
782 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$") | |
783 (widen))) | |
784 ) | |
785 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
786 (defun YaTeX-typeset-menu () |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
787 "Typeset, preview, visit error and miscellaneous convinient menu." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
788 (interactive) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
789 (message "J)latex P)review V)iewerror") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
790 (let ((c (read-char))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
791 (cond |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
792 ((= c ?j) (YaTeX-typeset)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
793 ((= c ?p) (call-interactively 'YaTeX-preview)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
794 ((= c ?v) (YaTeX-view-error)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
795 ((= c ?b) (YaTeX-insert-string "\\")))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
796 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
797 |
3 | 798 (defun YaTeX-get-preview-file-name () |
799 "Get file name to preview by inquiring YaTeX-get-latex-command" | |
800 (let* ((latex-cmd (YaTeX-get-latex-command)) | |
801 (fname (substring latex-cmd (1+ (rindex latex-cmd ? )))) | |
802 (period)) | |
803 (if (eq fname "") | |
804 (setq fname (substring (buffer-name) 0 -4)) | |
805 (setq period (rindex fname ?.)) | |
806 (setq fname (substring fname 0 (if (eq -1 period) nil period))) | |
807 )) | |
808 ) | |
809 | |
1 | 810 (defun YaTeX-get-latex-command () |
811 "Specify the latex-command name and its argument. | |
812 If there is a line which begins by string: \"%#!\", the following | |
813 strings are assumed to be the latex-command and arguments. The | |
814 default value of latex-command is: | |
815 tex-command (buffer-name) | |
816 and if you write \"%#!jlatex\" in the beginning of certain line. | |
817 \"jlatex \" (buffer-name) | |
818 will be the latex-command, | |
819 and you write \"%#!jlatex main.tex\" | |
820 \"jlatex main.tex\" | |
821 will be given to the shell." | |
822 (let* | |
823 ((default-command | |
824 (concat tex-command " " (buffer-name)))) ;default value | |
825 (save-excursion | |
826 (goto-char (point-min)) | |
827 (if (null (re-search-forward "^%#!" (point-max) t)) | |
828 default-command | |
829 (skip-chars-forward "%#! ") | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
830 (if (eolp)1z |
1 | 831 default-command |
832 (let ((s (point))) | |
833 (skip-chars-forward "A-z") ;Skip command name | |
834 ;(setq YaTeX-latex-command (buffer-substring s (point))) | |
835 (if (eolp) ;Only change command name | |
836 (concat (buffer-substring s (point)) " " (buffer-name)) | |
837 (end-of-line) ;Change entire command name | |
838 (buffer-substring s (point)) ;including arguments. | |
839 )) | |
840 )))) | |
841 ) | |
842 | |
3 | 843 (defun YaTeX-goto-corresponding-environment () |
844 "Go to corresponding begin/end enclosure." | |
845 (interactive) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
846 (if (not (YaTeX-on-begin-end-p)) |
3 | 847 (error "No environment declaration")) |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
848 (let ((p (match-end 0) env) |
3 | 849 (m0 (match-beginning 0)) |
850 (m1 (match-beginning 1)) | |
851 (m2 (match-beginning 2))) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
852 (if (not |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
853 (save-excursion |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
854 (goto-char p) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
855 (search-forward "}" (point-end-of-line) t))) |
3 | 856 (error "Unterminated brackets for begin/end")) |
857 (setq env (buffer-substring p (match-beginning 0))) ;get current env | |
858 (cond | |
859 ((equal m0 m1) ;if begin{xxx} | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
860 (search-forward (concat "end{" env "}"))) |
3 | 861 ((equal m0 m2) ;if end{xxx} |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
862 (search-backward (concat "begin{" env "}"))) |
3 | 863 ) |
864 (beginning-of-line) | |
865 );let | |
866 ) | |
867 | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
868 (defun YaTeX-comment-region () |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
869 "Comment out region by '%'. If you call this function on the 'begin{}' or |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
870 'end{}' line, it comments out whole environment" |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
871 (interactive) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
872 (if (not (YaTeX-on-begin-end-p)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
873 (comment-region YaTeX-comment-prefix) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
874 (YaTeX-comment-uncomment-env 'comment-region)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
875 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
876 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
877 (defun YaTeX-uncomment-region () |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
878 "Uncomment out region by '%'." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
879 (interactive) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
880 (if (not (YaTeX-on-begin-end-p)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
881 (uncomment-region YaTeX-comment-prefix) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
882 (YaTeX-comment-uncomment-env 'uncomment-region)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
883 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
884 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
885 (defun YaTeX-comment-uncomment-env (func) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
886 "Comment or uncomment out one LaTeX environment switching function by FUNC." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
887 (save-excursion |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
888 (if (eq (match-beginning 0) (match-beginning 2)) ; if on the '\end{}' line |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
889 (YaTeX-goto-corresponding-environment)) ; goto '\begin{}' line |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
890 (beginning-of-line) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
891 (push-mark) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
892 (YaTeX-goto-corresponding-environment) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
893 (forward-line 1) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
894 (funcall func YaTeX-comment-prefix t) ; t makes uncomment once |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
895 (pop-mark) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
896 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
897 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
898 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
899 (defun YaTeX-mark-environment () |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
900 "Not implemented yet." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
901 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
902 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
903 (defun YaTeX-on-begin-end-p () |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
904 (save-excursion |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
905 (beginning-of-line) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
906 (re-search-forward "\\(begin{\\)\\|\\(end{\\)" (point-end-of-line) t)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
907 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
908 |
3 | 909 (defun YaTeX-comment-paragraph () |
910 "Comment out current paragraph." | |
911 (interactive) | |
912 (save-excursion | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
913 (if (YaTeX-on-begin-end-p) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
914 (progn |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
915 (beginning-of-line) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
916 (insert YaTeX-comment-prefix) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
917 (YaTeX-goto-corresponding-environment) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
918 (beginning-of-line) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
919 (insert YaTeX-comment-prefix)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
920 (mark-paragraph) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
921 (if (not (bobp)) (forward-line 1)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
922 (comment-region "%"))) |
3 | 923 ) |
924 | |
925 (defun YaTeX-uncomment-paragraph () | |
926 "Uncomment current paragraph." | |
927 (interactive) | |
928 (save-excursion | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
929 (if (YaTeX-on-begin-end-p) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
930 (progn |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
931 (YaTeX-remove-prefix YaTeX-comment-prefix t) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
932 (YaTeX-goto-corresponding-environment) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
933 (YaTeX-remove-prefix YaTeX-comment-prefix t)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
934 (let ((prefix fill-prefix)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
935 (setq fill-prefix "") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
936 (mark-paragraph) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
937 (if (not (bobp)) (forward-line 1)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
938 (uncomment-region "%") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
939 (setq fill-prefix prefix)))) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
940 ) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
941 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
942 (defun YaTeX-remove-prefix (prefix &optional once) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
943 "Remove prefix on current line so far as prefix detected. But |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
944 optional argument ONCE makes deletion once." |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
945 (interactive "sPrefix:") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
946 (beginning-of-line) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
947 (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
|
948 (replace-match "") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
949 (if once (end-of-line))) |
3 | 950 ) |
951 | |
0 | 952 (defun YaTeX-read-user-completion-table () |
953 "Append user completion table of LaTeX word" | |
954 (message "Loading personal completion table") | |
955 (let ((user-table (expand-file-name YaTeX-user-completion-table))) | |
956 (if (file-exists-p user-table) | |
957 (load-file user-table) | |
958 (message "Personal completion table not found.")) | |
959 )) | |
960 | |
961 (defun YaTeX-save-table () | |
962 "Save personal completion table as dictionary." | |
963 (interactive) | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
964 (if (not YaTeX-user-table-modified) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
965 nil |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
966 (message "Saving user table in %s" YaTeX-user-completion-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
967 (find-file (expand-file-name YaTeX-user-completion-table)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
968 (erase-buffer) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
969 ;; (prin1-to-string user-section-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
970 (insert "(setq user-section-table '(\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
971 (mapcar '(lambda (s) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
972 (insert (prin1-to-string s)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
973 (insert "\n")) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
974 user-section-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
975 (insert "))\n\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
976 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
977 (insert "(setq user-article-table '(\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
978 (mapcar '(lambda (s) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
979 (insert (prin1-to-string s)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
980 (insert "\n")) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
981 user-article-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
982 (insert "))\n\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
983 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
984 (insert "(setq user-env-table '(\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
985 (mapcar '(lambda (s) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
986 (insert (prin1-to-string s)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
987 (insert "\n")) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
988 user-env-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
989 (insert "))\n\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
990 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
991 (insert "(setq user-fontsize-table '(\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
992 (mapcar '(lambda (s) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
993 (insert (prin1-to-string s)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
994 (insert "\n")) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
995 user-fontsize-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
996 (insert "))\n\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
997 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
998 (insert "(setq user-singlecmd-table '(\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
999 (mapcar '(lambda (s) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1000 (insert (prin1-to-string s)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1001 (insert "\n")) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1002 user-singlecmd-table) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1003 (insert "))\n") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1004 |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1005 (basic-save-buffer) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1006 (kill-buffer (current-buffer)) |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1007 (message "") |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1008 (setq YaTeX-user-table-modified nil)) |
0 | 1009 ) |
1010 | |
3 | 1011 ;; --------------- General sub functions --------------- |
1012 | |
1013 ;(defun index (string char) | |
1014 ; (let ((pos 0)(len (1- (length string)))(index -1)) | |
1015 ; (while (<= pos len) | |
1016 ; (cond | |
1017 ; ((= (aref string pos) char) | |
1018 ; (setq index pos) (setq pos len)) | |
1019 ; (t (setq pos (1+ pos)))) | |
1020 ; ) | |
1021 ; index) | |
1022 ;) | |
1023 | |
1024 (defun rindex (string char) | |
1025 (let ((pos (1- (length string)))(index -1)) | |
1026 (while (>= pos 0) | |
1027 (cond | |
1028 ((= (aref string pos) char) | |
1029 (setq index pos) (setq pos -1)) | |
1030 (t (setq pos (1- pos)))) | |
1031 ) | |
1032 index) | |
1033 ) | |
1034 | |
1035 (defun point-beginning-of-line () | |
1036 (save-excursion (beginning-of-line)(point)) | |
1037 ) | |
1038 | |
1039 (defun point-end-of-line () | |
1040 (save-excursion (end-of-line)(point)) | |
1041 ) | |
1042 | |
0 | 1043 (defun append-to-hook (hook hook-list) |
1044 "Add hook-list to certain emacs's hook correctly. | |
1045 Argument hook-list is the list of function int the form to be called | |
1046 Call this function with argument as next example, | |
1047 (append-to-hook '((ding))) ;If one function to add. | |
1048 (append-to-hook '((func1)(func2 arg)))." | |
1049 (if (null (eval hook)) ;Not defined | |
1050 (set hook | |
1051 (append '(lambda ()) hook-list)) | |
1052 (if (listp (eval hook)) | |
1053 (if (eq (car (eval hook)) 'lambda) ;'(lambda () ....) | |
1054 (set hook | |
1055 (append (eval hook) hook-list)) | |
1056 (if (eq hook 'kill-emacs-hook) ;'(hook1 hook2 ...) | |
1057 (progn ; this format is not | |
1058 (ding) ; for kill-emacs-hook | |
1059 (message | |
1060 "Caution!! you have wrong format of kill-emacs-hook")) | |
1061 (while (not (null hook-list)) | |
1062 (set hook | |
1063 (append (eval hook) (car hook-list))) | |
1064 (setq hook-list (cdr hook-list)))) | |
1065 ) | |
1066 (set hook ;'hook | |
1067 (append '(lambda ()) | |
1068 (cons (list (eval hook)) hook-list))))) | |
1069 ) | |
1070 (append-to-hook 'kill-emacs-hook '((YaTeX-save-table))) | |
1071 | |
1072 ;--------------------------------- History --------------------------------- | |
1073 ; Rev. | Date | Contents | |
1074 ;------+----------+--------------------------------------------------------- | |
1075 ; 1.00 | 91/ 6/13 | Initial version. | |
1076 ; | | Auto compilation & preview. | |
1077 ; | | \section{}-type and \begin{}\end{}-type completion. | |
1078 ; 1.01 | 91/ 6/14 | Add {\large ..} type completion (prefix+l). | |
1079 ; 1.10 | 6/21 | Add learning feature of completion. | |
1080 ; 1.11 | 6/27 | Simplify function begin-document etc. using lambda. | |
1081 ; 1.12 | 7/ 6 | Modify YaTeX-make-section, show section-name. | |
1082 ; 1.13 | 12/ 4 | Delete blank lines in make begin/end environment. | |
1083 ; 1.20 | 12/ 5 | Saving learned completion into user file. | |
1084 ; 1.21 | 12/ 6 | Add \maketitle type completion (prefix+m). | |
1085 ; 1.22 | 12/30 | Port yatex.el to DOS(Demacs). | |
1086 ; 1.23 | 92/ 1/ 8 | Enable latex and preview command on DOS. | |
1087 ; 1.24 | 1/ 9 | Add YaTeX-save-table to kill-emacs-hook automatically. | |
1088 ; 1.25 | 1/16 | YaTeX-do-completion (prefix+SPC) and argument | |
3 | 1089 ; | | acceptable YaTeX-make-section works. Put region into |
0 | 1090 ; | | \begin...\end by calling YaTeX-make-begin-end with ARG. |
1091 ; | | append-kill-emacs-hook was revised to append-to-hook. | |
1092 ; 1.26 | 1/18 | Region mode is added to {\large }. Default fontsize. | |
3 | 1093 ; 1.27 | 1/21 | Default name on completing-read. |
1 | 1094 ; 1.28 | 7/ 2 | Add \nonstopmode{} automatically on DOS. |
1095 ; | 7/20 | %#! usage to specify latex command and its arguments. | |
3 | 1096 ; | | Change default fill-prefix from TAB to null string. |
1097 ; 1.29 | 7/21 | Add YaTeX-end-environment. | |
1098 ; 1.30 | 9/26 | Support project 30 lines(other than 25 lines). | |
1099 ; 1.31 | 10/28 | Variable argument for previewer from %#! usage. | |
4
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1100 ; 1.32 | 11/16 | YaTeX-goto-corresponding-environment. |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1101 ; | | Comment out region/paragraph added. |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1102 ; 1.33 | 11/29 | Variable default value, on DOS and other OS. |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1103 ; | | make dvi2-command buffer local. Change the behavior of |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1104 ; | | comment out region/paragraph on the \begin{} or \end{} |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1105 ; | | line. Make faster YaTeX-end-environment. Add YaTeX- |
78dfe28b6a35
Provide service function to define begin/end insert key-bind.
yuuji
parents:
3
diff
changeset
|
1106 ; | | define-key, YaTeX-define-begend-(region-)key. |
0 | 1107 ;------+----------+--------------------------------------------------------- |
1108 ; | |
1109 ;----------------------------- End of yatex.el ----------------------------- |