From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: edgar@openmail.cc Newsgroups: gmane.emacs.help Subject: Re: How to use a new buffer as Python shell? Date: Fri, 19 Aug 2022 20:12:37 +0000 Message-ID: <20220819201237.Horde.pSYE-jbI7qXJRgfu7GxeR7e@www.vfemail.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2976"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Horde Application Framework 5 Cc: help-gnu-emacs@gnu.org To: Anders Munch Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 19 22:13:46 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oP8NF-0000Yq-LZ for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 19 Aug 2022 22:13:45 +0200 Original-Received: from localhost ([::1]:56532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP8NE-0000U8-IR for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 19 Aug 2022 16:13:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP8Mg-0000RW-Up for help-gnu-emacs@gnu.org; Fri, 19 Aug 2022 16:13:10 -0400 Original-Received: from smtp152.vfemail.net ([146.59.185.152]:38665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP8Me-0004R5-7P for help-gnu-emacs@gnu.org; Fri, 19 Aug 2022 16:13:09 -0400 Original-Received: (qmail 30033 invoked from network); 19 Aug 2022 20:13:03 +0000 Original-Received: from localhost (HELO freequeue.vfemail.net) () by smtpout.vfemail.net with ESMTPS (ECDHE-RSA-AES256-GCM-SHA384 encrypted); 19 Aug 2022 20:13:03 +0000 Original-Received: (qmail 509 invoked from network); 19 Aug 2022 20:12:28 -0000 Original-Received: from localhost (HELO nl101-2.vfemail.net) (bmE=@127.0.0.1) by freequeue.vfemail.net with (DHE-RSA-AES256-SHA encrypted) SMTP; 19 Aug 2022 20:12:27 -0000 Original-Received: (qmail 98988 invoked from network); 19 Aug 2022 20:12:02 -0000 Original-Received: by simscan 1.4.0 ppid: 98958, pid: 98968, t: 0.1060s scanners:none Original-Received: from unknown (HELO localhost) (ZWRnYXJAb3Blbm1haWwuY2M=@192.168.1.192) by nl101.vfemail.net with ESMTPA; 19 Aug 2022 20:12:02 -0000 X-VFEmail-Originating-IP: 2405:8100:8000:5ca1::14e:4d59 X-VFEmail-AntiSpam: Notify admin@vfemail.net of any spam, and include VFEmail headers Content-Disposition: inline Received-SPF: pass client-ip=146.59.185.152; envelope-from=edgar@openmail.cc; helo=smtp152.vfemail.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138940 Archived-At: 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 "", line 1, in 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!