auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-devel] [elpa] externals/auctex bfd5f18 09/69: Merge master branc


From: Tassilo Horn
Subject: [AUCTeX-devel] [elpa] externals/auctex bfd5f18 09/69: Merge master branch.
Date: Sat, 26 Mar 2016 21:36:32 +0000

branch: externals/auctex
commit bfd5f18bb8480d4333b97086064df48d60c9bbe5
Merge: 3dec183 a262726
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Merge master branch.
---
 ChangeLog        |   56 +++++++++
 doc/auctex.texi  |   32 +++++-
 doc/changes.texi |    9 ++-
 doc/todo.texi    |   14 +-
 font-latex.el    |   27 ++--
 tex-buf.el       |  365 +++++++++++++++++++++++++++++++++++++-----------------
 tex-site.el.in   |   34 +++--
 7 files changed, 388 insertions(+), 149 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2f27437..c873968 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,59 @@
+2014-05-23  Stefan Monnier  <address@hidden>
+
+       Backport from ELPA repository.
+       * tex-site.el (TeX-modes-set): Use advice-add if available.
+       * font-latex.el (font-latex-make-sectioning-faces): Don't rely on
+       dynamic scoping for `num'.
+       (font-latex-make-built-in-keywords): Don't use `eval' needlessly.
+       (font-latex-doctex-syntactic-keywords): Declare before first use.
+       (font-latex-match-command-with-arguments):
+       Stay away from `add-to-list' on let-bound variables.
+       (font-latex-match-command-in-braces): Remove unused var `end'.
+
+2014-05-20  Mos� Giordano  <address@hidden>
+
+       * tex-buf.el: Update copyright years.
+       (TeX-error-last-visited): New buffer-local variable.
+       (TeX-get-parse-function): New function.
+       (TeX-next-error): Add `apt' argument and make all arguments
+       optional.  Use `TeX-get-parse-function'.
+       (TeX-previous-error): Use `TeX-get-parse-function'.  Use
+       `TeX-parse-TeX' to move between errors when possible.
+       (TeX-TeX-sentinel): Parse the output log when
+       `TeX-parse-all-errors' is non-nil.
+       (TeX-LaTeX-sentinel): Ditto.
+       (TeX-parse-reset): Add an optional `reparse' argument and reparse
+       the output log when it is non-nil.  Reset also `TeX-error-list'
+       and `TeX-error-last-visited'.
+       (TeX-parse-command): Add `arg' argument.
+       (TeX-parse-TeX): Add `arg' argument.  When `TeX-parse-all-errors'
+       is non-nil, use `TeX-error-list' to move to the error point.
+       (TeX-error-list): New buffer-local variable.
+       (TeX-parse-all-errors): New customizable variable.
+       (TeX-parse-all-errors): New function.
+       (TeX-parse-error): Add an optional `store' argument.  Make the
+       function return non-nil when an error or a warning is found.
+       (TeX-error): Add an optional `store' argument: when it is non-nil
+       store the relevant information about the error in
+       `TeX-error-list'.  Use `TeX-error--find-display-help'.
+       (TeX-error--find-display-help): New function.
+       (TeX-warning): Add an optional `store' argument: when it is
+       non-nil store the relevant information about the warning in
+       `TeX-error-list'.  Use `TeX-warning--find-display-help'.
+       (TeX-warning--find-display-help): New function.
+       (TeX-output-mode-map): Bind `p' to the now working
+       `TeX-previous-error'.
+
+       * doc/auctex.texi (Debugging): Document `TeX-previous-error' and
+       `TeX-parse-all-errors'.  Update `TeX-next-error'.
+
+       * doc/changes.texi: Update copyright years.  Mention
+       `TeX-next-error' and `TeX-previous-error' changes and the new
+       `TeX-parse-all-errors'.
+
+       * doc/todo.texi: Update copyright years.
+       (Wishlist): Update a couple of items related to error parsing.
+
 2014-05-17  Mos� Giordano  <address@hidden>
 
        * font-latex.el: Update copyright years.
diff --git a/doc/auctex.texi b/doc/auctex.texi
index c84282a..6320543 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -3097,14 +3097,44 @@ to do exactly.  In xdvi you normally have to use 
@kbd{C-down-mouse-1}.
 Once you've formatted your document you may `debug' it, i.e. browse
 through the errors (La)@TeX{} reported.
 
