comparison yatexprc.el @ 64:36a48185b95a

Changes are listed in yatex.new. Major one is supporing GNU Emacs20 and XEmacs.
author yuuji
date Tue, 16 Dec 1997 13:28:38 +0000
parents b9f753846b6b
children 0eb6997bee16
comparison
equal deleted inserted replaced
63:6ad4a2399731 64:36a48185b95a
1 ;;; -*- Emacs-Lisp -*- 1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX process handler. 2 ;;; YaTeX process handler.
3 ;;; yatexprc.el 3 ;;; yatexprc.el
4 ;;; (c )1993-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] 4 ;;; (c )1993-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
5 ;;; Last modified Mon Jan 27 10:22:06 1997 on crx 5 ;;; Last modified Thu Dec 11 16:16:21 1997 on crx
6 ;;; $Id$ 6 ;;; $Id$
7 7
8 (require 'yatex) 8 ;(require 'yatex)
9 (require 'yatexlib)
9 10
10 (defvar YaTeX-typeset-process nil 11 (defvar YaTeX-typeset-process nil
11 "Process identifier for jlatex" 12 "Process identifier for jlatex"
12 ) 13 )
13 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*" 14 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*"
21 22
22 (defvar YaTeX-shell-command-option 23 (defvar YaTeX-shell-command-option
23 (or (and (boundp 'shell-command-option) shell-command-option) 24 (or (and (boundp 'shell-command-option) shell-command-option)
24 (if YaTeX-dos "/c" "-c")) 25 (if YaTeX-dos "/c" "-c"))
25 "Shell option for command execution.") 26 "Shell option for command execution.")
27
28 (defvar YaTeX-latex-message-code
29 (cond
30 (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist)))
31 ((and YaTeX-emacs-20 (member 'undecided (coding-system-list))
32 'undecided))
33 ((featurep 'mule)
34 (or (and (boundp '*autoconv*) *autoconv*)
35 (and (fboundp 'coding-system-list) 'automatic-conversion)))
36 ((boundp 'NEMACS)
37 (cdr (assq (if YaTeX-dos 1 2) YaTeX-kanji-code-alist))))
38 "Process coding system for LaTeX.")
26 39
27 (if YaTeX-typeset-buffer-syntax nil 40 (if YaTeX-typeset-buffer-syntax nil
28 (setq YaTeX-typeset-buffer-syntax 41 (setq YaTeX-typeset-buffer-syntax
29 (make-syntax-table (standard-syntax-table))) 42 (make-syntax-table (standard-syntax-table)))
30 (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax) 43 (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax)
36 (defun YaTeX-typeset (command buffer &optional prcname modename) 49 (defun YaTeX-typeset (command buffer &optional prcname modename)
37 "Execute jlatex (or other) to LaTeX typeset." 50 "Execute jlatex (or other) to LaTeX typeset."
38 (interactive) 51 (interactive)
39 (save-excursion 52 (save-excursion
40 (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer)) 53 (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer))
41 (map YaTeX-typesetting-mode-map)) 54 (map YaTeX-typesetting-mode-map)
55 (outcode
56 (cond ((eq major-mode 'yatex-mode) YaTeX-coding-system)
57 ((eq major-mode 'yahtml-mode) yahtml-coding-system))))
42 (if (and YaTeX-typeset-process 58 (if (and YaTeX-typeset-process
43 (eq (process-status YaTeX-typeset-process) 'run)) 59 (eq (process-status YaTeX-typeset-process) 'run))
44 ;; if tex command is halting. 60 ;; if tex command is halting.
45 (YaTeX-kill-typeset-process YaTeX-typeset-process)) 61 (YaTeX-kill-typeset-process YaTeX-typeset-process))
46 (YaTeX-put-nonstopmode) 62 (YaTeX-put-nonstopmode)
55 (set-buffer (get-buffer-create buffer)) 71 (set-buffer (get-buffer-create buffer))
56 (setq default-directory execdir) 72 (setq default-directory execdir)
57 (cd execdir) 73 (cd execdir)
58 (erase-buffer) 74 (erase-buffer)
59 (cond 75 (cond
60 (YaTeX-dos ;if MS-DOS 76 ((not (fboundp 'start-process)) ;YaTeX-dos;if MS-DOS
61 ;(YaTeX-put-nonstopmode)
62 (call-process 77 (call-process
63 shell-file-name nil buffer nil YaTeX-shell-command-option command) 78 shell-file-name nil buffer nil YaTeX-shell-command-option command))
64 ;(YaTeX-remove-nonstopmode)
65 )
66 (t ;if UNIX 79 (t ;if UNIX
67 (set-process-buffer 80 (set-process-buffer
68 (setq YaTeX-typeset-process 81 (setq YaTeX-typeset-process
69 (start-process prcname buffer shell-file-name 82 (start-process prcname buffer shell-file-name
70 YaTeX-shell-command-option command)) 83 YaTeX-shell-command-option command))
74 (setq YaTeX-current-TeX-buffer (buffer-name)) 87 (setq YaTeX-current-TeX-buffer (buffer-name))
75 (use-local-map map) ;map may be localized 88 (use-local-map map) ;map may be localized
76 (set-syntax-table YaTeX-typeset-buffer-syntax) 89 (set-syntax-table YaTeX-typeset-buffer-syntax)
77 (setq mode-name modename) 90 (setq mode-name modename)
78 (if YaTeX-typeset-process ;if process is running (maybe on UNIX) 91 (if YaTeX-typeset-process ;if process is running (maybe on UNIX)
79 (cond ((boundp 'MULE) 92 (cond ((fboundp 'set-current-process-coding-system)
80 (set-current-process-coding-system 93 (set-current-process-coding-system
81 YaTeX-latex-message-code YaTeX-coding-system)) 94 YaTeX-latex-message-code outcode))
95 ((fboundp 'set-process-coding-system)
96 (set-process-coding-system
97 YaTeX-typeset-process YaTeX-latex-message-code outcode))
98 (YaTeX-emacs-20
99 (set-buffer-process-coding-system
100 YaTeX-latex-message-code outcode))
82 ((boundp 'NEMACS) 101 ((boundp 'NEMACS)
83 (set-kanji-process-code YaTeX-latex-message-code)))) 102 (set-kanji-process-code YaTeX-latex-message-code))))
84 (if YaTeX-dos (message "Done.") 103 (if YaTeX-dos (message "Done.")
85 (insert " ") 104 (insert " ")
86 (set-marker (process-mark YaTeX-typeset-process) (1- (point)))) 105 (set-marker (process-mark YaTeX-typeset-process) (1- (point))))
211 ;;(set-buffer buffer) ;for clarity 230 ;;(set-buffer buffer) ;for clarity
212 (let ((hilit-auto-highlight nil)) 231 (let ((hilit-auto-highlight nil))
213 (set-buffer (find-file-noselect texput))) 232 (set-buffer (find-file-noselect texput)))
214 ;;(find-file YaTeX-texput-file) 233 ;;(find-file YaTeX-texput-file)
215 (erase-buffer) 234 (erase-buffer)
216 (if YaTeX-need-nonstop 235 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop)
217 (insert "\\nonstopmode{}\n")) 236 (insert "\\nonstopmode{}\n"))
218 (insert preamble "\n" subpreamble "\n") 237 (insert preamble "\n" subpreamble "\n")
219 (setq lineinfo (list (count-lines 1 (point-end-of-line)) lineinfo)) 238 (setq lineinfo (list (count-lines 1 (point-end-of-line)) lineinfo))
220 (insert-buffer-substring buffer reg-begin reg-end) 239 (insert-buffer-substring buffer reg-begin reg-end)
221 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method. 240 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method.
338 (let ((df default-directory)) ;preserve current buf's pwd 357 (let ((df default-directory)) ;preserve current buf's pwd
339 (set-buffer (get-buffer-create buffer)) ;1.61.3 358 (set-buffer (get-buffer-create buffer)) ;1.61.3
340 (setq default-directory df) 359 (setq default-directory df)
341 (cd df)) 360 (cd df))
342 (erase-buffer) 361 (erase-buffer)
343 (if YaTeX-dos 362 (if (not (fboundp 'start-process))
344 (call-process 363 (call-process
345 shell-file-name nil buffer nil YaTeX-shell-command-option command) 364 shell-file-name nil buffer nil YaTeX-shell-command-option command)
346 (if (and (get-buffer-process buffer) 365 (if (and (get-buffer-process buffer)
347 (eq (process-status (get-buffer-process buffer)) 'run) 366 (eq (process-status (get-buffer-process buffer)) 'run)
348 (not 367 (not
384 (set-buffer (get-buffer-create pbuffer)) 403 (set-buffer (get-buffer-create pbuffer))
385 (erase-buffer) 404 (erase-buffer)
386 (setq default-directory dir) ;for 18 405 (setq default-directory dir) ;for 18
387 (cd dir) ;for 19 406 (cd dir) ;for 19
388 (cond 407 (cond
389 (YaTeX-dos ;if MS-DOS 408 ((not (fboundp 'start-process)) ;if MS-DOS
390 (send-string-to-terminal "\e[2J\e[>5h") ;CLS & hide cursor 409 (send-string-to-terminal "\e[2J\e[>5h") ;CLS & hide cursor
391 (call-process shell-file-name "con" "*dvi-preview*" nil 410 (call-process shell-file-name "con" "*dvi-preview*" nil
392 YaTeX-shell-command-option 411 YaTeX-shell-command-option
393 (concat preview-command " " preview-file)) 412 (concat preview-command " " preview-file))
394 (send-string-to-terminal "\e[>5l") ;show cursor 413 (send-string-to-terminal "\e[>5l") ;show cursor
571 (point)))) 590 (point))))
572 (if (string= "" s) default s))) 591 (if (string= "" s) default s)))
573 ) 592 )
574 593
575 (defun YaTeX-put-nonstopmode () 594 (defun YaTeX-put-nonstopmode ()
576 (if (and YaTeX-need-nonstop (eq major-mode 'yatex-mode)) 595 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop)
577 (if (re-search-backward "\\\\nonstopmode{}" (point-min) t) 596 (if (re-search-backward "\\\\nonstopmode{}" (point-min) t)
578 nil ;if already written in text then do nothing 597 nil ;if already written in text then do nothing
579 (save-excursion 598 (save-excursion
580 (YaTeX-visit-main t) 599 (YaTeX-visit-main t)
581 (goto-char (point-min)) 600 (goto-char (point-min))
583 (if (buffer-file-name) (basic-save-buffer)))) 602 (if (buffer-file-name) (basic-save-buffer))))
584 ) 603 )
585 ) 604 )
586 605
587 (defun YaTeX-remove-nonstopmode () 606 (defun YaTeX-remove-nonstopmode ()
588 (if (and YaTeX-need-nonstop (eq major-mode 'yatex-mode)) ;for speed 607 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) ;for speed
589 (save-excursion 608 (save-excursion
590 (YaTeX-visit-main t) 609 (YaTeX-visit-main t)
591 (goto-char (point-min)) 610 (goto-char (point-min))
592 (forward-line 1) 611 (forward-line 1)
593 (narrow-to-region (point-min) (point)) 612 (narrow-to-region (point-min) (point))
690 lbuffer (function (lambda (x) (nth 3 (window-edges x))))) 709 lbuffer (function (lambda (x) (nth 3 (window-edges x)))))
691 (set-buffer (get-buffer-create lbuffer)) 710 (set-buffer (get-buffer-create lbuffer))
692 (erase-buffer) 711 (erase-buffer)
693 (cd dir) ;for 19 712 (cd dir) ;for 19
694 (cond 713 (cond
695 (YaTeX-dos 714 ((not (fboundp 'start-process))
696 (call-process shell-file-name "con" "*dvi-printing*" nil 715 (call-process shell-file-name "con" "*dvi-printing*" nil
697 YaTeX-shell-command-option cmd)) 716 YaTeX-shell-command-option cmd))
698 (t 717 (t
699 (set-process-buffer 718 (set-process-buffer
700 (start-process "print" "*dvi-printing*" shell-file-name 719 (start-process "print" "*dvi-printing*" shell-file-name

yatex.org