예제 #1
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
예제 #2
0
def discover(directory):
    directory = os.path.expanduser(
        directory)  # The tilde does not work with os.chdir
    os.chdir(directory)

    # Discovering tests using unittest framework
    loader = TestLoader()
    tests = loader.discover(directory, top_level_dir=directory)
    result = EmacsTestResult()

    # Create a buffer (if it not exists) and put the formatted results
    # inside it
    let = Let()
    lisp.get_buffer_create("unittest")
    let.push_excursion()
    lisp.set_buffer("unittest")
    lisp.erase_buffer()
    tests.run(result)
    lisp.insert("\n")
    lisp.insert("Errors:\n")
    for test, traceback in result.errors:
        lisp.insert(str(test))
        lisp.insert(traceback)
    let.pop_excursion()

    lisp.pop_to_buffer("unittest")
    lisp.compilation_mode()
    lisp.beginning_of_buffer()
예제 #3
0
def _switchToConsole():
    consolebuf = lisp.get_buffer_create("BicycleRepairManConsole")
    lisp.switch_to_buffer_other_window(consolebuf)
    lisp.compilation_mode("BicycleRepairMan")
    lisp.erase_buffer()
    lisp.insert("Bicycle Repair Man\n")
    lisp.insert("(Hint: Press Return a Link)\n")
예제 #4
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
예제 #5
0
파일: unitdiscover.py 프로젝트: pdee/pdee
def discover(directory):
    directory = os.path.expanduser(directory) # The tilde does not work with os.chdir
    os.chdir(directory)
    
    # Discovering tests using unittest framework
    loader = TestLoader()
    tests = loader.discover(directory, top_level_dir=directory)
    result = EmacsTestResult()
    
    # Create a buffer (if it not exists) and put the formatted results
    # inside it
    let = Let()
    lisp.get_buffer_create("unittest")
    let.push_excursion()
    lisp.set_buffer("unittest")
    lisp.erase_buffer()
    tests.run(result)
    lisp.insert("\n")
    lisp.insert("Errors:\n")
    for test, traceback in result.errors:
        lisp.insert(str(test))
        lisp.insert(traceback)
    let.pop_excursion()
    
    lisp.pop_to_buffer("unittest")
    lisp.compilation_mode()
    lisp.beginning_of_buffer()
예제 #6
0
def _switchToConsole():
    consolebuf = lisp.get_buffer_create("BicycleRepairManConsole")
    lisp.switch_to_buffer_other_window(consolebuf)
    lisp.compilation_mode("BicycleRepairMan")
    lisp.erase_buffer()
    lisp.insert("Bicycle Repair Man\n")
    lisp.insert("(Hint: Press Return a Link)\n")
예제 #7
0
def new_buffer_from_paste(paste):
    """Creates a new buffer from `paste`"""
    lisp.switch_to_buffer('paste %s' % paste.id)
    lisp.erase_buffer()
    lisp.insert(paste.code)
    # simple guessing of the buffer mode
    # XXX: is there a better way?
    # FIXME: do at least a bit of error handling and check, if there is such a mode
    mode = lisp['%s-mode' % paste.language]
    mode()
예제 #8
0
def new_buffer_from_paste(paste):
    """Creates a new buffer from `paste`"""
    lisp.switch_to_buffer('paste {0.id}'.format(paste))
    lisp.erase_buffer()
    lisp.insert(paste.code)
    # simple guessing of the buffer mode
    # XXX: is there a better way?
    # FIXME: do at least a bit of error handling and check, if there is such a mode
    mode = lisp['{0.language}-mode'.format(paste)]
    mode()
예제 #9
0
def insert_in_other_buffer(bufname, text):
    """Creates/erases a buffer with the given name, opens it in a
     separate visible  pane, and pastes the given text into it."""

    lisp.get_buffer_create(bufname)
    lisp.display_buffer(bufname, 1)
    old_buf = lisp.current_buffer()
    lisp.set_buffer(bufname)
    lisp.erase_buffer()
    lisp.insert(text)
    lisp.set_buffer(old_buf)
예제 #10
0
def insert_in_other_buffer(bufname, text):
     """Creates/erases a buffer with the given name, opens it in a
     separate visible  pane, and pastes the given text into it."""
     
     lisp.get_buffer_create(bufname)
     lisp.display_buffer(bufname, 1)
     old_buf = lisp.current_buffer()
     lisp.set_buffer(bufname)
     lisp.erase_buffer()
     lisp.insert(text)
     lisp.set_buffer(old_buf)
예제 #11
0
    # The +1 is because we prefer to have the result of an assignation when the cursor is on it, not one line later.
    var_info = jarvis.commands.external_inspect_vars(filename, line + 1)

    var_info = utils.inspect_format(var_info)

    found = False
    for window in lisp.window_list():
        buffer = lisp.window_buffer(window)
        if lisp.buffer_name(buffer) == BUFFER_NAME:
            found = True


    buffer = lisp.get_buffer_create(BUFFER_NAME)
    lisp.set_buffer(buffer)
    lisp.erase_buffer()
    lisp.insert(str(var_info))

    if not found:
        lisp.split_window_vertically(-10)
        lisp.other_window(1)
        lisp.switch_to_buffer(buffer)
        lisp.goto_line(1)
        lisp.other_window(1)

#    if not timer_installed:

    timer_installed = utils.get_command_global_var(VAR_KEY, False)
    if not timer_installed:
        utils.set_command_global_var(VAR_KEY, True)
        # This is a bit unstable right now, it trigger refresh of the window when needed ...
예제 #12
0
    line = utils.cursor_line_number()

    # The +1 is because we prefer to have the result of an assignation when the cursor is on it, not one line later.
    var_info = jarvis.commands.external_inspect_vars(filename, line + 1)

    var_info = utils.inspect_format(var_info)

    found = False
    for window in lisp.window_list():
        buffer = lisp.window_buffer(window)
        if lisp.buffer_name(buffer) == BUFFER_NAME:
            found = True

    buffer = lisp.get_buffer_create(BUFFER_NAME)
    lisp.set_buffer(buffer)
    lisp.erase_buffer()
    lisp.insert(str(var_info))

    if not found:
        lisp.split_window_vertically(-10)
        lisp.other_window(1)
        lisp.switch_to_buffer(buffer)
        lisp.goto_line(1)
        lisp.other_window(1)

#    if not timer_installed:

    timer_installed = utils.get_command_global_var(VAR_KEY, False)
    if not timer_installed:
        utils.set_command_global_var(VAR_KEY, True)
        # This is a bit unstable right now, it trigger refresh of the window when needed ...