Anonymous avatar Anonymous committed fd21f1b

ropemacs: added a few buffer commands to LispUtils

Comments (0)

Files changed (2)

ropecommon/interface.py

             self.env.message('No docs avilable!')
 
     def _get_text(self):
-        if not lisp.buffer_modified_p():
+        if not self.env.is_modified():
             return self._get_resource().read()
         return self.env.get_text()
 
             self.env.find_file(str(resource.real_path),
                                resource.project == self.project)
         if lineno:
-            lisp.goto_line(lineno)
+            self.env.goto_line(lineno)
 
     def _get_location(self):
         resource = self._get_resource()
             if arg == 0:
                 arg = len(names)
             common_start = self._calculate_prefix(names[:arg])
-            lisp.insert(common_start[self.offset - self.starting_offset:])
+            self.env.insert(common_start[self.offset - self.starting_offset:])
             self._starting = common_start
             self._offset = self.starting_offset + len(common_start)
         prompt = 'Completion for %s: ' % self.expression
         if ' : ' in assist:
             name, module = assist.rsplit(' : ', 1)
             lisp.delete_region(self.starting_offset + 1, self.offset + 1)
-            lisp.insert(name)
+            self.env.insert(name)
             self._insert_import(name, module)
         else:
             lisp.delete_region(self.starting_offset + 1, self.offset + 1)
-            lisp.insert(assist)
+            self.env.insert(assist)
 
     def _calculate_proposals(self):
         self.interface._check_project()
 
     def _insert_import(self, name, module):
         lineno = self.autoimport.find_insertion_line(self.source)
-        current = lisp.point()
-        lisp.goto_line(lineno)
-        newimport = 'from %s import %s\n' % (module, name)
-        lisp.insert(newimport)
-        lisp.goto_char(current + len(newimport))
+        line = 'from %s import %s' % (module, name)
+        self.env.insert_line(line, lineno)
 
     def _calculate_prefix(self, names):
         if not names:
     def filename(self):
         return lisp.buffer_file_name()
 
+    def is_modified(self):
+        return lisp.buffer_modified_p()
+
+    def goto_line(self, lineno):
+        lisp.goto_line(lineno)
+
+    def insert_line(self, line, lineno):
+        current = lisp.point()
+        lisp.goto_line(lineno)
+        lisp.insert(line + '\n')
+        lisp.goto_char(current + len(line) + 1)
+
+    def insert(self, text):
+        lisp.insert(text)
+
     def filenames(self):
         result = []
         for buffer in lisp.buffer_list():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.