yatex

view yatex19.el @ 46:cd1b63102eed

Support Mule2
author yuuji
date Mon, 19 Sep 1994 16:54:19 +0000
parents
children d7e7b4654058
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX facilities for Emacs 19
3 ;;; (c )1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
4 ;;; Last modified Sat Sep 17 12:53:23 1994 on figaro
5 ;;; $Id$
7 ;;; $B$H$j$"$($:(B hilit19 $B$r;H$C$F$$$k;~$K?'$,IU$/$h$&$K$7$F(B
8 ;;; $B%a%K%e!<%P!<$G$4$K$g$4$K$g$G$-$k$h$&$K$7$?$@$1!#(B
9 ;;; $B$$$C$?$$C/$,%a%K%e!<%P!<;H$C$F(BLaTeX$B%=!<%9=q$/$s$@$m$&$+(B?
10 ;;; $B$^$"$$$$$dN}=,N}=,!#8e$m$NJ}$K$A$g$C$H%3%a%s%H$"$j!#(B
12 (defun YaTeX-19-define-sub-menu (map vec &rest bindings)
13 "Define sub-menu-item in MAP at vector VEC as BINDINGS.
14 BINDINGS is a form with optional length: (symbol title binding).
15 When you defined menu-bar keymap such like:
16 (define-key foo-map [menu-bar foo] (make-sparse-keymap \"foo menu\"))
17 and you want to define sub menu for `foo menu' as followings.
18 foo -> menu1 (calling function `func1')
19 menu2 (doing interactive call `(func2 ...)'
20 Call this function like this:
21 (YaTeX-19-define-sub-menu foo-map [menu-bar foo]
22 '(m1 \"Function 1\" func1)
23 '(m2 \"Function 2\" (lambda () (interactive) (func2 ...))))
24 where
25 `m1' and `m2' are the keymap symbol for sub-menu of `[menu-bar foo].
26 `Funtion 1' and `Function 2' are the title strings for sub-menu.
27 "
28 (let ((i 0) (vec2 (make-vector (1+ (length vec)) nil)))
29 (while (< i (length vec))
30 (aset vec2 i (aref vec i))
31 (setq i (1+ i)))
32 (setq bindings (reverse bindings))
33 (mapcar
34 (function
35 (lambda (bind)
36 (aset vec2 (1- (length vec2)) (car bind)) ;set menu-symbol
37 (define-key map vec2
38 (cons (car (cdr bind))
39 (car (cdr (cdr bind)))))))
40 bindings)))
42 ;; Menu for Typeset relating processes ----------------------------------------
43 (define-key YaTeX-mode-map [menu-bar yatex]
44 (cons "YaTeX" (make-sparse-keymap "YaTeX")))
45 (define-key YaTeX-mode-map [menu-bar yatex process]
46 (cons "Process" (make-sparse-keymap "Process")))
47 (YaTeX-19-define-sub-menu
48 YaTeX-mode-map [menu-bar yatex process]
49 '(buffer "LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?j)))
50 '(kill "Kill LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?k)))
51 '(bibtex "BibTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?b)))
52 '(makeindex "makeindex" (lambda () (interactive) (YaTeX-typeset-menu nil ?i)))
53 '(preview "Preview" (lambda () (interactive) (YaTeX-typeset-menu nil ?p)))
54 '(lpr "lpr" (lambda () (interactive) (YaTeX-typeset-menu nil ?l)))
55 '(lpq "lpq" (lambda () (interactive) (YaTeX-typeset-menu nil ?q)))
56 )
58 ;; Help for LaTeX ------------------------------------------------------------
59 (YaTeX-19-define-sub-menu
60 YaTeX-mode-map [menu-bar yatex]
61 '(sephelp "--")
62 '(help "Help on LaTeX commands" YaTeX-help)
63 '(apropos "Apropos on LaTeX commands" YaTeX-apropos))
65 ;; Switch modes --------------------------------------------------------------
66 (define-key YaTeX-mode-map [menu-bar yatex switch]
67 (cons "Switching YaTeX's modes" (make-sparse-keymap "modes")))
68 (or YaTeX-auto-math-mode
69 (define-key YaTeX-mode-map [menu-bar yatex switch math]
70 '("Toggle math mode" . (lambda () (interactive)
71 (YaTeX-switch-mode-menu nil ?t)))))
72 (define-key YaTeX-mode-map [menu-bar yatex switch mod]
73 '("Toggle modify mode" . (lambda () (interactive)
74 (YaTeX-switch-mode-menu nil ?m))))
76 ;; % menu --------------------------------------------------------------------
77 (define-key YaTeX-mode-map [menu-bar yatex percent]
78 (cons "Edit %# notation" (make-sparse-keymap "Edit %# notation")))
79 (YaTeX-19-define-sub-menu
80 YaTeX-mode-map [menu-bar yatex percent]
81 '(! "Change LaTeX typesetter(%#!)"
82 (lambda () (interactive) (YaTeX-%-menu nil nil ?!)))
83 '(begend "Set %#BEGIN-%#END on region"
84 (lambda () (interactive) (YaTeX-%-menu nil nil ?b)))
85 '(lpr "Change LPR format"
86 (lambda () (interactive) (YaTeX-%-menu nil nil ?l))))
88 ;; What position -------------------------------------------------------------
89 (YaTeX-19-define-sub-menu
90 YaTeX-mode-map [menu-bar yatex]
91 '(what "What column in tabular" YaTeX-what-column))
93 ;; Jump cursor ---------------------------------------------------------------
94 (define-key YaTeX-mode-map [menu-bar yatex jump]
95 (cons "Jump cursor"
96 (make-sparse-keymap "Jump cursor")))
97 (YaTeX-19-define-sub-menu
98 YaTeX-mode-map [menu-bar yatex jump]
99 '(corres "Goto corersponding position" YaTeX-goto-corresponding-*)
100 '(main "Visit main source" (lambda () (interactive) (YaTeX-visit-main)))
101 '(main-other "Visit main source other window" YaTeX-visit-main-other-window)
102 )
104 ;; ===========================================================================
105 (define-key YaTeX-mode-map [menu-bar yatex sepcom]
106 '("---" . nil))
108 ;; Comment/Uncomment ---------------------------------------------------------
109 (YaTeX-19-define-sub-menu
110 YaTeX-mode-map [menu-bar yatex]
111 '(comment "Comment region or environment" YaTeX-comment-region)
112 '(uncomment "Unomment region or environment" YaTeX-uncomment-region)
113 '(commentp "Comment paragraph" YaTeX-comment-paragraph)
114 '(uncommentp "Unomment paragraph" YaTeX-uncomment-paragraph)
115 '(sepcom "--" nil)
116 )
119 ;; ===========================================================================
120 ;; Change/Kill/Fill
121 (YaTeX-19-define-sub-menu
122 YaTeX-mode-map [menu-bar yatex]
123 '(change "Change macros" YaTeX-change-*)
124 '(kill "Kill macros" YaTeX-kill-*)
125 '(fillitem "Fill \\item" YaTeX-fill-item)
126 '(newline "Newline" YaTeX-intelligent-newline)
127 '(sepchg "--" nil)
128 )
130 ;; Menu for completions ------------------------------------------------------
133 ;;;(YaTeX-19-define-sub-menu
134 ;;; YaTeX-mode-map [menu-bar yatex]
135 ;;; '(secr "Section-type command on region" YaTeX-make-section-region)
136 ;;; '(sec "Section-type command" YaTeX-make-section))
138 (define-key YaTeX-mode-map [menu-bar yatex sectionr]
139 (cons "Section-type region(long name)"
140 (make-sparse-keymap "Enclose region with section-type macro")))
141 (define-key YaTeX-mode-map [menu-bar yatex section]
142 (cons "Sectio-type(long name)"
143 (make-sparse-keymap "Section-type macro")))
144 (let ((sorted-section
145 (sort
146 (delq nil
147 (mapcar (function (lambda (s)
148 (if (> (length (car s)) 5)
149 (car s))))
150 (append section-table user-section-table)))
151 'string<)))
152 (apply 'YaTeX-19-define-sub-menu
153 YaTeX-mode-map [menu-bar yatex section]
154 (mapcar (function (lambda (secname)
155 (list (intern secname) secname
156 (list 'lambda ()
157 (list 'interactive)
158 (list 'YaTeX-make-section
159 nil nil nil secname)))))
160 sorted-section))
161 (apply 'YaTeX-19-define-sub-menu
162 YaTeX-mode-map [menu-bar yatex sectionr]
163 (mapcar (function (lambda (secname)
164 (list (intern secname) secname
165 (list 'lambda ()
166 (list 'interactive)
167 (list 'YaTeX-make-section
168 nil
169 (list 'region-beginning)
170 (list 'region-end)
171 secname)))))
172 sorted-section)))
174 (define-key YaTeX-mode-map [menu-bar yatex envr]
175 (cons "Environment region" (make-sparse-keymap "Environment region")))
176 (define-key YaTeX-mode-map [menu-bar yatex env]
177 (cons "Environment" (make-sparse-keymap "Environment")))
178 (let (prev envname)
179 (mapcar
180 (function
181 (lambda (envalist)
182 (setq envname (car envalist))
183 (define-key-after
184 (lookup-key YaTeX-mode-map [menu-bar yatex env])
185 (vector (intern envname))
186 (cons envname
187 (list 'lambda () (list 'interactive)
188 (list 'YaTeX-insert-begin-end
189 envname nil)))
190 prev)
191 (define-key-after
192 (lookup-key YaTeX-mode-map [menu-bar yatex envr])
193 (vector (intern envname))
194 (cons envname
195 (list 'lambda () (list 'interactive)
196 (list 'YaTeX-insert-begin-end
197 envname t)))
198 prev)
199 (setq prev (intern envname))))
200 (sort (append env-table user-env-table)
201 '(lambda (x y) (string< (car x) (car y))))))
203 ;; Highlightening
204 ;; $B%m!<%+%k$J%^%/%m$rFI$_9~$s$@8e(B redraw $B$9$k$H(B
205 ;; $B%m!<%+%k%^%/%m$r(B keyword $B$H$7$F8w$i$;$k(B(keyword$B$8$c$^$:$$$+$J!D(B)$B!#(B
206 (defvar YaTeX-hilit-pattern-adjustment
207 (list
208 ;;\def $B$,(B define $B$J$s$@$+$i(B new* $B$b(B define $B$G$7$g$&!#(B
209 '("\\\\\\(re\\)?new\\(environment\\|command\\){" "}" define)
210 '("\\\\new\\(length\\|theorem\\|counter\\){" "}" define)
211 ;;$B%;%/%7%g%s%3%^%s%I$,C1$J$k%-!<%o!<%I$C$F$3$H$O$J$$$G$7$g$&!#(B
212 (list
213 (concat "\\\\\\(" YaTeX-sectioning-regexp "\\){") "}"
214 'sectioning))
215 "Adjustment for hilit19's LaTeX hilit pattern.")
216 (defvar YaTeX-hilit-sectioning-face
217 'yellow/cornflowerblue)
218 (defun YaTeX-19-collect-macro ()
219 (cond
220 ((and (featurep 'hilit19) (fboundp 'hilit-translate))
221 (hilit-translate sectioning YaTeX-hilit-sectioning-face)
222 (setq hilit-patterns-alist ;Remove at the first time.
223 (delq 'yatex-mode hilit-patterns-alist)
224 hilit-patterns-alist
225 (cons
226 (cons 'yatex-mode
227 (append
228 YaTeX-hilit-pattern-adjustment
229 (cdr (assq 'latex-mode hilit-patterns-alist))
230 (list
231 (list
232 (concat "\\\\\\("
233 (mapconcat
234 (function (lambda (s) (regexp-quote (car s))))
235 (append user-section-table tmp-section-table)
236 "\\|")
237 "\\){")
238 "}" 'keyword))))
239 hilit-patterns-alist)))))
240 (YaTeX-19-collect-macro)
241 (defun YaTeX-hilit-recenter (arg)
242 "Collect current local macro and hilit-recenter."
243 (interactive "P")
244 (YaTeX-19-collect-macro)
245 (hilit-recenter arg))
246 (if (fboundp 'hilit-recenter) ;Replace hilit-recenter with
247 (mapcar (function (lambda (key) ;YaTeX-hilit-recenter in yatex-mode
248 (define-key YaTeX-mode-map key 'YaTeX-hilit-recenter)))
249 (where-is-internal 'hilit-recenter)))
251 ;;; reverseVideo $B$K$7$F(B hilit-background-mode $B$r(B 'dark
252 ;;; $B$K$7$F$$$k?M$O?t<0$J$I$,0E$/$J$j$9$.$F8+$E$i$$$+$b$7$l$J$$!#(B
253 ;;; $B<!$N%3!<%I$r(B hilit19 $B$r%m!<%I$7$F$$$k>l=j$ND>8e$KCV$/$H$A$g$C(B
254 ;;; $B$H$O$^$7!#(B
255 ;;; (if (eq hilit-background-mode 'dark)
256 ;;; (hilit-translate
257 ;;; string 'mediumspringgreen
258 ;;; formula 'khaki
259 ;;; label 'yellow-underlined))
261 (provide 'yatex19)