address@hidden Command TeX-next-error
address@hidden Command TeX-next-error @var{arg} @var{reparse}
 @kindex C-c `
 (@kbd{C-c `})  Go to the next error reported by @TeX{}.  The view will
 be split in two, with the cursor placed as close as possible to the
 error in the top view.  In the bottom view, the error message will be
 displayed along with some explanatory text.
+
+An optional numeric @var{arg}, positive or negative, specifies how many
+error messages to move.  A negative @var{arg} means to move back to
+previous error messages, see also @code{TeX-previous-error}.
+
+The optional @var{reparse} argument makes @AUCTeX{} reparse the error
+message buffer and start the debugging from the first error.  This can
+also be achieved by calling the function with a prefix argument
+(@kbd{C-u}).
address@hidden deffn
+
address@hidden Command TeX-previous-error @var{arg}
address@hidden M-g p
+(@kbd{M-g p}) Go to the previous error reported by @TeX{}.  An optional
+numeric @var{arg} specifies how many error messages to move backward.
+This is like calling @code{TeX-next-error} with a negative argument.
 @end deffn
 
+The command @code{TeX-previous-error} works only if @AUCTeX{} can parse
+the whole @TeX{} log buffer.  This is controlled by the
address@hidden variable.
+
address@hidden TeX-parse-all-errors
+If t, @AUCTeX{} automatically parses the whole output log buffer right
+after running a @TeX{} command, in order to collect all warnings and
+errors.  This makes it possible to navigate back and forth between the
+error messages using @code{TeX-next-error} and
address@hidden  This is the default.  If nil, @AUCTeX{} do
+not parse the whole output log buffer and @code{TeX-previous-error}
+cannot be used.
address@hidden defopt
+
 Normally @AUCTeX{} will only report real errors, but you may as well
 ask it to report `bad boxes' and warnings as well.
 
diff --git a/doc/changes.texi b/doc/changes.texi
index b8eb96a..3c2273e 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -1,5 +1,6 @@
 @c This is part of the AUCTeX manual.
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012 Free Software 
Foundation, Inc.
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012-2014 Free Software
address@hidden Foundation, Inc.
 @c See file auctex.texi for copying conditions.
 @include macros.texi
 @ifset rawfile
@@ -14,6 +15,12 @@
 @code{TeX-PDF-mode} is now enabled by default.
 
 @item
+Now @code{TeX-previous-error} works with @TeX{} commands if the new
+option @code{TeX-parse-all-errors} is non-nil, which is the default.
address@hidden and @code{TeX-previous-error} can take a numeric
+argument to specify how many errors to move forward or backward.
+
address@hidden
 Style file authors are encouraged to distinguish common from expert
 macros/environments, and mark the latter using
 @code{TeX-declare-expert-macros} and
diff --git a/doc/todo.texi b/doc/todo.texi
index f17a644..b084ca5 100644
--- a/doc/todo.texi
+++ b/doc/todo.texi
@@ -1,5 +1,6 @@
 @c This is part of the AUCTeX Manual.
address@hidden Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2006, 2008, 2009, 2013, 2014 Free Software
address@hidden Foundation, Inc.
 @c See the file auctex.texi for copying conditions.
 @ifset rawfile
 @include macros.texi
@@ -91,8 +92,9 @@ A special ispell dictionary for macros could be nice to have.
 @item Quick error overviews
 
 An error overview window (extract from the log file with just the error
-lines, clickable like a ``grep'' buffer) and/or fringe indicators for
-errors in the main text would be nice.
+lines, clickable like a ``grep'' buffer; @code{TeX-error-list} can be
+used for this purpose) and/or fringe indicators for errors in the main
+text would be nice.
 
 @item A math entry grid
 
@@ -275,10 +277,8 @@ of the standard @code{TeX-mode} would help convince some 
people to
 change to @AUCTeX{}.
 
 @item
-Make @code{TeX-next-error} parse ahead and store the results in a list,
-using markers to remember buffer positions in order to be more robust
-with regard to line numbers and changed files.  This is what
address@hidden does. (Or did, until Emacs 19).
+Use markers in @code{TeX-error-list} to remember buffer positions in
+order to be more robust with regard to line numbers and changed files.
 
 @item
 Finish the Texinfo mode.  For one thing, many Texinfo mode commands do
diff --git a/font-latex.el b/font-latex.el
index f2ad1f9..217d302 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -261,7 +261,7 @@ Emacs."
 
 Probably you don't want to customize this face directly.  Better
 change the base face `font-latex-sectioning-5-face' or customize the
