Permalink
Browse files

no need to import snippets.Document on every ui update

  • Loading branch information...
1 parent 1643164 commit e7bba2889ea8a52c42920d213c08578b45d45263 @fmarcia committed Jun 4, 2010
Showing with 13 additions and 8 deletions.
  1. +13 −8 zencoding/zen_editor.py
View
@@ -24,6 +24,13 @@
from html_navigation import HtmlNavigation
from lorem_ipsum import lorem_ipsum
+try:
+ sys.path.append('/usr/lib/gedit-2/plugins')
+ from snippets.Document import Document as SnippetDocument
+ USE_SNIPPETS = True
+except:
+ USE_SNIPPETS = False
+
class ZenSnippet():
def __init__(self, abbreviation, content):
@@ -92,7 +99,7 @@ def set_context(self, view):
if self.document:
zen_core.set_variable('charset', self.document.get_encoding().get_charset())
- self.view = view #self.window.get_active_view()
+ self.view = view
if self.view:
self.buffer = self.view.get_buffer()
if self.view.get_insert_spaces_instead_of_tabs():
@@ -102,13 +109,11 @@ def set_context(self, view):
#zen_core.set_newline(???)
- if self.view and not (self.view in self.snippet_document):
- try:
- sys.path.append('/usr/lib/gedit-2/plugins')
- from snippets.Document import Document
- self.snippet_document[self.view] = Document(None, self.view)
- except:
- self.snippet_document[self.view] = None
+ if USE_SNIPPETS and self.view:
+ if not (self.view in self.snippet_document):
+ self.snippet_document[self.view] = SnippetDocument(None, self.view)
+ else:
+ self.snippet_document[self.view] = None
def get_selection_range(self):

0 comments on commit e7bba28

Please sign in to comment.