def find_file(self, filename, readonly=False, other=False):
     if other:
         lisp.find_file_other_window(filename)
     elif readonly:
         lisp.find_file_read_only(filename)
     else:
         lisp.find_file(filename)
Beispiel #2
0
 def find_file(self, filename, readonly=False, other=False):
     if other:
         lisp.find_file_other_window(filename)
     elif readonly:
         lisp.find_file_read_only(filename)
     else:
         lisp.find_file(filename)
Beispiel #3
0
def main():    
    d = emacs.get_user_dir("commands")
    name = arg[0]
    name = name.replace("-", "_")
    
    # Check if command already exists
    command_file_name = emacs.get_command_file(name, create = True)
    
    if command_file_name != None:
        lisp.message("Command already exists, opening %s" % command_file_name)
        lisp.find_file(command_file_name)
        return
    
    filename = os.path.join(d, name + ".py")    
    f = open(filename, "w")

    newcommand = """if 'arg' in globals():
    from Pymacs import lisp
    import jarvis.emacs.utils as utils

    # 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()
    lisp.delete_region(start, end)
    lisp.insert('\\n'.join(words))"""

    f.write(newcommand)
    f.close()

    lisp.pymacs_load("jarvis.emacs", "j-")
    lisp.find_file(filename)
Beispiel #4
0
 def project_config(self):
     self._check_project()
     if self.project.ropefolder is not None:
         config = self.project.ropefolder.get_child('config.py')
         lisp.find_file(config.real_path)
     else:
         lisputils.message('No rope project folder found')
Beispiel #5
0
 def _goto_location(self, resource, lineno):
     if resource:
         if resource.project == self.project:
             lisp.find_file(str(resource.real_path))
         else:
             lisp.find_file_read_only(str(resource.real_path))
     if lineno:
         lisp.goto_line(lineno)
Beispiel #6
0
def find_file_at_symbol():
    """
    finds file at point
    """
    fname=lisp.buffer_file_name()
    a = Project(fname)
    thing, start = thing_at_point(RIGHT1, LEFT1)
    file = a.find_file_for_thing(thing, fname)    
    lisp.message(file)
    lisp.find_file(file)
Beispiel #7
0
def promptCallback(filename,line,colbegin,colend):
    let = Let().push_excursion()   # gets popped when let goes out of scope
    buffer = lisp.current_buffer()
    if let:
        ans = 0
        lisp.find_file(filename)
        lisp.goto_line(line)
        lisp.move_to_column(colbegin)
        lisp.set_mark(lisp.point() + (colend - colbegin))
        if is_xemacs:
            lisp.activate_region()
        ans = lisp.y_or_n_p("Couldn't deduce object type - rename this method reference? ")
    del let
    lisp.switch_to_buffer(buffer)
    return ans
Beispiel #8
0
 def _create(self, name, callback, parentname='source'):
     self._check_project()
     confs = {'name': dialog.Data(name.title() + ' name: ')}
     parentname = parentname + 'folder'
     optionals = {parentname: dialog.Data(
             parentname.title() + ' Folder: ',
             default=self.project.address, kind='directory')}
     action, values = dialog.show_dialog(
         lisputils.askdata, ['perform', 'cancel'], confs, optionals)
     if action == 'perform':
         parent = libutils.path_to_resource(
             self.project, values.get(parentname, self.project.address))
         resource = callback(parent, values['name'])
         if resource:
             lisp.find_file(resource.real_path)
 def reload_files(self, filenames, moves={}):
     if self.filename() in moves:
         initial = None
     else:
         initial = lisp.current_buffer()
     for filename in filenames:
         buffer = lisp.find_buffer_visiting(filename)
         if buffer:
             if filename in moves:
                 lisp.kill_buffer(buffer)
                 lisp.find_file(moves[filename])
             else:
                 lisp.set_buffer(buffer)
                 lisp.revert_buffer(False, True)
     if initial is not None:
         lisp.set_buffer(initial)
