Commits

Anonymous committed 686be0d

refactor: preview should use the current window

Comments (0)

Files changed (3)

ropemacs/interface.py

         self.project = None
         self.old_content = None
         lisp(DEFVARS)
-        #lisp['pymacs-forget-mutability'] = True
 
         self.global_keys = [
             ('o', lisp.rope_open_project),
 
     def _reload_buffers_for_changes(self, changed_resources,
                                     moved_resources={}):
+        initial = lisp.current_buffer()
         for resource in changed_resources:
             buffer = lisp.find_buffer_visiting(str(resource.real_path))
             if buffer:
                     new_resource = moved_resources[resource]
                     lisp.kill_buffer(buffer)
                     lisp.find_file(new_resource.real_path)
+        lisp.set_buffer(initial)
 
     def _get_moved_resources(self, changes, undo=False):
         result = {}

ropemacs/lisputils.py

     return lisp.yes_or_no_p(prompt)
 
 
-def make_buffer(name, contents, empty_goto=True, switch=False, modes=[]):
+def make_buffer(name, contents, empty_goto=True,
+                switch=False, window='other', modes=[]):
+    """Make an emacs buffer
+
+    `window` can be one of `None`, 'current' or 'other'.
+
+    """
     new_buffer = lisp.get_buffer_create(name)
     lisp.set_buffer(new_buffer)
     lisp.toggle_read_only(-1)
         lisp.insert(contents)
         for mode in modes:
             lisp[mode + '-mode']()
-        lisp.display_buffer(new_buffer)
         lisp.buffer_disable_undo(new_buffer)
         lisp.toggle_read_only(1)
         if switch:
-            lisp.switch_to_buffer_other_window(new_buffer)
+            if window == 'current':
+                lisp.switch_to_buffer(new_buffer)
+            else:
+                lisp.switch_to_buffer_other_window(new_buffer)
+        elif window == 'other':
+            lisp.display_buffer(new_buffer)
         lisp.goto_line(1)
     return new_buffer
 
 
-def hide_buffer(name):
+def hide_buffer(name, delete=True):
     buffer = lisp.get_buffer(name)
     if buffer is not None:
         window = lisp.get_buffer_window(buffer)
         if window is not None:
-            lisp.delete_window(window)
             lisp.bury_buffer(buffer)
+            if delete:
+                lisp.delete_window(window)
+            else:
+                if lisp.buffer_name(lisp.current_buffer()) == name:
+                    lisp.switch_to_buffer(None)
 
 
 class RunTask(object):

ropemacs/refactor.py

         if action == 'preview':
             if changes is not None:
                 diffs = str(changes.get_description())
-                lisputils.make_buffer('*rope-preview*', diffs, modes=['diff'])
+                lisputils.make_buffer('*rope-preview*', diffs, switch=True,
+                                      modes=['diff'], window='current')
                 if lisputils.yes_or_no('Do the changes? '):
                     self._perform(changes)
                 else:
                     lisputils.message('Thrown away!')
-                lisputils.hide_buffer('*rope-preview*')
+                lisputils.hide_buffer('*rope-preview*', delete=False)
             else:
                 lisputils.message('No changes!')
 
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.