[gedit-latex] Use DocumentPrefs to allow one to define their own fixme/issue commands.



commit d621480a35ef6194aebc2532a5892cb8abd7a7a4
Author: John Stowers <john stowers gmail com>
Date:   Wed Aug 17 23:00:52 2011 +1200

    Use DocumentPrefs to allow one to define their
    own fixme/issue commands.
    
    This is a common operation when using the fixme package,
    and markup such as fxnote

 ...org.gnome.gedit.plugins.latex.gschema.xml.in.in |    4 ++++
 latex/latex/validator.py                           |    5 +++++
 test/article.tex                                   |    5 ++++-
 3 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in b/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in
index ec7b930..633bb9b 100644
--- a/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in
+++ b/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in
@@ -55,6 +55,10 @@
       <default>'.'</default>
       <_summary>Paths Relative to .tex File to Look for Graphics</_summary>
     </key>
+    <key name="extra-issue-commands" type="s">
+      <default>'fxnote'</default>
+      <_summary>Extra LaTeX commands used to mark issues, such as \fxnote{foo}</_summary>
+    </key>
 
     <key name="light-foreground-color" type="s">
       <default>'#957d47'</default>
diff --git a/latex/latex/validator.py b/latex/latex/validator.py
index 4be8a12..65c5199 100644
--- a/latex/latex/validator.py
+++ b/latex/latex/validator.py
@@ -65,6 +65,7 @@ class LaTeXValidator(object):
         # cache some settings now to save time
         self._potential_graphics_extensions = [""] + document_preferences.get("graphics-extensions").split(",")
         self._potential_graphics_paths = document_preferences.get("graphics-paths").split(",")
+        self._extra_issue_commands = set([c for c in document_preferences.get("extra-issue-commands").split(",") if len(c)])
 
         # prepare a map for checking labels
         self._labels = {}
@@ -239,6 +240,10 @@ class LaTeXValidator(object):
                     except IndexError:
                         issue_handler.issue(Issue("Malformed command", node.start, node.lastEnd, node.file, Issue.SEVERITY_ERROR))
 
+                elif node.value in self._extra_issue_commands:
+                    text = node.firstOfType(Node.MANDATORY_ARGUMENT).innerText
+                    issue_handler.issue(Issue(text, node.start, node.lastEnd, node.file, Issue.SEVERITY_TASK))
+
             if recurse:
                 self._run(node, issue_handler)
 
diff --git a/test/article.tex b/test/article.tex
index 35a7b0f..bf8b81a 100644
--- a/test/article.tex
+++ b/test/article.tex
@@ -1,5 +1,6 @@
 
-% gedit:graphics-paths = .
+% gedit:extra-issue-commands = testissue
+
 
 \documentclass[12pt]{book}
 \usepackage{graphicx}
@@ -13,10 +14,12 @@
 \newcommand{\testref}[1]{(\ref{#1})}
 \newcommand{\testfoo}{FOO}
 \newcommand{\teste}[1]{\ensuremath{\times 10^{#1}}}
+\newcommand{\testissue}[1]{\textbf{#1}}
 
 \begin{document}
 \maketitle
 
+\testissue{need to fix this}
 
 \chapter{Main Stuff}
 \section{foo}



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