diff --git a/lisp/ein_inspector.py b/lisp/ein_inspector.py index 48a2f79..84dddaf 100644 --- a/lisp/ein_inspector.py +++ b/lisp/ein_inspector.py @@ -32,9 +32,12 @@ def generate_inspector_data(obj_str, globals, locals): else: odata['doc'] = inspect.getdoc(obj) odata['type'], odata['repr'] = determine_object_type(obj) - odata['source_file'] = inspect.getsourcefile(obj) - odata['source_lines'] = inspect.getsourcelines(obj) - + try: + odata['source_file'] = inspect.getsourcefile(obj) + odata['source_lines'] = inspect.getsourcelines(obj) + except: + odata['source_file'] = None + odata['source_lines'] = None print(json.dumps(odata)) return odata @@ -78,6 +81,6 @@ def determine_object_type(obj): elif inspect.ismemberdescriptor(obj): return 'Member Descriptor', obj.__str__() elif inspect.isbuiltin(obj): - return type(obj), obj.__str__() + return str(type(obj)), obj.__str__() else: - return type(obj), obj.__str__() + return str(type(obj)), obj.__str__() diff --git a/lisp/ob-ein.el b/lisp/ob-ein.el index b481b67..1c1e588 100644 --- a/lisp/ob-ein.el +++ b/lisp/ob-ein.el @@ -130,6 +130,20 @@ jupyter kernels. (slot-value cell 'traceback)))) (org-babel-ein-process-outputs (slot-value cell 'outputs) processed-params))))) + +(defun org-babel-edit-prep:ein (babel-info) + "Set up source code completion for editing and EIN source block." + (let ((session (assoc :session (third babel-info)))) + (case ein:completion-backend + (ein:use-ac-backend (ein:complete-on-dot-install python-mode-map 'ein:notebook-complete-dot) + (auto-complete-mode +1)) + (ein:use-ac-jedi-backend (ein:jedi-complete-on-dot-install python-mode-map) + (auto-complete-mode +1)) + (ein:use-company-backend (company-mode +1)) + (ein:use-company-jedi-backend (warn "Support for jedi+company currently not implemented. Defaulting to just company-mode") + (company-mode +1)) + (t nil)))) + ;; This function should be used to assign any variables in params in ;; the context of the session environment. (defun org-babel-prep-session:ein (session params)