def dispatch(self, data): """Parses an :emacs-rex command an returns lisp response.""" command, form, package, thread, rid = read_lisp(data) self.package = package self.thread = thread self.id = rid # form is the lisp espression fn = form[0] args = form[1:] method_name = fn.replace(":", "_").replace("-", "_") logging.debug(method_name) logging.debug(args) for i, arg in enumerate(args): if hasattr(arg, 'unquote'): args[i] = arg.unquote() try: response = [ symbol(":return"), { ":ok": getattr(self, method_name)(*args) }, self.id ] except Exception as e: return write_lisp( [symbol(":debug"), 0, 1, [e, False], [], [], self.id]) lisp_response = write_lisp(response) header = "{0:06x}".format(len(lisp_response)) return header + lisp_response
def dispatch(self, data): """Parses an :emacs-rex command an returns lisp response.""" command, form, package, thread, rid = read_lisp(data) self.package = package; self.thread = thread; self.id = rid; fn = form[0]; args = form[1:] method_name = fn.replace(":", "_").replace("-", "_") logger.debug(method_name) logger.debug(args) for i, arg in enumerate(args): if hasattr(arg, 'unquote'): args[i] = arg.unquote() try: response = [ symbol(":return"), {":ok": getattr(self, method_name)(*args)}, self.id ] except Exception as e: return [ symbol(":debug"), 0, 1, [e, False], [], [], self.id ] lisp_response = write_lisp(response) header = "{0:06x}".format(len(lisp_response)) return header + lisp_response
def indentation_update(self): response = [symbol(":indentation-update"), [ cons("def", 1), cons("class", 1), cons("if", 1), cons("else", 1), cons("while", 1), cons("for", 1), cons("try", 1), cons("except", 1), cons("finally", 1) ]] lisp_response = write_lisp(response) header = "{0:06x}".format(len(lisp_response)) return header + lisp_response
def indentation_update(self): response = [ symbol(":indentation-update"), [ cons("def", 1), cons("class", 1), cons("if", 1), cons("else", 1), cons("while", 1), cons("for", 1), cons("try", 1), cons("except", 1), cons("finally", 1) ] ] lisp_response = write_lisp(response) header = "{0:06x}".format(len(lisp_response)) return header + lisp_response