def _make_buffer(self, name, contents, empty_goto=True, switch=False,
                     window='other', modes=[], fit_lines=None):
        """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.erase_buffer()
        if contents or empty_goto:
            lisp.insert(contents)
            for mode in modes:
                lisp[mode + '-mode']()
            lisp.buffer_disable_undo(new_buffer)
            lisp.toggle_read_only(1)
            if switch:
                if window == 'current':
                    lisp.switch_to_buffer(new_buffer)
                else:
                    lisp.switch_to_buffer_other_window(new_buffer)
                lisp.goto_char(lisp.point_min())
            elif window == 'other':
                new_window = lisp.display_buffer(new_buffer)
                lisp.set_window_point(new_window, lisp.point_min())
                if fit_lines and lisp.fboundp(lisp['fit-window-to-buffer']):
                    lisp.fit_window_to_buffer(new_window, fit_lines)
                    lisp.bury_buffer(new_buffer)
        return new_buffer
Beispiel #2
0
    def _make_buffer(self,
                     name,
                     contents,
                     empty_goto=True,
                     switch=False,
                     window='other',
                     modes=[],
                     fit_lines=None):
        """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.erase_buffer()
        if contents or empty_goto:
            lisp.insert(contents)
            for mode in modes:
                lisp[mode + '-mode']()
            lisp.buffer_disable_undo(new_buffer)
            lisp.toggle_read_only(1)
            if switch:
                if window == 'current':
                    lisp.switch_to_buffer(new_buffer)
                else:
                    lisp.switch_to_buffer_other_window(new_buffer)
                lisp.goto_char(lisp.point_min())
            elif window == 'other':
                new_window = lisp.display_buffer(new_buffer)
                lisp.set_window_point(new_window, lisp.point_min())
                if fit_lines and lisp.fboundp(lisp['fit-window-to-buffer']):
                    lisp.fit_window_to_buffer(new_window, fit_lines)
                    lisp.bury_buffer(new_buffer)
        return new_buffer
 def _hide_buffer(self, 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.bury_buffer(buffer)
             if delete:
                 lisp.delete_window(window)
             else:
                 if lisp.buffer_name(lisp.current_buffer()) == name:
                     lisp.switch_to_buffer(None)
Beispiel #4
0
 def _hide_buffer(self, 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.bury_buffer(buffer)
             if delete:
                 lisp.delete_window(window)
             else:
                 if lisp.buffer_name(lisp.current_buffer()) == name:
                     lisp.switch_to_buffer(None)