Beispiel #10
0
 def reload_files(self, filenames, moves={}):
     if self.filename() in moves:
         initial = None
     else:
         initial = lisp.current_buffer()
     for filename in filenames:
         buffer = lisp.find_buffer_visiting(filename)
         if buffer:
             if filename in moves:
                 lisp.kill_buffer(buffer)
                 lisp.find_file(moves[filename])
             else:
                 lisp.set_buffer(buffer)
                 lisp.revert_buffer(False, True)
     if initial is not None:
         lisp.set_buffer(initial)
Beispiel #11
0
def promptCallback(filename, line, colbegin, colend):
    let = Let().push_excursion()  # gets popped when let goes out of scope
    buffer = lisp.current_buffer()
    if let:
        ans = 0
        lisp.find_file(filename)
        lisp.goto_line(line)
        lisp.move_to_column(colbegin)
        lisp.set_mark(lisp.point() + (colend - colbegin))
        if is_xemacs:
            lisp.activate_region()
        ans = lisp.y_or_n_p(
            "Couldn't deduce object type - rename this method reference? ")
    del let
    lisp.switch_to_buffer(buffer)
    return ans
Beispiel #12
0
 def _reload_buffers_for_changes(self, changed_resources,
                                 moved_resources={}):
     if self._get_resource() in moved_resources:
         initial = None
     else:
         initial = lisp.current_buffer()
     for resource in changed_resources:
         buffer = lisp.find_buffer_visiting(str(resource.real_path))
         if buffer:
             if resource.exists():
                 lisp.set_buffer(buffer)
                 lisp.revert_buffer(False, True)
             elif resource in moved_resources:
                 new_resource = moved_resources[resource]
                 lisp.kill_buffer(buffer)
                 lisp.find_file(new_resource.real_path)
     if initial is not None:
         lisp.set_buffer(initial)
Beispiel #13
0
 def find_file(self, prefix):
     file = self._base_find_file(prefix)
     if file is not None:
         lisp.find_file(file.real_path)
Beispiel #14
0
from Pymacs import lisp
import jarvis

errorpath = jarvis.get_filename(jarvis.ERROR_FILE)
f = open(errorpath).read()

finalfilename = None
finalline = None

for l in f.split("\n"):
    if "File \"" in l:
        parts = l.split()
        filename = parts[1][1:-2]
        line = parts[3].strip(",")
        finalfilename = filename
        finalline = line

if finalfilename != None and finalline != None:
    lisp.find_file(finalfilename)
    lisp.goto_line(int(finalline))
Beispiel #15
0
    # Ask for the kind of test to create
    testtypename = lisp.completing_read("What kind of test do you want to create ?", tests)
    if testtypename == None or len(testtypename) == 0:
        testtypename = "simple"

    # Create the test filename
    f = open(testfilename, "w")

    # Find the variable names 
    module = module_name
    shortmodule = module_name.split(".")[-1]
    testclassname = "".join(map(lambda x: x.capitalize(), module_name.split(".")))

    class_names = utils.find_class_names(filename)

    if len(class_names) != 1:
        # Ask for the kind of test to create
        class_name = lisp.completing_read("For which class do you want to create a test ?", class_names)
    else:
        class_name = class_names[0]

    # Run the snippet
    TESTBASE = utils.load_snippet("test_%s_create" % testtypename, module= module, shortmodule = shortmodule, ClassName = class_name, TestClassName = testclassname)
    # Write it into the file
    f.write(TESTBASE)
    f.close()

lisp.find_file(testfilename)

lisp.j_test_filename_function_set(testfilename + ":main")
Beispiel #16
0
    f = open(testfilename, "w")

    # Find the variable names
    module = module_name
    shortmodule = module_name.split(".")[-1]
    testclassname = "".join(
        map(lambda x: x.capitalize(), module_name.split(".")))

    class_names = utils.find_class_names(filename)

    if len(class_names) != 1:
        # Ask for the kind of test to create
        class_name = lisp.completing_read(
            "For which class do you want to create a test ?", class_names)
    else:
        class_name = class_names[0]

    # Run the snippet
    TESTBASE = utils.load_snippet("test_%s_create" % testtypename,
                                  module=module,
                                  shortmodule=shortmodule,
                                  ClassName=class_name,
                                  TestClassName=testclassname)
    # Write it into the file
    f.write(TESTBASE)
    f.close()

lisp.find_file(testfilename)

lisp.j_test_filename_function_set(testfilename + ":main")