comparison yatexprc.el @ 52:5d94deabb9f9

Set YaTeX-indent-line to 'indent-line-function. Revise fill features.
author yuuji
date Sun, 22 Jan 1995 14:20:46 +0000
parents b0371b6ed799
children 5f4b18da14b3
comparison
equal deleted inserted replaced
51:b0371b6ed799 52:5d94deabb9f9
1 ;;; -*- Emacs-Lisp -*- 1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX process handler. 2 ;;; YaTeX process handler.
3 ;;; yatexprc.el 3 ;;; yatexprc.el
4 ;;; (c )1993-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] 4 ;;; (c )1993-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
5 ;;; Last modified Wed Dec 14 16:58:15 1994 on 98fa 5 ;;; Last modified Sun Jan 22 23:14:44 1995 on landcruiser
6 ;;; $Id$ 6 ;;; $Id$
7 7
8 (require 'yatex) 8 (require 'yatex)
9 9
10 (defvar YaTeX-typeset-process nil 10 (defvar YaTeX-typeset-process nil
140 (defvar YaTeX-texput-file "texput.tex" 140 (defvar YaTeX-texput-file "texput.tex"
141 "*File name for temporary file of typeset-region." 141 "*File name for temporary file of typeset-region."
142 ) 142 )
143 143
144 (defun YaTeX-typeset-region () 144 (defun YaTeX-typeset-region ()
145 "Paste the region to the file `texput.tex' and execute jlatex (or other) 145 "Paste the region to the file `texput.tex' and execute typesetter.
146 to LaTeX typeset. The region is specified by the rule: 146 The region is specified by the rule:
147 (1)If keyword `%#BEGIN' is found in the upper direction from (point). 147 (1)If keyword `%#BEGIN' is found in the upper direction from (point).
148 (1-1)if the keyword `%#END' is found after `%#BEGIN', 148 (1-1)if the keyword `%#END' is found after `%#BEGIN',
149 ->Assume the text between `%#BEGIN' and `%#END' as region. 149 ->Assume the text between `%#BEGIN' and `%#END' as region.
150 (1-2)if the keyword `%#END' is not found anywhere after `%#BEGIN', 150 (1-2)if the keyword `%#END' is not found anywhere after `%#BEGIN',
151 ->Assume the text after `%#BEGIN' as region. 151 ->Assume the text after `%#BEGIN' as region.
159 ((end "") typeout ;Type out message that tells the method of cutting. 159 ((end "") typeout ;Type out message that tells the method of cutting.
160 (texput YaTeX-texput-file) 160 (texput YaTeX-texput-file)
161 (cmd (concat (YaTeX-get-latex-command nil) " " texput)) 161 (cmd (concat (YaTeX-get-latex-command nil) " " texput))
162 (buffer (current-buffer)) opoint preamble (subpreamble "") main 162 (buffer (current-buffer)) opoint preamble (subpreamble "") main
163 (hilit-auto-highlight nil) ;for Emacs19 with hilit19 163 (hilit-auto-highlight nil) ;for Emacs19 with hilit19
164 reg-begin reg-end) 164 reg-begin reg-end lineinfo)
165 165
166 (save-excursion 166 (save-excursion
167 (if (search-backward "%#BEGIN" nil t) 167 (if (search-backward "%#BEGIN" nil t)
168 (progn 168 (progn
169 (setq typeout "--- Region from BEGIN to " 169 (setq typeout "--- Region from BEGIN to "
171 reg-begin (match-end 0)) 171 reg-begin (match-end 0))
172 (if (search-forward "%#END" nil t) 172 (if (search-forward "%#END" nil t)
173 (setq reg-end (match-beginning 0) 173 (setq reg-end (match-beginning 0)
174 end "END ---") 174 end "END ---")
175 (setq reg-end (point-max)))) 175 (setq reg-end (point-max))))
176 (setq typeout "=== Region from (point) to (mark) ===") 176 (setq typeout "=== Region from (point) to (mark) ==="
177 (setq reg-begin (point) reg-end (mark))) 177 reg-begin (point) reg-end (mark)))
178 (goto-char (min reg-begin reg-end))
179 (setq lineinfo (count-lines (point-min) (point-end-of-line)))
178 (goto-char (point-min)) 180 (goto-char (point-min))
179 (while (search-forward "%#REQUIRE" nil t) 181 (while (search-forward "%#REQUIRE" nil t)
180 (setq subpreamble 182 (setq subpreamble
181 (concat subpreamble 183 (concat subpreamble
182 (cond 184 (cond
199 (buffer-substring (point-min) (match-end 0)) 201 (buffer-substring (point-min) (match-end 0))
200 (concat "\\documentstyle{" YaTeX-default-document-style "}\n" 202 (concat "\\documentstyle{" YaTeX-default-document-style "}\n"
201 "\\begin{document}"))) 203 "\\begin{document}")))
202 (goto-char opoint) 204 (goto-char opoint)
203 ;;(set-buffer buffer) ;for clarity 205 ;;(set-buffer buffer) ;for clarity
204 (set-buffer (find-file-noselect texput)) 206 (let ((hilit-auto-highlight nil))
207 (set-buffer (find-file-noselect texput)))
205 ;;(find-file YaTeX-texput-file) 208 ;;(find-file YaTeX-texput-file)
206 (erase-buffer) 209 (erase-buffer)
207 (if YaTeX-need-nonstop 210 (if YaTeX-need-nonstop
208 (insert "\\nonstopmode{}\n")) 211 (insert "\\nonstopmode{}\n"))
209 (insert preamble "\n" subpreamble "\n") 212 (insert preamble "\n" subpreamble "\n")
213 (setq lineinfo (list (count-lines 1 (point-end-of-line)) lineinfo))
210 (insert-buffer-substring buffer reg-begin reg-end) 214 (insert-buffer-substring buffer reg-begin reg-end)
211 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method. 215 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method.
212 (insert "\n\\end{document}\n") 216 (insert "\n\\end{document}\n")
213 (basic-save-buffer) 217 (basic-save-buffer)
214 (kill-buffer (current-buffer)) 218 (kill-buffer (current-buffer))
215 (set-buffer main) ;return to parent file or itself. 219 (set-buffer main) ;return to parent file or itself.
216 (YaTeX-typeset cmd YaTeX-typeset-buffer) 220 (YaTeX-typeset cmd YaTeX-typeset-buffer)
217 (switch-to-buffer buffer) ;for Emacs-19 221 (switch-to-buffer buffer) ;for Emacs-19
218 (put 'dvi2-command 'region t))) 222 (put 'dvi2-command 'region t)
223 (put 'dvi2-command 'file buffer)
224 (put 'dvi2-command 'offset lineinfo)
225 ))
219 ) 226 )
220 227
221 (defun YaTeX-typeset-buffer () 228 (defun YaTeX-typeset-buffer ()
222 "Typeset whole buffer. If %#! usage says other buffer is main text, 229 "Typeset whole buffer. If %#! usage says other buffer is main text,
223 visit main buffer to confirm if its includeonly list contains current 230 visit main buffer to confirm if its includeonly list contains current
377 (message 384 (message
378 (concat "Starting " preview-command 385 (concat "Starting " preview-command
379 " to preview " preview-file)))))) 386 " to preview " preview-file))))))
380 ) 387 )
381 388
389 (defun YaTeX-set-virtual-error-position (file-sym line-sym)
390 "Replace the value of FILE-SYM, LINE-SYM by virtual error position."
391 (cond
392 ((and (get 'dvi2-command 'region)
393 (> (symbol-value line-sym) (car (get 'dvi2-command 'offset))))
394 (set file-sym (get 'dvi2-command 'file))
395 (set line-sym
396 (+ (- (apply '- (get 'dvi2-command 'offset)))
397 (symbol-value line-sym)
398 -1)))))
399
382 (defun YaTeX-prev-error () 400 (defun YaTeX-prev-error ()
383 "Visit previous typeset error. 401 "Visit previous typeset error.
384 To avoid making confliction of line numbers by editing, jump to 402 To avoid making confliction of line numbers by editing, jump to
385 error or warning lines in reverse order." 403 error or warning lines in reverse order."
386 (interactive) 404 (interactive)
402 (setq error-line 420 (setq error-line
403 (string-to-int 421 (string-to-int
404 (buffer-substring 422 (buffer-substring
405 (point) 423 (point)
406 (progn (skip-chars-forward "0-9" (match-end 0)) (point)))) 424 (progn (skip-chars-forward "0-9" (match-end 0)) (point))))
407 error-buffer (YaTeX-get-error-file cur-buf) 425 error-buffer (YaTeX-get-error-file cur-buf))
408 error-win (get-buffer-window error-buffer))
409 (if (or (null error-line) (equal 0 error-line)) 426 (if (or (null error-line) (equal 0 error-line))
410 (error "Can't detect error position.")) 427 (error "Can't detect error position."))
428 (YaTeX-set-virtual-error-position 'error-buffer 'error-line)
429 (setq error-win (get-buffer-window error-buffer))
411 (select-window cur-win) 430 (select-window cur-win)
412 (cond 431 (cond
413 (error-win (select-window error-win)) 432 (error-win (select-window error-win))
414 ((eq (get-lru-window) typeset-win) 433 ((eq (get-lru-window) typeset-win)
415 (YaTeX-switch-to-buffer error-buffer)) 434 (YaTeX-switch-to-buffer error-buffer))
440 (if (eobp) (insert (this-command-keys)) 459 (if (eobp) (insert (this-command-keys))
441 (error "No line number expression.")) 460 (error "No line number expression."))
442 (goto-char (match-beginning 0)) 461 (goto-char (match-beginning 0))
443 (setq error-line (string-to-int 462 (setq error-line (string-to-int
444 (buffer-substring (match-beginning 1) (match-end 1))) 463 (buffer-substring (match-beginning 1) (match-end 1)))
445 error-file (YaTeX-get-error-file YaTeX-current-TeX-buffer) 464 error-file (YaTeX-get-error-file YaTeX-current-TeX-buffer))
446 error-buf (YaTeX-switch-to-buffer error-file t)) 465 (YaTeX-set-virtual-error-position 'error-file 'error-line)
466 (setq error-buf (YaTeX-switch-to-buffer error-file t)))
447 (if (null error-buf) 467 (if (null error-buf)
448 (error "`%s' is not found in this directory." error-file)) 468 (error "`%s' is not found in this directory." error-file))
449 (YaTeX-showup-buffer error-buf nil t) 469 (YaTeX-showup-buffer error-buf nil t)
450 (goto-line error-line))) 470 (goto-line error-line))
451 ) 471 )
452 472
453 (defun YaTeX-send-string () 473 (defun YaTeX-send-string ()
454 "Send string to current typeset process." 474 "Send string to current typeset process."
455 (interactive) 475 (interactive)
583 (defun YaTeX-lpr (arg) 603 (defun YaTeX-lpr (arg)
584 "Print out. If prefix arg ARG is non nil, call print driver without 604 "Print out. If prefix arg ARG is non nil, call print driver without
585 page range description." 605 page range description."
586 (interactive "P") 606 (interactive "P")
587 (let*((cmd (or (YaTeX-get-builtin "LPR") dviprint-command-format)) 607 (let*((cmd (or (YaTeX-get-builtin "LPR") dviprint-command-format))
588 from to (lbuffer "*dvi-printing*")) 608 from to (lbuffer "*dvi-printing*") dir)
589 (setq 609 (setq
590 cmd 610 cmd
591 (YaTeX-replace-format 611 (YaTeX-replace-format
592 cmd "f" 612 cmd "f"
593 (if (or arg (not (string-match "%f" cmd))) 613 (if (or arg (not (string-match "%f" cmd)))
614 "Edit command line: " 634 "Edit command line: "
615 (format cmd (YaTeX-get-preview-file-name)) 635 (format cmd (YaTeX-get-preview-file-name))
616 'YaTeX-lpr-command-history)) 636 'YaTeX-lpr-command-history))
617 (save-excursion 637 (save-excursion
618 (YaTeX-visit-main t) ;;change execution directory 638 (YaTeX-visit-main t) ;;change execution directory
639 (setq dir default-directory)
619 (YaTeX-showup-buffer 640 (YaTeX-showup-buffer
620 lbuffer (function (lambda (x) (nth 3 (window-edges x))))) 641 lbuffer (function (lambda (x) (nth 3 (window-edges x)))))
621 (set-buffer (get-buffer-create lbuffer)) 642 (set-buffer (get-buffer-create lbuffer))
622 (erase-buffer) 643 (erase-buffer)
644 (cd dir) ;for 19
623 (cond 645 (cond
624 (YaTeX-dos 646 (YaTeX-dos
625 (call-process shell-file-name "con" "*dvi-printing*" nil 647 (call-process shell-file-name "con" "*dvi-printing*" nil
626 YaTeX-shell-command-option cmd)) 648 YaTeX-shell-command-option cmd))
627 (t 649 (t
634 ) 656 )
635 657
636 (defun YaTeX-main-file-p () 658 (defun YaTeX-main-file-p ()
637 "Return if current buffer is main LaTeX source." 659 "Return if current buffer is main LaTeX source."
638 (cond 660 (cond
661 (YaTeX-parent-file
662 (eq (get-file-buffer YaTeX-parent-file) (current-buffer)))
639 ((YaTeX-get-builtin "!") 663 ((YaTeX-get-builtin "!")
640 (string-match (YaTeX-guess-parent (YaTeX-get-builtin "!")) (buffer-name))) 664 (string-match (YaTeX-guess-parent (YaTeX-get-builtin "!")) (buffer-name)))
641 (t 665 (t
642 (save-excursion 666 (save-excursion
643 (let ((latex-main-id (concat "^\\s *" YaTeX-ec-regexp "documentstyle"))) 667 (let ((latex-main-id (concat "^\\s *" YaTeX-ec-regexp "documentstyle")))

yatex.org