Beispiel #1
0
def new_paste(code, language, filename):
    """Creates a new paste."""
    lisp.message('Transferring paste to server...')
    id = lodgeit.new_paste(code, language, filename=filename)
    paste = lodgeit.get_paste_by_id(id)
    lisp.message(
        'New paste with id {0.id} created. Refer to {0.url}'.format(paste))
    if lisp.paste_kill_url.value():
        lisp.kill_new(paste.url)
    if lisp.paste_show_in_browser.value():
        lisp.browse_url(paste.url)
Beispiel #2
0
def new_paste(code, language, filename):
    """Creates a new paste."""
    lisp.message('Transferring paste to server...')
    id = lodgeit.new_paste(code, language, filename=filename)
    paste = lodgeit.get_paste_by_id(id)
    lisp.message('New paste with id %s created. Refer to %s', paste.id,
                 paste.url)
    if lisp.paste_kill_url.value():
        lisp.kill_new(paste.url)
    if lisp.paste_show_in_browser.value():
        lisp.browse_url(paste.url)
Beispiel #3
0
def new(language, region_start=None, region_end=None):
    """
    Create a new paste.  Use the given (programming) ``language`` for server
    side highlighting.

    If ``region_start`` and ``region_end`` are given, create a paste with
    the contents of this region.

    When called interactively with transient mark mode enabled and an active
    mark, create a paste with the contents of the region.  Otherwise create
    a paste with the contents of the whole buffer.
    """

    lodgeit = lodgeIt()

    mark_active = lisp.mark_active.value()
    transient_mark_mode = lisp.transient_mark_mode.value()
    if lisp.interactive and  transient_mark_mode and mark_active:
        # use a region, if we have one
        region_start = lisp.region_beginning()
        region_end = lisp.region_end()
    elif region_start:
        # otherwise use the given arguments
        region_start = min(region_start, region_end)
        region_end = max(region_start, region_end)
    else:
        # as last resort, paste the whole buffer
        region_start = lisp.point_min_marker()
        region_end = lisp.point_max_marker()

    code = unicode(lisp.buffer_substring(region_start, region_end))
    filename = lisp.buffer_file_name()

    lisp.message('Transferring paste to server...')
    paste_id = lodgeit.new_paste(code, language, filename=filename)
    paste = lodgeit.get_paste_by_id(paste_id)
    lisp.message(
        'New paste with ID {0.id} created. Refer to {0.url}'.format(paste))
    if lisp.paste_kill_url.value():
        lisp.kill_new(paste.url)
    if lisp.paste_show_in_browser.value():
        lisp.browse_url(paste.url)