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, 06 Jul 2023 22:39:34 +0200 Message-ID: <87lefsai61.fsf@gmail.com> References: <87leg0b0oy.fsf@gmail.com> <87edlrbok2.fsf@gmail.com> <83o7kpijyf.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="1192"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: kobarity , 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 06 22:40:26 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 1qHVm5-00004t-VC for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Jul 2023 22:40:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHVlo-0003Ob-3b; Thu, 06 Jul 2023 16:40:08 -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 1qHVli-0003Mn-Un for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 16:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHVlh-0006EB-Vx for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 16:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qHVlh-0000SM-RM for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 16:40:01 -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, 06 Jul 2023 20:40:01 +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.16886759851725 (code B ref 64397); Thu, 06 Jul 2023 20:40:01 +0000 Original-Received: (at 64397) by debbugs.gnu.org; 6 Jul 2023 20:39:45 +0000 Original-Received: from localhost ([127.0.0.1]:42143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHVlR-0000Rk-6y for submit@debbugs.gnu.org; Thu, 06 Jul 2023 16:39:45 -0400 Original-Received: from mail-lj1-f170.google.com ([209.85.208.170]:51420) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHVlO-0000RW-01 for 64397@debbugs.gnu.org; Thu, 06 Jul 2023 16:39:43 -0400 Original-Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2b6ff1ada5dso17590471fa.2 for <64397@debbugs.gnu.org>; Thu, 06 Jul 2023 13:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688675976; x=1691267976; 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=lyV8mRBYKZNA6A2ytqZkpUZ/yM8ootYI9VomY/34N50=; b=rT4Q6TXTN1mNE1W4uBWWkYV3BUCNxFPu57SVsFB5etUJ0MQDO5bwhmG8RjApnmSFCc WGDizshnfS4gpQ7+FNmRQcPJGZH7CkQFKihJBQcpx4eEY1dOJQeBZMo+KaxbtkxxAu0i hITYdrc7uynEbcCFkl4IV+lsrGBN6lFMJOQR1XNfGIF2puWWQnm61DdLsB2BSXsGr7OQ 36tBZQm7fY7afcmLx4AJq+52mwRGynQISiTptyvdkKE6jxjlQdlmz66EKnhDTUpwepp4 kMjzurKZ+F4dQvfSMGMCfqfe80Qn7VCOVPCRpDxUwOcZD2R6Nzl2gm2gKvI5Qbqq66wU TWCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688675976; x=1691267976; 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=lyV8mRBYKZNA6A2ytqZkpUZ/yM8ootYI9VomY/34N50=; b=CSZ1DXcfiH607fzMt9sgsfDlE1aq3wZwLyQTC6UAwZOtq7zV2vr3iWxCzEf9+FL5Ld FpiW8+Nb+kg1FT9bdqq4jJsAXKFxn7e96Y9zpOfKsrEbWt/50YOA/SfBHQAAe8+22cMB DVjWZei1l0Ca8TX5MNovr9IRhc13WTLNql2n9INLcPzG3CbDT/7w9t08lEGT3kLjHNrY q6oLBMcvXTlJZOJJINCrVi+67sWoDd8E5ZIEcUSP/HrxVbp/yfJA8lXdeoxD/eycvWn1 TJ03hS16msWIABU3bACmTDwhd6Rc6RHmgYevcBcf6BtKOT8AmFpyCimFquwllqSP9HcZ Rakw== X-Gm-Message-State: ABy/qLY5wBVtqMwzEzKjfw7vse2NN5dgDZX80JHsdFQFDO5Or/GwH2PQ g4IVIZcb6iqBORRIBzVtw8sVLWVpFk7ZmA== X-Google-Smtp-Source: APBJJlGi0/+lDmHRcRgU51NiLKa1FVS5QeCK2ykAALSVROVzuBBUJAg8f9W1PMi3B/2NFGo4c1BJXQ== X-Received: by 2002:a05:6512:12c7:b0:4fb:8bcd:acd4 with SMTP id p7-20020a05651212c700b004fb8bcdacd4mr2534848lfg.37.1688675975545; Thu, 06 Jul 2023 13:39:35 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id t13-20020a7bc3cd000000b003fbaade072dsm527961wmj.23.2023.07.06.13.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jul 2023 13:39:34 -0700 (PDT) In-Reply-To: <83o7kpijyf.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 06 Jul 2023 10:21:28 +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:264699 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Matthias Meulien >> Date: Sat, 01 Jul 2023 18:10:21 +0200 >> >> Here's a patch adding a python-interpreter-args custom variable. > > Thanks. A few minor comments below. > >> +(defcustom python-interpreter-args "" >> + "Default arguments for the Python interpreter." >> + :type 'string) > > New defcustoms should have the :version tag. > >> (defcustom python-shell-interpreter-args "-i" >> - "Default arguments for the Python interpreter." >> + "Default arguments for the Python interpreter for shell." > > I think this doc string needs to be clarified, in particular what is > the significance of the "for shell" addition. > > We also need a NEWS entry calling out the new defcustom. > > kobarity, any comments to this change? See the description of the > original issue in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64397#5. Thanks for your careful reading. Here is an updated patch. Not sure it address your very relevant comment on the doc string of python-shell-interpreter-args. I must confess I don't understand the meaning of the word "shell" in this file python-mode.el (even after reading https://en.wikipedia.org/wiki/Shell_(computing))! --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Custom-var-python-interpreter-args-bug-64397.patch >From d56ab4c8fc8979dc5f07f40c2c0d87b336a09593 Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Sat, 1 Jul 2023 16:07:01 +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--list-imports, python--do-isort, python-fix-imports): Make process use customisable arguments. --- etc/NEWS | 4 +++ lisp/progmodes/python.el | 53 ++++++++++++++++++++++++++++------------ 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1a86c9e55e2..46eab6c38bc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -383,6 +383,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..4d5bcfcaa49 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -297,11 +297,19 @@ python (defcustom python-interpreter "python" "Python interpreter for noninteractive use. + +Some Python interpreters also require changes to +`python-interpreter-args'. + To customize the Python shell, modify `python-shell-interpreter' instead." :version "29.1" :type 'string) +(defcustom python-interpreter-args "" + "Default arguments for the Python interpreter." + :version "30.1" + :type 'string) ;;; Bindings @@ -2558,7 +2566,7 @@ python-shell-interpreter (cond ((executable-find "python3") "python3") ((executable-find "python") "python") (t "python3")) - "Default Python interpreter for shell. + "Default Python interpreter used for user interactions. Some Python interpreters also require changes to `python-shell-interpreter-args'. In particular, setting @@ -2573,7 +2581,7 @@ python-shell-internal-buffer-name :safe 'stringp) (defcustom python-shell-interpreter-args "-i" - "Default arguments for the Python interpreter." + "Default arguments for the Python interpreter for shell." :type 'string) (defcustom python-shell-interpreter-interactive-arg "-i" @@ -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 --=-=-=--