[latexila/wip/latexila-next: 2/2] PostProcessorLatexmk: better heuristic for setting has-details
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/latexila-next: 2/2] PostProcessorLatexmk: better heuristic for setting has-details
- Date: Tue, 30 Sep 2014 19:05:16 +0000 (UTC)
commit 417278a29a11b8e4a7382062b3d0fc8d6de593f3
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Sep 30 21:02:18 2014 +0200
PostProcessorLatexmk: better heuristic for setting has-details
src/liblatexila/latexila-post-processor-latex.c | 14 +++++++++++
src/liblatexila/latexila-post-processor-latex.h | 6 +++-
src/liblatexila/latexila-post-processor-latexmk.c | 25 ++++++++++++++++-----
3 files changed, 37 insertions(+), 8 deletions(-)
---
diff --git a/src/liblatexila/latexila-post-processor-latex.c b/src/liblatexila/latexila-post-processor-latex.c
index 7e585d6..72876e2 100644
--- a/src/liblatexila/latexila-post-processor-latex.c
+++ b/src/liblatexila/latexila-post-processor-latex.c
@@ -1443,3 +1443,17 @@ latexila_post_processor_latex_new (void)
{
return g_object_new (LATEXILA_TYPE_POST_PROCESSOR_LATEX, NULL);
}
+
+/**
+ * latexila_post_processor_latex_get_errors_count:
+ * @pp: a #LatexilaPostProcessorLatex.
+ *
+ * Returns: the number of errors.
+ */
+gint
+latexila_post_processor_latex_get_errors_count (LatexilaPostProcessorLatex *pp)
+{
+ g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR_LATEX (pp), 0);
+
+ return pp->priv->errors_count;
+}
diff --git a/src/liblatexila/latexila-post-processor-latex.h b/src/liblatexila/latexila-post-processor-latex.h
index ab980e6..ea602c2 100644
--- a/src/liblatexila/latexila-post-processor-latex.h
+++ b/src/liblatexila/latexila-post-processor-latex.h
@@ -48,9 +48,11 @@ struct _LatexilaPostProcessorLatexClass
LatexilaPostProcessorClass parent_class;
};
-GType latexila_post_processor_latex_get_type (void) G_GNUC_CONST;
+GType latexila_post_processor_latex_get_type (void) G_GNUC_CONST;
-LatexilaPostProcessor * latexila_post_processor_latex_new (void);
+LatexilaPostProcessor * latexila_post_processor_latex_new (void);
+
+gint latexila_post_processor_latex_get_errors_count (LatexilaPostProcessorLatex *pp);
G_END_DECLS
diff --git a/src/liblatexila/latexila-post-processor-latexmk.c
b/src/liblatexila/latexila-post-processor-latexmk.c
index fbb397f..23357b7 100644
--- a/src/liblatexila/latexila-post-processor-latexmk.c
+++ b/src/liblatexila/latexila-post-processor-latexmk.c
@@ -522,6 +522,8 @@ run_latex_post_processor (LatexilaPostProcessorLatexmk *pp,
LatexilaBuildMsg *msg;
GQueue *initial_children;
GList *l;
+ gboolean has_details;
+ gint latex_errors_count;
g_assert (pp->priv->last_latex_sub_command != NULL);
g_assert (pp->priv->last_latex_lines != NULL);
@@ -544,7 +546,6 @@ run_latex_post_processor (LatexilaPostProcessorLatexmk *pp,
initial_children = msg->children;
msg->children = latexila_post_processor_take_messages (pp_latex);
- g_object_unref (pp_latex);
pp->priv->last_latex_messages = msg->children->head;
@@ -559,12 +560,24 @@ run_latex_post_processor (LatexilaPostProcessorLatexmk *pp,
/* Expand only the last latex command. */
msg->expand = TRUE;
- /* Almost all the time, the user wants to see only the latex output.
- * If an error has occured, we verify if the last command was a latex command.
- * If it is the case, there is no need to show all output.
+ /* Set has-details.
+ * Almost all the time, the user wants to see only the latex output.
+ */
+
+ /* Another solution is to know if the last rule was a latex rule, but it
+ * doesn't work well. For example if a BibTeX error occurs, Latexmk run the
+ * latex command a second time, so the last command is latex, but the latex
+ * output has no errors, the error is only in BibTeX.
+ * So it's probably better to check the number of latex errors, as is done
+ * below.
*/
- if (succeeded || pp->priv->last_rule_is_latex_rule)
- g_object_set (pp, "has-details", TRUE, NULL);
+
+ latex_errors_count = latexila_post_processor_latex_get_errors_count (LATEXILA_POST_PROCESSOR_LATEX
(pp_latex));
+
+ has_details = succeeded || latex_errors_count > 0;
+ g_object_set (pp, "has-details", has_details, NULL);
+
+ g_object_unref (pp_latex);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]