コード例 #1
0
def get_region(delete=0):
    """Returns the text of the current region, optionally
     deleting the region from the buffer."""

    start = lisp.point()
    end = lisp.mark(lisp.t)
    text = lisp.buffer_substring(start, end)
    if delete:
        lisp.delete_region(start, end)
    return text
コード例 #2
0
ファイル: pymdev.py プロジェクト: emacsvsvi/linux-dev-env
def get_region(delete=0):
     """Returns the text of the current region, optionally
     deleting the region from the buffer."""
     
     start = lisp.point()
     end = lisp.mark(lisp.t)
     text = lisp.buffer_substring(start, end)
     if delete:
          lisp.delete_region(start, end)
     return text
コード例 #3
0
ファイル: jhr.py プロジェクト: joehakimrahme/.emacs.d
def camelCase_to_underscore():
    start, end = lisp.point(), lisp.mark(True)
    text = lisp.buffer_substring(start, end)

    replacement =re.sub(r'\w+',
                        lambda x: "".join(upper_split_gen(x)),
                        text)

    lisp.delete_region(start, end)
    lisp.insert(replacement)
コード例 #4
0
ファイル: enshell_plugin.py プロジェクト: LRFrank/envisage
def run_text():
    start = lisp.point()
    end = lisp.mark(True)
    if start > end:
        start, end = end, start
    text = lisp.buffer_substring(start, end)
    if len(text):
        client.run_text(text)
    else:
        # TODO Complain in message bar
        pass
コード例 #5
0
ファイル: manglers.py プロジェクト: markwatson/Emacs.d
def replace_region(replacer):
    start = lisp.point()
    end = lisp.mark(True)
    if start > end:
        start, end = end, start
    text = lisp.buffer_substring(start, end)

    replacement = replacer(text)

    lisp.delete_region(start, end)
    lisp.insert(replacement)
コード例 #6
0
def _getCoords():
    line = lisp.count_lines(1, lisp.point())
    col = lisp.current_column()
    if col == 0:
        line += 1  # get round 'if col == 0, then line is 1 out' problem

    if mark_exists() and lisp.point() > lisp.mark():
        lisp.exchange_point_and_mark()
        col = lisp.current_column()
        lisp.exchange_point_and_mark()
    return line, col
コード例 #7
0
def run_text():
    start = lisp.point()
    end = lisp.mark(True)
    if start > end:
        start, end = end, start
    text = lisp.buffer_substring(start, end)
    if len(text):
        client.run_text(text)
    else:
        # TODO Complain in message bar
        pass
コード例 #8
0
def _getCoords():
    line = lisp.count_lines(1,lisp.point())
    col = lisp.current_column()
    if col == 0:            
        line += 1  # get round 'if col == 0, then line is 1 out' problem

    if mark_exists() and lisp.point() > lisp.mark():
        lisp.exchange_point_and_mark()
        col = lisp.current_column()
        lisp.exchange_point_and_mark()
    return line,col
コード例 #9
0
ファイル: peval.py プロジェクト: caitouwh/kod
def pexec_region():
    global glob
    start = time.time()
    start, end = lisp.point(), lisp.mark(lisp.t)
    content = lisp.buffer_substring(start, end)
    lines = content.split("\n")
    for line in lines:
        line = line.replace("\n","")
        if line != "":
            c = compile(source=line,filename="",mode="single")
            eval(c,glob)
    elapsed = (time.time() - start)
    lisp.message("Ran in " + str(elapsed) + " seconds")
コード例 #10
0
ファイル: pym.py プロジェクト: Airead/airemacs.d
def cut_region(mode='string'):
    """Return the active region and remove it from Emacs.

    The mode parameter (default 'string') defines whether to return the region
    as a string or as a list of lines (mode='list').

    It is the caller's responsibility to insert the updated text at the
    end back in the Emacs buffer with a call to lisp.insert(...)."""

    start, end = lisp.point(), lisp.mark(lisp.t)
    # BUG: buffer_substring() can't extract regions with dos line endings (\r\n)
    # It dumps a traceback.
    region = lisp.buffer_substring(start, end)
    if mode == 'list':
        region = region.splitlines()
    lisp.delete_region(start, end)
    return region
