Closed fast-90 closed 1 year ago
What's your project layout? Where did you install jupyter? Can you give me a trace of pet-executable-find
and/or pet-virtualenv-root
?
Thanks for the suggestion to trace those functions! (Sorry still relatively new to Elisp).
See below for the trace. Reading it it seems that the error is caused by the executables it could not find (and therefore returning nil
). This makes sense as I do not have those packages (e.g. black) installed in the project venv.
Do you have any suggestions on how to configure pet
to avoid running python-pet-hook
for org-src blocks? In my normal Python projects I do use these tools, so I would like to keep them in python-pet-hook
. I just need them to not search for the executables for my Org notebooks.
I have tried the following without results:
(use-package pet
:elpaca t
:hook
(python-mode . python-pet-hook)
(org-src-mode. org-src-pet-hook)
:init
(defun python-pet-hook ()
(unless (org-src-edit-buffer-p)
(pet-mode)))
(defun org-src-pet-hook ()
(remove-hook 'python-mode-hook 'python-pet-hook t)))
I have also tried variants with org-in-src-block-p
and (bound-and-true-p org-src-mode)
without succes. Any suggestions?
I don't know. I don't use org-mode. AFAIK, similar modes like polymode and markdown-mode have(had) the same problem. This is a problem with how Emacs expose major mode switching lifecycle hooks and how these modes reuse major modes in source code blocks. There's nothing you can do about it at the moment, but perhaps you can file a ticket to Emacs.
Alternatively, you may try to detect whether you are in a project in your hook, and only activate pet mode when you are.
Fair enough! I have a hacky workaround atm using (when buffer-file-name ...)
(as those org-src-edit buffers don't have a file name), but will send an email to the org-mode maillist to ask for their advice.
In any case I'm closing this issue as it is not related to PET. Thanks for the replies, and thanks for this great package which is making my Python package development process a lot easier :)
Description
When using
pet-mode
withjupyter
(emacs-jupyter), entering anorg-edit-special
buffer results inpyenv exited with status 127 [3 times]
(as observed in the*Messages*
buffer when turning onpet-debug
).This behaviour causes several issues for me when using
jupyter
notebooks in org-mode, in particular a few seconds of lag when I try to add a new line with RET or indent a line with TAB (as org-mode opens anorg-edit-special
buffer in the background withpython-mode
on to get the "correct" indentation behaviour).Reproduction steps
init.el
```el (setq native-comp-async-report-warnings-errors nil) (use-package org :elpaca nil :init (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (python . t))) :custom (org-confirm-babel-evaluate nil) (org-src-fontify-natively t) (org-edit-src-content-indentation 2)) (use-package jupyter :elpaca t :init (setq native-comp-jit-compilation-deny-list '("jupyter-channel.*.el")) ; Needed to ignore a recent bug on main (org-babel-do-load-languages 'org-babel-load-languages (append org-babel-load-languages '((jupyter . t)))) (setq org-babel-default-header-args:jupyter-python '((:async . "yes") (:session . "py") (:kernel . "python3")))) (use-package pet :elpaca t :hook (python-mode . python-pet-hook) :init (defun python-pet-hook () (pet-mode))) ```
```el :PROPERTIES: :header-args:python: :async yes :kernel python3 :session py :END: #+begin_src python print("Hello world!") #+end_src ```notebook.org
(adjust kernel name in the notebook if needed)RET
to add new line b. PressC-c '
to open anorg-edit-special
buffer c. PressTAB
to indent a line*Messages*
buffer ifpet-debug
is turned on)Expected behavior
No lagged behaviour when doing any of the actions in step 4 above, no error message even when
pet-debug
is on. This expected behaviour is observed whenpet-mode
is removed from thepython-mode-hook
.PET version 2023-06-21 version from MELPA
Emacs version GNU Emacs 29.0.91 (build 1, x86_64-apple-darwin22.3.0, NS appkit-2299.40 Version 13.2.1 (Build 22D68)) of 2023-06-05 (Installed via emacs-plus, although I have tested this on a different machine with WSL2 and observed the same behaviour).
Desktop
System tools versions
pyenv v2.3.18
Additional context
Result of
M-x (pet-verify-setup)
in theorg-edit-special
buffer:Hope this is sufficiently clear, otherwise please let me know what other information I should provide. I can also provide a short video showing the lagged behaviour if required.