-variable `font-latex-fontify-sectioning'." num)
+variable `font-latex-fontify-sectioning'." ',num)
          :group 'font-latex-highlighting-faces))
       (when (and (featurep 'xemacs)
                 ;; Do not touch customized  faces.
@@ -587,8 +587,8 @@ This is an internal variable which should not be set 
directly.
 Use `font-latex-add-keywords' instead.
 
 Generated by `font-latex-make-built-in-keywords'.")))
-      (eval `(make-variable-buffer-local
-             ',(intern (concat prefix name "-keywords-local"))))
+      (make-variable-buffer-local
+       (intern (concat prefix name "-keywords-local")))
 
       ;; defun font-latex-match-*-make
       ;; Note: The functions are byte-compiled at the end of font-latex.el.
@@ -606,8 +606,8 @@ Generated by `font-latex-make-built-in-keywords'.")
                 (dolist (elt keywords)
                   (let ((keyword (if (listp elt) (car elt) elt)))
                     (if (string-match "^[A-Za-z]" keyword)
-                        (add-to-list 'multi-char-macros keyword)
-                      (add-to-list 'single-char-macros keyword))))
+                        (push keyword multi-char-macros)
+                      (push keyword single-char-macros))))
                 (when (or multi-char-macros single-char-macros)
                   (setq ,(intern (concat prefix name))
                         (concat
@@ -652,8 +652,7 @@ Generated by `font-latex-make-built-in-keywords'.")
       ;; defvar font-latex-match-*
       (eval `(defvar ,(intern (concat prefix name))
               ,(intern (concat prefix name "-keywords"))))
-      (eval `(make-variable-buffer-local
-             ',(intern (concat prefix name))))
+      (make-variable-buffer-local (intern (concat prefix name)))
 
       ;; defun font-latex-match-*
       (font-latex-make-match-defun prefix name face type)
@@ -879,6 +878,9 @@ The car is used for subscript, the cdr is used for 
superscripts."
 The form should be the same as in `font-lock-syntactic-keywords'.")
 (make-variable-buffer-local 'font-latex-syntactic-keywords-extra)
 
+;; Set and updated in `font-latex-set-syntactic-keywords'.
+(defvar font-latex-doctex-syntactic-keywords nil)
+
 (defun font-latex-set-syntactic-keywords ()
   "Set the variable `font-latex-syntactic-keywords'.
 This function can be used to refresh the variable in case other
@@ -1452,13 +1454,13 @@ Returns nil if none of KEYWORDS is found."
                                          (match-beginning 0))
        (let* ((beg (match-beginning 0))
               end                 ; Used for multiline text property.
-              match-data match-beg syntax-error alternative spec
+              (match-data (list beg))
+              match-beg syntax-error alternative spec
               error-indicator-pos
               (spec-list (string-to-list
                           (or (cadr (assoc (match-string 1) keywords))
                               font-latex-command-with-args-default-spec)))
               (parse-sexp-ignore-comments t)) ; scan-sexps ignores comments
-         (add-to-list 'match-data beg)
          (goto-char (match-end 0))
          ;; Check for starred macro if first spec is an asterisk.
          (when (eq (car spec-list) ?*)
@@ -1466,7 +1468,7 @@ Returns nil if none of KEYWORDS is found."
            (skip-chars-forward "*" (1+ (point))))
          ;; Add current point to match data and use keyword face for
          ;; region from start to point.
-         (add-to-list 'match-data (point) t)
+         (nconc match-data (list (point)))
          (add-to-list 'font-latex-matched-faces 'font-lock-keyword-face)
          (setq end (point))
          (catch 'break
@@ -1572,7 +1574,7 @@ Returns nil if no command is found."
                                          (match-beginning 0))
        (let ((kbeg (match-beginning 0)) (kend (match-end 1))
              (beg  (match-end 0))
-             end cbeg cend
+             cbeg cend
              (parse-sexp-ignore-comments t)) ; scan-sexps ignores comments
          (goto-char kbeg)
          (if (not (eq (preceding-char) ?\{))
@@ -1927,9 +1929,6 @@ END marks boundaries for searching for quotation ends."
   (append font-latex-keywords-2
          '(("^%<[^>]*>" (0 font-latex-doctex-preprocessor-face t)))))
 
-;; Set and updated in `font-latex-set-syntactic-keywords'.
-(defvar font-latex-doctex-syntactic-keywords nil)
-
 ;; Copy and adaptation of `doctex-font-lock-^^A' in `tex-mode.el' of
 ;; CVS Emacs (March 2004)
 (defun font-latex-doctex-^^A ()
diff --git a/tex-buf.el b/tex-buf.el
index a6dbe65..479d669 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-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1999, 2001-2014 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex, wp
@@ -266,26 +266,61 @@ the master file."
       (find-file (TeX-master-file TeX-default-extension))
     (switch-to-buffer TeX-command-buffer)))
 
-(defun TeX-next-error (reparse)
+(defvar TeX-error-last-visited -1
+  "Index of the last visited error listed in `TeX-error-list'.
+
+This variable is intended to be set only in output buffer so it
+will be shared among all files of the same document.")
+(make-variable-buffer-local 'TeX-error-last-visited)
+
+(defun TeX-get-parse-function ()
+  "Get the parse function for the current buffer."
+  (with-current-buffer TeX-command-buffer
+    (TeX-process-get-variable (TeX-active-master) 'TeX-parse-function)))
+
+(defun TeX-next-error (&optional arg reparse)
   "Find the next error in the TeX output buffer.
-With \[universal-argument] prefix, start from the beginning of the errors."
+
+A prefix ARG specifies how many error messages to move;
+negative means move back to previous error messages, if possible.
+
+If REPARSE is non-nil, reparse the error message buffer.
+
+\[universal-argument] as a prefix means reparse the error
+message buffer and start at the first error."
   (interactive "P")
   (if (or (null (TeX-active-buffer))
          (eq 'compilation-mode (with-current-buffer TeX-command-buffer
                                  major-mode)))
-      (next-error reparse)
-    (funcall (with-current-buffer TeX-command-buffer
-              (TeX-process-get-variable (TeX-active-master) 
'TeX-parse-function))
-            reparse)))
+      (next-error arg reparse)
+
+    ;; Force reparsing when the function is called with a universal-argument.
+    (if (consp arg) (setq reparse t arg nil))
+
+    (funcall (TeX-get-parse-function) arg reparse)))
 
 (defun TeX-previous-error (arg)
-  "Find the previous error in the TeX output buffer."
-  (interactive "P")
+  "Find the previous error in the TeX output buffer.
+
+Prefix arg N says how many error messages to move backward (or
+forward, if negative).
+
+This works only with TeX commands and if the
+`TeX-parse-all-errors' variable is non-nil."
+  (interactive "p")
   (if (or (null (TeX-active-buffer))
          (eq 'compilation-mode (with-current-buffer TeX-command-buffer
                                  major-mode)))
       (previous-error arg)
-    (error "Jumping to previous error not supported")))
+
+    (let ((parse-function (TeX-get-parse-function)))
+      (if (and TeX-parse-all-errors (equal parse-function 'TeX-parse-TeX))
+         ;; When `TeX-parse-all-errors' and the parsing function is
+         ;; `TeX-parse-TeX' we can move backward in the errors.
+         (TeX-parse-TeX (- arg) nil)
+       ;; XXX: moving backward in the errors hasn't yet been implemented for
+       ;; other parsing functions.
+       (error "Jumping to previous error not supported.")))))
 
 ;;; Command Query
 
@@ -886,10 +921,15 @@ NAME is the name of the process.")
   (make-variable-buffer-local 'TeX-sentinel-default-function)
 
 (defun TeX-TeX-sentinel (process name)
-  "Cleanup TeX output buffer after running TeX."
+  "Cleanup TeX output buffer after running TeX.
+
+Parse the output buffer to collect errors and warnings if the
+variable `TeX-parse-all-errors' is non-nil."
   (if (TeX-TeX-sentinel-check process name)
       ()
     (message (concat name ": formatted " (TeX-current-pages)))
+    (if TeX-parse-all-errors
+       (TeX-parse-all-errors))
     (setq TeX-command-next TeX-command-Show)))
 
 (defun TeX-current-pages ()
@@ -950,7 +990,12 @@ Warnings can be indicated by LaTeX or packages."
 
 ;; should go into latex.el? --pg
 (defun TeX-LaTeX-sentinel (process name)
-  "Cleanup TeX output buffer after running LaTeX."
+  "Cleanup TeX output buffer after running LaTeX.
+
+Parse the output buffer to collect errors and warnings if the
+variable `TeX-parse-all-errors' is non-nil."
+  (if TeX-parse-all-errors
+      (TeX-parse-all-errors))
   (cond ((TeX-TeX-sentinel-check process name))
        ((and (save-excursion
                (re-search-forward
@@ -1442,34 +1487,68 @@ the directory."
 
  (make-variable-buffer-local 'TeX-error-offset)
 
-(defun TeX-parse-reset ()
-  "Reset all variables used for parsing TeX output."
-  (setq TeX-error-point (point-min))
-  (setq TeX-error-offset nil)
-  (setq TeX-error-file nil))
+(defun TeX-parse-reset (&optional reparse)
+  "Reset all variables used for parsing TeX output.
+If optional argument REPARSE is non-nil, reparse the output log."
+  (setq TeX-error-point (point-min)
+       TeX-error-offset nil
+       TeX-error-file nil
+       TeX-error-list nil
+       TeX-error-last-visited -1)
+  (if reparse
+      (TeX-parse-all-errors)))
 
 ;;; - Parsers Hooks
 
-(defun TeX-parse-command (reparse)
+;; All this parsers hooks should have the same arguments even though they will
+;; be ignored, because `TeX-next-error' can call any of these functions.
+(defun TeX-parse-command (arg reparse)
   "We can't parse anything but TeX."
-  (error "I cannot parse %s output, sorry"
+  (error "I cannot parse %s output, sorry."
         (if (TeX-active-process)
             (process-name (TeX-active-process))
           "this")))
 
-(defun TeX-parse-TeX (reparse)
+(defun TeX-parse-TeX (arg reparse)
   "Find the next error produced by running TeX.
-With \[universal-argument] prefix, start from the beginning of the errors.
+
+ARG specifies how many error messages to move, when possible;
+negative means move back to previous error messages.
+
+If REPARSE is non-nil, reparse the output log.
 
 If the file occurs in an included file, the file is loaded (if not
 already in an Emacs buffer) and the cursor is placed at the error."
   (let ((old-buffer (current-buffer))
-       (default-major-mode major-mode))
+       (default-major-mode major-mode)
+       max-index item)
+
+    ;; Switch to the output buffer.
     (with-current-buffer (TeX-active-buffer)
       (if reparse
-         (TeX-parse-reset))
-      (goto-char TeX-error-point)
-      (TeX-parse-error old-buffer))))
+         (TeX-parse-reset reparse))
+      (if TeX-parse-all-errors
+         (progn
+           (setq max-index (length TeX-error-list)
+                 TeX-error-last-visited (+ (or arg 1) TeX-error-last-visited)
+                 item (nth TeX-error-last-visited TeX-error-list))
+           (if (< TeX-error-last-visited -1)
+               (setq TeX-error-last-visited -1))
+           (cond ((or (null item)
+                      (< TeX-error-last-visited 0))
+                  (if (> TeX-error-last-visited max-index)
+                      (setq TeX-error-last-visited max-index))
+                  (message "No more errors.")
+                  (beep)
+                  (TeX-pop-to-buffer old-buffer))
+                 (t
+                  (apply (intern
+                          (concat "TeX-" (symbol-name (car item))
+                                  "--find-display-help"))
+                         (cdr item)))))
+
+       (goto-char TeX-error-point)
+       (TeX-parse-error old-buffer)))))
 
 ;;; - Parsing (La)TeX
 
@@ -1479,8 +1558,39 @@ already in an Emacs buffer) and the cursor is placed at 
the error."
 You might want to examine and modify the free variables `file',
 `offset', `line', `string', `error', and `context' from this hook.")
 
-(defun TeX-parse-error (old)
-  "Goto next error.  Pop to OLD buffer if no more errors are found."
+(defvar TeX-error-list nil
+  "List of warning and errors.
+
+This variable is intended to be set only in output buffer so it
+will be shared among all files of the same document.")
+(make-variable-buffer-local 'TeX-error-list)
+
+(defcustom TeX-parse-all-errors t
+  "Whether to automatically collect all warning and errors after running TeX.
+
+If t, it make it possible to use `TeX-previous-error' with TeX
+commands."
+  :group 'TeX-command
+  :type 'boolean)
+
+(defun TeX-parse-all-errors ()
+  "Parse TeX output buffer to collect all warnings and errors."
+  ;; Reset error list.
+  (setq TeX-error-list nil)
+  (save-excursion
+    (goto-char (point-min))
+    (while (TeX-parse-error nil t)))
+  ;; Reset last visited error.
+  (setq TeX-error-last-visited -1))
+
+(defun TeX-parse-error (old &optional store)
+  "Goto next error.  Pop to OLD buffer if no more errors are found.
+
+If the optional argument STORE is non-nil, the function will
+store the found warning or error in `TeX-error-list' instead of
+displaying the issue.
+
+Return non-nil if an error or warning is found."
   (let ((regexp
         (concat
          ;; TeX error
@@ -1497,15 +1607,17 @@ You might want to examine and modify the free variables 
`file',
          "^\(\(?:Overfull\|Underfull\|Tight\|Loose\)\
  \\.*?[0-9]+--[0-9]+\)\|"
          ;; LaTeX warning
-         "^\(LaTeX [A-Za-z]*\|Package [A-Za-z]+ \)Warning:.*")))
+         "^\(LaTeX [A-Za-z]*\|Package [A-Za-z]+ \)Warning:.*"))
+       (error-found nil))
     (while
        (cond
         ((null
           (re-search-forward regexp nil t))
          ;; No more errors.
-         (message "No more errors.")
-         (beep)
-         (TeX-pop-to-buffer old)
+         (unless store
+           (message "No more errors.")
+           (beep)
+           (TeX-pop-to-buffer old))
          nil)
         ;; TeX error
         ((match-beginning 1)
@@ -1515,15 +1627,17 @@ You might want to examine and modify the free variables 
`file',
              (push nil TeX-error-offset))
            (unless (car TeX-error-offset)
              (rplaca TeX-error-file (TeX-match-buffer 2))))
+         (setq error-found t)
          (if (looking-at "Preview ")
              t
-           (TeX-error)
+           (TeX-error store)
            nil))
         ;; LaTeX bad box
         ((match-beginning 7)
          (if TeX-debug-bad-boxes
              (progn
-               (TeX-warning (TeX-match-buffer 7))
+               (setq error-found t)
+               (TeX-warning (TeX-match-buffer 7) store)
                nil)
            (re-search-forward "
?
\
 \(?:.\{79\}
?
\
@@ -1533,7 +1647,8 @@ You might want to examine and modify the free variables 
`file',
         ((match-beginning 8)
          (if TeX-debug-warnings
              (progn
-               (TeX-warning (TeX-match-buffer 8))
+               (setq error-found t)
+               (TeX-warning (TeX-match-buffer 8) store)
                nil)
            t))
 
@@ -1573,12 +1688,16 @@ You might want to examine and modify the free variables 
`file',
         ((match-beginning 6)
          (setq TeX-error-file
                (list (TeX-match-buffer 6)))
-         t)))))
+         t)))
+    error-found))
+
+(defun TeX-error (&optional store)
+  "Display an error.
 
-(defun TeX-error ()
-  "Display an error."
+If optional argument STORE is non-nil, store the error
+information in `TeX-error-list' instead of displaying the error."
 
-  (let* (;; We need the error message to show the user.
+  (let* ( ;; We need the error message to show the user.
         (error (progn
                  (re-search-forward "\(.*\)")
                  (TeX-match-buffer 1)))
@@ -1622,42 +1741,53 @@ You might want to examine and modify the free variables 
`file',
 
     ;; Remember where we was.
     (setq TeX-error-point (point))
-
-    ;; Find the error.
-    (when (null file)
+    (if store
+       ;; Store the error information.
+       (add-to-list 'TeX-error-list
+                    (list 'error file line error offset context string) t)
+      ;; Find the error point and display the help.
+      (TeX-error--find-display-help
+       file line error offset context string))))
+
+(defun TeX-error--find-display-help (file line error offset context
+                                         string)
+  "Find the error and display the help."
+  ;; Find the error.
+  (if (null file)
       (error "Error occurred after last TeX file closed"))
-    (when (not (file-exists-p file))
-      (error "No such file: %s" file))
-    (let ((runbuf (current-buffer))
-         (master (with-current-buffer
-                     TeX-command-buffer
-                   (expand-file-name (TeX-master-file))))
-         (command-buffer TeX-command-buffer)
-         error-file-buffer)
-      (run-hooks 'TeX-translate-location-hook)
-      (setq error-file-buffer (find-file file))
-      ;; Set the value of `TeX-command-buffer' in the next file with an
-      ;; error to be displayed to the value it has in the current buffer.
-      (with-current-buffer error-file-buffer
-       (set (make-local-variable 'TeX-command-buffer) command-buffer))
-      (goto-char (point-min))
-      (forward-line (+ offset line -1))
-      (if (not (string= string " "))
-         (search-forward string nil t))
-
-      ;; Explain the error.
-      (cond ((eq TeX-display-help 'expert)
-            (TeX-pop-to-buffer runbuf nil t)
-            (goto-char TeX-error-point)
-            (TeX-pop-to-buffer error-file-buffer nil t))
-           (TeX-display-help
-            (TeX-help-error error context runbuf))
-           (t
-            (message (concat "! " error)))))))
-
-(defun TeX-warning (string)
-  "Display a warning for STRING."
-
+  (let ((runbuf (current-buffer))
+       (master (with-current-buffer
+                   TeX-command-buffer
+                 (expand-file-name (TeX-master-file))))
+       (command-buffer TeX-command-buffer)
+       error-file-buffer)
+    (run-hooks 'TeX-translate-location-hook)
+    (setq error-file-buffer (find-file file))
+    ;; Set the value of `TeX-command-buffer' in the next file with an
+    ;; error to be displayed to the value it has in the current buffer.
+    (with-current-buffer error-file-buffer
+      (set (make-local-variable 'TeX-command-buffer) command-buffer))
+    (goto-char (point-min))
+    (forward-line (+ offset line -1))
+    (if (not (string= string " "))
+       (search-forward string nil t))
+
+    ;; Explain the error.
+    (cond ((eq TeX-display-help 'expert)
+          (TeX-pop-to-buffer runbuf nil t)
+          (goto-char TeX-error-point)
+          (TeX-pop-to-buffer error-file-buffer nil t))
+         (TeX-display-help
+          (TeX-help-error error context runbuf))
+         (t
+          (message (concat "! " error))))))
+
+(defun TeX-warning (string &optional store)
+  "Display a warning for STRING.
+
+If optional argument STORE is non-nil, store the warning
+information in `TeX-error-list' instead of displaying the
+warning."
   (let* ((error (concat "** " string))
 
         ;; bad-box is nil if this is a "LaTeX Warning"
@@ -1703,44 +1833,56 @@ You might want to examine and modify the free variables 
`file',
     (goto-char error-point)
     (setq TeX-error-point (point))
 
-    (unless file
-      (error "Could not determine file for warning"))
-
-    ;; Go back to TeX-buffer
-    (let ((runbuf (current-buffer))
-         (master (with-current-buffer
-                     TeX-command-buffer
-                   (expand-file-name (TeX-master-file))))
-         (command-buffer TeX-command-buffer)
-         error-file-buffer)
-      (run-hooks 'TeX-translate-location-hook)
-      (setq error-file-buffer (find-file file))
-      ;; Set the value of `TeX-command-buffer' in the next file with an
-      ;; error to be displayed to the value it has in the current buffer.
-      (with-current-buffer error-file-buffer
-       (set (make-local-variable 'TeX-command-buffer) command-buffer))
-      ;; Find line and string
-      (when line
+    (if store
+       ;; Store the warning information.
+       (add-to-list 'TeX-error-list
+                    (list 'warning file line error offset context
+                          string line-end bad-box) t)
+      ;; Find the warning point and display the help.
+      (TeX-warning--find-display-help
+       file line error offset context string line-end bad-box))))
+
+(defun TeX-warning--find-display-help (file line error offset context
+                                           string line-end bad-box)
+  "Find the warning and display the help."
+  (unless file
+    (error "Could not determine file for warning"))
+
+  ;; Go back to TeX-buffer
+  (let ((runbuf (current-buffer))
+       (master (with-current-buffer
+                   TeX-command-buffer
+                 (expand-file-name (TeX-master-file))))
+       (command-buffer TeX-command-buffer)
+       error-file-buffer)
+    (run-hooks 'TeX-translate-location-hook)
+    (setq error-file-buffer (find-file file))
+    ;; Set the value of `TeX-command-buffer' in the next file with an
+    ;; error to be displayed to the value it has in the current buffer.
+    (with-current-buffer error-file-buffer
+      (set (make-local-variable 'TeX-command-buffer) command-buffer))
+    ;; Find line and string
+    (when line
+      (goto-char (point-min))
+      (forward-line (+ offset line -1))
+      (beginning-of-line 0)
+      (let ((start (point)))
        (goto-char (point-min))
-       (forward-line (+ offset line -1))
-       (beginning-of-line 0)
-       (let ((start (point)))
-         (goto-char (point-min))
-         (forward-line (+ offset line-end -1))
-         (end-of-line)
-         (when string
-           (search-backward string start t)
-           (search-forward string nil t))))
-      ;; Display help
-      (cond ((eq TeX-display-help 'expert)
-            (TeX-pop-to-buffer runbuf nil t)
-            (goto-char TeX-error-point)
-            (TeX-pop-to-buffer error-file-buffer nil t))
-           (TeX-display-help
-            (TeX-help-error error (if bad-box context (concat "
" context))
-                            runbuf))
-           (t
-            (message (concat "! " error)))))))
+       (forward-line (+ offset line-end -1))
+       (end-of-line)
+       (when string
+         (search-backward string start t)
+         (search-forward string nil t))))
+    ;; Display help
+    (cond ((eq TeX-display-help 'expert)
+          (TeX-pop-to-buffer runbuf nil t)
+          (goto-char TeX-error-point)
+          (TeX-pop-to-buffer error-file-buffer nil t))
+         (TeX-display-help
+          (TeX-help-error error (if bad-box context (concat "
" context))
+                          runbuf))
+         (t
+          (message (concat "! " error))))))
 
 ;;; - Help
 
@@ -2249,8 +2391,7 @@ error."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map TeX-special-mode-map)
     (define-key map "n" 'TeX-next-error)
-    ;; TODO: Implement TeX-previous-error
-    ;; (define-key map "p" 'TeX-previous-error)
+    (define-key map "p" 'TeX-previous-error)
     (define-key map "b" 'TeX-toggle-debug-bad-boxes)
     (define-key map "w" 'TeX-toggle-debug-warnings)
     (define-key map "i" (lambda ()
diff --git a/tex-site.el.in b/tex-site.el.in
index 3c43aae..8937315 100644
--- a/tex-site.el.in
+++ b/tex-site.el.in
@@ -116,13 +116,18 @@ definition."
   (let ((list TeX-mode-alist) elt)
     (while list
       (setq elt (car (pop list)))
-      (when (or update (null (get elt 'tex-saved)))
-       (when (fboundp elt)
-         (put elt 'tex-saved (symbol-function elt))))
-      (defalias elt
-       (if (memq elt value)
-           (intern (concat "TeX-" (symbol-name elt)))
-         (get elt 'tex-saved))))))
+      (let ((dst (intern (concat "TeX-" (symbol-name elt)))))
+        (if (fboundp 'advice-add)
+            (if (memq elt value)
+                (advice-add elt :override dst)
+              (advice-remove elt dst))
+          (when (or update (null (get elt 'tex-saved)))
+            (when (fboundp elt)
+              (put elt 'tex-saved (symbol-function elt))))
+          (defalias elt
+            (if (memq elt value)
+                dst
+              (get elt 'tex-saved))))))))
 
 (defcustom TeX-modes
   (mapcar 'car TeX-mode-alist)
@@ -134,13 +139,14 @@ set it with `TeX-modes-set'."
              (mapcar (lambda(x) (list 'const (car x))) TeX-mode-alist))
   :set 'TeX-modes-set
   :group 'AUCTeX
-  :initialize (lambda (var value)
-               (custom-initialize-reset var value)
-               (let ((list TeX-mode-alist))
-                 (while list
-                   (eval-after-load (cdar list)
-                     `(TeX-modes-set ',var ,var t))
-                   (setq list (cdr list))))))
+  :initialize(lambda (var value)
+              (custom-initialize-reset var value)
+              (unless (fboundp 'advice-add)
+                (let ((list TeX-mode-alist))
+                  (while list
+                    (eval-after-load (cdar list)
+                      `(TeX-modes-set ',var ,var t))
+                    (setq list (cdr list)))))) )
 
 (defconst AUCTeX-version "@AUCTEXVERSION@"
     "AUCTeX version.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]