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: Mon, 17 Jul 2023 21:17:19 +0200 Message-ID: <87bkgacpq8.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> <87fs5rv64p.fsf@gmail.com> <83o7kdd1bp.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="29735"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: kobarity@gmail.com, 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 Mon Jul 17 21:18:18 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 1qLTje-0007Wd-En for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Jul 2023 21:18:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLTjP-0000oz-WD; Mon, 17 Jul 2023 15:18: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 1qLTjO-0000oo-Ew for bug-gnu-emacs@gnu.org; Mon, 17 Jul 2023 15:18:02 -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 1qLTjO-0007CF-7H for bug-gnu-emacs@gnu.org; Mon, 17 Jul 2023 15:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qLTjO-0006Hx-2i for bug-gnu-emacs@gnu.org; Mon, 17 Jul 2023 15:18: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: Mon, 17 Jul 2023 19:18: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.168962145324136 (code B ref 64397); Mon, 17 Jul 2023 19:18:02 +0000 Original-Received: (at 64397) by debbugs.gnu.org; 17 Jul 2023 19:17:33 +0000 Original-Received: from localhost ([127.0.0.1]:50940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLTiu-0006HE-Ko for submit@debbugs.gnu.org; Mon, 17 Jul 2023 15:17:33 -0400 Original-Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:44057) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLTip-0006Gy-F0 for 64397@debbugs.gnu.org; Mon, 17 Jul 2023 15:17:31 -0400 Original-Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fb863edcb6so7944561e87.0 for <64397@debbugs.gnu.org>; Mon, 17 Jul 2023 12:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689621441; x=1692213441; 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=2xNxbMfzd90ASqgwLDQ7eJKXMn76nJAZkM6EpbbecCc=; b=fQlDgLzs544Ga40SQ754cL0dibxwtwfACFRwUl31m3cK2m61YzgMeRFKl2BeIVUEZe qcDRicpbv3bIoE6uRdPDxN47i6lhhxkAjXFOr0pK6KTTLpMdKf0pqmrq/dC6g0favsQH UIpFyktnQex2OepHPzbpbe8zAGmU5BGZK/ocjX9MHy8riU6xnCGx0e4ENI9DHBj7KUYC rbR9PUnaZmDFnCgBsfBjfHrQeQpy12KHtIpnTfsxoRBXlLJTvzBdZOCLuvkVWuAiDtSc Msienp/Zy6/2D0veElZXCrgves+6Xs+tWlwjJeko+oqSoPOUVnFQWXkYW4H1P1Q9V/5Z 7AjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689621441; x=1692213441; 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=2xNxbMfzd90ASqgwLDQ7eJKXMn76nJAZkM6EpbbecCc=; b=h74m3LFCXVTL5ZBOppFkHyJ5B6ML90JD7izyuyagiW+CfqQ6pUEFL2rT5+6KilpYKr ajI256SvFmD4gJy0G301/4W5LjGpGrV3KmW73wxpBfuWII1UuegB7sr79m9889KjiOOu oVzJI766kRUdIQGeAtL7YYEug8uJGVhaMtZFtpSecuhfB2pEXvcPYUhuG7oVlfsmrp3A uYT2BLP/4QWb1F5NsE6xxJcgZDp/YrPTOdldwppoGRRNiGE3QbupfI7EJ6+yw/aIdfk4 fV/Ulo/Pp+WOOFY1VB97bM13LvaWNXlzadE5CUos3S+JW6iAtAEx03jgNuUHdWmmd3R2 zvJg== X-Gm-Message-State: ABy/qLbt7Qs7IQ74qQ1g6s1D2X7nVqe02q+YgC3NNv38Pai1/1jnuTvr Jgf/2eqgDcgDwjjG69TV9XXmi5hsP2NOjw== X-Google-Smtp-Source: APBJJlHcb7TnoTgjMf9W9AWuHlrBGP7/4YatlhfiuoJPnDZKZoc6WjPEfUSyxAuC0MQBmEdfUrIg5Q== X-Received: by 2002:ac2:5445:0:b0:4fc:6e21:ff51 with SMTP id d5-20020ac25445000000b004fc6e21ff51mr134380lfn.40.1689621440861; Mon, 17 Jul 2023 12:17:20 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id q17-20020a7bce91000000b003fbca942499sm8749896wmj.14.2023.07.17.12.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 12:17:19 -0700 (PDT) In-Reply-To: <83o7kdd1bp.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 15 Jul 2023 11:30:02 +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:265411 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Thanks. This is for master, right? Because it fails to apply, even > without the NEWS entry (which are sometimes problematic). Could you > please rebase on master and resubmit? Yes, this is for master. Here is an updated patch generated from commit bec707da4db. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Custom-var-python-interpreter-args-bug-64397.patch >From 11a08b43ab581fe0b4c91a82a6344486793c7bbf 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 3cfc36e10da..bc596f5c03e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -411,6 +411,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 a23339a2180..52e5a36f4b0 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") @@ -6505,18 +6513,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) (python--list-imports-check-status status) (goto-char (point-min)) @@ -6559,7 +6574,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))) (unless (eq 0 status) (error "%s exited with status %s (maybe isort is missing?)" @@ -6629,10 +6648,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 --=-=-= Content-Type: text/plain -- Matthias --=-=-=--