From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.bugs Subject: bug#64397: 29.0.91; Limited configuration of commands based on python-interpreter Date: Thu, 13 Jul 2023 23:44:22 +0200 Message-ID: <87fs5rv64p.fsf@gmail.com> References: <87leg0b0oy.fsf@gmail.com> <87edlrbok2.fsf@gmail.com> <83o7kpijyf.fsf@gnu.org> <87lefsai61.fsf@gmail.com> <83wmzademg.fsf@gnu.org> <87h6qe2wri.fsf@gmail.com> <83fs5s5phj.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23969"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: kobarity , arstoffel@gmail.com, 64397@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 13 23:45:14 2023 Return-path: Envelope-to: geb-bug-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 1qK47d-0005yU-TI for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Jul 2023 23:45:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qK47U-0002H6-RM; Thu, 13 Jul 2023 17:45:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qK47T-0002Gu-7Y for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2023 17:45:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qK47S-0005NX-TU for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2023 17:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qK47S-0007o0-Dr for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2023 17:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthias Meulien Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Jul 2023 21:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64397 X-GNU-PR-Package: emacs Original-Received: via spool by 64397-submit@debbugs.gnu.org id=B64397.168928468229946 (code B ref 64397); Thu, 13 Jul 2023 21:45:02 +0000 Original-Received: (at 64397) by debbugs.gnu.org; 13 Jul 2023 21:44:42 +0000 Original-Received: from localhost ([127.0.0.1]:40944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qK477-0007mv-Pg for submit@debbugs.gnu.org; Thu, 13 Jul 2023 17:44:42 -0400 Original-Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:58431) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qK46w-0007mJ-TA for 64397@debbugs.gnu.org; Thu, 13 Jul 2023 17:44:40 -0400 Original-Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-307d58b3efbso1361962f8f.0 for <64397@debbugs.gnu.org>; Thu, 13 Jul 2023 14:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689284665; x=1691876665; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=VSDWHxF8NzbUjPvxMrjGVfCWzf56+ryWLoRmffT8xxE=; b=UUKs7idZa0JbsaBHjy0Chet1ZUjLWDKJyusQprfRY8ijsT5HxkVC6ibKjoPjD+4MOg 1Afhd+xc0NgzB9IbmHv+XvR0N2ugb4SlBwvtBumbBgVbiYJgismGB/HRlazKtsnrOZZ3 /wTksXeqhPIJaaQLJWA+/NFPgo6hhe6bXaF0QVxqQLa3C8VaSwSiz9SWd5y8F162jO8F 9QOx5L4jse/zD6hBemuaMoRMgd+ve7X3DgxiKl0Ddm58KF9Ut+bmgnCeYpTfPKX91QLj dfosKadJvw9ufvfXFNKtupulRPUreN/JeYPf9aphk6aWI1aLJtk3gFrX9DeKEPUpCXkF OrSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689284665; x=1691876665; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VSDWHxF8NzbUjPvxMrjGVfCWzf56+ryWLoRmffT8xxE=; b=Y9GhaUDVP4+qY2Sl9axckrbW5BrNglArGz+5bVK1y0Lvtj26k1kXawTcgbAxU+VoI5 4OSS77J3GlizrVtT3Zce3d05OnjZ8k4+0hb9meR3k6JYMlvf1h3rxpAWVA0DOTCyB5TQ gSiD9s/U1SRSbKCzduOqAcGiMYxb99JhkD167ihGZRK0rFqegurZcOWEZQQRvdTYD+mc fnP0qKVlbQVpkfR5cb/vRxpXuNlJXET8gyYGQrCLXPJH8sBN0dMgkOevVQq6RWzdAMOI KGhLvVW2HCbjGU/OY4OD3rQU6H+99MQvliH8IDMCBgNG/+MOWDGHe1XBUFtfmpU67yZR ATOA== X-Gm-Message-State: ABy/qLZa3XyZzVFiIPpbnacfUMOcIP9f6S+0W3K0goNcm59QWQw6Ol3t 2vkxBCxSyEetQt6LZD0BlIcKixrTYyMIUA== X-Google-Smtp-Source: APBJJlGCMXbaHfzS/XiV3dSvzoDNQZCxCp7WXSJI66MOK6qMVkbc8htv59RPGWwrXiEc3iIgz42bwA== X-Received: by 2002:a5d:4bcc:0:b0:314:11ab:11a0 with SMTP id l12-20020a5d4bcc000000b0031411ab11a0mr2500200wrt.34.1689284664914; Thu, 13 Jul 2023 14:44:24 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id o4-20020a5d4084000000b003142c85fbcdsm9151707wrp.11.2023.07.13.14.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 14:44:23 -0700 (PDT) In-Reply-To: <83fs5s5phj.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 13 Jul 2023 08:50:48 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:265050 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Date: Sun, 09 Jul 2023 21:17:48 +0900 >> From: kobarity >> Cc: Eli Zaretskii , >> Augusto Stoffel , >> 64397@debbugs.gnu.org >> >> >> Matthias Meulien wrote: >> > >> > kobarity writes: >> > >> > > (...) How about the following descriptions? >> > > >> > > python-interpreter >> > > Python interpreter for noninteractive use. >> > > python-interpreter-args >> > > Arguments for the Python interpreter for noninteractive use. >> > > python-shell-interpreter >> > > Python interpreter for interactive use. >> > > python-shell-interpreter-args >> > > Arguments for the Python interpreter for interactive use. >> > >> > I like it. But you skipped python-shell-interpreter-interactive-arg... >> >> Sorry, I forgot about that. >> `python-shell-interpreter-interactive-arg' is used only for prompt >> detection, and its docstring has only one line: >> >> Interpreter argument to force it to run interactively. >> >> I think we can leave it as is, but if we want to improve it, how about >> adding the second line? I could not shorten it to fit on one line. >> >> Interpreter argument to force it to run interactively. >> This is used only for prompt detection. > > Thanks. > > Matthias, can you post an updated patch where the last comments about > doc strings are taken care of? Yes, here it is. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Custom-var-python-interpreter-args-bug-64397.patch >From e93577859330e8d7e42bc7cb7c9229ba6e722666 Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Thu, 13 Jul 2023 23:38:41 +0200 Subject: [PATCH] Custom var python-interpreter-args (bug#64397) * lisp/progmodes/python.el (python-interpreter): Mention new variable in documentation. (python-interpreter-args): New custom variable. (python-shell-interpreter, python-shell-interpreter-args) (python-shell-interpreter-interactive-arg): Improve documentation. (python--list-imports, python--do-isort, python-fix-imports): Make process use customisable arguments. --- etc/NEWS | 4 +++ lisp/progmodes/python.el | 59 ++++++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 5d5ea990b92..ee099189e3b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -397,6 +397,10 @@ instead of: and another_expression): do_something() +*** New user option 'python-interpreter-args'. +This allows the user to specify command line arguments to the non +interactive Python interpreter specified by 'python-interpreter'. + ** use-package +++ diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4291ab03ca6..e7044012cde 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -297,11 +297,18 @@ python (defcustom python-interpreter "python" "Python interpreter for noninteractive use. -To customize the Python shell, modify `python-shell-interpreter' -instead." +Some Python interpreters also require changes to +`python-interpreter-args'. + +To customize the Python interpreter for interactive use, modify +`python-shell-interpreter' instead." :version "29.1" :type 'string) +(defcustom python-interpreter-args "" + "Arguments for the Python interpreter for noninteractive use." + :version "30.1" + :type 'string) ;;; Bindings @@ -2558,7 +2565,7 @@ python-shell-interpreter (cond ((executable-find "python3") "python3") ((executable-find "python") "python") (t "python3")) - "Default Python interpreter for shell. + "Python interpreter for interactive use. Some Python interpreters also require changes to `python-shell-interpreter-args'. In particular, setting @@ -2573,11 +2580,12 @@ python-shell-internal-buffer-name :safe 'stringp) (defcustom python-shell-interpreter-args "-i" - "Default arguments for the Python interpreter." + "Arguments for the Python interpreter for interactive use." :type 'string) (defcustom python-shell-interpreter-interactive-arg "-i" - "Interpreter argument to force it to run interactively." + "Interpreter argument to force it to run interactively. +This is used only for prompt detection." :type 'string :version "24.4") @@ -6494,18 +6502,25 @@ python--list-imports (let* ((temp (current-buffer)) (status (if (bufferp source) (with-current-buffer source - (call-process-region (point-min) (point-max) - python-interpreter - nil (list temp nil) nil - "-c" python--list-imports - (or name ""))) + (apply #'call-process-region + (point-min) (point-max) + python-interpreter + nil (list temp nil) nil + (append + (split-string-shell-command + python-interpreter-args) + `("-c" ,python--list-imports) + (list (or name ""))))) (with-current-buffer buffer (apply #'call-process python-interpreter nil (list temp nil) nil - "-c" python--list-imports - (or name "") - (mapcar #'file-local-name source))))) + (append + (split-string-shell-command + python-interpreter-args) + `("-c" ,python--list-imports) + (list (or name "")) + (mapcar #'file-local-name source)))))) lines) (cond ((eq 1 status) @@ -6554,7 +6569,11 @@ python--do-isort (point-min) (point-max) python-interpreter nil (list temp nil) nil - "-m" "isort" "-" args)) + (append + (split-string-shell-command + python-interpreter-args) + '("-m" "isort" "-") + args))) (tick (buffer-chars-modified-tick))) (cond ((eq 1 status) @@ -6628,10 +6647,14 @@ python-fix-imports (with-temp-buffer (let ((temp (current-buffer))) (with-current-buffer buffer - (call-process-region (point-min) (point-max) - python-interpreter - nil temp nil - "-m" "pyflakes")) + (apply #'call-process-region + (point-min) (point-max) + python-interpreter + nil temp nil + (append + (split-string-shell-command + python-interpreter-args) + '("-m" "pyflakes")))) (goto-char (point-min)) (when (looking-at-p ".* No module named pyflakes$") (error "%s couldn't find pyflakes" python-interpreter)) -- 2.39.2 --=-=-=--