Change jupyter- org-mode prefix to jupy-

This is to avoid name clashing with another popular package that uses the same
prefix.
This commit is contained in:
Nathaniel Nicandro 2018-11-18 11:40:10 -06:00
parent 99c0bf0f55
commit cec69a6d30
3 changed files with 17 additions and 14 deletions

View file

@ -169,8 +169,8 @@ For users of =org-mode=, integration with =org-babel= is provided through the
Note, =jupyter= should be added as the last element when loading languages
since it depends on the values of variables such as =org-src-lang-modes= and
=org-babel-tangle-lang-exts=. After =ob-jupyter= has been loaded, new source
code blocks with names of the form =jupyter-LANG= will be available. =LANG= can
be any one of the kernel languages found on your system. See
code blocks with names of the form =jupy-LANG= will be available. =LANG= can be
any one of the kernel languages found on your system. See
=jupyter-available-kernelspecs=.
Every Jupyter source code block requires that the =:session= parameter be
@ -214,9 +214,9 @@ the underlying REPL buffer for a source code block is a based on both
=:session= and =:kernel=.
In addition, any of the defaults for a language can be changed by setting
=org-babel-default-header-args:jupyter-LANG= to an appropriate value. For
example to change the default header arguments of the =julia= kernel, you can
set =org-babel-default-header-args:jupyter-julia= to something like
=org-babel-default-header-args:jupy-LANG= to an appropriate value. For example
to change the default header arguments of the =julia= kernel, you can set
=org-babel-default-header-args:jupy-julia= to something like
#+BEGIN_SRC elisp
(setq org-babel-default-header-args:jupyter-julia '((:async . "yes")

View file

@ -168,7 +168,7 @@ source code block. Set by `org-babel-execute:jupyter'.")))
(let* ((el (org-element-at-point))
(lang (org-element-property :language el))
info params syntax client)
(when (string-prefix-p "jupyter-" lang)
(when (string-prefix-p "jupy-" lang)
(setq info (org-babel-get-src-block-info el)
params (nth 2 info)
client (with-current-buffer

View file

@ -68,7 +68,7 @@
(:async . "no"))
"Default header arguments for Jupyter src-blocks.")
(defvar org-babel-jupyter-language-regex "^[ \t]*#\\+begin_src[ \t]+jupyter-\\([^ \f\t\n\r\v]+\\)[ \t]*"
(defvar org-babel-jupyter-language-regex "^[ \t]*#\\+begin_src[ \t]+jupy-\\([^ \f\t\n\r\v]+\\)[ \t]*"
"Regular expression used to extract a source block's language name.")
(defun org-babel-variable-assignments:jupyter (params &optional lang)
@ -253,17 +253,20 @@ the PARAMS alist."
"Simimilar to `org-babel-make-language-alias' but for Jupyter src-blocks.
KERNEL should be the name of the default kernel to use for kernel
LANG. All necessary org-babel functions for a language with the
name jupyter-LANG will be aliased to the jupyter functions."
name jupy-LANG will be aliased to the Jupyter functions."
(dolist (fn '("execute" "expand-body" "prep-session" "edit-prep"
"variable-assignments" "load-session"))
;; Use :jupyter here for the base functions, for all the language aliases
;; use :jupy-LANG, this is to avoid name clashes with the ob-ipython
;; package.
(let ((sym (intern-soft (concat "org-babel-" fn ":jupyter"))))
(when (and sym (fboundp sym))
(defalias (intern (concat "org-babel-" fn ":jupyter-" lang)) sym))))
(defalias (intern (concat "org-babel-jupyter-" lang "-initiate-session"))
(defalias (intern (concat "org-babel-" fn ":jupy-" lang)) sym))))
(defalias (intern (concat "org-babel-jupy-" lang "-initiate-session"))
'org-babel-jupyter-initiate-session)
(set (intern (concat "org-babel-header-args:jupyter-" lang))
(set (intern (concat "org-babel-header-args:jupy-" lang))
org-babel-header-args:jupyter)
(set (intern (concat "org-babel-default-header-args:jupyter-" lang))
(set (intern (concat "org-babel-default-header-args:jupy-" lang))
`((:kernel . ,kernel)
(:async . "no"))))
@ -283,10 +286,10 @@ Optional argument REFRESH has the same meaning as in
do (org-babel-jupyter-make-language-alias kernel lang)
(when (assoc lang org-babel-tangle-lang-exts)
(add-to-list 'org-babel-tangle-lang-exts
(cons (concat "jupyter-" lang)
(cons (concat "jupy-" lang)
(cdr (assoc lang org-babel-tangle-lang-exts)))))
(add-to-list 'org-src-lang-modes
(cons (concat "jupyter-" lang)
(cons (concat "jupy-" lang)
(intern (or (cdr (assoc lang org-src-lang-modes))
(replace-regexp-in-string
"[0-9]*" "" lang)))))))