Commits

Ali Gholami Rudi  committed a41a3ea

Hiding preview buffer after previewing

  • Participants
  • Parent commits dbb91de

Comments (0)

Files changed (3)

File docs/ropemacs.txt

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

File 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):

File 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!')