ob-ein: Tap into ein autocompletion for org source edit buffers.

Will try to use ein completion backend configured by user when editing ein
source blocks in org.

Also slightly more robust inspecting in ein_inspector.py
This commit is contained in:
John Miller 2017-09-19 13:08:13 -05:00
parent 15ad1c49c7
commit 1bcc3b87c5
2 changed files with 22 additions and 5 deletions

View file

@ -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)
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__()

View file

@ -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)