[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 254/299: Simplify error finding and help displaying functions.
From: |
Stefan Monnier |
Subject: |
[elpa] 254/299: Simplify error finding and help displaying functions. |
Date: |
Sun, 02 Nov 2014 03:11:48 +0000 |
monnier pushed a commit to branch externals/auctex
in repository elpa.
commit bc9e5d622852c09d9f8d20a54db601c48cd99c4c
Author: Mosè Giordano <address@hidden>
Date: Sat Jun 21 18:57:23 2014 +0200
Simplify error finding and help displaying functions.
* tex-buf.el (TeX-parse-TeX): Use `TeX-find-display-help' in place
of `TeX-error-list-find-display-help'.
(TeX-error-list-find-display-help): Removed, replaced by more
general `TeX-find-display-help'.
(TeX-find-display-help): New function.
(TeX-error): Append nils to the `TeX-error-list' entry to make
each entry of the same lenght for both errors and warnings.
Append also `TeX-error-point'. This fixes a bug occurring when
`TeX-display-help' is set to `expert'. Use
`TeX-find-display-help' to display the help.
(TeX-warning): Append `TeX-error-point' to the `TeX-error-list'
entry to fix the above mentioned bug. Use `TeX-find-display-help'
to display the help.
---
ChangeLog | 16 ++++++
tex-buf.el | 163 +++++++++++++++++++++++++-----------------------------------
2 files changed, 83 insertions(+), 96 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c663758..f408ff7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2014-06-21 Mos� Giordano <address@hidden>
+
+ * tex-buf.el (TeX-parse-TeX): Use `TeX-find-display-help' in place
+ of `TeX-error-list-find-display-help'.
+ (TeX-error-list-find-display-help): Removed, replaced by more
+ general `TeX-find-display-help'.
+ (TeX-find-display-help): New function.
+ (TeX-error): Append nils to the `TeX-error-list' entry to make
+ each entry of the same lenght for both errors and warnings.
+ Append also `TeX-error-point'. This fixes a bug occurring when
+ `TeX-display-help' is set to `expert'. Use
+ `TeX-find-display-help' to display the help.
+ (TeX-warning): Append `TeX-error-point' to the `TeX-error-list'
+ entry to fix the above mentioned bug. Use `TeX-find-display-help'
+ to display the help.
+
2014-06-04 Mos� Giordano <address@hidden>
* tex-buf.el (TeX-parse-TeX): Use
diff --git a/tex-buf.el b/tex-buf.el
index e006ea6..61f5aa7 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1539,7 +1539,7 @@ already in an Emacs buffer) and the cursor is placed at
the error."
(beep)
(TeX-pop-to-buffer old-buffer))
(t
- (TeX-error-list-find-display-help item))))
+ (apply 'TeX-find-display-help item))))
(goto-char TeX-error-point)
(TeX-parse-error old-buffer)))))
@@ -1688,19 +1688,62 @@ Return non-nil if an error or warning is found."
t)))
error-found))
-(defun TeX-error-list-find-display-help (item)
- "Find the error and display the help associated to it.
-ITEM is an element of `TeX-error-list' with all relevant
-information about the error or warning."
- (let ((type (car item)))
- (apply (intern (concat "TeX-"
- (cond
- ((equal type 'error)
- "error")
- ((or (equal type 'warning) (equal type 'bad-box))
- "warning"))
- "--find-display-help"))
- (cdr item))))
+(defun TeX-find-display-help (type file line error offset context string
+ line-end bad-box error-point)
+ "Find the error and display the help."
+ (unless file
+ (cond
+ ;; XXX: error messages have to be different?
+ ((equal type 'error)
+ (error "Error occurred after last TeX file closed"))
+ (t
+ (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 start)
+ (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 the location of the error or warning.
+ (when line
+ (goto-char (point-min))
+ (forward-line (+ offset line -1))
+ (cond
+ ;; Error.
+ ((equal type 'error)
+ (if (not (string= string " "))
+ (search-forward string nil t)))
+ ;; Warning or bad box.
+ (t
+ (beginning-of-line 0)
+ (setq 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 the help.
+ (cond ((eq TeX-display-help 'expert)
+ (TeX-pop-to-buffer runbuf nil t)
+ (goto-char error-point)
+ (TeX-pop-to-buffer error-file-buffer nil t))
+ (TeX-display-help
+ (TeX-help-error
+ error
+ (if (equal type 'warning) (concat "\n" context) context)
+ runbuf type))
+ (t
+ (message (concat "! " error))))))
(defun TeX-error (&optional store)
"Display an error.
@@ -1755,43 +1798,11 @@ information in `TeX-error-list' instead of displaying
the error."
(if store
;; Store the error information.
(add-to-list 'TeX-error-list
- (list 'error file line error offset context string) t)
+ (list 'error file line error offset context string nil nil
+ TeX-error-point) 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"))
- (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 'error))
- (t
- (message (concat "! " error))))))
+ (TeX-find-display-help
+ 'error file line error offset context string nil nil TeX-error-point))))
(defun TeX-warning (warning &optional store)
"Display a warning for WARNING.
@@ -1800,7 +1811,7 @@ If optional argument STORE is non-nil, store the warning
information in `TeX-error-list' instead of displaying the
warning."
- (let* (;; bad-box is nil if this is a "LaTeX Warning"
+ (let* ( ;; bad-box is nil if this is a "LaTeX Warning"
(bad-box (string-match "\\\\[vh]box.*[0-9]*--[0-9]*" warning))
;; line-string: match 1 is beginning line, match 2 is end line
(line-string (if bad-box " \\([0-9]*\\)--\\([0-9]*\\)"
@@ -1848,52 +1859,12 @@ warning."
;; Store the warning information.
(add-to-list 'TeX-error-list
(list (if bad-box 'bad-box 'warning) file line warning
- offset context string line-end bad-box) t)
+ offset context string line-end bad-box
+ TeX-error-point) t)
;; Find the warning point and display the help.
- (TeX-warning--find-display-help
- file line warning 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-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 "\n" context))
- runbuf (if bad-box 'bad-box 'warning)))
- (t
- (message (concat "! " error))))))
+ (TeX-find-display-help (if bad-box 'bad-box 'warning) file line warning
+ offset context string line-end bad-box
+ TeX-error-point))))
;;; - Help
- [elpa] 247/299: Convert font-latex-fontify-sectioning to float when used as a number., (continued)
- [elpa] 247/299: Convert font-latex-fontify-sectioning to float when used as a number., Stefan Monnier, 2014/11/01
- [elpa] 252/299: Fix possible infinite loop in TeX-parse-all-errors., Stefan Monnier, 2014/11/01
- [elpa] 249/299: Backport from ELPA repository., Stefan Monnier, 2014/11/01
- [elpa] 245/299: Use TeX-esc as completion separator for units in siunitx.el., Stefan Monnier, 2014/11/01
- [elpa] 253/299: Cater for bad boxes in error descriptions., Stefan Monnier, 2014/11/01
- [elpa] 257/299: Fix TeX-find-display-help., Stefan Monnier, 2014/11/01
- [elpa] 251/299: Color TeX Help buffer., Stefan Monnier, 2014/11/01
- [elpa] 255/299: Better check for mgs., Stefan Monnier, 2014/11/01
- [elpa] 258/299: Prettify file names in error overview., Stefan Monnier, 2014/11/01
- [elpa] 259/299: Update Future Development section in manual., Stefan Monnier, 2014/11/01
- [elpa] 254/299: Simplify error finding and help displaying functions.,
Stefan Monnier <=
- [elpa] 263/299: Fix remaining XEmacs compilation issues., Stefan Monnier, 2014/11/01
- [elpa] 260/299: Improve selection of the forward/inverse search method., Stefan Monnier, 2014/11/01
- [elpa] 262/299: Fix some XEmacs compilation issues., Stefan Monnier, 2014/11/01
- [elpa] 264/299: Fix some runtime issues in XEmacs., Stefan Monnier, 2014/11/01
- [elpa] 248/299: Implement TeX-previous-error., Stefan Monnier, 2014/11/01
- [elpa] 267/299: Remove .cvsignore and tests from the release tarball., Stefan Monnier, 2014/11/01
- [elpa] 265/299: Fix other runtime issues in XEmacs and Emacs 21., Stefan Monnier, 2014/11/01
- [elpa] 269/299: Fix outline promotion/demotion., Stefan Monnier, 2014/11/01
- [elpa] 261/299: Hide some entries of the Command menu when not available., Stefan Monnier, 2014/11/01
- [elpa] 256/299: Implement error overview., Stefan Monnier, 2014/11/01