diff --git a/mode/html.py b/mode/html.py index 8111032..c35a62a 100644 --- a/mode/html.py +++ b/mode/html.py @@ -1,4 +1,4 @@ -import color, mode +import color, method, mode from lex import Grammar, PatternRule, RegionRule from mode.xml import TagGrammar from mode.javascript import JavascriptGrammar @@ -27,6 +27,7 @@ class HTML(mode.Fundamental): self.add_bindings('close-paren', (')',)) self.add_bindings('close-brace', ('}',)) self.add_bindings('close-bracket', (']',)) + self.add_action(HtmlCheckSpelling()) _colorbase = { 'start': ('default', 'default'), @@ -43,4 +44,14 @@ for _name in _colorbase: HTML.colors['style.%s' % _name] = _colorbase[_name] HTML.colors['tag.%s' % _name] = _colorbase[_name] +class HtmlCheckSpelling(method.Method): + """Check the spelling of the document via ispell -t""" + def _execute(self, w, **vargs): + # -x no backup file + # -M show context menu + # -H treat input document as HTML + w.application.run_external('ispell', '-x', '-M', '-H', w.buffer.path) + if w.buffer.changed_on_disk(): + w.buffer.reload() + install = HTML.install diff --git a/mode/latex.py b/mode/latex.py index 45c3cb1..1bfe4b7 100644 --- a/mode/latex.py +++ b/mode/latex.py @@ -6,6 +6,7 @@ from mode.text import TextInsertSpace class LatexGrammar(Grammar): rules = [ PatternRule(r'comment', r'\%.*$'), + PatternRule(r'latex_wrapper', r'\\(?:begin|end)'), PatternRule(r'latex_control', r'\\[a-zA-Z]+'), RegionRule(r'latex_argument', r'{', None, r'}'), RegionRule(r'latex_string', r"``", None, r"''"), @@ -19,6 +20,7 @@ class Latex(mode.Fundamental): extensions = ['.latex', '.tex'] grammar = LatexGrammar colors = { + 'latex_wrapper': ('magenta', 'default', 'bold'), 'latex_control': ('blue', 'default', 'bold'), 'latex_argument.null': ('cyan', 'default', 'bold'), 'latex_string.start': ('green', 'default', 'bold'), @@ -113,7 +115,11 @@ class LatexInsertSpace(TextInsertSpace): class LatexCheckSpelling(method.Method): """Check the spelling of the document via ispell -t""" def _execute(self, w, **vargs): - w.application.run_external('ispell', '-M', '-t', w.buffer.path) - w.buffer.reload() + # -x no backup file + # -M show context menu + # -t treat input document as TeX + w.application.run_external('ispell', '-x', '-M', '-t', w.buffer.path) + if w.buffer.changed_on_disk(): + w.buffer.reload() install = Latex.install