[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex a07f436 16/78: Implement TeX-update.
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex a07f436 16/78: Implement TeX-update. |
Date: |
Mon, 19 Oct 2015 09:10:43 +0000 |
branch: externals/auctex
commit a07f43647eb3ed649d47a14bc6e1db181cd18a7b
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>
Implement TeX-update.
* tex-buf.el: Update copyright year.
(TeX-command-sequence-max-runs-same-command)
(TeX-command-sequence-max-runs): New customizable variables.
(TeX-command-sequence-count-same-command)
(TeX-command-sequence-count, TeX-command-sequence-last-command)
(TeX-command-sequence-sentinel, TeX-command-sequence-command): New
variables.
(TeX-command-sequence): New function.
(TeX-command-default): New function, stripped off from
`TeX-command-query'.
(TeX-command-query): Use `TeX-command-default'.
(TeX-command-sequence-sentinel): New function.
* tex.el (TeX-update): New function.
(TeX-mode-map): Add key binding for `TeX-update'.
(TeX-mode-specific-command-menu-entries): Add entry for
`TeX-update'.
* doc/auctex.texi: Update copyright year.
(Starting a Command): Document `TeX-update'.
* doc/changes.texi: Update copyright year.
Mention `TeX-update'.
* doc/quickstart.texi (Processing Facilities): Mention
`TeX-update' and `TeX-error-overview'.
* doc/todo.texi: Update copyright year.
(Wishlist): Remove entry for `TeX-update'.
---
ChangeLog | 32 ++++++++++
doc/auctex.texi | 14 ++++-
doc/changes.texi | 7 ++-
doc/quickstart.texi | 10 +++
doc/todo.texi | 13 +----
tex-buf.el | 171 ++++++++++++++++++++++++++++++++++++++++++++-------
tex.el | 16 +++---
7 files changed, 219 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a5f6908..4edd55f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2015-08-31 Mos� Giordano <address@hidden>
+
+ * tex-buf.el: Update copyright year.
+ (TeX-command-sequence-max-runs-same-command)
+ (TeX-command-sequence-max-runs): New customizable variables.
+ (TeX-command-sequence-count-same-command)
+ (TeX-command-sequence-count, TeX-command-sequence-last-command)
+ (TeX-command-sequence-sentinel, TeX-command-sequence-command): New
+ variables.
+ (TeX-command-sequence): New function.
+ (TeX-command-default): New function, stripped off from
+ `TeX-command-query'.
+ (TeX-command-query): Use `TeX-command-default'.
+ (TeX-command-sequence-sentinel): New function.
+
+ * tex.el (TeX-update): New function.
+ (TeX-mode-map): Add key binding for `TeX-update'.
+ (TeX-mode-specific-command-menu-entries): Add entry for
+ `TeX-update'.
+
+ * doc/auctex.texi: Update copyright year.
+ (Starting a Command): Document `TeX-update'.
+
+ * doc/changes.texi: Update copyright year.
+ Mention `TeX-update'.
+
+ * doc/quickstart.texi (Processing Facilities): Mention
+ `TeX-update' and `TeX-error-overview'.
+
+ * doc/todo.texi: Update copyright year.
+ (Wishlist): Remove entry for `TeX-update'.
+
2015-08-30 Arash Esbati <address@hidden>
* style/caption.el ("caption"): Add support for undocumented
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 141afff..ad1e951 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,7 +12,7 @@ This manual is for @AUCTeX{}
(version @value{VERSION} from @value{UPDATED}),
a sophisticated TeX environment for Emacs.
-Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2014
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2015
Free Software Foundation, Inc.
@quotation
@@ -2700,6 +2700,18 @@ master file. The command is then actually run on the
region file. See
@code{TeX-command-region} for details.
@end deffn
+It is also possible to compile automatically the whole document until it
+is ready with a single command: @code{TeX-update}.
+
address@hidden Command TeX-update
address@hidden C-c C-u
+(@kbd{C-c C-u}) Compile the current document until an error occurs or it
+is finished. If compilation finishes successfully, run the viewer at
+the end.
address@hidden deffn
+
+Here are some relevant variables.
+
@defopt TeX-region
The name of the file for temporarily storing the text when formatting
the current region.
diff --git a/doc/changes.texi b/doc/changes.texi
index 2178387..c2c4140 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -1,5 +1,5 @@
@c This is part of the AUCTeX manual.
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012-2014 Free Software
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012-2015 Free Software
@c Foundation, Inc.
@c See file auctex.texi for copying conditions.
@include macros.texi
@@ -12,6 +12,11 @@
@itemize @bullet
@item
+You can now run all commands needed to compile a document and then open
+the viewer with a single command: @code{TeX-update}, bound to @kbd{C-c
+C-u}.
+
address@hidden
Commands such as LaTeX and View can now be executed conveniently on the
current section (or part, chapter, subsection, etc). See
@code{LaTeX-command-section} and
diff --git a/doc/quickstart.texi b/doc/quickstart.texi
index 90076ce..0f9beeb 100644
--- a/doc/quickstart.texi
+++ b/doc/quickstart.texi
@@ -228,6 +228,12 @@ When no processor invocation is necessary anymore,
@AUCTeX{} will
suggest to run a viewer, or you can chose to create a PostScript file
using @command{dvips}, or to directly print it.
+Actually, there is another command which comes in handy to compile
+documents: type @kbd{C-c C-u} (@code{TeX-update}) and @AUCTeX{} will
+compile the document for you until it is ready and then run the viewer.
+This is the same as issuing repeatedly @kbd{C-c C-c} and letting
address@hidden guess the next command to run.
+
At this place, a warning needs to be given: First, although @AUCTeX{} is
really good in detecting the standard situations when an additional
@command{latex} run is necessary, it cannot detect it always. Second,
@@ -278,6 +284,10 @@ may be repeated until all errors have been dealt with. By
pressing
@AUCTeX{} should notify you of overfull and underfull boxes in addition
to regular errors.
+If you have a recent version of GNU Emacs (24 or later), issue @kbd{M-x
+TeX-error-overview RET} to see a nicely formatted list of all errors and
+warnings reported by the compiler.
+
If a command got stuck in a seemingly infinite loop, or you want to stop
execution for other reasons, you can use @kbd{C-c C-k} (for ``kill'').
Similar to @kbd{C-l}, which centers the buffer you are in around your
diff --git a/doc/todo.texi b/doc/todo.texi
index cd5b2de..59b0f29 100644
--- a/doc/todo.texi
+++ b/doc/todo.texi
@@ -1,5 +1,5 @@
@c This is part of the AUCTeX Manual.
address@hidden Copyright (C) 2004-2006, 2008, 2009, 2013, 2014 Free Software
address@hidden Copyright (C) 2004-2006, 2008, 2009, 2013-2015 Free Software
@c Foundation, Inc.
@c See the file auctex.texi for copying conditions.
@ifset rawfile
@@ -190,17 +190,6 @@ stuff. Suggested by John Interrante
@samp{<interran@@uluru.Stanford.EDU>}.
@item
-Make features.
-
-A new command @code{TeX-update} (@kbd{C-c C-u}) could be used to create
-an up-to-date dvi file by repeatedly running address@hidden, MakeIndex and
-(La)@TeX{}, until an error occurs or we are done.
-
-An alternative is to have an @samp{Update} command that ensures the
address@hidden file is up to date. This could be called before printing and
-previewing.
-
address@hidden
Documentation of variables that can be set in a style hook.
We need a list of what can safely be done in an ordinary style hook.
diff --git a/tex-buf.el b/tex-buf.el
index 3be47d7..1bf6b5d 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1,6 +1,6 @@
;;; tex-buf.el --- External commands for AUCTeX.
-;; Copyright (C) 1991-1999, 2001-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1999, 2001-2015 Free Software Foundation, Inc.
;; Maintainer: address@hidden
;; Keywords: tex, wp
@@ -555,6 +555,114 @@ ORIGINALS which are modified but not saved yet."
(setq found t)))
found))
+(defcustom TeX-command-sequence-max-runs-same-command 4
+ "Maximum number of runs of the same command."
+ :type 'integer
+ :group 'TeX-command)
+
+(defcustom TeX-command-sequence-max-runs 12
+ "Maximum number of total runs."
+ :type 'integer
+ :group 'TeX-command)
+
+(defvar TeX-command-sequence-count-same-command 1
+ "Counter for the runs of the same command in `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-count 1
+ "Counter for the total runs of `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-last-command nil
+ "Last command run in `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-sentinel nil
+ "Sentinel for `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-command nil
+ "Command argument for `TeX-command-sequence'.
+
+It is set in `TeX-command-sequence' and used in
+`TeX-command-sequence-sentinel' to call again
+`TeX-command-sequence' with the appropriate command argument.")
+
+(defun TeX-command-sequence (command &optional reset)
+ "Run a sequence of TeX commands defined by COMMAND.
+
+The COMMAND argument may be
+
+ * nil: no command will be run in this case
+
+ * a string with a command from `TeX-command-list'
+
+ * a non-nil list of strings, which are commands from
+ `TeX-command-list'; the car of the list is used as command to
+ be executed in the first run of `TeX-command-sequence', the
+ cdr of the list will be passed to the function in the next
+ run, etc.
+
+ * a function name, returning a string which is command from
+ `TeX-command-list'; it will be funcall'd (without arguments!)
+ and used again in the next run of `TeX-command-sequence'.
+
+ * with any other value the function `TeX-command-default' is
+ used to determine the command to run, until a stopping
+ condition is met.
+
+This function runs at most
+`TeX-command-sequence-max-runs-same-command' times the same
+command in a row, and `TeX-command-sequence-max-runs' times in
+total in any case. It ends when `TeX-command-Show' is the
+command to be run.
+
+A non-nil value for the optional argument RESET means this is the
+first run of the function and some variables need to be reset."
+ (if (null command)
+ (message "No command to run.")
+ (let (cmd process)
+ (cond
+ ((stringp command)
+ (setq cmd command
+ TeX-command-sequence-command nil))
+ ((listp command)
+ (setq cmd (pop command)
+ TeX-command-sequence-command command))
+ ((functionp command)
+ (setq cmd (funcall command)
+ TeX-command-sequence-command command))
+ (t
+ (setq cmd (TeX-command-default (TeX-master-file))
+ TeX-command-sequence-command t)))
+ (TeX-command cmd 'TeX-master-file 0)
+ (when reset
+ (setq TeX-command-sequence-count-same-command 1
+ TeX-command-sequence-count 1
+ TeX-command-sequence-last-command nil))
+ (cond
+ ;; Stop when the same command has been run
+ ;; `TeX-command-sequence-max-runs-same-command' times in a row.
+ ((>= TeX-command-sequence-count-same-command
+ TeX-command-sequence-max-runs-same-command)
+ (message "Stopping after running %S %d times in a row."
+ TeX-command-sequence-last-command
+ TeX-command-sequence-count-same-command))
+ ;; Stop when there have been `TeX-command-sequence-max-runs' total
+ ;; compilations.
+ ((>= TeX-command-sequence-count TeX-command-sequence-max-runs)
+ (message "Stopping after %d compilations." TeX-command-sequence-count))
+ ;; The command just run is `TeX-command-Show'.
+ ((equal command TeX-command-Show))
+ ;; In any other case continue: increase counters (when needed), update
+ ;; `TeX-command-sequence-last-command' and run the sentinel.
+ (t
+ (if (equal cmd TeX-command-sequence-last-command)
+ (setq TeX-command-sequence-count-same-command
+ (1+ TeX-command-sequence-count-same-command))
+ (setq TeX-command-sequence-count-same-command 1))
+ (setq TeX-command-sequence-count (1+ TeX-command-sequence-count)
+ TeX-command-sequence-last-command cmd)
+ (and (setq process (get-buffer-process (current-buffer)))
+ (setq TeX-command-sequence-sentinel (process-sentinel process))
+ (set-process-sentinel process 'TeX-command-sequence-sentinel)))))))
+
(defcustom TeX-save-query t
"*If non-nil, ask user for permission to save files before starting TeX."
:group 'TeX-command
@@ -562,29 +670,32 @@ ORIGINALS which are modified but not saved yet."
(defvar TeX-command-history nil)
+(defun TeX-command-default (name)
+ "Guess the next command to be run on NAME."
+ (cond ((if (string-equal name TeX-region)
+ (TeX-check-files (concat name "." (TeX-output-extension))
+ (list name)
+ TeX-file-extensions)
+ (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))
+ (append BibTeX-file-extensions
+ TeX-Biber-file-extensions)))
+ ;; We should check for bst files here as well.
+ (if LaTeX-using-Biber TeX-command-Biber TeX-command-BibTeX))
+ ((TeX-process-get-variable name
+ 'TeX-command-next
+ TeX-command-Show))
+ (TeX-command-Show)))
+
(defun TeX-command-query (name)
"Query the user for what TeX command to use."
- (let* ((default
- (cond ((if (string-equal name TeX-region)
- (TeX-check-files (concat name "." (TeX-output-extension))
- (list name)
- TeX-file-extensions)
- (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))
- (append BibTeX-file-extensions
- TeX-Biber-file-extensions)))
- ;; We should check for bst files here as well.
- (if LaTeX-using-Biber TeX-command-Biber TeX-command-BibTeX))
- ((TeX-process-get-variable name
- 'TeX-command-next
- TeX-command-Show))
- (TeX-command-Show)))
+ (let* ((default (TeX-command-default name))
(completion-ignore-case t)
(answer (or TeX-command-force
(completing-read
@@ -1268,6 +1379,22 @@ Rerun to get mark in right position\\." nil t)
"Run LaTeX again to get citations right."))
(setq TeX-command-next TeX-command-default))))
+(defun TeX-command-sequence-sentinel (process string)
+ "Call the appropriate sentinel for the current process.
+
+If there are no errors, call back `TeX-command-sequence' using
+`TeX-command-sequence-command' as command argument, unless this
+variable is nil."
+ (with-current-buffer (process-buffer process)
+ (funcall TeX-command-sequence-sentinel process string)
+ (if (string-match "\\(finished\\|exited\\)" string)
+ (with-current-buffer TeX-command-buffer
+ (unless
+ (or
+ (plist-get TeX-error-report-switches (intern (TeX-master-file)))
+ (null TeX-command-sequence-command))
+ (TeX-command-sequence TeX-command-sequence-command))))))
+
;;; Process Control
diff --git a/tex.el b/tex.el
index 24971b8..630349c 100644
--- a/tex.el
+++ b/tex.el
@@ -1276,13 +1276,6 @@ restarting Emacs."
(repeat :tag "List of executables" (string :tag "Name"))
(const :tag "No executable" nil)))))
-;; XXX: Regarding a possibility to (manually) run an update command,
-;; one could support this through `TeX-view' by letting it temporarily
-;; set a variable which is checked with a predicate in the viewer
-;; selection. If the check is positive, the update command is run
-;; instead of the normal viewer command. Direct support through the
-;; View command would require a predicate which knows when an update
-;; has to be done.
(defcustom TeX-view-program-selection
(cond
((eq system-type 'windows-nt)
@@ -2050,6 +2043,10 @@ output files."
(delete-file (concat master-dir file))))
(message "No files to be deleted"))))
+(defun TeX-update ()
+ "Compile the current document until an error occurs or it is finished."
+ (interactive)
+ (TeX-command-sequence t t))
;;; Master File
@@ -4667,6 +4664,7 @@ Brace insertion is only done if point is in a math
construct and
(define-key map "\C-c\C-r" 'TeX-command-region)
(define-key map "\C-c\C-b" 'TeX-command-buffer)
(define-key map "\C-c\C-c" 'TeX-command-master)
+ (define-key map "\C-c\C-u" 'TeX-update)
(define-key map "\C-c\C-k" 'TeX-kill-job)
(define-key map "\C-c\C-l" 'TeX-recenter-output-buffer)
(define-key map "\C-c^" 'TeX-home-buffer)
@@ -4763,7 +4761,9 @@ Brace insertion is only done if point is in a math
construct and
:help "Make \"Next Error\" show overfull and underfull boxes"]
["Debug Warnings" TeX-toggle-debug-warnings
:style toggle :selected TeX-debug-warnings
- :help "Make \"Next Error\" show warnings"])))
+ :help "Make \"Next Error\" show warnings"])
+ ["Compile and view" TeX-update
+ :help "Compile the document until it is ready and open the viewer"]))
(let ((file 'TeX-command-on-current)) ;; is this actually needed?
(TeX-maybe-remove-help
(delq nil
- [elpa] externals/auctex a3e3ab8 14/78: Add new style transparent.el., (continued)
- [elpa] externals/auctex a3e3ab8 14/78: Add new style transparent.el., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 8d5acb0 13/78: Do not indent the content of `filecontents[*]' env., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 57338ec 24/78: Improve my last commit, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 400609e 18/78: New TeX--if-macro-fboundp compatibility macro, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 08ab3c1 23/78: Allow hiding ^ and _ script signs, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 0b3a6e8 12/78: Do not indent the content of `Form' environment., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 40963e5 08/78: Check engine before running LaTeX command., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 33cee84 19/78: Allow TeX-command-sequence to process the region, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 513490f 22/78: Implement multi-level script fontification, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 76eb240 25/78: Docfix, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a07f436 16/78: Implement TeX-update.,
Tassilo Horn <=
- [elpa] externals/auctex dbc87df 17/78: Generate PDF via dvips+ps2pdf., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex dd9adef 21/78: Case-sensitive mode detection + AMS-TeX fixes, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex da7419f 42/78: Add new style AlegreyaSans.el., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 9cfd5d8 47/78: Improve LaTeX-find-matching-end, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 647a8fc 29/78: Fixes for "run-all" on current section, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 5ed22c0 45/78: FiX TeX error parsing., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 66b97ff 20/78: Don't add font-latex-setup to latex-mode-hook, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex c3cb0ff 26/78: Rename TeX-update to TeX-command-run-all., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex e2b2413 28/78: Reference TeX-command-run-all in documentation., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 69004bc 33/78: Fix wrong TeX-command-default guess for region files, Tassilo Horn, 2015/10/19