mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 07:41:37 -05:00
Remove unused code
This commit is contained in:
parent
a28952c643
commit
5f902e1593
1 changed files with 0 additions and 66 deletions
|
@ -62,72 +62,6 @@ See `org-babel-jupyter-file-name'."
|
|||
(defvar org-babel-jupyter-language-regex "^[ \t]*#\\+begin_src[ \t]+jupyter-\\([^ \f\t\n\r\v]+\\)[ \t]*"
|
||||
"Regular expression used to extract a source block's language name.")
|
||||
|
||||
;; TODO: Handle the case when the kernel changes
|
||||
;;
|
||||
;; TODO: How to cache results properly? To handle the case when the kernel
|
||||
;; argument changes, we are checking for lang every time. Previously we were
|
||||
;; adding a text property at the beginning of the block, what we can do instead
|
||||
;; is add one as the last character of the kernel argument.
|
||||
;;
|
||||
;;
|
||||
;; FIXME: Parsing with `org-element-at-point' seems to depend on how far away a
|
||||
;; source block is from the subtree header line. This is not good if we want
|
||||
;; this to be fast, it seems the default value of `org-element-use-cache' is to
|
||||
;; blame. In the meantime, do not write large subtrees or large src blocks.
|
||||
;; Shouldn't have to anyway.
|
||||
(defun org-babel-jupyter-src-block-lang (&optional context)
|
||||
"Get the kernel language of a Jupyter src-block.
|
||||
CONTEXT should be a src-block org element and and defaults to the
|
||||
`org-element-context'."
|
||||
(or context (setq context (org-element-context)))
|
||||
(let ((type (org-element-type context)))
|
||||
(when (and (memq type '(src-block inline-src-block))
|
||||
(equal (org-element-property :language context) "jupyter"))
|
||||
(let* ((kernel
|
||||
(or (alist-get
|
||||
:kernel
|
||||
(ignore-errors
|
||||
(org-babel-parse-header-arguments
|
||||
(org-element-property :parameters context))))
|
||||
(alist-get
|
||||
:kernel
|
||||
(ignore-errors
|
||||
(apply #'append
|
||||
(mapcar #'org-babel-parse-header-arguments
|
||||
(org-element-property :header context)))))
|
||||
(alist-get
|
||||
:kernel
|
||||
(ignore-errors
|
||||
(org-with-point-at
|
||||
(org-element-property :begin context)
|
||||
;; FIXME: This looks expensive, but it seems like
|
||||
;; having the kernel language be a file local variable
|
||||
;; would be common
|
||||
(org-babel-params-from-properties "jupyter"))))))
|
||||
;; Possibly cache based on the kernel name. Since
|
||||
;; `jupyter-find-kernelspecs' matches prefixes, it could
|
||||
;; possibly match single letters which is not good.
|
||||
(spec (cddar (jupyter-find-kernelspecs kernel))))
|
||||
(plist-get spec :language)))))
|
||||
|
||||
;; All calls of `org-src--get-lang-mode' in `org-src' currently have `point' at
|
||||
;; the src-block <2018-01-23 Tue>.
|
||||
;; (defun org-babel-jupyter--get-lang-mode (orig-fun lang &rest args)
|
||||
;; "Identical to `org-src--get-lang-mode' but handle jupyter blocks specially.
|
||||
;; This is an advice function for `org-src--get-lang-mode' which
|
||||
;; should be passed as the ORIG-FUN argument. Whenever LANG is
|
||||
;; \"jupyter\" pass the result of `org-babel-jupyter-src-block-lang'
|
||||
;; to ORIG-FUN as its first argument instead of \"jupyter\". ARGS
|
||||
;; are any additional arguments to pass to ORIG-FUN. This should be
|
||||
;; nil."
|
||||
;; (apply orig-fun
|
||||
;; (if (equal lang "jupyter")
|
||||
;; (org-babel-jupyter-src-block-lang)
|
||||
;; lang)
|
||||
;; args))
|
||||
|
||||
;; (advice-add 'org-src--get-lang-mode :around #'org-babel-jupyter--get-lang-mode)
|
||||
|
||||
(defun org-babel-variable-assignments:jupyter (params &optional lang)
|
||||
"Assign variables in PARAMS according to the Jupyter kernel language.
|
||||
Use `org-babel-jupyter-src-block-lang' to get the kernel language
|
||||
|
|
Loading…
Add table
Reference in a new issue