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)
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)
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')
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)
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)
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
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)
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
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)
def find_file(self, prefix): file = self._base_find_file(prefix) if file is not None: lisp.find_file(file.real_path)
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))
# 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")
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")