emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-e-latex--collect-errors
@ 2012-09-15 11:34 Philipp Kroos
  2012-09-15 12:28 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Philipp Kroos @ 2012-09-15 11:34 UTC (permalink / raw)
  To: orgmode

Hi,

the attached patch tries to solve two issues:
- Currently, org-e-latex--collect-errors only finds errors in 
  pdf.*latex-logs. I removed the `pdf`, cause most of the time I'm using 
  xelatex which wouldn't match. I don't know if this is generic enough 
  for all engines though.
- Occasionally, I'm running into errors currently not matched (Like 
  'Runaway argument'). What about the customizable 
  org-e-latex-known-errors introduced in the patch that would allow the 
  user to adjust the matcher to his needs and the used engine?
  This also makes the code more concise.

What do you think about this?
(The first customizable I ever wrote, I think it's correct like this, is 
it?)

Thanks,
Philipp


From 0ea78f6ffa3a53e0e07b3df6d532e48cf1b2df7c Mon Sep 17 00:00:00 2001
From: Philipp Kroos <philipp.kroos@t-online.de>
Date: Sat, 15 Sep 2012 13:11:58 +0200
Subject: [PATCH] org-e-latex: Introduced org-e-latex-known-errors

* contrib/lisp/org-e-latex.el: new customizable org-e-latex-known-errors
  is an alist of possible errors, taken from org-e-latex--collect-errors

* contrib/lisp/org-e-latex.el (org-e-latex--collect-errors):
  More concise code.
  The previous explicit search for errors is replaced by an iteration
  over the alist org-e-latex-known-errors.
---
 contrib/lisp/org-e-latex.el | 42 ++++++++++++++++++++++++++----------------
 1 Datei geändert, 26 Zeilen hinzugefügt(+), 16 Zeilen entfernt(-)

diff --git a/contrib/lisp/org-e-latex.el b/contrib/lisp/org-e-latex.el
index 458579c..2e0604f 100644
--- a/contrib/lisp/org-e-latex.el
+++ b/contrib/lisp/org-e-latex.el
@@ -2698,6 +2698,26 @@ Return PDF file name or an error if it couldn't be produced."
 	    pdffile))
       (set-window-configuration wconfig))))
 
+
+(defcustom org-e-latex-known-errors
+  '(("Reference.*?undefined" .  "[undefined reference]")
+    ("Citation.*?undefined" .  "[undefined citation]")
+    ("Undefined control sequence" .  "[undefined control sequence]")
+    ("^! LaTeX.*?Error" .  "[LaTeX error]")
+    ("^! Package.*?Error" .  "[package error]")
+    ("Runaway argument" .  "Runaway argument"))
+  "Alist of regular expressions and associated messages for the user.
+   The regular expressions are used to find possible errors in
+   the log of a latex-run."
+  
+  :group 'org-export-e-latex
+  :type '(repeat
+	  (cons
+	   (string :tag "Regexp")
+	   (string :tag "Message"))))
+
+    
+
 (defun org-e-latex--collect-errors (buffer)
   "Collect some kind of errors from \"pdflatex\" command output.
 
@@ -2709,26 +2729,16 @@ none."
     (save-excursion
       (goto-char (point-max))
       ;; Find final "pdflatex" run.
-      (when (re-search-backward "^[ \t]*This is pdf.*?TeX.*?Version" nil t)
+      (when (re-search-backward "^[ \t]*This is .*?TeX.*?Version" nil t)
 	(let ((case-fold-search t)
 	      (errors ""))
-	  (when (save-excursion
-		  (re-search-forward "Reference.*?undefined" nil t))
-	    (setq errors (concat errors " [undefined reference]")))
-	  (when (save-excursion
-		  (re-search-forward "Citation.*?undefined" nil t))
-	    (setq errors (concat errors " [undefined citation]")))
-	  (when (save-excursion
-		  (re-search-forward "Undefined control sequence" nil t))
-	    (setq errors (concat errors " [undefined control sequence]")))
-	  (when (save-excursion
-		  (re-search-forward "^! LaTeX.*?Error" nil t))
-	    (setq errors (concat errors " [LaTeX error]")))
-	  (when (save-excursion
-		  (re-search-forward "^! Package.*?Error" nil t))
-	    (setq errors (concat errors " [package error]")))
+	  (dolist (latex-error org-e-latex-known-errors)
+	    (when (save-excursion
+		    (re-search-forward (car latex-error) nil t))
+	      (setq errors (concat errors " " (cdr latex-error)))))
 	  (and (org-string-nw-p errors) (org-trim errors)))))))
 
 
+
 (provide 'org-e-latex)
 ;;; org-e-latex.el ends here
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-15 13:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-15 11:34 [PATCH] org-e-latex--collect-errors Philipp Kroos
2012-09-15 12:28 ` Nicolas Goaziou
2012-09-15 13:08   ` Philipp Kroos
2012-09-15 13:23     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).