yatex

view yatexlib.el @ 72:0aaebd07dad0

Support font-lock on XEmacs-21, Emacs-20, Emacs-21. Support Emacs-21.
author yuuji
date Mon, 25 Dec 2000 10:19:28 +0000
parents 44e3a5e1e883
children f41b01fef5d6
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX and yahtml common libraries, general functions and definitions
3 ;;; yatexlib.el
4 ;;; (c )1994-2000 by HIROSE Yuuji.[yuuji@yatex.org]
5 ;;; Last modified Mon Dec 25 18:51:11 2000 on firestorm
6 ;;; $Id$
8 ;; General variables
9 (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2)))
10 (defvar YaTeX-emacs-19 (>= (string-to-int emacs-version) 19))
11 (defvar YaTeX-emacs-20 (>= (string-to-int emacs-version) 20))
12 (defvar YaTeX-emacs-21 (>= (string-to-int emacs-version) 21))
13 (defvar YaTeX-user-completion-table
14 (if YaTeX-dos "~/_yatexrc" "~/.yatexrc")
15 "*Default filename in which user completion table is saved.")
17 (defvar YaTeX-display-color-p
18 (or (and (fboundp 'display-color-p) (display-color-p))
19 (and (fboundp 'device-class)
20 (eq 'color (device-class (selected-device))))
21 window-system) ; falls down lazy check..
22 "Current display's capability of expressing colors.")
24 (defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE) YaTeX-emacs-20)
25 "Whether yatex mode is running on Japanese environment or not.")
27 ;; autoload from yahtml.el
28 (autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t)
30 (defvar YaTeX-kanji-code-alist
31 (cond
32 ((boundp '*junet*)
33 (list (cons
34 1
35 (if YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos)
36 *sjis*))
37 '(2 . *junet*) '(3 . *euc-japan*)))
38 (YaTeX-emacs-20
39 ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist)))
40 (list (cons
41 1 (cond (YaTeX-dos 'shift_jis-dos)
42 ((member 'shift_jis (coding-system-list)) 'shift_jis-unix)
43 (t 'sjis)))
44 '(2 . iso-2022-jp-unix)
45 '(3 . euc-jp-unix))))
46 "Kanji-code expression translation table.")
47 (defvar YaTeX-inhibit-prefix-letter nil
48 "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter.")
50 (defvar YaTeX-no-begend-shortcut nil
51 "*T for disabling shortcut of begin-type completion, [prefix] b d, etc.")
53 (defvar YaTeX-default-pop-window-height 10
54 "Default typesetting buffer height.
55 If integer, sets the window-height of typesetting buffer.
56 If string, sets the percentage of it.
57 If nil, use default pop-to-buffer.")
59 (defvar YaTeX-create-file-prefix-g nil
60 "*Non-nil creates new file when [prefix] g on \\include{foo}.")
62 (defvar YaTeX-nervous t
63 "*If you are nervous about maintenance of yatexrc, set this value to T.
64 And you will have the local dictionary.")
66 (defvar YaTeX-use-italic-bold (string< "20" emacs-version)
67 "*Non-nil tries to find italic/bold fontset.
68 This variable is effective when font-lock is used.
69 \it, \bf 内部での日本語が□になってしまう場合はこれをnilにして下さい。")
71 ;----------- work variables ----------------------------------------
72 (defvar YaTeX-typesetting-mode-map nil
73 "Keymap used in YaTeX typesetting buffer")
75 (if YaTeX-typesetting-mode-map nil
76 (setq YaTeX-typesetting-mode-map (make-keymap))
77 ;(suppress-keymap YaTeX-typesetting-mode-map t)
78 (define-key YaTeX-typesetting-mode-map " " 'YaTeX-jump-error-line)
79 (define-key YaTeX-typesetting-mode-map "\C-m" 'YaTeX-send-string)
80 (define-key YaTeX-typesetting-mode-map "1" 'delete-other-windows)
81 (define-key YaTeX-typesetting-mode-map "0" 'delete-window)
82 (define-key YaTeX-typesetting-mode-map "q" 'delete-window))
84 (defvar YaTeX-parent-file nil
85 "*Main LaTeX source file name used when %#! expression doesn't exist.")
86 (make-variable-buffer-local 'YaTeX-parent-file)
88 ;---------- Define default key bindings on YaTeX mode map ----------
89 ;;;###autoload
90 (defun YaTeX-define-key (key binding &optional map)
91 "Define key on YaTeX-prefix-map."
92 (if YaTeX-inhibit-prefix-letter
93 (let ((c (aref key 0)))
94 (cond
95 ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a))))
96 ((and (>= c ?A) (<= c ?Z) (numberp YaTeX-inhibit-prefix-letter))
97 (aset key 0 (1+ (- c ?A))))
98 (t nil))))
99 (define-key (or map YaTeX-prefix-map) key binding))
101 ;;;###autoload
102 (defun YaTeX-local-table-symbol (symbol)
103 "Return the lisp symbol which keeps local completion table of SYMBOL."
104 (intern (concat "YaTeX$"
105 default-directory
106 (symbol-name symbol))))
108 ;;;###autoload
109 (defun YaTeX-sync-local-table (symbol)
110 "Synchronize local variable SYMBOL.
111 Copy its corresponding directory dependent completion table to SYMBOL."
112 (if (boundp (YaTeX-local-table-symbol symbol))
113 (set symbol (symbol-value (YaTeX-local-table-symbol symbol)))))
115 (defvar YaTeX-user-table-is-read nil
116 "Flag that means whether user completion table has been read or not.")
117 ;;;###autoload
118 (defun YaTeX-read-user-completion-table (&optional forcetoread)
119 "Append user completion table of LaTeX macros"
120 (let*((user-table (expand-file-name YaTeX-user-completion-table))
121 (local-table (expand-file-name (file-name-nondirectory user-table)))
122 var localvar localbuf (curbuf (current-buffer)) sexp)
123 (if YaTeX-user-table-is-read nil
124 (message "Loading user completion table")
125 (if (file-exists-p user-table) (load-file user-table)
126 (message "Welcome to the field of YaTeX. I'm glad to see you!")))
127 (setq YaTeX-user-table-is-read t)
128 (cond
129 ((file-exists-p local-table)
130 (set-buffer (setq localbuf (find-file-noselect local-table)))
131 (widen)
132 (goto-char (point-min))
133 (while (re-search-forward "(setq \\([^ ]+\\)" nil t)
134 (setq var (intern (buffer-substring
135 (match-beginning 1) (match-end 1)))
136 localvar (YaTeX-local-table-symbol var))
137 (goto-char (match-beginning 0))
138 (setq sexp (buffer-substring (point)
139 (progn (forward-sexp) (point))))
140 (set-buffer curbuf)
141 (or (assq var (buffer-local-variables)) (make-local-variable var))
142 (eval (read sexp))
143 (or (and (boundp localvar)
144 (symbol-value localvar)
145 (not forcetoread))
146 (set localvar (symbol-value var)))
147 (set-buffer localbuf))
148 (kill-buffer localbuf)))
149 (set-buffer curbuf)))
151 ;;;###autoload
152 (defun YaTeX-reload-dictionary ()
153 "Reload local dictionary.
154 Use this function after editing ./.yatexrc."
155 (interactive)
156 (let ((YaTeX-user-table-is-read nil))
157 (YaTeX-read-user-completion-table t)))
159 ;;;###autoload
160 (defun YaTeX-lookup-table (word type)
161 "Lookup WORD in completion table whose type is TYPE.
162 This function refers the symbol tmp-TYPE-table, user-TYPE-table, TYPE-table.
163 Typically, TYPE is one of 'env, 'section, 'fontsize, 'singlecmd."
164 (if (symbolp type) (setq type (symbol-name type)))
165 (or (assoc word (symbol-value (intern (concat "tmp-" type "-table"))))
166 (assoc word (symbol-value (intern (concat "user-" type "-table"))))
167 (assoc word (symbol-value (intern (concat type "-table"))))))
169 ;;;###autoload
170 (defun YaTeX-update-table (vallist default-table user-table local-table)
171 "Update completion table if the car of VALLIST is not in current tables.
172 Second argument DEFAULT-TABLE is the quoted symbol of default completion
173 table, third argument USER-TABLE is user table which will be saved in
174 YaTeX-user-completion-table, fourth argument LOCAL-TABLE should have the
175 completion which is valid during current Emacs's session. If you
176 want to make LOCAL-TABLE valid longer span (but restrict in this directory)
177 create the file in current directory which has the same name with
178 YaTeX-user-completion-table."
179 (let ((car-v (car vallist)) key answer
180 (file (file-name-nondirectory YaTeX-user-completion-table)))
181 (cond
182 ((assoc car-v (symbol-value default-table))
183 nil) ;Nothing to do
184 ((setq key (assoc car-v (symbol-value user-table)))
185 (if (equal (cdr vallist) (cdr key)) nil
186 ;; if association hits, but contents differ.
187 (message
188 "%s's attributes turned into %s" (car vallist) (cdr vallist))
189 (set user-table (delq key (symbol-value user-table)))
190 (set user-table (cons vallist (symbol-value user-table)))
191 (YaTeX-update-dictionary
192 YaTeX-user-completion-table user-table "user")))
193 ((setq key (assoc car-v (symbol-value local-table)))
194 (if (equal (cdr vallist) (cdr key)) nil
195 (message
196 "%s's attributes turned into %s" (car vallist) (cdr vallist))
197 (set local-table (delq key (symbol-value local-table)))
198 (set local-table (cons vallist (symbol-value local-table)))
199 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table))
200 (YaTeX-update-dictionary file local-table)))
201 ;; All of above cases, there are some completion in tables.
202 ;; Then update tables.
203 (t
204 (if (not YaTeX-nervous)
205 (setq answer "u")
206 (message
207 (cond
208 (YaTeX-japan
209 "`%s'の登録先: U)ユーザ辞書 L)ローカル辞書 N)メモリ D)しない")
210 (t
211 "Register `%s' into: U)serDic L)ocalDic N)one D)iscard"))
212 (if (> (length car-v) 23)
213 (concat (substring car-v 0 10) "..." (substring car-v -9))
214 car-v))
215 (setq answer (char-to-string (read-char))))
216 (cond
217 ((string-match answer "uy")
218 (set user-table (cons vallist (symbol-value user-table)))
219 (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user")
220 )
221 ((string-match answer "tl")
222 (set local-table (cons vallist (symbol-value local-table)))
223 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table))
224 (YaTeX-update-dictionary file local-table))
225 ((string-match answer "d") nil) ;discard it
226 (t (set default-table
227 (cons vallist (symbol-value default-table)))))))))
229 ;;;###autoload
230 (defun YaTeX-cplread-with-learning
231 (prom default-table user-table local-table
232 &optional pred reqmatch init hsym)
233 "Completing read with learning.
234 Do a completing read with prompt PROM. Completion table is what
235 DEFAULT-TABLE, USER-TABLE, LOCAL table are appended in reverse order.
236 Note that these tables are passed by the symbol.
237 Optional arguments PRED, REQMATH and INIT are passed to completing-read
238 as its arguments PREDICATE, REQUIRE-MATCH and INITIAL-INPUT respectively.
239 If optional 8th argument HSYM, history symbol, is passed, use it as
240 history list variable."
241 (YaTeX-sync-local-table local-table)
242 (let*((table (append (symbol-value local-table)
243 (symbol-value user-table)
244 (symbol-value default-table)))
245 (word (completing-read-with-history
246 prom table pred reqmatch init hsym)))
247 (if (and (string< "" word) (not (assoc word table)))
248 (YaTeX-update-table (list word) default-table user-table local-table))
249 word))
251 ;;;###autoload
252 (defun YaTeX-update-dictionary (file symbol &optional type)
253 (let ((local-table-buf (find-file-noselect file))
254 (name (symbol-name symbol))
255 (value (symbol-value symbol)))
256 (save-excursion
257 (message "Updating %s dictionary..." (or type "local"))
258 (set-buffer local-table-buf)
259 (goto-char (point-max))
260 (search-backward (concat "(setq " name) nil t)
261 (delete-region (point) (progn (forward-sexp) (point)))
262 (delete-blank-lines)
263 (insert "(setq " name " '(\n")
264 (mapcar '(lambda (s)
265 (insert (format "%s\n" (prin1-to-string s))))
266 value)
267 (insert "))\n\n")
268 (delete-blank-lines)
269 (basic-save-buffer)
270 (kill-buffer local-table-buf)
271 (message "Updating %s dictionary...Done" (or type "local")))))
273 ;;;###autoload
274 (defun YaTeX-define-begend-key-normal (key env &optional map)
275 "Define short cut YaTeX-make-begin-end key."
276 (YaTeX-define-key
277 key
278 (list 'lambda '(arg) '(interactive "P")
279 (list 'YaTeX-insert-begin-end env 'arg))
280 map))
282 ;;;###autoload
283 (defun YaTeX-define-begend-region-key (key env &optional map)
284 "Define short cut YaTeX-make-begin-end-region key."
285 (YaTeX-define-key key (list 'lambda nil '(interactive)
286 (list 'YaTeX-insert-begin-end env t)) map))
288 ;;;###autoload
289 (defun YaTeX-define-begend-key (key env &optional map)
290 "Define short cut key for begin type completion both for normal
291 and region mode. To customize YaTeX, user should use this function."
292 (YaTeX-define-begend-key-normal key env map)
293 (if YaTeX-inhibit-prefix-letter nil
294 (YaTeX-define-begend-region-key
295 (concat (upcase (substring key 0 1)) (substring key 1)) env)))
297 ;;;###autoload
298 (defun YaTeX-search-active-forward (string cmntrx &optional bound err cnt func)
299 "Search STRING which is not commented out by CMNTRX.
300 Optional arguments after BOUND, ERR, CNT are passed literally to search-forward
301 or search-backward.
302 Optional sixth argument FUNC changes search-function."
303 (let ((sfunc (or func 'search-forward)) found md)
304 (while (and (prog1
305 (setq found (funcall sfunc string bound err cnt))
306 (setq md (match-data)))
307 (or
308 (and (eq major-mode 'yatex-mode)
309 (YaTeX-in-verb-p (match-beginning 0)))
310 (save-excursion
311 (goto-char (match-beginning 0))
312 (beginning-of-line)
313 (re-search-forward cmntrx (match-beginning 0) t)))))
314 (store-match-data md)
315 found))
317 (defun YaTeX-re-search-active-forward (regexp cmntrx &optional bound err cnt)
318 "Search REGEXP backward which is not commented out by regexp CMNTRX.
319 See also YaTeX-search-active-forward."
320 (YaTeX-search-active-forward regexp cmntrx bound err cnt 're-search-forward))
322 (defun YaTeX-search-active-backward (string cmntrx &optional bound err cnt)
323 "Search STRING backward which is not commented out by regexp CMNTRX.
324 See also YaTeX-search-active-forward."
325 (YaTeX-search-active-forward string cmntrx bound err cnt 'search-backward))
327 (defun YaTeX-re-search-active-backward (regexp cmntrx &optional bound err cnt)
328 "Search REGEXP backward which is not commented out by regexp CMNTRX.
329 See also YaTeX-search-active-forward."
330 (YaTeX-search-active-forward
331 regexp cmntrx bound err cnt 're-search-backward))
333 ;;;###autoload
334 (defun YaTeX-switch-to-buffer (file &optional setbuf)
335 "Switch to buffer if buffer exists, find file if not.
336 Optional second arg SETBUF t make use set-buffer instead of switch-to-buffer."
337 (interactive "Fswitch to file: ")
338 (if (bufferp file)
339 (setq file (buffer-file-name file))
340 (and (string-match "^[^/].*/" file)
341 (eq major-mode 'yatex-mode)
342 YaTeX-search-file-from-top-directory
343 (save-excursion
344 (YaTeX-visit-main t)
345 (setq file (expand-file-name file)))))
346 (let (buf (hilit-auto-highlight (not setbuf)))
347 (cond
348 ((setq buf (get-file-buffer file))
349 (funcall (if setbuf 'set-buffer 'switch-to-buffer)
350 (get-file-buffer file))
351 buf)
352 ((or YaTeX-create-file-prefix-g (file-exists-p file))
353 (or ;find-file returns nil but set current-buffer...
354 (if setbuf (set-buffer (find-file-noselect file))
355 (find-file file))
356 (current-buffer)))
357 (t (message "%s was not found in this directory." file)
358 nil))))
360 ;;;###autoload
361 (defun YaTeX-switch-to-buffer-other-window (file)
362 "Switch to buffer if buffer exists, find file if not."
363 (interactive "Fswitch to file: ")
364 (and (eq major-mode 'yatex-mode)
365 (stringp file)
366 (string-match "^[^/].*/" file)
367 YaTeX-search-file-from-top-directory
368 (save-excursion
369 (YaTeX-visit-main t)
370 (setq file (expand-file-name file))))
371 (if (bufferp file) (setq file (buffer-file-name file)))
372 (cond
373 ((get-file-buffer file)
374 (switch-to-buffer-other-window (get-file-buffer file))
375 t)
376 ((or YaTeX-create-file-prefix-g (file-exists-p file))
377 (find-file-other-window file) t)
378 (t (message "%s was not found in this directory." file)
379 nil)))
381 (defun YaTeX-get-file-buffer (file)
382 "Return the FILE's buffer.
383 Base directory is that of main file or current directory."
384 (let (dir main (cdir default-directory))
385 (or (and (eq major-mode 'yatex-mode)
386 YaTeX-search-file-from-top-directory
387 (save-excursion
388 (YaTeX-visit-main t)
389 (get-file-buffer file)))
390 (get-file-buffer file))))
392 (defun YaTeX-replace-format-sub (string format repl)
393 (let ((beg (or (string-match (concat "^\\(%" format "\\)") string)
394 (string-match (concat "[^%]\\(%" format "\\)") string)))
395 (len (length format)))
396 (if (null beg) string ;no conversion
397 (concat
398 (substring string 0 (match-beginning 1)) (or repl "")
399 (substring string (match-end 1))))))
401 ;;;###autoload
402 (defun YaTeX-replace-format (string format repl)
403 "In STRING, replace first appearance of FORMAT to REPL as if
404 function `format' does. FORMAT does not contain `%'"
405 (let ((ans string))
406 (while (not (string=
407 ans (setq string (YaTeX-replace-format-sub ans format repl))))
408 (setq ans string))
409 string))
411 ;;;###autoload
412 (defun YaTeX-replace-formats (string replace-list)
413 (let ((list replace-list))
414 (while list
415 (setq string (YaTeX-replace-format
416 string (car (car list)) (cdr (car list)))
417 list (cdr list)))
418 string))
420 ;;;###autoload
421 (defun YaTeX-replace-format-args (string &rest args)
422 "Translate the argument mark #1, #2, ... #n in the STRING into the
423 corresponding real arguments ARGS."
424 (let ((argp 1))
425 (while args
426 (setq string
427 (YaTeX-replace-format string (int-to-string argp) (car args)))
428 (setq args (cdr args) argp (1+ argp))))
429 string)
431 ;;;###autoload
432 (defun rindex (string char)
433 (let ((pos (1- (length string)))(index -1))
434 (while (>= pos 0)
435 (cond
436 ((= (aref string pos) char)
437 (setq index pos) (setq pos -1))
438 (t (setq pos (1- pos))))
439 )
440 index))
442 ;;;###autoload
443 (defun point-beginning-of-line ()
444 (save-excursion (beginning-of-line)(point)))
446 ;;;###autoload
447 (defun point-end-of-line ()
448 (save-excursion (end-of-line)(point)))
451 ;;;###autoload
452 (defun YaTeX-showup-buffer (buffer &optional func select)
453 "Make BUFFER show up in certain window (but current window)
454 that gives the maximum value by the FUNC. FUNC should take an argument
455 of its window object. Non-nil for optional third argument SELECT selects
456 that window. This function never selects minibuffer window."
457 (or (and (if (and YaTeX-emacs-19 select)
458 (get-buffer-window buffer t)
459 (get-buffer-window buffer))
460 (progn
461 (if select
462 (goto-buffer-window buffer))
463 t))
464 (let ((window (selected-window))
465 (wlist (YaTeX-window-list)) win w (x 0))
466 (cond
467 ((> (length wlist) 2)
468 (if func
469 (while wlist
470 (setq w (car wlist))
471 (if (and (not (eq window w))
472 (> (funcall func w) x))
473 (setq win w x (funcall func w)))
474 (setq wlist (cdr wlist)))
475 (setq win (get-lru-window)))
476 (select-window win)
477 (switch-to-buffer buffer)
478 (or select (select-window window)))
479 ((= (length wlist) 2)
480 ;(other-window 1);This does not work properly on Emacs-19
481 (select-window (get-lru-window))
482 (switch-to-buffer buffer)
483 (or select (select-window window)))
484 (t ;if one-window
485 (cond
486 ((and YaTeX-emacs-19 (get-buffer-window buffer t))
487 nil) ;if found in other frame
488 (YaTeX-default-pop-window-height
489 (split-window-calculate-height YaTeX-default-pop-window-height)
490 ;;(pop-to-buffer buffer) ;damn! emacs-19.30
491 (select-window (next-window nil 1))
492 (switch-to-buffer (get-buffer-create buffer))
493 (or select (select-window window)))
494 (t nil)))
495 ))))
497 (cond
498 ((fboundp 'screen-height)
499 (fset 'YaTeX-screen-height 'screen-height)
500 (fset 'YaTeX-screen-width 'screen-width))
501 ((fboundp 'frame-height)
502 (fset 'YaTeX-screen-height 'frame-height)
503 (fset 'YaTeX-screen-width 'frame-width))
504 (t (error "I don't know how to run windows.el on this Emacs...")))
506 ;;;###autoload
507 (defun split-window-calculate-height (height)
508 "Split current window wight specified HEIGHT.
509 If HEIGHT is number, make a new window that has HEIGHT lines.
510 If HEIGHT is string, make a new window that occupies HEIGT % of screen height.
511 Otherwise split window conventionally."
512 (if (one-window-p t)
513 (split-window
514 (selected-window)
515 (max
516 (min
517 (- (YaTeX-screen-height)
518 (if (numberp height)
519 (+ height 2)
520 (/ (* (YaTeX-screen-height)
521 (string-to-int height))
522 100)))
523 (- (YaTeX-screen-height) window-min-height 1))
524 window-min-height))))
526 ;;;###autoload
527 (defun YaTeX-window-list ()
528 (let*((curw (selected-window)) (win curw) (wlist (list curw)))
529 (while (not (eq curw (setq win (next-window win))))
530 (or (eq win (minibuffer-window))
531 (setq wlist (cons win wlist))))
532 wlist))
534 (if YaTeX-emacs-21
535 ;; Emacs-21's next-window returns other frame's window even if called
536 ;; with argument ALL-FRAMES nil, when called from minibuffer context.
537 ;; Therefore, check frame identity here.
538 (defun YaTeX-window-list ()
539 (let*((curw (selected-window)) (win curw) (wlist (list curw))
540 (curf (window-frame curw)))
541 (while (and (not (eq curw (setq win (next-window win))))
542 (eq curf (window-frame win)))
543 (or (eq win (minibuffer-window))
544 (setq wlist (cons win wlist))))
545 wlist)))
547 ;;;###autoload
548 (defun substitute-all-key-definition (olddef newdef keymap)
549 "Replace recursively OLDDEF with NEWDEF for any keys in KEYMAP now
550 defined as OLDDEF. In other words, OLDDEF is replaced with NEWDEF
551 where ever it appears."
552 (if YaTeX-emacs-19
553 (substitute-key-definition olddef newdef keymap global-map)
554 (mapcar
555 (function (lambda (key) (define-key keymap key newdef)))
556 (where-is-internal olddef keymap))))
558 ;;;###autoload
559 (defun YaTeX-match-string (n &optional m)
560 "Return (buffer-substring (match-beginning n) (match-beginning m))."
561 (if (match-beginning n)
562 (buffer-substring (match-beginning n)
563 (match-end (or m n)))))
565 ;;;###autoload
566 (defun YaTeX-minibuffer-complete ()
567 "Complete in minibuffer.
568 If the symbol 'delim is bound and is string, its value is assumed to be
569 the character class of delimiters. Completion will be performed on
570 the last field separated by those delimiters.
571 If the symbol 'quick is bound and is 't, when the try-completion results
572 in t, exit minibuffer immediately."
573 (interactive)
574 (save-restriction
575 (narrow-to-region
576 (if (fboundp 'field-beginning) (field-beginning (point-max)) (point-min))
577 (point-max))
578 (let ((md (match-data)) beg word compl
579 (quick (and (boundp 'quick) (eq quick t)))
580 (displist ;function to display completion-list
581 (function
582 (lambda ()
583 (with-output-to-temp-buffer "*Completions*"
584 (display-completion-list
585 (all-completions word minibuffer-completion-table)))))))
586 (setq beg (if (and (boundp 'delim) (stringp delim))
587 (save-excursion
588 (skip-chars-backward (concat "^" delim))
589 (point))
590 (point-min))
591 word (buffer-substring beg (point-max))
592 compl (try-completion word minibuffer-completion-table))
593 (cond
594 ((eq compl t)
595 (if quick (exit-minibuffer)
596 (let ((p (point)) (max (point-max)))
597 (unwind-protect
598 (progn
599 (goto-char max)
600 (insert " [Sole completion]")
601 (goto-char p)
602 (sit-for 1))
603 (delete-region max (point-max))
604 (goto-char p)))))
605 ((eq compl nil)
606 (ding)
607 (save-excursion
608 (let (p)
609 (unwind-protect
610 (progn
611 (goto-char (setq p (point-max)))
612 (insert " [No match]")
613 (goto-char p)
614 (sit-for 2))
615 (delete-region p (point-max))))))
616 ((string= compl word)
617 (funcall displist))
618 (t (delete-region beg (point-max))
619 (insert compl)
620 (if quick
621 (if (eq (try-completion compl minibuffer-completion-table) t)
622 (exit-minibuffer)
623 (funcall displist)))))
624 (store-match-data md))))
626 (defun YaTeX-minibuffer-quick-complete ()
627 "Set 'quick to 't and call YaTeX-minibuffer-complete.
628 See documentation of YaTeX-minibuffer-complete."
629 (interactive)
630 (let ((quick t))
631 (self-insert-command 1)
632 (YaTeX-minibuffer-complete)))
634 (defun foreach-buffers (pattern job)
635 "For each buffer which matches with PATTERN, do JOB."
636 (let ((list (buffer-list)))
637 (save-excursion
638 (while list
639 (set-buffer (car list))
640 (if (or (and (stringp pattern)
641 (buffer-file-name)
642 (string-match pattern (buffer-file-name)))
643 (and (symbolp pattern) major-mode (eq major-mode pattern)))
644 (eval job))
645 (setq list (cdr list))))))
647 (defun goto-buffer-window (buffer)
648 "Select window which is bound to BUFFER.
649 If no such window exist, switch to buffer BUFFER."
650 (interactive "BGoto buffer: ")
651 (if (stringp buffer)
652 (setq buffer (or (get-file-buffer buffer) (get-buffer buffer))))
653 (if (get-buffer buffer)
654 (cond
655 ((get-buffer-window buffer)
656 (select-window (get-buffer-window buffer)))
657 ((and YaTeX-emacs-19 (get-buffer-window buffer t))
658 (let*((win (get-buffer-window buffer t))
659 (frame (window-frame win)))
660 (select-frame frame)
661 (raise-frame frame)
662 (focus-frame frame)
663 (select-window win)
664 (set-mouse-position frame 0 0)
665 (and (featurep 'windows) (fboundp 'win:adjust-window)
666 (win:adjust-window))))
667 ((and (featurep 'windows) (fboundp 'win:get-buffer-window)
668 (let ((w (win:get-buffer-window buffer)))
669 (and w (win:switch-window w))))
670 (select-window (get-buffer-window buffer)))
671 (t (switch-to-buffer buffer)))))
673 ;; Here starts the functions which support gmhist-vs-Emacs19 compatible
674 ;; reading with history.
675 ;;;###autoload
676 (defun completing-read-with-history
677 (prompt table &optional predicate must-match initial hsym)
678 "Completing read with general history: gmhist, Emacs-19."
679 (let ((minibuffer-history
680 (or (symbol-value hsym)
681 (and (boundp 'minibuffer-history) minibuffer-history)))
682 (minibuffer-history-symbol (or hsym 'minibuffer-history)))
683 (prog1
684 (if (fboundp 'completing-read-with-history-in)
685 (completing-read-with-history-in
686 minibuffer-history-symbol prompt table predicate must-match initial)
687 (completing-read prompt table predicate must-match initial))
688 (if (and YaTeX-emacs-19 hsym) (set hsym minibuffer-history)))))
690 ;;;###autoload
691 (defun read-from-minibuffer-with-history (prompt &optional init map read hsym)
692 "Read from minibuffer with general history: gmhist, Emacs-19."
693 (cond
694 (YaTeX-emacs-19
695 (read-from-minibuffer prompt init map read hsym))
696 (t
697 (let ((minibuffer-history-symbol hsym))
698 (read-from-minibuffer prompt init map read)))))
700 ;;;###autoload
701 (defun read-string-with-history (prompt &optional init hsym)
702 "Read string with history: gmhist(Emacs-18) and Emacs-19."
703 (cond
704 (YaTeX-emacs-19
705 (read-from-minibuffer prompt init minibuffer-local-map nil hsym))
706 ((featurep 'gmhist-mh)
707 (read-with-history-in hsym prompt init))
708 (t (read-string prompt init))))
710 ;;;###autoload
711 (fset 'YaTeX-rassoc
712 (if (and nil (fboundp 'rassoc) (subrp (symbol-function 'rassoc)))
713 (symbol-function 'rassoc)
714 (function
715 (lambda (key list)
716 (let ((l list))
717 (catch 'found
718 (while l
719 (if (equal key (cdr (car l)))
720 (throw 'found (car l)))
721 (setq l (cdr l)))))))))
723 (defun YaTeX-insert-file-contents (file visit &optional beg end)
724 (cond
725 ((and (string< "19" emacs-version) (not (featurep 'xemacs)))
726 (insert-file-contents file visit beg end))
727 ((string-match "unix" (symbol-name system-type))
728 (let ((default-process-coding-system
729 (and (boundp '*noconv*) (list '*noconv*)))
730 (file-coding-system (and (boundp '*noconv*) '*noconv*))
731 kanji-fileio-code
732 (default-process-kanji-code 0))
733 (call-process shell-file-name file (current-buffer) nil
734 (or (and (boundp 'shell-command-option)
735 shell-command-option)
736 "-c")
737 (format "head -c %d | tail -c +%d" end beg))))
738 (t (insert-file-contents file))))
740 (defun YaTeX-split-string (str &optional sep null)
741 "Split string STR by every occurrence of SEP(regexp).
742 If the optional second argument SEP is nil, it defaults to \"[ \f\t\n\r\v]+\".
743 Do not include null string by default. Non-nil for optional third argument
744 NULL includes null string in a list."
745 (let ((sep (or sep "[ \f\t\n\r\v]+"))
746 list m)
747 (while str
748 (if (setq m (string-match sep str))
749 (progn
750 (if (or (> m 0) null)
751 (setq list (cons (substring str 0 m) list)))
752 (setq str (substring str (match-end 0))))
753 (if (or null (string< "" str))
754 (setq list (cons str list)))
755 (setq str nil)))
756 (nreverse list)))
758 ;;;
759 ;; Interface function for windows.el
760 ;;;
761 ;;;###autoload
762 (defun YaTeX-switch-to-window ()
763 "Switch to windows.el's window decided by last pressed key."
764 (interactive)
765 (or (featurep 'windows) (error "Why don't you use `windows.el'?"))
766 (win-switch-to-window 1 (- last-command-char win:base-key)))
768 ;;;###autoload
769 (defun YaTeX-reindent (col)
770 "Remove current indentation and reindento to COL column."
771 (save-excursion
772 (beginning-of-line)
773 (skip-chars-forward " \t")
774 (if (/= col (current-column))
775 (progn
776 (delete-region (point) (progn (beginning-of-line) (point)))
777 (indent-to col))))
778 (skip-chars-forward " \t" (point-end-of-line)))
780 (defun YaTeX-inner-environment (&optional quick)
781 "Return current inner-most environment.
782 Non-nil for optional argument QUICK restricts search bound to most
783 recent sectioning command. Matching point is stored to property 'point
784 of 'YaTeX-inner-environment, which can be referred by
785 (get 'YaTeX-inner-environment 'point)."
786 (let*((nest 0)
787 (beg (YaTeX-replace-format-args
788 (regexp-quote YaTeX-struct-begin)
789 ;YaTeX-struct-begin ;=== TENTATIVE!! ==
790 YaTeX-struct-name-regexp
791 (if (eq major-mode 'yahtml-mode) "\\s *.*" "")
792 ""))
793 (end (YaTeX-replace-format-args
794 (regexp-quote YaTeX-struct-end)
795 YaTeX-struct-name-regexp "" ""))
796 (begend (concat "\\(" beg "\\)\\|\\(" end "\\)"))
797 bound m0
798 (htmlp (eq major-mode 'yahtml-mode))
799 (open
800 (concat "^" (or (cdr (assq major-mode '((yahtml-mode . "<")))) "{")))
801 (close
802 (concat "^"
803 (or (cdr(assq major-mode '((yahtml-mode . "\n\t >")))) "}"))))
804 (save-excursion
805 (if quick
806 (setq bound
807 (save-excursion
808 (if htmlp
809 ;;(re-search-backward YaTeX-sectioning-regexp nil 1)
810 (goto-char (point-min)) ;Is this enough? 97/6/26
811 (YaTeX-re-search-active-backward
812 (concat YaTeX-ec-regexp
813 "\\(" YaTeX-sectioning-regexp "\\)\\*?{")
814 YaTeX-comment-prefix nil 1))
815 (or (bobp) (end-of-line))
816 (point))))
817 (if (catch 'begin
818 (if (and (numberp bound) (< (point) bound)) (throw 'begin nil))
819 (while (YaTeX-re-search-active-backward
820 begend YaTeX-comment-prefix bound t)
821 (setq m0 (match-beginning 0))
822 (if (looking-at end) ;;(match-beginning 2)
823 (setq nest (1+ nest))
824 (setq nest (1- nest)))
825 (if (< nest 0)
826 (progn
827 (put 'YaTeX-inner-environment 'point m0)
828 (goto-char m0)
829 (put 'YaTeX-inner-environment 'indent (current-column))
830 (throw 'begin t)))))
831 (buffer-substring
832 (progn (skip-chars-forward open) (1+ (point)))
833 (progn (skip-chars-forward close) (point)))))))
835 (defun YaTeX-end-environment ()
836 "Close opening environment"
837 (interactive)
838 (let ((env (YaTeX-inner-environment)))
839 (if (not env) (error "No premature environment")
840 (save-excursion
841 (if (YaTeX-search-active-forward
842 (YaTeX-replace-format-args YaTeX-struct-end env "" "")
843 YaTeX-comment-prefix nil t)
844 (if (y-or-n-p
845 (concat "Environment `" env
846 "' may be already closed. Force close?"))
847 nil
848 (error "end environment aborted."))))
849 (message "") ;Erase (y or n) message.
850 (YaTeX-insert-struc 'end env)
851 (save-excursion
852 (goto-char (or (get 'YaTeX-inner-environment 'point) (match-end 0)))
853 (if (pos-visible-in-window-p)
854 (sit-for (if YaTeX-dos 2 1))
855 (message "Matches with %s at line %d"
856 (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
857 (count-lines (point-min) (point))))))))
859 (defun YaTeX-beginning-of-environment (&optional limit-search-bound end)
860 "Goto the beginning of the current environment.
861 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound to
862 most recent sectioning command. Non-nil for optional third argument END
863 goes to end of environment."
864 (interactive)
865 (let ((op (point)))
866 (if (YaTeX-inner-environment limit-search-bound)
867 (progn
868 (goto-char (get 'YaTeX-inner-environment 'point))
869 (and end (YaTeX-goto-corresponding-environment))
870 (if (interactive-p) (push-mark op))
871 t))))
873 (defun YaTeX-end-of-environment (&optional limit-search-bound)
874 "Goto the end of the current environment.
875 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound
876 to most recent sectioning command."
877 (interactive)
878 (YaTeX-beginning-of-environment limit-search-bound t))
880 (defun YaTeX-mark-environment ()
881 "Mark current position and move point to end of environment."
882 (interactive)
883 (let ((curp (point)))
884 (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin
885 (forward-line 1)
886 (beginning-of-line))
887 (if (not (YaTeX-end-of-environment)) ;arg1 turns to match-beginning 1
888 (progn
889 (goto-char curp)
890 (error "Cannot found the end of current environment."))
891 (YaTeX-goto-corresponding-environment)
892 (beginning-of-line) ;for confirmation
893 (if (< curp (point))
894 (progn
895 (message "Mark this environment?(y or n): ")
896 (if (= (read-char) ?y) nil
897 (goto-char curp)
898 (error "Abort. Please call again at more proper position."))))
899 (set-mark-command nil)
900 (YaTeX-goto-corresponding-environment)
901 (end-of-line)
902 (if (eobp) nil (forward-char 1)))))
904 (defun YaTeX-kill-buffer (buffer)
905 "Make effort to show parent buffer after kill."
906 (interactive "bKill buffer: ")
907 (or (get-buffer buffer)
908 (error "No such buffer %s" buffer))
909 (let ((pf YaTeX-parent-file))
910 (kill-buffer buffer)
911 (and pf
912 (get-file-buffer pf)
913 (switch-to-buffer (get-file-buffer pf)))))
915 ;;;VER2
916 (defun YaTeX-insert-struc (what env)
917 (cond
918 ((eq what 'begin)
919 (insert (YaTeX-replace-format-args
920 YaTeX-struct-begin env (YaTeX-addin env))))
921 ((eq what 'end)
922 (insert (YaTeX-replace-format-args YaTeX-struct-end env)))
923 (t nil)))
925 ;;; Function for menu support
926 (defun YaTeX-define-menu (keymap bindlist)
927 "Define KEYMAP(symbol)'s menu-bindings according to BINDLIST.
928 KEYMAP should be a quoted symbol of newly allocated keymap.
929 BINDLIST consists of binding list. Each element is as follows.
931 '(menusymbol DOC_String . contents)
933 CONTENTS is one of lambda-form, interactive function, or other keymap.
934 See yatex19.el for example."
935 (cond
936 ((featurep 'xemacs)
937 (let (name)
938 (if (keymapp (symbol-value keymap))
939 (progn
940 (setq name (keymap-name (symbol-value keymap)))
941 (set keymap nil))
942 (setq name (car (symbol-value keymap)))
943 (set keymap (cdr (symbol-value keymap))))
944 (mapcar
945 (function
946 (lambda (bind)
947 (setq bind (cdr bind))
948 (if (eq (car-safe (cdr bind)) 'lambda)
949 (setcar (cdr bind) 'progn))
950 (if (stringp (car-safe (cdr bind)))
951 (set keymap
952 (cons (cdr bind) (symbol-value keymap)))
953 (set keymap
954 (cons (vector (car bind) (cdr bind) t)
955 (symbol-value keymap))))))
956 bindlist)
957 (set keymap (cons name (symbol-value keymap)))))
958 (t
959 (mapcar
960 (function
961 (lambda (bind)
962 (define-key (symbol-value keymap) (vector (car bind)) (cdr bind))))
963 bindlist))))
965 ;;;
966 ;; Emacs 21 compensational wrapper
967 ;;;
968 (defun YaTeX-minibuffer-begin ()
969 (if (fboundp 'field-beginning)
970 (field-beginning (point-max))
971 (point-min)))
973 (defun YaTeX-minibuffer-end ()
974 (if (fboundp 'field-end)
975 (field-end (point-max))
976 (point-max)))
978 (defun YaTeX-minibuffer-string ()
979 (buffer-substring (YaTeX-minibuffer-begin) (YaTeX-minibuffer-end)))
981 (defun YaTeX-minibuffer-erase ()
982 (if (eq (selected-window) (minibuffer-window))
983 (if (fboundp 'delete-field) (delete-field) (erase-buffer))))
985 ;;;
986 ;; hilit19 vs. font-lock
987 ;;;
988 (defun YaTeX-convert-pattern-hilit2fontlock (h19pa)
989 "Convert hilit19's H19PA patterns alist to font-lock's one.
990 This function is a makeshift for YaTeX and yahtml."
991 (let ((ignorecase (not (null (car h19pa))))
992 (palist (cdr h19pa))
993 flpa i newface
994 (mapping
995 '((bold . YaTeX-font-lock-bold-face)
996 (italic . YaTeX-font-lock-italic-face)
997 (define . font-lock-function-name-face)
998 (keyword . font-lock-keyword-face)
999 (decl . YaTeX-font-lock-declaration-face)
1000 (label . YaTeX-font-lock-label-face)
1001 (crossref . YaTeX-font-lock-crossref-face)
1002 (include . YaTeX-font-lock-include-face)
1003 (formula . YaTeX-font-lock-formula-face)
1004 (string . ignore) (comment . ignore)
1005 )))
1006 (while (setq i (car palist))
1007 (setq newface (nth 2 i)
1008 newface (or (cdr (assq newface mapping)) newface))
1009 (cond
1010 ((eq newface 'ignore) nil) ;no translation
1011 ((stringp (car i)) ;hiliting by regexp
1012 (setq flpa
1013 (cons
1014 (if (numberp (car (cdr i)))
1015 (list (car i) ;regexp
1016 (car (cdr i)) ;matching group number
1017 newface t) ;'keep) ;keep is hilit19 taste
1018 (list
1019 (concat
1020 (car i) ;original regexp and..
1021 ;;"[^"
1022 ;;(regexp-quote (substring (car (cdr i)) 0 1))
1023 ;;"]+" ;for shortest match
1024 ".*"
1025 (car (cdr i)))
1026 0 (list 'quote newface) t)) ;;'keep))
1027 flpa)))
1028 ((and (symbolp (car i)) (fboundp (car i)))
1029 (setq flpa
1030 (cons
1031 (list (car (cdr i)) ;regexp
1032 (list
1033 (list
1034 'lambda (list 'dummy)
1035 '(goto-char (match-beginning 0))
1036 '(remove-text-properties
1037 (point) (1+ (point))
1038 '(face nil font-lock-multiline nil))
1039 (list
1040 'let (list '(e (match-end 0))
1041 (list 'm (list (car i) (car (cdr i)))))
1042 (list
1043 'if 'm
1044 (list
1045 'YaTeX-font-lock-fillin
1046 (list 'car 'm)
1047 (list 'cdr 'm)
1048 (list 'quote 'face)
1049 (list 'quote 'font-lock)
1050 (list 'quote newface))
1051 '(goto-char e)
1052 ))
1053 nil) ;retun nil to cheat font-lock
1054 nil nil)) ;pre-match, post-match both nil
1055 flpa))))
1056 (setq palist (cdr palist)));while
1057 (if (featurep 'xemacsp)
1058 (nreverse flpa)
1059 flpa)))
1061 (cond
1062 ((featurep 'font-lock)
1063 ;; In each defface, '(class static-color) is for Emacs-21 -nw
1064 ;; '(class tty) is for XEmacs-21 -nw
1065 (defface YaTeX-font-lock-label-face
1066 '((((class static-color)) (:foreground "yellow" :underline t))
1067 (((type tty)) (:foreground "yellow" :underline t))
1068 (((class color) (background dark)) (:foreground "pink" :underline t))
1069 (((class color) (background light)) (:foreground "red" :underline t))
1070 (t (:bold t :underline t)))
1071 "Font Lock mode face used to highlight labels."
1072 :group 'font-lock-faces)
1073 (defvar YaTeX-font-lock-label-face 'YaTeX-font-lock-label-face)
1075 (defface YaTeX-font-lock-declaration-face
1076 '((((class color) (background dark)) (:foreground "cyan"))
1077 (((class color) (background light)) (:foreground "RoyalBlue"))
1078 (t (:bold t :underline t)))
1079 "Font Lock mode face used to highlight some declarations."
1080 :group 'font-lock-faces)
1081 (defvar YaTeX-font-lock-declaration-face 'YaTeX-font-lock-declaration-face)
1083 (defface YaTeX-font-lock-include-face
1084 '((((class color) (background dark)) (:foreground "Plum1"))
1085 (((class color) (background light)) (:foreground "purple"))
1086 (t (:bold t :underline t)))
1087 "Font Lock mode face used to highlight expression for including."
1088 :group 'font-lock-faces)
1089 (defvar YaTeX-font-lock-include-face 'YaTeX-font-lock-include-face)
1091 (defface YaTeX-font-lock-formula-face
1092 '((((class static-color)) (:bold t))
1093 (((type tty)) (:bold t))
1094 (((class color) (background dark)) (:foreground "khaki" :bold t))
1095 (((class color) (background light)) (:foreground "Goldenrod"))
1096 (t (:bold t :underline t)))
1097 "Font Lock mode face used to highlight formula."
1098 :group 'font-lock-faces)
1099 (defvar YaTeX-font-lock-formula-face 'YaTeX-font-lock-formula-face)
1101 (defface YaTeX-font-lock-crossref-face
1102 '((((class color) (background dark)) (:foreground "lightgoldenrod"))
1103 (((class color) (background light)) (:foreground "DarkGoldenrod"))
1104 (t (:bold t :underline t)))
1105 "Font Lock mode face used to highlight cress references."
1106 :group 'font-lock-faces)
1107 (defvar YaTeX-font-lock-crossref-face 'YaTeX-font-lock-crossref-face)
1109 (defface YaTeX-font-lock-bold-face
1110 '((t (:bold t)))
1111 "Font Lock mode face used to express bold itself."
1112 :group 'font-lock-faces)
1113 (defvar YaTeX-font-lock-bold-face 'YaTeX-font-lock-bold-face)
1115 (defface YaTeX-font-lock-italic-face
1116 '((t (:italic t)))
1117 "Font Lock mode face used to express italic itself."
1118 :group 'font-lock-faces)
1119 (defvar YaTeX-font-lock-italic-face 'YaTeX-font-lock-italic-face)
1121 ;; Make sure the 'YaTeX-font-lock-{italic,bold}-face is bound with
1122 ;; italic/bold fontsets
1123 (if (and (fboundp 'fontset-list) YaTeX-use-italic-bold)
1124 (let ((flist (fontset-list)) fnt italic bold)
1125 (while flist
1126 (setq fnt (car flist))
1127 (condition-case err
1128 (cond
1129 ((and (string-match "-medium-i-" fnt) (null italic))
1130 (set-face-font 'YaTeX-font-lock-italic-face (setq italic fnt)))
1131 ((and (string-match "-bold-r-" fnt) (null bold))
1132 (set-face-font 'YaTeX-font-lock-bold-face (setq bold fnt))))
1133 (error nil))
1134 (setq flist (cdr flist)))))
1136 ;;Borrowed from XEmacs's font-lock.el
1137 (defsubst YaTeX-font-lock-fillin (start end setprop markprop value &optional object)
1138 "Fill in one property of the text from START to END.
1139 Arguments PROP and VALUE specify the property and value to put where none are
1140 already in place. Therefore existing property values are not overwritten.
1141 Optional argument OBJECT is the string or buffer containing the text."
1142 (let ((start (text-property-any start end markprop nil object)) next
1143 (putfunc (if (fboundp 'put-nonduplicable-text-property)
1144 'put-nonduplicable-text-property
1145 'put-text-property)))
1146 (if (eq putfunc 'put-text-property)
1147 (setq markprop setprop))
1148 (while start
1149 (setq next (next-single-property-change start markprop object end))
1150 (funcall putfunc start next setprop value object)
1151 (funcall putfunc start next markprop value object)
1152 (setq start (text-property-any next end markprop nil object)))))
1154 (defun YaTeX-warning-font-lock (mode)
1155 (let ((sw (selected-window)))
1156 ;;(pop-to-buffer (format " *%s warning*" mode))
1157 ;;(erase-buffer)
1158 (momentary-string-display
1159 (cond
1160 (YaTeX-japan
1161 (concat mode " は、既に font-lock に対応しました。\n"
1162 "~/.emacs などにある\n"
1163 "\t(put 'yatex-mode 'font-lock-keywords 'tex-mode)\n"
1164 "\t(put 'yahtml-mode 'font-lock-keywords 'html-mode)\n"
1165 "などの間に合わせの記述はもはや不要です。"))
1166 (t
1167 (concat mode " now supports the font-lock by itself.\n"
1168 "So you can remove the descriptions such as\n"
1169 "\t(put 'yatex-mode 'font-lock-keywords 'tex-mode)\n"
1170 "\t(put 'yahtml-mode 'font-lock-keywords 'html-mode)\n"
1171 "in your ~/.emacs file. Thank you."))) (point))
1172 (select-window sw)))
1173 ))
1176 ;;;
1177 ;; Functions for the Installation time
1178 ;;;
1180 (defun bcf-and-exit ()
1181 "Byte compile rest of argument and kill-emacs."
1182 (if command-line-args-left
1183 (let ((load-path (cons "." load-path)))
1184 (and (fboundp 'set-language-environment)
1185 (featurep 'mule)
1186 (set-language-environment "Japanese"))
1187 (mapcar 'byte-compile-file command-line-args-left)
1188 (kill-emacs))))
1190 (provide 'yatexlib)
1191 ; Local variables:
1192 ; fill-prefix: ";;; "
1193 ; paragraph-start: "^$\\| \\|;;;$"
1194 ; paragraph-separate: "^$\\| \\|;;;$"
1195 ; buffer-file-coding-system: sjis
1196 ; End: