Anonymous avatar Anonymous committed 356c0db

Showing file paths in find file

Comments (0)

Files changed (3)

-===========
- Done List
-===========
+======
+ Done
+======
 
+- find file and advanced maching : November 25, 2007
 - generate python element; ``C-c n [vfcmp]`` : November 23, 2007
 - rope find file; ``C-c p f`` : November 23, 2007
 - code-assist; ``M-/`` : November 23, 2007
 
 * specifying refactoring options
 * new file/directory/module/package; C-x p n [fdmp]
-* find file and advanced maching
+* showing proposal type in code-assist
 * code assists when the buffer is changed causes problems
+* only saving python files before refactorings

ropemacs/__init__.py

 
     def do_rename(self, module=False):
         self._check_project()
-        lisp.save_some_buffers()
+        self._save_buffers()
         resource, offset = self._get_location()
         if module:
             offset = None
 
     def _create_mover(self, module=False):
         self._check_project()
-        lisp.save_some_buffers()
+        self._save_buffers()
         resource, offset = self._get_location()
         if module:
             offset = None
     @interactive()
     def inline(self):
         self._check_project()
-        lisp.save_some_buffers()
+        self._save_buffers()
         resource, offset = self._get_location()
         inliner = rope.refactor.inline.create_inline(
             self.project, resource, offset)
     def find_file(self):
         self._check_project()
         files = self.project.get_files()
+        names = []
+        for file in files:
+            names.append('<'.join(reversed(file.path.split('/'))))
         source = lisp.buffer_string()
-        result = _ask_values('Rope Find File: ',
-                             [file.name for file in files], exact=True)
-        for file in files:
-            if result == file.name:
-                lisp.find_file(file.real_path)
+        result = _ask_values('Rope Find File: ', names, exact=True)
+        path = '/'.join(reversed(result.split('<')))
+        file = self.project.get_file(path)
+        lisp.find_file(file.real_path)
 
     def _generate_element(self, kind):
         self._check_project()
+        self._save_buffers()
         resource, offset = self._get_location()
         generator = generate.create_generate(kind, self.project,
                                              resource, offset)
         offset = self._get_offset()
         return resource, offset
 
-    def _get_resource(self):
-        filename = lisp.buffer_file_name()
+    def _get_resource(self, filename=None):
+        if filename is None:
+            filename = lisp.buffer_file_name()
         resource = libutils.path_to_resource(self.project, filename, 'file')
         return resource
 
                 lisp.set_buffer(buffer)
                 lisp.revert_buffer(None, 1)
 
+    def _save_buffers(self, ask=True):
+        if ask:
+            lisp.save_some_buffers()
+        else:
+            current_buffer = lisp.current_buffer()
+            buffers = lisp.buffer_list()
+            for buffer in buffers:
+                filename = lisp.buffer_file_name(buffer)
+                if filename:
+                    resource = self._get_resource(filename)
+                    if resource.exists() and \
+                       self.project.pycore.is_python_file(resource):
+                        lisp.set_buffer(buffer)
+                        lisp.save_buffer()
+            lisp.set_buffer(current_buffer)
+
 
 def _register_functions(interface):
     for attrname in dir(interface):
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.