help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use a new buffer as Python shell?


From: edgar
Subject: Re: How to use a new buffer as Python shell?
Date: Fri, 19 Aug 2022 20:12:37 +0000
User-agent: Horde Application Framework 5

On 2022-08-19 09:48, Anders Munch wrote:
You are using python.el.  You may have more luck with python-mode.el.

C-u M-x py-shell RET
starts a new dedicated interpreter subshell.
--- snip 8< ---

regards, Anders

Thanks, Anders. When I
0. cd ~/.emacs.d/ && git clone https://gitlab.com/python-mode-devs/python-mode.git
1. emacs -q
2. evaluate

      (push "~/.emacs.d/eglot" load-path)
      (autoload 'eglot "eglot")
      (autoload 'ensure-eglot "eglot")
      (autoload 'eglot-ensure "eglot")
      (with-eval-after-load "eglot"
        (setq eldoc-echo-area-use-multiline-p 2))

      (push "~/.emacs.d/python-mode" load-path)
      (autoload 'python-mode "python-mode" "Python Mode." t)

      ;; Add Eglot to Python
      (add-hook 'python-mode-hook 'eglot-ensure)

      ;; Configuration for python-mode.el
      (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
      (add-to-list 'interpreter-mode-alist '("python3" . python-mode))

3. Execute =C-x C-f myfile.py=  =(find-file "myfile.py")=
4. Issue =C-u M-x py-shell=

The frame is split into 2 windows. The buffer in which I was working is not shown (I have to =C-x b= to return). When I am back at the buffer with =myfile.py=, I run =M-x py-execute-line=. This creates a temporary buffer that I have to kill manually. Also, in step 3 I get

Directory-local variables error: (error Command attempted to use minibuffer while in minibuffer)

Does anybody know if it is possible to avoid switching to a different buffer when =C-u M-x py-shell= is called? To avoid the temporary buffer, I added =(setq py-execute-no-temp-p t)=, at the end of the configuration. Now, the temporary buffer is not shown, but if I go to the REPL and type =np RET= twice, I have this:

    >>> >>> >>> np
    >>> np
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'np' is not defined
    >>>

(the first line of myfile.py is a comment. The second line--the one that I try to run--is =import numpy as np=). I also have a second *Python-xxxx* buffer which was automatically created. All this happens with or without the Eglot lines.

"GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)
 of 2022-04-28"
python-mode.el commit: 765af45, Tag: 6.3.0 (72)


-------------------------------------------------
This free account was provided by VFEmail.net - report spam to abuse@vfemail.net

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the 
NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features! 15GB disk! No bandwidth quotas! Commercial and Bulk Mail Options!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]