Anonymous avatar Anonymous committed ca478a7

ropemacs: added LispUtils.find_file()

Comments (0)

Files changed (2)

ropecommon/interface.py

         if tokens:
             resource = self.project.get_resource(tokens[0])
             offset = int(tokens[2])
-            lisp.find_file_other_window(resource.real_path)
+            self.env.find_file(resource.real_path, other=True)
             lisp.goto_char(offset + 1)
             lisp.switch_to_buffer_other_window('*rope-occurrences*')
 
     def find_file(self, prefix):
         file = self._base_find_file(prefix)
         if file is not None:
-            lisp.find_file(file.real_path)
+            self.env.find_file(file.real_path)
 
     @decorators.global_command('4 f', 'P')
     def find_file_other_window(self, prefix):
         file = self._base_find_file(prefix)
         if file is not None:
-            lisp.find_file_other_window(file.real_path)
+            self.env.find_file(file.real_path, other=True)
 
     def _base_find_file(self, prefix):
         self._check_project()
         self._check_project()
         if self.project.ropefolder is not None:
             config = self.project.ropefolder.get_child('config.py')
-            lisp.find_file(config.real_path)
+            self.env.find_file(config.real_path)
         else:
             self.env.message('No rope project folder found')
 
                 self.project, values.get(parentname, self.project.address))
             resource = callback(parent, values['name'])
             if resource:
-                lisp.find_file(resource.real_path)
+                self.env.find_file(resource.real_path)
 
     def _goto_location(self, resource, lineno):
         if resource:
-            if resource.project == self.project:
-                lisp.find_file(str(resource.real_path))
-            else:
-                lisp.find_file_read_only(str(resource.real_path))
+            self.env.find_file(str(resource.real_path),
+                               resource.project == self.project)
         if lineno:
             lisp.goto_line(lineno)
 
         if initial is not None:
             lisp.set_buffer(initial)
 
+    def find_file(self, filename, readonly=False, other=False):
+        if other:
+            self.find_file_other_window(filename)
+        elif not readonly:
+            lisp.find_file(filename)
+        else:
+            lisp.find_file_read_only(filename)
+
     def make_buffer(self, name, contents, empty_goto=True, switch=False,
                     window='other', modes=[], fit_lines=None):
         """Make an emacs buffer
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.