yatex

view yatexprc.el @ 13:eafae54794a0

Show message at comment-region on begin/end mode. Greek letters completion in yatexmth. YaTeX-mark environment and YaTeX-%-menu added. Erase cursor at the execution of dviout(DOS). Enable recursive completion at section-type completion.
author yuuji
date Sat, 29 Jan 1994 07:59:59 +0000
parents a7f397790cdc
children b7b023a74293
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX process handler.
3 ;;; yatexprc.el
4 ;;; (c )1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
5 ;;; Last modified Sat Jan 29 16:54:54 1994 on gloria
6 ;;; $Id$
8 (require 'yatex)
10 (defvar YaTeX-typeset-process nil
11 "Process identifier for jlatex"
12 )
13 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*"
14 "Process buffer for jlatex")
16 (defvar YaTeX-typeset-buffer-syntax nil
17 "*Syntax table for typesetting buffer")
19 (if YaTeX-typeset-buffer-syntax nil
20 (setq YaTeX-typeset-buffer-syntax
21 (make-syntax-table (standard-syntax-table)))
22 (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax)
23 (modify-syntax-entry ?\} "w" YaTeX-typeset-buffer-syntax)
24 (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax)
25 (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax)
26 )
28 (defun YaTeX-typeset (command buffer)
29 "Execute jlatex (or other) to LaTeX typeset."
30 (interactive)
31 (let ((window (selected-window)))
32 (if (and YaTeX-typeset-process
33 (eq (process-status YaTeX-typeset-process) 'run))
34 ;; if tex command is halting.
35 (YaTeX-kill-typeset-process YaTeX-typeset-process))
36 (YaTeX-visit-main t);;execution directory
37 ;;Select under-most window if there are more than 2 windows and
38 ;;typeset buffer not seen.
39 (YaTeX-showup-buffer
40 buffer (function (lambda (x) (nth 3 (window-edges x)))))
41 (with-output-to-temp-buffer buffer
42 (if YaTeX-dos ;if MS-DOS
43 (progn
44 (message (concat "Typesetting " (buffer-name) "..."))
45 (YaTeX-put-nonstopmode)
46 (call-process shell-file-name
47 nil buffer nil "/c" command)
48 (YaTeX-remove-nonstopmode))
49 (setq YaTeX-typeset-process ;if UNIX
50 (start-process "LaTeX" buffer shell-file-name "-c"
51 command))
52 (set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel)))
53 (setq current-TeX-buffer (buffer-name))
54 (select-window (get-buffer-window buffer))
55 (use-local-map YaTeX-typesetting-mode-map)
56 (set-syntax-table YaTeX-typeset-buffer-syntax)
57 (setq mode-name "typeset")
58 (if YaTeX-typeset-process ; if process is running (maybe on UNIX)
59 (cond ((boundp 'MULE)
60 (set-current-process-coding-system
61 YaTeX-latex-message-code YaTeX-coding-system))
62 ((boundp 'NEMACS)
63 (set-kanji-process-code YaTeX-latex-message-code))))
64 (message "Type SPC to continue.")
65 (goto-char (point-max))
66 (if YaTeX-dos (message "Done.")
67 (insert (message " "))
68 (set-marker (process-mark YaTeX-typeset-process) (1- (point))))
69 (if (bolp) (forward-line -1))
70 (recenter -1)
71 (select-window window))
72 )
74 (defun YaTeX-typeset-sentinel (proc mes)
75 (cond ((null (buffer-name (process-buffer proc)))
76 ;; buffer killed
77 (set-process-buffer proc nil))
78 ((memq (process-status proc) '(signal exit))
79 (let* ((obuf (current-buffer)) (pbuf (process-buffer proc))
80 (owin (selected-window)) win)
81 ;; save-excursion isn't the right thing if
82 ;; process-buffer is current-buffer
83 (unwind-protect
84 (progn
85 ;; Write something in *typesetting* and hack its mode line
86 (YaTeX-pop-to-buffer pbuf)
87 (set-buffer (process-buffer proc))
88 (goto-char (point-max))
89 (recenter -3)
90 (insert ?\n "latex typesetting " mes)
91 (forward-char -1)
92 (insert " at " (substring (current-time-string) 0 -5) "\n")
93 (forward-char 1)
94 (setq mode-line-process
95 (concat ": "
96 (symbol-name (process-status proc))))
97 (message "latex typesetting done.")
98 ;; If buffer and mode line shows that the process
99 ;; is dead, we can delete it now. Otherwise it
100 ;; will stay around until M-x list-processes.
101 (delete-process proc)
102 )
103 (setq YaTeX-typesetting-process nil)
104 ;; Force mode line redisplay soon
105 (set-buffer-modified-p (buffer-modified-p))
106 )
107 (select-window owin)
108 (set-buffer obuf))))
109 )
111 (defvar YaTeX-texput-file "texput.tex"
112 "*File name for temporary file of typeset-region."
113 )
115 (defun YaTeX-typeset-region ()
116 "Paste the region to the file `texput.tex' and execute jlatex (or other)
117 to LaTeX typeset. The region is specified by the rule:
118 (1)If keyword `%#BEGIN' is found in the upper direction from (point).
119 (1-1)if the keyword `%#END' is found after `%#BEGIN',
120 ->Assume the text between `%#BEGIN' and `%#END' as region.
121 (1-2)if the keyword `%#END' is not found anywhere after `%#BEGIN',
122 ->Assume the text after `%#BEGIN' as region.
123 (2)If no `%#BEGIN' usage is found before the (point),
124 ->Assume the text between current (point) and (mark) as region.
125 DON'T forget to eliminate the `%#BEGIN/%#END' notation after editing
126 operation to the region."
127 (interactive)
128 (save-excursion
129 (let*
130 ((end "") typeout ;Type out message that tells the method of cutting.
131 (cmd (concat (YaTeX-get-latex-command nil) " " YaTeX-texput-file))
132 (buffer (current-buffer)) opoint preamble
133 (region
134 (if (re-search-backward
135 "%#BEGIN" nil t)
136 (progn
137 (setq typeout "--- Region from BEGIN to " end "END ---")
138 (buffer-substring
139 (match-end 0)
140 (if (re-search-forward "%#END" nil t)
141 (match-beginning 0)
142 (setq end "end of buffer ---")
143 (point-max))))
144 (setq typeout "=== Region from (point) to (mark) ===")
145 (buffer-substring (point) (mark)))))
146 (YaTeX-visit-main t)
147 (setq opoint (point))
148 (goto-char (point-min))
149 (setq
150 preamble
151 (if (re-search-forward "^[ ]*\\\\begin.*{document}" nil t)
152 (buffer-substring (point-min) (match-end 0))
153 (concat "\\documentstyle{" YaTeX-default-document-style "}\n"
154 "\\begin{document}")))
155 (goto-char opoint)
156 ;;(set-buffer buffer) ;for clarity
157 (find-file YaTeX-texput-file)
158 (erase-buffer)
159 (if YaTeX-need-nonstop
160 (insert "\\nonstopmode{}\n"))
161 (insert preamble "\n")
162 (insert region)
163 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method.
164 (insert "\n\\end{document}\n")
165 (basic-save-buffer)
166 (kill-buffer (current-buffer))
167 (YaTeX-visit-main t)
168 (YaTeX-typeset cmd YaTeX-typeset-buffer)
169 (put 'dvi2-command 'region t)))
170 )
172 (defun YaTeX-typeset-buffer ()
173 "Typeset whole buffer. If %#! usage says other buffer is main text,
174 visit main buffer to confirm if its includeonly list contains current
175 buffer's file. And if it doesn't contain editing text, ask user which
176 action wants to be done, A:Add list, R:Replace list, %:comment-out list."
177 (interactive)
178 (YaTeX-save-buffers)
179 (let*((me (substring (buffer-name) 0 (rindex (buffer-name) ?.)))
180 (mydir (file-name-directory (buffer-file-name)))
181 (cmd (YaTeX-get-latex-command t)))
182 (if (YaTeX-main-file-p) nil
183 (save-excursion
184 (YaTeX-visit-main t) ;search into main buffer
185 (save-excursion
186 (push-mark (point) t)
187 (goto-char (point-min))
188 (if (and (re-search-forward "^[ ]*\\\\begin{document}" nil t)
189 (re-search-backward "^[ ]*\\\\includeonly{" nil t))
190 (let*
191 ((b (progn (skip-chars-forward "^{") (point)))
192 (e (progn (skip-chars-forward "^}") (1+ (point))))
193 (s (buffer-substring b e)) c
194 (pardir (file-name-directory (buffer-file-name))))
195 (if (string-match (concat "[{,/]" me "[,}]") s)
196 nil ; Nothing to do when it's already in includeonly.
197 (ding)
198 (switch-to-buffer (current-buffer));Display this buffer.
199 (setq
200 me ;;Rewrite my name(me) to contain sub directory name.
201 (concat
202 (if (string-match pardir mydir) ;if mydir is child of main
203 (substring mydir (length pardir)) ;cut absolute path
204 mydir) ;else concat absolute path name.
205 me))
206 (message
207 "`%s' is not in \\includeonly. A)dd R)eplace %%)comment? "
208 me)
209 (setq c (read-char))
210 (cond
211 ((= c ?a)
212 (goto-char (1+ b))
213 (insert me (if (string= s "{}") "" ",")))
214 ((= c ?r)
215 (delete-region (1+ b) (1- e)) (insert me))
216 ((= c ?%)
217 (beginning-of-line) (insert "%"))
218 (t nil))
219 (basic-save-buffer))))
220 (exchange-point-and-mark))
221 ))
222 (YaTeX-typeset cmd YaTeX-typeset-buffer)
223 (put 'dvi2-command 'region nil))
224 )
226 (defun YaTeX-call-command-on-file (base-cmd buffer)
227 (YaTeX-save-buffers)
228 (YaTeX-typeset
229 (read-string "Call command: "
230 (concat base-cmd " " (YaTeX-get-preview-file-name)))
231 buffer)
232 )
234 (defun YaTeX-bibtex-buffer (cmd)
235 "Pass the bibliography data of editing file to bibtex."
236 (interactive)
237 (YaTeX-save-buffers)
238 (YaTeX-call-command-on-file cmd "*YaTeX-bibtex*" )
239 )
241 (defun YaTeX-kill-typeset-process (proc)
242 "Kill process PROC after sending signal to PROC.
243 PROC should be process identifier."
244 (cond
245 (YaTeX-dos
246 (error "MS-DOS can't have concurrent process."))
247 ((or (null proc) (not (eq (process-status proc) 'run)))
248 (error "No typesetting process."))
249 (t (interrupt-process proc)
250 (delete-process proc)))
251 )
253 (defun YaTeX-system (command buffer)
254 "Execute some command on buffer. Not a official function."
255 (save-excursion
256 (with-output-to-temp-buffer buffer
257 (if YaTeX-dos
258 (call-process shell-file-name nil buffer nil "/c " command)
259 (start-process "system" buffer shell-file-name "-c" command))))
260 )
262 (defun YaTeX-preview (preview-command preview-file)
263 "Execute xdvi (or other) to tex-preview."
264 (interactive
265 (list (read-string "Preview command: " dvi2-command)
266 (read-string "Preview file[.dvi]: "
267 ;;(substring (buffer-name) 0 -4)
268 (if (get 'dvi2-command 'region)
269 (substring YaTeX-texput-file
270 0 (rindex YaTeX-texput-file ?.))
271 (YaTeX-get-preview-file-name))
272 )))
273 (setq dvi2-command preview-command)
274 (save-excursion
275 (YaTeX-visit-main t)
276 (with-output-to-temp-buffer "*dvi-preview*"
277 (if YaTeX-dos ;if MS-DOS
278 (progn (send-string-to-terminal "\e[2J\e[>5h") ;CLS & hide cursor
279 (call-process shell-file-name "con" "*dvi-preview*" nil
280 "/c " dvi2-command preview-file)
281 (send-string-to-terminal "\e[>5l") ;show cursor
282 (redraw-display))
283 (start-process "preview" "*dvi-preview*" shell-file-name "-c"
284 (concat dvi2-command " " preview-file)) ;if UNIX
285 (message
286 (concat "Starting " dvi2-command " to preview " preview-file)))))
287 )
289 (defun YaTeX-prev-error ()
290 "Visit previous error. The reason why not NEXT-error is to
291 avoid making confliction of line numbers by editing."
292 (interactive)
293 (let ((cur-buf (buffer-name)) (cur-win (selected-window))
294 YaTeX-error-line typeset-win error-buffer error-win)
295 (if (null (get-buffer YaTeX-typeset-buffer))
296 (message "There is no output buffer of typesetting.")
297 (YaTeX-pop-to-buffer YaTeX-typeset-buffer)
298 (setq typeset-win (selected-window))
299 (if YaTeX-dos
300 (if (search-backward latex-dos-emergency-message nil t)
301 (progn (goto-char (point-max))
302 (setq error-regexp latex-error-regexp))
303 (beginning-of-line)
304 (forward-char -1)
305 (setq error-regexp latex-warning-regexp))
306 (if YaTeX-typeset-process ; if jlatex on UNIX
307 (if (eq (process-status YaTeX-typeset-process) 'run)
308 (progn
309 (goto-char (point-max))
310 (setq error-regexp latex-error-regexp))
311 (beginning-of-line)
312 (setq error-regexp latex-warning-regexp))))
313 (if (re-search-backward error-regexp nil t)
314 (setq YaTeX-error-line
315 (string-to-int
316 (buffer-substring
317 (progn (goto-char (match-beginning 0))
318 (skip-chars-forward "^0-9")
319 (point))
320 (progn (skip-chars-forward "0-9") (point)))))
321 (message "No more errors on %s" cur-buf)
322 (ding))
323 (setq error-buffer (YaTeX-get-error-file cur-buf)); arg. is default buf.
324 (setq error-win (get-buffer-window error-buffer))
325 (select-window cur-win)
326 (if (or (null YaTeX-error-line) (equal 0 YaTeX-error-line))
327 nil
328 ;; if warning or error found
329 (if error-win (select-window error-win)
330 (select-window (get-lru-window))
331 (YaTeX-switch-to-buffer error-buffer)
332 (setq error-win (selected-window)))
333 (goto-line YaTeX-error-line)
334 (message "latex error or warning in '%s' at line: %d"
335 error-buffer YaTeX-error-line)
336 (select-window typeset-win)
337 (skip-chars-backward "[0-9]")
338 (recenter (/ (window-height) 2))
339 (sit-for 3)
340 (forward-char -1)
341 (select-window error-win)
342 )))
343 )
345 (defun YaTeX-jump-error-line ()
346 "Jump to corresponding line on latex command's error message."
347 (interactive)
348 (let ((p (point))
349 (end (progn (end-of-line) (point)))
350 (begin (progn (beginning-of-line)(point))))
351 (if (null (re-search-forward "l[ ines]*\\.*[1-9][0-9]*" end t))
352 (if (save-excursion (end-of-line) (eobp))
353 (progn (goto-char p) (insert (this-command-keys)))
354 (message "No line number expression"))
355 (goto-char (match-beginning 0))
356 (re-search-forward "[1-9][0-9]*" end t)
357 (save-restriction
358 (let ((error-line
359 (string-to-int (buffer-substring (match-beginning 0)
360 (match-end 0))))
361 (error-file (YaTeX-get-error-file current-TeX-buffer)))
362 ;;(goto-char (match-beginning 0))
363 (other-window -1)
364 (message "errors in %s" error-file)
365 ;(switch-to-buffer current-TeX-buffer)
366 (if (not (YaTeX-switch-to-buffer error-file))
367 (error "%s is not found in this directory."))
368 (goto-line error-line)))))
369 )
371 (defun YaTeX-send-string ()
372 "Send string to current typeset process."
373 (interactive)
374 (if (and (eq (process-status YaTeX-typeset-process) 'run)
375 (>= (point) (process-mark YaTeX-typeset-process)))
376 (let ((b (process-mark YaTeX-typeset-process))
377 (e (point-end-of-line)))
378 (goto-char b)
379 (skip-chars-forward " \t" e)
380 (setq b (point))
381 (process-send-string
382 YaTeX-typeset-process (concat (buffer-substring b e) "\n"))
383 (goto-char e)
384 (insert "\n")
385 (set-marker (process-mark YaTeX-typeset-process) (point))
386 (insert " "))
387 (ding))
388 )
390 (defun YaTeX-view-error ()
391 (interactive)
392 (if (null (get-buffer YaTeX-typeset-buffer))
393 (message "No typeset buffer found.")
394 (let ((win (selected-window)))
395 (YaTeX-pop-to-buffer YaTeX-typeset-buffer)
396 (goto-char (point-max))
397 (recenter -1)
398 (select-window win)))
399 )
401 (defun YaTeX-get-error-file (default)
402 "Get current processing file from typesetting log."
403 (save-excursion
404 (let(s)
405 (condition-case () (up-list -1)
406 (error
407 (let ((list 0) found)
408 (while
409 (and (<= list 0) (not found)
410 (re-search-backward "\\((\\)\\|\\()\\)" nil t))
411 (if (equal (match-beginning 0) (match-beginning 2)) ;close paren.
412 (setq list (1- list)) ;open paren
413 (setq list (1+ list))
414 (if (= list 1)
415 (if (looking-at "\\([^,{}%]+\.\\)tex\\|sty")
416 (setq found t)
417 (setq list (1- list)))))))))
418 (setq s
419 (buffer-substring
420 (progn (forward-char 1) (point))
421 (progn (skip-chars-forward "-A-Za-z0-9_/\.\\" (point-end-of-line))
422 (point))))
423 (if (string= "" s) default s)))
424 )
426 (defun YaTeX-put-nonstopmode ()
427 (if YaTeX-need-nonstop
428 (if (re-search-backward "\\nonstopmode{}" (point-min) t)
429 nil ;if already written in text then do nothing
430 (save-excursion
431 (YaTeX-visit-main t)
432 (goto-char (point-min))
433 (insert "\\nonstopmode{}%_YaTeX_%\n")))
434 )
435 )
437 (defun YaTeX-remove-nonstopmode ()
438 (if YaTeX-need-nonstop ;for speed
439 (save-excursion
440 (YaTeX-visit-main t)
441 (goto-char (point-min))
442 (forward-line 1)
443 (narrow-to-region (point-min) (point))
444 (goto-char (point-min))
445 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$")
446 (widen)))
447 )
449 (defun YaTeX-get-preview-file-name ()
450 "Get file name to preview by inquiring YaTeX-get-latex-command"
451 (let* ((latex-cmd (YaTeX-get-latex-command t))
452 (rin (rindex latex-cmd ? ))
453 (fname (if (> rin -1) (substring latex-cmd (1+ rin)) ""))
454 (period))
455 (if (string= fname "")
456 (setq fname (substring (buffer-name) 0 -4))
457 (setq period (rindex fname ?.))
458 (setq fname (substring fname 0 (if (eq -1 period) nil period)))
459 ))
460 )
462 (defun YaTeX-get-latex-command (&optional switch)
463 "Specify the latex-command name and its argument.
464 If there is a line which begins by string: \"%#!\", the following
465 strings are assumed to be the latex-command and arguments. The
466 default value of latex-command is:
467 tex-command (buffer-name)
468 and if you write \"%#!jlatex\" in the beginning of certain line.
469 \"jlatex \" (buffer-name)
470 will be the latex-command,
471 and you write \"%#!jlatex main.tex\" on some line and argument SWITCH
472 is t, then
473 \"jlatex main.tex\"
474 will be given to the shell."
475 (let*
476 ((default-command
477 (concat tex-command " "
478 (if switch (buffer-name) ""))));default value
479 (save-excursion
480 (goto-char (point-min))
481 (if (null (re-search-forward "^%#!" (point-max) t))
482 default-command
483 (skip-chars-forward "%#! ")
484 (if (eolp)
485 default-command
486 (let ((s (point)))
487 (skip-chars-forward "^ " (point-end-of-line)) ;Skip command
488 (skip-chars-forward " " (point-end-of-line))
489 ;(setq YaTeX-latex-command (buffer-substring s (point)))
490 (cond
491 ((null switch)
492 (buffer-substring s (point)))
493 ((eolp) ;Only return command name
494 (concat (buffer-substring s (point)) " " (buffer-name)))
495 (t(end-of-line) ;Change entire command name
496 (buffer-substring s (point))) ;including arguments.
497 ))
498 ))))
499 )
501 (defun YaTeX-lpr (arg)
502 "Print out. If prefix arg ARG is non nil, call print driver without
503 page range description."
504 (interactive "P")
505 (let*(from to (cmd (or (YaTeX-get-builtin "LPR") dviprint-command-format)))
506 (setq
507 cmd
508 (YaTeX-replace-format
509 cmd "f"
510 (if (or arg (not (string-match "%f" cmd)))
511 ""
512 (YaTeX-replace-format
513 dviprint-from-format
514 "b"
515 (if (string=
516 (setq from (read-string "From page(default 1): ")) "")
517 "1" from))))
518 )
519 (setq
520 cmd
521 (YaTeX-replace-format
522 cmd "t"
523 (if (or arg (not (string-match "%t" cmd))
524 (string=
525 (setq to (read-string "To page(default none): ")) ""))
526 ""
527 (YaTeX-replace-format dviprint-to-format "e" to)))
528 )
529 (setq cmd (read-string "Edit command line: "
530 (format cmd (YaTeX-get-preview-file-name))))
531 (save-excursion
532 (YaTeX-visit-main t) ;;change execution directory
533 (with-output-to-temp-buffer "*dvi-printing*"
534 (if YaTeX-dos
535 (call-process shell-file-name "con" "*dvi-printing*" nil
536 "/c " cmd)
537 (start-process "print" "*dvi-printing*" shell-file-name "-c" cmd)
538 (message (concat "Starting " cmd " to printing "
539 (YaTeX-get-preview-file-name))))
540 )))
541 )
543 (defun YaTeX-main-file-p ()
544 "Return if current buffer is main LaTeX source."
545 (string-match (concat "^" (YaTeX-get-preview-file-name) ".tex")(buffer-name))
546 )
548 (defun YaTeX-visit-main (&optional setbuf)
549 "Switch to buffer main LaTeX source. Use set-buffer instead of
550 switch-to-buffer if optional second argument SETBUF is t(Use it only
551 in Emacs-Lisp program)."
552 (interactive)
553 (let ((main-file (YaTeX-get-preview-file-name)))
554 (if (string-match (concat "^" main-file ".tex") (buffer-name))
555 (if (interactive-p) (message "I think this is main LaTeX source.") nil)
556 (cond
557 ((YaTeX-switch-to-buffer (setq main-file (concat main-file ".tex"))
558 setbuf))
559 ((and (file-exists-p (setq main-file (concat "../" main-file)))
560 (y-or-n-p (concat (expand-file-name main-file)
561 " is main file?:")))
562 (YaTeX-switch-to-buffer main-file setbuf))
563 (t (find-file (read-file-name "Enter your main text: " nil nil 1)))
564 )))
565 nil
566 )
568 (defun YaTeX-visit-main-other-window ()
569 "Switch to buffer main LaTeX source in other window."
570 (interactive)
571 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.")
572 (YaTeX-switch-to-buffer-other-window
573 (concat (YaTeX-get-preview-file-name) ".tex")))
574 )
576 (defun YaTeX-get-builtin (key)
577 "Read source built-in command of %# usage."
578 (save-excursion
579 (goto-char (point-min))
580 (if (and (search-forward (concat "%#" key) nil t)
581 (not (eolp)))
582 (buffer-substring
583 (progn (skip-chars-forward " " (point-end-of-line))(point))
584 (point-end-of-line))
585 nil))
586 )
588 (defun YaTeX-save-buffers ()
589 "Save buffers which is in yatex-mode."
590 (basic-save-buffer)
591 (save-excursion
592 (mapcar '(lambda (buf)
593 (set-buffer buf)
594 (if (and (buffer-file-name buf)
595 (eq major-mode 'yatex-mode)
596 (buffer-modified-p buf)
597 (y-or-n-p (format "Save %s" (buffer-name buf))))
598 (save-buffer buf)))
599 (buffer-list)))
600 )
602 (defun YaTeX-pop-to-buffer (buffer &optional win)
603 (if (setq win (get-buffer-window buffer))
604 (select-window win)
605 (pop-to-buffer buffer))
606 )
608 (defun YaTeX-showup-buffer (buffer &optional func)
609 "Make BUFFER show up in certain window (but current window)
610 that gives the maximum value by the FUNC. FUNC should take an argument
611 of its window object"
612 (or (get-buffer-window buffer)
613 (< (length (YaTeX-window-list)) 3)
614 (let ((window (selected-window)) (list (YaTeX-window-list)) win w (x 0))
615 (while list
616 (setq w (car list))
617 (if (and (not (eq window w))
618 (> (funcall func w) x))
619 (setq win w x (funcall func w)))
620 (setq list (cdr list)))
621 (select-window win)
622 (switch-to-buffer buffer)
623 (select-window window)))
624 )
626 (defun YaTeX-window-list ()
627 (let*((curw (selected-window)) (win curw) (wlist (list curw)))
628 (while (not (eq curw (setq win (next-window win))))
629 (setq wlist (cons win wlist)))
630 wlist)
631 )
632 (provide 'yatexprc)