yatex
diff yatexprc.el @ 262:15ec86ff549c
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 |
line diff
1.1 --- a/yatexprc.el Mon Feb 13 21:59:32 2012 +0900 1.2 +++ b/yatexprc.el Fri Feb 17 17:42:27 2012 +0900 1.3 @@ -2,7 +2,7 @@ 1.4 ;;; YaTeX process handler. 1.5 ;;; yatexprc.el 1.6 ;;; (c)1993-2012 by HIROSE Yuuji.[yuuji@yatex.org] 1.7 -;;; Last modified Mon Feb 13 21:58:24 2012 on firestorm 1.8 +;;; Last modified Fri Feb 17 17:38:32 2012 on firestorm 1.9 ;;; $Id$ 1.10 1.11 ;(require 'yatex) 1.12 @@ -56,6 +56,8 @@ 1.13 (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax)) 1.14 1.15 (defvar YaTeX-typeset-marker nil) 1.16 +(defvar YaTeX-typeset-consumption nil) 1.17 +(make-variable-buffer-local 'YaTeX-typeset-consumption) 1.18 (defun YaTeX-typeset (command buffer &optional prcname modename ppcmd) 1.19 "Execute jlatex (or other) to LaTeX typeset." 1.20 (interactive) 1.21 @@ -95,6 +97,10 @@ 1.22 (set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel) 1.23 (put 'YaTeX-typeset-process 'thiscmd command) 1.24 (put 'YaTeX-typeset-process 'name prcname) 1.25 + (if (fboundp 'current-time) 1.26 + (setq YaTeX-typeset-consumption 1.27 + (cons (cons 'time (current-time)) 1.28 + (delq 'time YaTeX-typeset-consumption)))) 1.29 (let ((ppprop (get 'YaTeX-typeset-process 'ppcmd))) 1.30 (setq ppprop (delq (assq YaTeX-typeset-process ppprop) ppprop)) 1.31 (if ppcmd 1.32 @@ -146,12 +152,15 @@ 1.33 (switch-to-buffer cb) 1.34 (YaTeX-remove-nonstopmode)))) 1.35 1.36 +(defvar YaTeX-typeset-auto-rerun t 1.37 + "*Non-nil automatically reruns typesetter when cross-refs update found. 1.38 +This is a toy mechanism. DO NOT RELY ON THIS MECHANISM. 1.39 +You SHOULD check the integrity of cross-references with your eyes!! 1.40 +Supplying an integer to this variable inhibit compulsory call of bibtex, 1.41 +thus, it call bibtex only if warning messages about citation are seen.") 1.42 (defvar YaTeX-typeset-rerun-msg "Rerun to get cross-references right.") 1.43 (defvar YaTeX-typeset-citation-msg 1.44 "Warning: Citation \`") 1.45 -(defvar YaTeX-typeset-auto-rerun t 1.46 - "*Non-nil automatically reruns typesetter when cross-refs update found. 1.47 -This is mechanism is ") 1.48 (defun YaTeX-typeset-sentinel (proc mes) 1.49 (cond ((null (buffer-name (process-buffer proc))) 1.50 ;; buffer killed 1.51 @@ -183,7 +192,16 @@ 1.52 (if pwin (recenter -3)) 1.53 (insert ?\n mode-name " " mes) 1.54 (forward-char -1) 1.55 - (insert " at " (substring (current-time-string) 0 -5) "\n") 1.56 + (insert 1.57 + (format " at %s%s\n" 1.58 + (substring (current-time-string) 0 -5) 1.59 + (if (and (fboundp 'current-time) (fboundp 'float) 1.60 + (assq 'time YaTeX-typeset-consumption)) 1.61 + (format 1.62 + " (%.2f secs)" 1.63 + (YaTeX-elapsed-time 1.64 + (cdr (assq 'time YaTeX-typeset-consumption)) 1.65 + (current-time)))))) 1.66 (setq mode-line-process 1.67 (concat ": " 1.68 (symbol-name (process-status proc)))) 1.69 @@ -195,15 +213,24 @@ 1.70 ;; will stay around until M-x list-processes. 1.71 (delete-process proc) 1.72 (if (cond 1.73 - ((null YaTeX-typeset-auto-rerun) nil) 1.74 - ((and bibcmd 1.75 - (save-excursion 1.76 - (re-search-backward 1.77 - YaTeX-typeset-citation-msg 1.78 - YaTeX-typeset-marker t)) 1.79 - (save-excursion 1.80 + ((not YaTeX-typeset-auto-rerun) nil) 1.81 + ((and bibcmd ;Call bibtex if bibcmd defined && 1.82 + (or ; (1st call || warning found) 1.83 + (and (not (numberp YaTeX-typeset-auto-rerun)) 1.84 + ; cancel call at 1st, if value is a number. 1.85 + (not (string-match "bibtex" mode-name))) 1.86 + (re-search-backward 1.87 + YaTeX-typeset-citation-msg 1.88 + YaTeX-typeset-marker t)) 1.89 + (save-excursion ; && using .bbl files. 1.90 (search-backward 1.91 ".bbl" YaTeX-typeset-marker t))) 1.92 + ;; Always call bibtex after the first typesetting, 1.93 + ;; because bibtex doesn't warn disappeared \cite. 1.94 + ;; (Suggested by ryseto. 2012) 1.95 + ;; It is more efficient to call bibtex directly than 1.96 + ;; to call it after deep inspection on the balance 1.97 + ;; of \cite vs. \bib*'s referring all *.aux files. 1.98 (insert "\n" YaTeX-typeset-rerun-msg "\n") 1.99 (setq tobecalled bibcmd shortname "+bibtex")) 1.100 ((or 1.101 @@ -257,7 +284,7 @@ 1.102 shell-file-name YaTeX-shell-command-option 1.103 ppcmd) 1.104 'YaTeX-typeset-sentinel)) 1.105 - (t ;pull back original name 1.106 + (t ;pull back original mode-name 1.107 (setq mode-name "typeset")))) 1.108 (forward-char 1)) 1.109 (setq YaTeX-typeset-process nil) 1.110 @@ -384,7 +411,9 @@ 1.111 (setq pparg (substring cmd 0 (string-match "[;&]" cmd)) ;rm multistmt 1.112 pparg (substring pparg (rindex pparg ? )) ;get last arg 1.113 pparg (substring pparg 0 (rindex pparg ?.)) ;rm ext 1.114 - bibcmd (concat bibtex-command pparg)) 1.115 + bibcmd (or (YaTeX-get-builtin "BIBTEX") bibtex-command)) 1.116 + (or (string-match "\\s " bibcmd) ;if bibcmd has no spaces, 1.117 + (setq bibcmd (concat bibcmd pparg))) ;append argument(== %#!) 1.118 (and pp 1.119 (stringp pp) 1.120 (setq ppcmd (concat pp pparg)))