[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] Changes to auctex/tex-buf.el,v
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] Changes to auctex/tex-buf.el,v |
Date: |
Thu, 13 Sep 2012 10:14:20 +0000 |
CVSROOT: /sources/auctex
Module name: auctex
Changes by: Tassilo Horn <tsdh> 12/09/13 10:14:19
Index: tex-buf.el
===================================================================
RCS file: /sources/auctex/auctex/tex-buf.el,v
retrieving revision 1.286
retrieving revision 1.287
diff -u -b -r1.286 -r1.287
--- tex-buf.el 20 Mar 2011 08:59:15 -0000 1.286
+++ tex-buf.el 13 Sep 2012 10:14:18 -0000 1.287
@@ -76,7 +76,7 @@
(defun TeX-save-document (name)
"Save all files belonging to the current document.
-Return non-nil if document need to be re-TeX'ed."
+Return non-nil if document needs to be re-TeX'ed."
(interactive (list (TeX-master-file)))
(if (string-equal name "")
(setq name (TeX-master-file)))
@@ -366,37 +366,40 @@
command)
(defun TeX-check-files (derived originals extensions)
- "Check that DERIVED is newer than any of the ORIGINALS.
+ "Check if DERIVED is newer than any of the ORIGINALS.
Try each original with each member of EXTENSIONS, in all directories
-in `TeX-check-path'."
- (let ((found nil)
- (regexp (concat "\\`\\("
- (mapconcat (lambda (dir)
- (regexp-quote
- (expand-file-name
- (file-name-as-directory dir))))
- TeX-check-path "\\|")
- "\\).*\\("
- (mapconcat 'regexp-quote originals "\\|")
- "\\)\\.\\("
- (mapconcat 'regexp-quote extensions "\\|")
- "\\)\\'"))
+in `TeX-check-path'. Returns true if any of the ORIGINALS with any of the
+EXTENSIONS are newer than DERIVED. Will prompt to save the buffer of any
+ORIGINALS which are modified but not saved yet."
+ (let ((existingoriginals nil)
+ (found nil)
(buffers (buffer-list)))
+ (dolist (path (map 'list (lambda (dir)
+ (expand-file-name
+ (file-name-as-directory dir)))
+ TeX-check-path))
+ (dolist (orig originals)
+ (dolist (ext extensions)
+ (let ((filepath (concat path orig "." ext)))
+ (if (file-exists-p filepath)
+ (setq existingoriginals (cons filepath existingoriginals)))))))
(while buffers
(let* ((buffer (car buffers))
(name (buffer-file-name buffer)))
(setq buffers (cdr buffers))
- (if (and name (string-match regexp name))
+ (if (and name (member name existingoriginals))
(progn
(and (buffer-modified-p buffer)
(or (not TeX-save-query)
(y-or-n-p (concat "Save file "
(buffer-file-name buffer)
"? ")))
- (save-excursion (set-buffer buffer) (save-buffer)))
- (if (file-newer-than-file-p name derived)
- (setq found t))))))
- found))
+ (save-excursion (set-buffer buffer) (save-buffer)))))))
+ (dolist (eo existingoriginals)
+ (if (file-newer-than-file-p eo derived)
+ (setq found t)))
+ found
+ ))
(defcustom TeX-save-query t
"*If non-nil, ask user for permission to save files before starting TeX."
@@ -405,6 +408,11 @@
(defvar TeX-command-history nil)
+;; Something to remember - if you are testing on a document with no content at
+;; all, perhaps one with just \nocite{*} in it for testing Biber runs, no PDF
+;; file is created by latex and so the first cond clause will match because
+;; (file-newer-than-p) returns t when the second argument does not exist
+;; ... this has caused hours of pointless investigations before ...
(defun TeX-command-query (name)
"Query the user for what TeX command to use."
(let* ((default (cond ((if (string-equal name TeX-region)
@@ -414,12 +422,14 @@
(TeX-save-document (TeX-master-file)))
TeX-command-default)
((and (memq major-mode '(doctex-mode latex-mode))
+ ;; Want to know if bib file is newer than .bbl
+ ;; We don't care whether the bib files are open
in emacs
(TeX-check-files (concat name ".bbl")
(mapcar 'car
(LaTeX-bibliography-list))
- BibTeX-file-extensions))
+ BibTeX-Biber-file-extensions))
;; We should check for bst files here as well.
- TeX-command-BibTeX)
+ (if LaTeX-using-Biber TeX-command-Biber
TeX-command-BibTeX))
((TeX-process-get-variable name
'TeX-command-next
TeX-command-Show))
@@ -430,7 +440,7 @@
(concat "Command: (default " default ") ")
(TeX-mode-specific-command-list major-mode) nil t
nil 'TeX-command-history))))
- ;; If the answer "latex" it will not be expanded to "LaTeX"
+ ;; If the answer is "latex" it will not be expanded to "LaTeX"
(setq answer (car-safe (TeX-assoc answer TeX-command-list)))
(if (and answer
(not (string-equal answer "")))
@@ -673,6 +683,14 @@
process
(TeX-synchronous-sentinel name file process))))
+(defun TeX-run-Biber (name command file)
+ "Create a process for NAME using COMMAND to format FILE with Biber."
+ (let ((process (TeX-run-command name command file)))
+ (setq TeX-sentinel-function 'TeX-Biber-sentinel)
+ (if TeX-process-asynchronous
+ process
+ (TeX-synchronous-sentinel name file process))))
+
(defun TeX-run-compile (name command file)
"Ignore first and third argument, start compile with second argument."
(compile command))
@@ -940,17 +958,34 @@
(cond ((TeX-TeX-sentinel-check process name))
((and (save-excursion
(re-search-forward
+ "^Package biblatex Warning: Please (re)run Biber on the file"
nil t))
+ (with-current-buffer TeX-command-buffer
+ (and (LaTeX-bibliography-list)
+ (TeX-check-files (TeX-master-file "bbl")
+ (TeX-style-list)
+ (append TeX-file-extensions
+ BibTeX-Biber-file-extensions)))))
+ (message "%s%s" "You should run Biber to get citations right, "
+ (TeX-current-pages))
+ (setq TeX-command-next (with-current-buffer TeX-command-buffer
+ TeX-command-Biber)))
+ ((and (save-excursion
+ (re-search-forward
"^\\(?:LaTeX\\|Package natbib\\) Warning: Citation" nil t))
(with-current-buffer TeX-command-buffer
(and (LaTeX-bibliography-list)
(TeX-check-files (TeX-master-file "bbl")
(TeX-style-list)
(append TeX-file-extensions
- BibTeX-file-extensions)))))
+ BibTeX-Biber-file-extensions)))))
(message "%s%s" "You should run BibTeX to get citations right, "
(TeX-current-pages))
(setq TeX-command-next (with-current-buffer TeX-command-buffer
TeX-command-BibTeX)))
+ ((re-search-forward "^(biblatex)\\W+Page breaks have changed" nil t)
+ (message "%s%s" "You should run LaTeX again - page breaks have
changed, "
+ (TeX-current-pages))
+ (setq TeX-command-next TeX-command-default))
((re-search-forward "^\\(?:LaTeX Warning: Label(s)\\|\
Package natbib Warning: Citation(s)\\)" nil t)
(message "%s%s" "You should run LaTeX again to get references right, "
@@ -1008,8 +1043,32 @@
"\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
(t
(message (concat "BibTeX finished successfully. "
- "Run LaTeX again to get citations right."))))
+ "Run LaTeX again to get citations right."))
+ (setq TeX-command-next TeX-command-default))))
+
+(defun TeX-Biber-sentinel (process name)
+ "Cleanup TeX output buffer after running Biber."
+ (goto-char (point-max))
+ (cond
+ ((re-search-backward (concat
+ "^INFO - \\(WARNINGS\\|ERRORS\\): \\([0-9]+\\)") nil
t)
+ (message (concat "Biber finished with %s %s. "
+ "Type `%s' to display output.")
+ (match-string 2) (downcase (match-string 1))
+ (substitute-command-keys
+ "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]"))
(setq TeX-command-next TeX-command-default))
+ ((re-search-backward (concat
+ "^FATAL") nil t)
+ (message (concat "Biber had a fatal error and did not finish! "
+ "Type `%s' to display output.")
+ (substitute-command-keys
+ "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]"))
+ (setq TeX-command-next TeX-command-Biber))
+ (t
+ (message (concat "Biber finished successfully. "
+ "Run LaTeX again to get citations right."))
+ (setq TeX-command-next TeX-command-default))))
;;; Process Control
- [AUCTeX-diffs] Changes to auctex/tex-buf.el,v,
Tassilo Horn <=