Anonymous avatar Anonymous committed a41a3ea

Hiding preview buffer after previewing

Comments (0)

Files changed (3)

docs/ropemacs.txt

 
   * Code-completion
   * Goto definition
-  * Show PyDoc
+  * Show pydoc
   * Organize imports (remove unused and duplicate imports and sort them)
   * Generating python elements
 

ropemacs/lisputils.py

     return lisp.yes_or_no_p(prompt)
 
 
-def make_buffer(name, contents, empty_goto=True, mode=None):
+def make_buffer(name, contents, empty_goto=True, modes=[]):
     new_buffer = lisp.get_buffer_create(name)
     lisp.set_buffer(new_buffer)
+    lisp.toggle_read_only(-1)
     lisp.erase_buffer()
     if contents or empty_goto:
         lisp.insert(contents)
-        if mode is not None:
+        for mode in modes:
             lisp[mode + '-mode']()
         lisp.display_buffer(new_buffer)
+        lisp.buffer_disable_undo(new_buffer)
+        lisp.toggle_read_only(1)
         lisp.goto_line(1)
 
 
+def hide_buffer(name):
+    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)
+
+
 class RunTask(object):
 
     def __init__(self, task, name, interrupts=True):

ropemacs/refactor.py

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