コード例 #11
0
ファイル: pym.py プロジェクト: caseboy01/myemacs
def cut_region(mode='string'):
    """Return the active region and remove it from Emacs.

    The mode parameter (default 'string') defines whether to return the region
    as a string or as a list of lines (mode='list').

    It is the caller's responsibility to insert the updated text at the
    end back in the Emacs buffer with a call to lisp.insert(...)."""

    start, end = lisp.point(), lisp.mark(lisp.t)
    # BUG: buffer_substring() can't extract regions with dos line endings (\r\n)
    # It dumps a traceback.
    region = lisp.buffer_substring(start, end)
    if mode == 'list':
        region = region.splitlines()
    lisp.delete_region(start, end)
    return region
コード例 #12
0
ファイル: prettify.py プロジェクト: aviramc/.emacs.d
    def wrapper():
        if lisp.mark_active.value():
            # fetch marked text
            start = lisp.point()
            end = lisp.mark(True)
        else:
            # fetch full line
            start = lisp.line_beginning_position()
            end = lisp.line_end_position()

        start, end = min(start, end), max(start, end)
            
        text = lisp.buffer_substring(start, end)
        new_text = func(text)
        if isinstance(new_text, str):
            # replace text with new text
            lisp.delete_region(start, end)
            lisp.insert(new_text)
コード例 #13
0
    def wrapper():
        if lisp.mark_active.value():
            # fetch marked text
            start = lisp.point()
            end = lisp.mark(True)
        else:
            # fetch full line
            start = lisp.line_beginning_position()
            end = lisp.line_end_position()

        start, end = min(start, end), max(start, end)

        text = lisp.buffer_substring(start, end)
        new_text = func(text)
        if isinstance(new_text, str):
            # replace text with new text
            lisp.delete_region(start, end)
            lisp.insert(new_text)
コード例 #14
0
ファイル: rebox.py プロジェクト: caseboy01/myemacs
    def find_region(self):
        """\
Return the limits of the region.
"""
        return lisp.point(), lisp.mark(lisp.t)
コード例 #15
0
ファイル: blank_cleanup.py プロジェクト: jaouad00/jarvis-1
if 'arg' in globals():
    from Pymacs import lisp

    # Retrieve current buffer file name
    filename = lisp.buffer_file_name()

    # Sample code : break on whitespace
    start, end = lisp.point(), lisp.mark(True)
    words = lisp.buffer_substring(start, end).split("\n")

    words = map(lambda x: x.rstrip(" "), words)
    lisp.delete_region(start, end)
    lisp.insert('\n'.join(words))
コード例 #16
0
ファイル: pyfuncs.py プロジェクト: bendikro/emacs-conf
def break_on_whitespace():
    start, end = lisp.point(), lisp.mark(True)
    words = lisp.buffer_substring(start, end).split()
    lisp.delete_region(start, end)
    lisp.insert('\n'.join(words))
コード例 #17
0
ファイル: blank_cleanup.py プロジェクト: Faqer/jarvis
if 'arg' in globals():
    from Pymacs import lisp

    # Retrieve current buffer file name
    filename = lisp.buffer_file_name()
    
    # Sample code : break on whitespace
    start, end = lisp.point(), lisp.mark(True)
    words = lisp.buffer_substring(start, end).split("\n")

    words = map(lambda x : x.rstrip(" "), words)
    lisp.delete_region(start, end)        
    lisp.insert('\n'.join(words))
コード例 #18
0
def mark_exists():
    if is_xemacs:
        return lisp.mark()
    else:
        return lisp("mark-active") and lisp.mark()
コード例 #19
0
def mark_exists():
    if is_xemacs:
        return lisp.mark()
    else:
        return lisp("mark-active") and lisp.mark()
コード例 #20
0
ファイル: pyfuncs.py プロジェクト: paxperscientiam/emacs-conf
def break_on_whitespace():
    start, end = lisp.point(), lisp.mark(True)
    words = lisp.buffer_substring(start, end).split()
    lisp.delete_region(start, end)
    lisp.insert('\n'.join(words))
コード例 #21
0
ファイル: rebox.py プロジェクト: ing7t/kod
    def find_region(self):
        """\
Return the limits of the region.
"""
        return lisp.point(), lisp.mark(lisp.t)