yatex

changeset 212:c63a4ec6a492 dev

Rerun typesetter when cross-reference warning seen.
author yuuji@gentei.org
date Thu, 12 Jan 2012 20:26:32 +0900
parents a024651a966f
children 6a2594372108
files yatex.el yatexprc.el
diffstat 2 files changed, 42 insertions(+), 13 deletions(-) [+]
line diff
     1.1 --- a/yatex.el	Thu Jan 12 12:30:24 2012 +0900
     1.2 +++ b/yatex.el	Thu Jan 12 20:26:32 2012 +0900
     1.3 @@ -1,15 +1,15 @@
     1.4  ;;; -*- Emacs-Lisp -*-
     1.5  ;;; Yet Another tex-mode for emacs - //–ì’¹//
     1.6 -;;; yatex.el rev. 1.75
     1.7 +;;; yatex.el rev. 1.75.1
     1.8  ;;; (c)1991-2012 by HIROSE Yuuji.[yuuji@yatex.org]
     1.9 -;;; Last modified Thu Jan 12 11:40:38 2012 on firestorm
    1.10 +;;; Last modified Thu Jan 12 20:25:32 2012 on firestorm
    1.11  ;;; $Id$
    1.12  ;;; The latest version of this software is always available at;
    1.13  ;;; http://www.yatex.org/
    1.14  
    1.15  (require 'comment)
    1.16  (require 'yatexlib)
    1.17 -(defconst YaTeX-revision-number "1.75"
    1.18 +(defconst YaTeX-revision-number "1.75.1"
    1.19    "Revision number of running yatex.el")
    1.20  
    1.21  ;---------- Local variables ----------
     2.1 --- a/yatexprc.el	Thu Jan 12 12:30:24 2012 +0900
     2.2 +++ b/yatexprc.el	Thu Jan 12 20:26:32 2012 +0900
     2.3 @@ -2,7 +2,7 @@
     2.4  ;;; YaTeX process handler.
     2.5  ;;; yatexprc.el
     2.6  ;;; (c)1993-2012 by HIROSE Yuuji.[yuuji@yatex.org]
     2.7 -;;; Last modified Mon Jan  9 20:20:24 2012 on firestorm
     2.8 +;;; Last modified Thu Jan 12 17:52:15 2012 on firestorm
     2.9  ;;; $Id$
    2.10  
    2.11  ;(require 'yatex)
    2.12 @@ -55,7 +55,8 @@
    2.13    (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax)
    2.14    (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax))
    2.15  
    2.16 -(defun YaTeX-typeset (command buffer &optional prcname modename ppcmd)
    2.17 +(defvar YaTeX-typeset-marker nil)
    2.18 +(defun YaTeX-typeset (command buffer &optional prcname modename ppcmd rerun)
    2.19    "Execute jlatex (or other) to LaTeX typeset."
    2.20    (interactive)
    2.21    (save-excursion
    2.22 @@ -80,7 +81,7 @@
    2.23        (set-buffer (get-buffer-create buffer))
    2.24        (setq default-directory execdir)
    2.25        (cd execdir)
    2.26 -      (erase-buffer)
    2.27 +      (or rerun (erase-buffer))
    2.28        (cond
    2.29         ((not (fboundp 'start-process)) ;YaTeX-dos;if MS-DOS
    2.30  	(call-process
    2.31 @@ -92,6 +93,8 @@
    2.32  			      YaTeX-shell-command-option command))
    2.33  	 (get-buffer buffer))
    2.34  	(set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel)
    2.35 +	(put 'YaTeX-typeset-process 'thiscmd command)
    2.36 +	(put 'YaTeX-typeset-process 'name prcname)
    2.37  	(let ((ppprop (get 'YaTeX-typeset-process 'ppcmd)))
    2.38  	  (setq ppprop (delq (assq YaTeX-typeset-process ppprop) ppprop))
    2.39  	  (if ppcmd
    2.40 @@ -114,6 +117,10 @@
    2.41  		  YaTeX-latex-message-code outcode))
    2.42  		((boundp 'NEMACS)
    2.43  		 (set-kanji-process-code YaTeX-latex-message-code))))
    2.44 +      (set-marker (or YaTeX-typeset-marker
    2.45 +		      (setq YaTeX-typeset-marker (make-marker)))
    2.46 +		  (point))
    2.47 +      (insert (format "Call `%s'\n" command))
    2.48        (if YaTeX-dos (message "Done.")
    2.49  	(insert " ")
    2.50  	(set-marker (process-mark YaTeX-typeset-process) (1- (point))))
    2.51 @@ -133,6 +140,7 @@
    2.52        (switch-to-buffer cb)
    2.53        (YaTeX-remove-nonstopmode))))
    2.54  
    2.55 +(defvar YaTeX-typeset-rerun-msg "Rerun to get cross-references right.")
    2.56  (defun YaTeX-typeset-sentinel (proc mes)
    2.57    (cond ((null (buffer-name (process-buffer proc)))
    2.58           ;; buffer killed
    2.59 @@ -140,7 +148,12 @@
    2.60          ((memq (process-status proc) '(signal exit))
    2.61           (let* ((obuf (current-buffer)) (pbuf (process-buffer proc))
    2.62  		(pwin (get-buffer-window pbuf))
    2.63 -		(owin (selected-window)) win)
    2.64 +		(owin (selected-window)) win
    2.65 +		(thiscmd (get 'YaTeX-typeset-process 'thiscmd))
    2.66 +		(ppprop (get 'YaTeX-typeset-process 'ppcmd))
    2.67 +		(ppcmd (cdr (assq proc ppprop))))
    2.68 +	   (put 'YaTeX-typeset-process 'ppcmd ;erase ppcmd
    2.69 +		(delq (assq proc ppprop) ppprop))
    2.70             ;; save-excursion isn't the right thing if
    2.71             ;;  process-buffer is current-buffer
    2.72             (unwind-protect
    2.73 @@ -165,17 +178,33 @@
    2.74                   ;; is dead, we can delete it now.  Otherwise it
    2.75                   ;; will stay around until M-x list-processes.
    2.76                   (delete-process proc)
    2.77 -		 ;; If ppcmd is active, call it.
    2.78 -		 (let* ((ppprop (get 'YaTeX-typeset-process 'ppcmd))
    2.79 -			(ppcmd (cdr (assq proc ppprop))))
    2.80 -		   (put 'YaTeX-typeset-process 'ppcmd ;erase ppcmd
    2.81 -			(delq (assq proc ppprop) ppprop))
    2.82 +		 (if (save-excursion
    2.83 +		       (search-backward
    2.84 +			YaTeX-typeset-rerun-msg YaTeX-typeset-marker t))
    2.85 +		     (progn
    2.86 +		       (insert
    2.87 +			(format
    2.88 +			 "===!!! %s !!!===\n"
    2.89 +			 (message "Rerun `%s' to get cross-references right"
    2.90 +				  thiscmd)))
    2.91 +		       (set-marker YaTeX-typeset-marker (point))
    2.92 +		       (save-excursion (sit-for 2))
    2.93 +		       (set-process-sentinel
    2.94 +			(start-process
    2.95 +			 mode-name pbuf
    2.96 +			 shell-file-name YaTeX-shell-command-option thiscmd)
    2.97 +			'YaTeX-typeset-sentinel)
    2.98 +		       (if ppcmd
    2.99 +			   (put 'YaTeX-typeset-process 'ppcmd
   2.100 +				(cons (cons (get-buffer-process pbuf) ppcmd)
   2.101 +				      ppprop))))
   2.102 +		   ;; If ppcmd is active, call it.
   2.103  		   (cond
   2.104  		    ((and ppcmd (string-match "finish" mes))
   2.105  		     (insert (format "=======> Success! Calling %s\n" ppcmd))
   2.106  		     (setq mode-name	; set process name
   2.107  			   (substring ppcmd 0 (string-match " " ppcmd)))
   2.108 -		     ; to reach here, 'start-process exists on this emacsen
   2.109 +					; to reach here, 'start-process exists on this emacsen
   2.110  		     (set-process-sentinel
   2.111  		      (start-process
   2.112  		       mode-name