From f1f162e7d75026d7739243c7cafe501a66357191 Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Mon, 15 May 2023 16:10:51 +0200 Subject: [PATCH] Prevent `ob-python' calling functions bound after loading `python' --- README.org | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/README.org b/README.org index d974951..ce941fc 100644 --- a/README.org +++ b/README.org @@ -2087,8 +2087,8 @@ list detailing and motivating each listing: (maxima . ,(fboundp 'maxima-mode)) (org . t) (perl . t) - ;; Postpone Python activation to prevent calling still unbound functions. - (python . nil) + ;; Beware: Python activation must not call still unbound functions. + (python . t) ;; MIT/GNU Scheme breaks Babel contrary to Guile, Chez and Chicken Scheme. (scheme . ,(fboundp 'geiser-mode)) (shell . t)) @@ -4944,16 +4944,28 @@ Finally, listing [[lst:flake8-nocolor][flake8-nocolor]] and [[lst:ruff-nocolor][ python-check-command python-flymake-command)))) #+end_src -#+caption[Setup Python mode]: -#+caption: Setup Python mode. +#+caption[Setup Python mode with =ob-python=]: +#+caption: Setup Python mode with =ob-python=. #+name: lst:setup-python-mode #+begin_src emacs-lisp -n :results silent +(with-eval-after-load 'ob-python + ;; (choose-common-python-interpreter 'python) + (setopt org-babel-python-command (concat (or (executable-find "python3") + (executable-find "python")) + " -E"))) + (with-eval-after-load 'python (setopt python-indent-guess-indent-offset nil python-shell-completion-native-disabled-interpreters '("ipython3" - "pypy")) - (choose-common-python-interpreter 'python) - (choose-common-python-linter 'ruff-nocolor)) + "pypy") + ;; (choose-common-python-interpreter 'python) + python-shell-interpreter (or (executable-find "python3") + (executable-find "python")) + python-shell-interpreter-args "-E -i" + ;; (choose-common-python-linter 'ruff-nocolor) + python-check-command (executable-find "ruff-nocolor") + python-flymake-command (list (executable-find "ruff-nocolor") + "--stdin-filename" "stdin" "-"))) #+end_src #+caption[Access =pyenv=]: