Esempio n. 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
Esempio n. 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
Esempio n. 3
0
def ask_directory(prompt, default=None, starting=None):
    if default is not None:
        prompt = prompt + ('[%s] ' % default)
    if lisp.fboundp(lisp['read-directory-name']):
        result = lisp.read_directory_name(prompt, starting, default)
    else:
        result = lisp.read_file_name(prompt, starting, default)
    if result == '' and default is not None:
        return default
    return result
Esempio n. 4
0
 def ask_directory(self, prompt, default=None, starting=None):
     location = starting or default
     if location is not None:
         prompt = prompt + ('[%s] ' % location)
     if lisp.fboundp(lisp['read-directory-name']):
         # returns default when starting is entered
         result = lisp.read_directory_name(prompt, location, location)
     else:
         result = lisp.read_file_name(prompt, location, location)
     if result == '' and location is not None:
         return location
     return result
Esempio n. 5
0
 def ask_directory(self, prompt, default=None, starting=None):
     location = starting or default
     if location is not None:
         prompt = prompt + ('[%s] ' % location)
     if lisp.fboundp(lisp['read-directory-name']):
         # returns default when starting is entered
         result = lisp.read_directory_name(prompt, location, location)
     else:
         result = lisp.read_file_name(prompt, location, location)
     if result == '' and location is not None:
         return location
     return result
Esempio n. 6
0
 def create_progress(self, name):
     if lisp.fboundp(lisp['make-progress-reporter']):
         progress = _LispProgress(name)
     else:
         progress = _OldProgress(name)
     return progress
Esempio n. 7
0
 def create_progress(self, name):
     if lisp.fboundp(lisp['make-progress-reporter']):
         progress = _LispProgress(name)
     else:
         progress = _OldProgress(name)
     return progress