Keep uppercase characters in kernel language names

Converting to lowercase was done arbitrarily.  So that one could write
`(jupyter-lang wolfram-language)` instead of
`(jupyter-lang Wolfram-Language)`.

fixes #241

* CHANGELOG.org: Add note.

* README.org: Update relevant sections.

* jupyter-base.el (jupyter-canonicalize-language-string): Do it.

* ob-jupyter.el (org-babel-jupyter-aliases-from-kernelspecs):
This commit is contained in:
Nathaniel Nicandro 2020-04-09 11:13:10 -05:00
parent 82f8fe691e
commit 587ed4e029
5 changed files with 21 additions and 14 deletions

View file

@ -1,3 +1,9 @@
* master
- Fixed regression due to uppercase characters in kernel language
names, e.g. R. =emacs-jupyter= would not work at all with language
specific features.
* v0.8.2 * v0.8.2
- Fix recursive loading error caused by =jupyter-tramp.el= autoloads. - Fix recursive loading error caused by =jupyter-tramp.el= autoloads.

View file

@ -419,10 +419,9 @@ to change the defaults for the =julia= kernel, you can set
#+END_SRC #+END_SRC
*** Note on the language name provided by a kernelspec *** Note on the language name provided by a kernelspec
Some kernelspecs use spaces or uppercase characters in the name of the kernel Some kernelspecs use spaces in the name of the kernel language. Those
language. Those get replaced by dashes or lowercase characters in the language get replaced by dashes in the language name you need to use for the
name you need to use for the source block, e.g. =Wolfram Language= source block, e.g. =Wolfram Language= becomes =jupyter-Wolfram-Language=.
becomes =jupyter-wolfram-language=.
*** Integration with =ob-async= *** Integration with =ob-async=
@ -1427,9 +1426,9 @@ kernel language is =julia= for indenting the current line:
(call-interactively #'julia-latexsub-or-indent)) (call-interactively #'julia-latexsub-or-indent))
#+END_SRC #+END_SRC
Note, when spaces or uppercase characters appear in the name of the kernel Note, when spaces appear in the name of the kernel language they
language they become dashes or lowercase characters in the symbol used for become dashes in the symbol used for the =jupyter-lang= context,
the =jupyter-lang= context, e.g. =Wolfram Language= becomes =wolfram-language=. e.g. =Wolfram Language= becomes =Wolfram-Language=.
There are many other entry points where methods may be overridden in such a There are many other entry points where methods may be overridden in such a
way. Below is the full list of methods that can be overridden in this way way. Below is the full list of methods that can be overridden in this way

View file

@ -537,12 +537,14 @@ Note only SSH tunnels are currently supported."
;;; Helper functions ;;; Helper functions
(defun jupyter-canonicalize-language-string (str) (defun jupyter-canonicalize-language-string (str)
"Return STR with \" \" converted to \"-\" and all characters in lower case." "Return STR with \" \" converted to \"-\".
The `file-name-nondirectory' of STR will be converted and
returned if it looks like a file path."
;; The call to `file-name-nondirectory' is here to be more robust when ;; The call to `file-name-nondirectory' is here to be more robust when
;; running on systems like Guix or Nix. Some builders on those kinds of ;; running on systems like Guix or Nix. Some builders on those kinds of
;; systems will indiscriminately replace "python" with something like ;; systems will indiscriminately replace "python" with something like
;; "/gnu/store/.../bin/python" when building the kernelspecs. ;; "/gnu/store/.../bin/python" when building the kernelspecs.
(downcase (replace-regexp-in-string " " "-" (file-name-nondirectory str)))) (replace-regexp-in-string " " "-" (file-name-nondirectory str)))
(defvar server-buffer) (defvar server-buffer)
(defvar jupyter-current-client) (defvar jupyter-current-client)

View file

@ -636,11 +636,10 @@ SPECS defaults to `jupyter-available-kernelspecs'. Optional
argument REFRESH has the same meaning as in argument REFRESH has the same meaning as in
`jupyter-available-kernelspecs'. `jupyter-available-kernelspecs'.
Note, spaces or uppercase characters in the kernel language name Note, spaces in the kernel language name are converted into
are converted into dashes or lowercase characters in the language dashes in the language alias, e.g.
alias, e.g.
Wolfram Language -> jupyter-wolfram-language Wolfram Language -> jupyter-Wolfram-Language
For convenience, after creating a language alias for a kernel For convenience, after creating a language alias for a kernel
language LANG, set the :kernel default header argument if not language LANG, set the :kernel default header argument if not

View file

@ -678,7 +678,8 @@
(ert-deftest jupyter-canonicalize-language-string () (ert-deftest jupyter-canonicalize-language-string ()
:tags '(base env) :tags '(base env)
(should (equal (jupyter-canonicalize-language-string "Wolfram Language") (should (equal (jupyter-canonicalize-language-string "Wolfram Language")
"wolfram-language")) "Wolfram-Language"))
(should (equal (jupyter-canonicalize-language-string "R") "R"))
(should (equal (jupyter-canonicalize-language-string "/gnu/store/python") (should (equal (jupyter-canonicalize-language-string "/gnu/store/python")
"python"))) "python")))