yatex

changeset 262:15ec86ff549c dev

Call always bibtex after first typesetting when document needs bibtex. Display total ellapsed time of all processing for impatients :). Use value of `%BIBTEX ...' line, if any, to automatic (re)run of bibtex.
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 17 Feb 2012 17:42:27 +0900
parents 8c555014f933
children 808f532d68d3
files yatexlib.el yatexprc.el
diffstat 2 files changed, 53 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/yatexlib.el	Mon Feb 13 21:59:32 2012 +0900
     1.2 +++ b/yatexlib.el	Fri Feb 17 17:42:27 2012 +0900
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; YaTeX and yahtml common libraries, general functions and definitions
     1.5  ;;; yatexlib.el
     1.6  ;;; (c)1994-2012 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Fri Feb 10 12:30:49 2012 on firestorm
     1.8 +;;; Last modified Fri Feb 17 17:15:37 2012 on firestorm
     1.9  ;;; $Id$
    1.10  
    1.11  ;; General variables
    1.12 @@ -1534,6 +1534,15 @@
    1.13  	 (kill-new string)
    1.14  	 (message (concat "`%s'" msg) string key))))
    1.15  
    1.16 +(defun YaTeX-elapsed-time (before after)
    1.17 +  "Get elapsed time from BEFORE and AFTER, which are given from currente-time."
    1.18 +  (if (fboundp 'float)			;Then, current-time function should be.
    1.19 +      (let ((mil (float 1000000)))	;To protect parse error before 19
    1.20 +	(+ (* (- (nth 0 after) (nth 0 before)) 65536)
    1.21 +	   (- (nth 1 after) (nth 1 before))
    1.22 +	   (- (/ (nth 2 after) mil)
    1.23 +	      (/ (nth 2 before) mil))))))
    1.24 +
    1.25  ;;;
    1.26  ;; Functions for the Installation time
    1.27  ;;;
     2.1 --- a/yatexprc.el	Mon Feb 13 21:59:32 2012 +0900
     2.2 +++ b/yatexprc.el	Fri Feb 17 17:42:27 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 Feb 13 21:58:24 2012 on firestorm
     2.8 +;;; Last modified Fri Feb 17 17:38:32 2012 on firestorm
     2.9  ;;; $Id$
    2.10  
    2.11  ;(require 'yatex)
    2.12 @@ -56,6 +56,8 @@
    2.13    (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax))
    2.14  
    2.15  (defvar YaTeX-typeset-marker nil)
    2.16 +(defvar YaTeX-typeset-consumption nil)
    2.17 +(make-variable-buffer-local 'YaTeX-typeset-consumption)
    2.18  (defun YaTeX-typeset (command buffer &optional prcname modename ppcmd)
    2.19    "Execute jlatex (or other) to LaTeX typeset."
    2.20    (interactive)
    2.21 @@ -95,6 +97,10 @@
    2.22  	(set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel)
    2.23  	(put 'YaTeX-typeset-process 'thiscmd command)
    2.24  	(put 'YaTeX-typeset-process 'name prcname)
    2.25 +	(if (fboundp 'current-time)
    2.26 +	    (setq YaTeX-typeset-consumption
    2.27 +		  (cons (cons 'time (current-time))
    2.28 +			(delq 'time YaTeX-typeset-consumption))))
    2.29  	(let ((ppprop (get 'YaTeX-typeset-process 'ppcmd)))
    2.30  	  (setq ppprop (delq (assq YaTeX-typeset-process ppprop) ppprop))
    2.31  	  (if ppcmd
    2.32 @@ -146,12 +152,15 @@
    2.33        (switch-to-buffer cb)
    2.34        (YaTeX-remove-nonstopmode))))
    2.35  
    2.36 +(defvar YaTeX-typeset-auto-rerun t
    2.37 +  "*Non-nil automatically reruns typesetter when cross-refs update found.
    2.38 +This is a toy mechanism.  DO NOT RELY ON THIS MECHANISM.
    2.39 +You SHOULD check the integrity of cross-references with your eyes!!
    2.40 +Supplying an integer to this variable inhibit compulsory call of bibtex,
    2.41 +thus, it call bibtex only if warning messages about citation are seen.")
    2.42  (defvar YaTeX-typeset-rerun-msg "Rerun to get cross-references right.")
    2.43  (defvar YaTeX-typeset-citation-msg
    2.44    "Warning: Citation \`")
    2.45 -(defvar YaTeX-typeset-auto-rerun t
    2.46 -  "*Non-nil automatically reruns typesetter when cross-refs update found.
    2.47 -This is mechanism is ")
    2.48  (defun YaTeX-typeset-sentinel (proc mes)
    2.49    (cond ((null (buffer-name (process-buffer proc)))
    2.50           ;; buffer killed
    2.51 @@ -183,7 +192,16 @@
    2.52  		 (if pwin (recenter -3))
    2.53                   (insert ?\n mode-name " " mes)
    2.54                   (forward-char -1)
    2.55 -                 (insert " at " (substring (current-time-string) 0 -5) "\n")
    2.56 +                 (insert
    2.57 +		  (format " at %s%s\n"
    2.58 +			  (substring (current-time-string) 0 -5)
    2.59 +			  (if (and (fboundp 'current-time) (fboundp 'float)
    2.60 +				   (assq 'time YaTeX-typeset-consumption))
    2.61 +			      (format
    2.62 +			       " (%.2f secs)"
    2.63 +			       (YaTeX-elapsed-time
    2.64 +				(cdr (assq 'time YaTeX-typeset-consumption))
    2.65 +				(current-time))))))
    2.66                   (setq mode-line-process
    2.67                         (concat ": "
    2.68                                 (symbol-name (process-status proc))))
    2.69 @@ -195,15 +213,24 @@
    2.70                   ;; will stay around until M-x list-processes.
    2.71                   (delete-process proc)
    2.72  		 (if (cond
    2.73 -		      ((null YaTeX-typeset-auto-rerun) nil)
    2.74 -		      ((and bibcmd
    2.75 -			    (save-excursion
    2.76 -			      (re-search-backward
    2.77 -			       YaTeX-typeset-citation-msg
    2.78 -			       YaTeX-typeset-marker t))
    2.79 -			    (save-excursion
    2.80 +		      ((not YaTeX-typeset-auto-rerun) nil)
    2.81 +		      ((and bibcmd     ;Call bibtex if bibcmd defined &&
    2.82 +			    (or	       ;  (1st call  || warning found)
    2.83 +			     (and (not (numberp YaTeX-typeset-auto-rerun))
    2.84 +				  ; cancel call at 1st, if value is a number.
    2.85 +				  (not (string-match "bibtex" mode-name)))
    2.86 +			     (re-search-backward
    2.87 +			      YaTeX-typeset-citation-msg
    2.88 +			      YaTeX-typeset-marker t))
    2.89 +			    (save-excursion ; && using .bbl files.
    2.90  			      (search-backward
    2.91  			       ".bbl" YaTeX-typeset-marker t)))
    2.92 +		       ;; Always call bibtex after the first typesetting,
    2.93 +		       ;; because bibtex doesn't warn disappeared \cite.
    2.94 +		       ;; (Suggested by ryseto. 2012)
    2.95 +		       ;; It is more efficient to call bibtex directly than
    2.96 +		       ;; to call it after deep inspection on the balance
    2.97 +		       ;; of \cite vs. \bib*'s referring all *.aux files.
    2.98  		       (insert "\n" YaTeX-typeset-rerun-msg "\n")
    2.99  		       (setq tobecalled bibcmd shortname "+bibtex"))
   2.100  		      ((or
   2.101 @@ -257,7 +284,7 @@
   2.102  		       shell-file-name YaTeX-shell-command-option
   2.103  		       ppcmd)
   2.104  		      'YaTeX-typeset-sentinel))
   2.105 -		    (t ;pull back original name
   2.106 +		    (t ;pull back original mode-name
   2.107  		     (setq mode-name "typeset"))))
   2.108  		 (forward-char 1))
   2.109  	     (setq YaTeX-typeset-process nil)
   2.110 @@ -384,7 +411,9 @@
   2.111      (setq pparg (substring cmd 0 (string-match "[;&]" cmd)) ;rm multistmt
   2.112  	  pparg (substring pparg (rindex pparg ? ))	 ;get last arg
   2.113  	  pparg (substring pparg 0 (rindex pparg ?.))	 ;rm ext
   2.114 -	  bibcmd (concat bibtex-command pparg))
   2.115 +	  bibcmd (or (YaTeX-get-builtin "BIBTEX") bibtex-command))
   2.116 +    (or (string-match "\\s " bibcmd)		;if bibcmd has no spaces,
   2.117 +	(setq bibcmd (concat bibcmd pparg)))	;append argument(== %#!)
   2.118      (and pp
   2.119  	 (stringp pp)
   2.120  	 (setq ppcmd (concat pp pparg)))