GNU bug report logs - #70198
M-x shell: deal with environment variables present when tab expanding

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Dan Jacobson <jidanni@HIDDEN>; dated Thu, 4 Apr 2024 13:52:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 70198 <at> debbugs.gnu.org:


Received: (at 70198) by debbugs.gnu.org; 10 Jul 2024 18:35:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 10 14:35:12 2024
Received: from localhost ([127.0.0.1]:57145 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sRc9o-0005TJ-Jq
	for submit <at> debbugs.gnu.org; Wed, 10 Jul 2024 14:35:12 -0400
Received: from eggs.gnu.org ([209.51.188.92]:55726)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1sRc9l-0005T1-Pa
 for 70198 <at> debbugs.gnu.org; Wed, 10 Jul 2024 14:35:11 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1sRc9W-0000mz-SJ; Wed, 10 Jul 2024 14:34:54 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=MEd6pvI0rZ9eD28MIkbPEZBYDqgvi3BoE49Y8loR6ZQ=; b=YAhzz6Kw2wbH
 AuNiqRGUbRxNBozw80q0I2QNljZEdYtms77Yq8RB+p74WUw6pKSpfFEli7ke1MYbFOmg1/UAjpGS0
 X7vSiC0SGBJ0dx+Tg9iMJDLBxgHAabP769CYCrOhcgS6eFu1XwSY1BR4DFyDHki2BnXbmfekHUDcY
 crxYbe+nRbz90LcukV6XQoRMNV5at6Ms/zKIQe0VK9402Nd7DJmC3lqFd+aPlOjCpJ6TSFxpU/CxW
 RQQW4hvVBqKhQj5t//uPCT1+SrwFrYLL2Hw9b7XVfQrbrweU4/1d5G70IgbnfXlxrCoGPOWAapAHK
 jr6//SNSVQDKeXg2MhwYmw==;
Date: Wed, 10 Jul 2024 21:34:51 +0300
Message-Id: <86ttgxm6yc.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Federico Tedin <federicotedin@HIDDEN>
In-Reply-To: <87frshyv5w.fsf@HIDDEN> (message from Federico Tedin on Wed, 10
 Jul 2024 20:11:07 +0200)
Subject: Re: bug#70198: M-x shell: deal with environment variables present
 when tab expanding
References: <Zg6wRQ1kVfgwALNU@HIDDEN> <87plrlz06s.fsf@HIDDEN>
 <86wmltm994.fsf@HIDDEN> <87frshyv5w.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 70198
Cc: 70198 <at> debbugs.gnu.org, jidanni@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Federico Tedin <federicotedin@HIDDEN>
> Cc: jidanni@HIDDEN,  70198 <at> debbugs.gnu.org
> Date: Wed, 10 Jul 2024 20:11:07 +0200
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > What happens if the '=' character is quoted?
> 
> What would be an example of this? (in the context of writing shell
> commands).

Something like

  $ FOO='foo=bar' date

> > I think a better idea might be first to try to find what is "the word
> > at point", and then complete only that word.  WDYT?
> 
> Yep, however I do think we still need to walk back some words in order
> to ensure that we are not autocompleting an argument; for example
> 
> $ echo whoam[TAB]
> 
> should not autocomplete to "whoami", I'm assuming.

It should, just not command completion.

> So for the actual walking backwards we need to maybe:
> - modify shell-backward-command so that it leaves the point at the
> beginning of the command, but after any env vars
> - or, move backwards using `shell-command-regexp' until the last thing
> that does not look like FOO=BAR or FOO= is found.
> 
> All of this just to ensure that the word at point is an actual command
> and not an argument to a command. Maybe this approach itself could be
> re-evaluated though !

If we want to detect FOO=BAR, we need to use syntax classes, and I'm
not sure regexps are the best instrument for that.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#70198; Package emacs. Full text available.

Message received at 70198 <at> debbugs.gnu.org:


Received: (at 70198) by debbugs.gnu.org; 10 Jul 2024 18:22:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 10 14:22:26 2024
Received: from localhost ([127.0.0.1]:57134 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sRbxR-00057q-Bw
	for submit <at> debbugs.gnu.org; Wed, 10 Jul 2024 14:22:26 -0400
Received: from mout.gmx.net ([212.227.15.19]:43347)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <federicotedin@HIDDEN>) id 1sRbmt-0004px-P6
 for 70198 <at> debbugs.gnu.org; Wed, 10 Jul 2024 14:11:32 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de;
 s=s31663417; t=1720635069; x=1721239869; i=federicotedin@HIDDEN;
 bh=g2/62kiOWgWJASzlESLZDsj72S7/EFpLd0toWXLFDOk=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date:
 Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding:
 content-type:date:from:message-id:mime-version:reply-to:subject:
 to;
 b=RlY/MSOeU98xVG5F2wjtsOEw+AV/FbUeju4hWHfj4tkN9a58LjGQVlmVcwjoTfSp
 QSyWzRN8cDF6SrbFK2BcfH2bhB3t0z3eWXQpZuSe86I40OGo3lqsPvlHeOAF+3A1H
 Nl3Lh6S0/JSMHmeyQ7Q5FDvLlFEz++TphXZLEgOEf+BkW9W1/Q4J5+RTBb3c0++WU
 YYfxEQE+rclQvJhrH1cU9Y1/UYUUi/GBWTfvysGGTgDCP5Ljtw1/UUQjIcOTdUMXM
 n6Ix1/iY9Bs6I+YZ0mcG/wddEOhoxgUYLz9PXQOmNdS9pY5YiWuhWLgzRHx8YBhZT
 1FvoM2vt5CK/c6F9kg==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from seele ([91.66.5.21]) by mail.gmx.net (mrgmx004
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MSKuA-1splQb1A1A-00KFrm; Wed, 10
 Jul 2024 20:11:09 +0200
From: Federico Tedin <federicotedin@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#70198: M-x shell: deal with environment variables present
 when tab expanding
In-Reply-To: <86wmltm994.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 10 Jul
 2024 20:45:11 +0300")
References: <Zg6wRQ1kVfgwALNU@HIDDEN> <87plrlz06s.fsf@HIDDEN>
 <86wmltm994.fsf@HIDDEN>
Date: Wed, 10 Jul 2024 20:11:07 +0200
Message-ID: <87frshyv5w.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K1:cD/zB1a1+jeZUArw1mZoPjod2nEv3vjAmebardgTZ+DtX93WXMV
 rEgdOZEUZ6Qamh4MRsIislsa/89x8dDGq/aOX1yilx2jAxDA82aa0g1Uumg41wfxBw8riwW
 CKwlq+ELSNVXhZShkJbkvqCesdYbPIT37VdLS6P7FYRuvw2Xb0ZixaykiblZ5AJjZIsgqLS
 RzUyMh0R/ND69tMvsAAlw==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:dRlHfoiRXls=;/xfx4c0zOAaBcy4HvvJI70YnXqZ
 xw/zaB5uhpD5lYDFIcInK5dqQE1kuuAPsYtID7rhkNhI4H2tt/ctXRypqIUVrc5bPmepGHTRb
 Jndyn7+bzKXtteBDpTH1dWA/Ye1xPN2wk+j/KpaiEWptnmSil7z43Bj6wir2/t32m8eJYzD7/
 EWR0DU/EvVw6ARyx9w4QcB3tMtB6Z7zR+s4Go1PRgZSNlZR1TxW7/I+/4lTvLfbg3/7ZCRWVq
 Na+wpgEma3KeqevNaCOqktccXhLA+SL0gzimK7ZogkMUW2Ph6C3+UpS5dhUw9PZ6aC+Ixko4s
 gR4Y651ygGXvGde0/BI66YH8GV6BOBC/Rqa0ZMwGeb/JEP5n327KO8KhhmNp4RRwXHfhI6p0+
 Eyy2MjuH2512gyKv0s8tcIoQt73t9QpeLt//2GdYjjNPIxU6bXhMiDrPBxSX7I7gL6C2Qw+tP
 vTChr72zs1vLc4fIDB33OEVPAtZ26WTXAqBIWUOoUTi97QHzHjc1CE+2ePjGfzGBQHPuv9VlC
 Hl5XLIowiJ1RShe9QQPXt91aaxo54hnAhiu6IDgzPnT2UjaTjf46IxglSQ0+kjo6R5D+0pH5r
 AZ0enRjg10r219OIG1NtX2MbZHImgZ35hugisac2++xn+NFvt4DY7taLZmcXCipIl+pbl3CF+
 PQy7rIa0D/SBU0Dt4jR1YZOg8liXuUVzJ1gVV3T3tukjrtoViqGtxqGQhEgvzh+ZBljRD7iZb
 qzOSDX1HjqZmIKum6a5+wQ8EfLT5oJaWevYZAGOj4h5ya7ue9wNIrKACoOfBZ/b3Eyt3GYLxK
 tiseFf9Dx8u23uNFGTYwDMSw==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 70198
X-Mailman-Approved-At: Wed, 10 Jul 2024 14:22:23 -0400
Cc: 70198 <at> debbugs.gnu.org, jidanni@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

> What happens if the command itself has embedded '='?

Ah good point, I incorrectly assumed that after
`comint-match-partial-filename' was called, the point would be at the
beginning of the command rather than at the end. That being said if we
used (match-beginning 0) as PT then it would address this particular
scenario (when calling `shell--skip-environment-variables' I mean).

> What happens if the '=' character is quoted?

What would be an example of this? (in the context of writing shell
commands).

> I think a better idea might be first to try to find what is "the word
> at point", and then complete only that word.  WDYT?

Yep, however I do think we still need to walk back some words in order
to ensure that we are not autocompleting an argument; for example

$ echo whoam[TAB]

should not autocomplete to "whoami", I'm assuming.

So for the actual walking backwards we need to maybe:
- modify shell-backward-command so that it leaves the point at the
beginning of the command, but after any env vars
- or, move backwards using `shell-command-regexp' until the last thing
that does not look like FOO=BAR or FOO= is found.

All of this just to ensure that the word at point is an actual command
and not an argument to a command. Maybe this approach itself could be
re-evaluated though !




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#70198; Package emacs. Full text available.

Message received at 70198 <at> debbugs.gnu.org:


Received: (at 70198) by debbugs.gnu.org; 10 Jul 2024 17:45:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 10 13:45:32 2024
Received: from localhost ([127.0.0.1]:57103 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sRbNj-00049A-W4
	for submit <at> debbugs.gnu.org; Wed, 10 Jul 2024 13:45:32 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52906)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1sRbNi-00048v-AG
 for 70198 <at> debbugs.gnu.org; Wed, 10 Jul 2024 13:45:30 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1sRbNU-0000OW-Ij; Wed, 10 Jul 2024 13:45:16 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=kf6n919g6zMksOZdUofD35yceDxF4d3T2STn+gdgG8o=; b=U+ExlYwyDkUy
 9jmi32+6c3KBglxyHZA/W0/o2OvIfwqBS9Kj8sra7gEEEFyBKDRKho9U9RNujukz4MySppvDo6mkP
 yKCY5j+6V30rvZ/K4tYzHgRxRSAIV4q1VI0IyCnid65QF7Snh0JdDe59wOKEHRXAEYbnLsMo7pu7M
 FA6V+D0cU+LK5XaKdJyoeE0MIs+n9QqB+arsLpcquPNEwQHDkse2jqRVFEgZCAq1EdbUEQ9UdaJ6z
 AQ3cS4oCuRfy2JQ6xGDK2/P23NhbqMjE2hESBJC18pV3N6wxOgLfk3JMef33tnaqTaY22+pihBAkz
 8LN0K8eFbQcwlf+tc+6VCQ==;
Date: Wed, 10 Jul 2024 20:45:11 +0300
Message-Id: <86wmltm994.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Federico Tedin <federicotedin@HIDDEN>
In-Reply-To: <87plrlz06s.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#70198: M-x shell: deal with environment variables present when
 tab expanding
References: <Zg6wRQ1kVfgwALNU@HIDDEN> <87plrlz06s.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 70198
Cc: 70198 <at> debbugs.gnu.org, jidanni@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 70198 <at> debbugs.gnu.org
> Date: Wed, 10 Jul 2024 18:22:35 +0200
> From:  Federico Tedin via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> +	         (save-match-data (not (string-match "[~/]" filename)))
> +	         (eq (match-beginning 0)
> +		         (save-excursion
> +                   ;; Go back to beginning of command
> +                   (shell-backward-command 1)
> +                   ;; Skip any potential environment variables
> +                   (shell--skip-environment-variables pt)
> +                   (point))))
> +	    (shell--command-completion-data))))
> +
> +(defun shell--skip-environment-variables (pt)
> +  "Move forward up to PT through any present environment variables."
> +  (while (re-search-forward "=" pt t)
> +    (skip-syntax-forward "^ " pt)
> +    (skip-syntax-forward " " pt)))

What happens if the command itself has embedded '='?
What happens if the '=' character is quoted?

I think a better idea might be first to try to find what is "the word
at point", and then complete only that word.  WDYT?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#70198; Package emacs. Full text available.

Message received at 70198 <at> debbugs.gnu.org:


Received: (at 70198) by debbugs.gnu.org; 10 Jul 2024 16:50:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 10 12:50:19 2024
Received: from localhost ([127.0.0.1]:57024 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sRaWH-0002ab-5r
	for submit <at> debbugs.gnu.org; Wed, 10 Jul 2024 12:50:19 -0400
Received: from mout.gmx.net ([212.227.17.21]:59111)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <federicotedin@HIDDEN>) id 1sRa5l-0007Up-GA
 for 70198 <at> debbugs.gnu.org; Wed, 10 Jul 2024 12:22:57 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de;
 s=s31663417; t=1720628557; x=1721233357; i=federicotedin@HIDDEN;
 bh=lLWDZpeg8ypaxrRiFdb35Y/TfHzFOYmFUj6pvsuiGPk=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date:
 Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding:
 content-type:date:from:message-id:mime-version:reply-to:subject:
 to;
 b=bWishouhf+kBahB67OlorGkj0z2IIuZEd1hAah6Ubg7RWqPXIxtBhXn9WIPj7V71
 IpTLPnayq6x3k4Tm6WryI/+IyZqnsc26TPYEiOqn5+mSDu7Y/bjBFjdqMYO4KRXI1
 /Q3RrTW4WrN2LV+wMkAnnrA5YHBJ94C+JNSvn9xvkuPbSpH9O0cuuYIuzcXQH2crs
 CDe6vEkOe+ZJlb/YmC+tCAwDmGgAwpB9eLEgrWYkg6vcf09e6A8olkCferr1fU7Gi
 urlFO4QvMqwN8+KIsu0ccl2c+KI1fF3bjkLLvbKRF++R/JEUNHnzvy6Q9ZcMqI3kI
 N2Wtj6igq4JPICesVQ==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from seele ([62.214.67.158]) by mail.gmx.net (mrgmx104
 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MCbIx-1sa4Y21chf-001So5; Wed, 10
 Jul 2024 18:22:37 +0200
From: Federico Tedin <federicotedin@HIDDEN>
To: Dan Jacobson <jidanni@HIDDEN>
Subject: Re: bug#70198: M-x shell: deal with environment variables present
 when tab expanding
In-Reply-To: <Zg6wRQ1kVfgwALNU@HIDDEN> (Dan Jacobson's message of "Thu, 4
 Apr 2024 21:51:01 +0800")
References: <Zg6wRQ1kVfgwALNU@HIDDEN>
Date: Wed, 10 Jul 2024 18:22:35 +0200
Message-ID: <87plrlz06s.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Provags-ID: V03:K1:k7kEHa//Rh1bDiqMc3YS1/2xYpdn1fl6bLp1+MgUJaQzTrCET/i
 LvEZ8Mhxk6MPNpC/uCu7uSfmg4fDWVaDr6UWFSar2gfrbXX8iOzpnOcFKxeZBthvaZGjVUf
 WZySkNZ2h29RQzqIoIuec+IwJ/zxGbrRpRNPik+1KiIvn7qh0tuX4sZo8F0Qf4oAl48umw8
 n6E9al7bqPIYO0J0KZBtQ==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:r9oIaRksZW0=;nSdfjgYRlmjJdK2sJYkW4fXjx0v
 Bk/VHnos6sD+lOhEo8R9utw3xj3P9hHVBpuD3pnKD65RQpQvNIi3LBtGd5yfCz76U2VK7TLD3
 X1aWeRT2l0neKmhDRL9LYmOtIf+6u99DNrDEgQljLJU0xOucWQRThlgdoTyg9HZkDO/LlAh3W
 XoxrVdFI/XEyWZMj6K9XuEYSbfsCYx+7C/d6X5t/NRb6IyFC/EFqdgECqubV2yrGP3FqSgk2u
 jpGWkUGMc/Q6r9TqGGjuNB4hmw/HIYYWF1w3a6t9ECbwR6Z3EvbRZKsLSCVqLzEQCkyU16FQ+
 Lxtgr+Q/OdBTFjnHDl2l67wx3OFpabFvIPNOKLPJ/yqb69/Nphu45HdP8m55/Rrw6JKQPvNwa
 MC/B8qfnfWt292TjgefRW3I0Mt+JQI8L5N3gJ9gT2OBOKpW8VgtEB0PD74cfWLs7LSTTLOy96
 IkW4S1SVxUWI2Iykm++Rg/0LS3AFTaeeDTec1fZKYgWMUqw1z53ya5OHhGfQLFD+MRof3dCNV
 0LrIDXznKb0m34TqXu9YzEAvD0Y6zh20a72Kr33onX03ggOAcehIh6e/EC4JJEm1MgPbdUhjH
 eD8gxZSojsLq3CkBct/F6WhMGoYQP5f5bY62KKIQi95CIy7LQyM70O4w1iiYeiaGsjYX5jXHn
 lTnxJSQK9yUc3m6x7jFNOGlkMyVa4bsj+xX59nekTV+BRUEovZ5qQnO3rGSLoIMFtT0wy8Ig/
 XJ7EiWtMh9fF5shfs67U5SGfd1R53El9hlYvPMAoUGHYJgAjUo+ed+OPsZmdbXxt9gdi5mS9y
 9a5Sg2FHiiT9H5y2R5w6AQZw==
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 70198
X-Mailman-Approved-At: Wed, 10 Jul 2024 12:50:15 -0400
Cc: 70198 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

--=-=-=
Content-Type: text/plain

Dan Jacobson <jidanni@HIDDEN> writes:

> In M-x shell
> $ dat<TAB>
> expands to date.
> Alas, unlike bash readline,
> $ LC_ALL=C dat<TAB>
> doesn't yet.
>
> emacs-version "29.3"

I took a crack at fixing this, I'm attaching a patch.

It's been some time since my last contribution, but I've kept the
copyright assignment updated (should be under federicotedin@HIDDEN).
There's a chance the formatting for the patch may be a bit off too but I
tried to re-read the guide at CONTRIBUTE.

I've also found something interesting with the
`shell-dynamic-complete-command' function. I do not see it being called,
referred to, or assigned to a key anywhere in the Emacs code, but the
manual mentions it as if it being were actively used:

> Some implementation details of the shell command completion may also be found
> in the lisp documentation of the @code{shell-dynamic-complete-command}
> function.

Maybe the manual is outdated?

- Fede


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-Fix-tab-expanding-not-working-in-shell-mode-bug-7019.patch
Content-Description: patch
Content-Transfer-Encoding: quoted-printable

=46rom 9250d0c78fbc1c23469c125279604bbb8c965626 Mon Sep 17 00:00:00 2001
From: Federico Tedin <federicotedin@HIDDEN>
Date: Mon, 8 Jul 2024 14:47:33 +0200
Subject: [PATCH] Fix tab expanding not working in shell-mode (bug#70198)

In shell-mode, fix tab expanding when environment variables are
present before the command.
* lisp/shell.el (shell-command-completion): Fix indentation and
call use `shell--skip-environment-variables'.
(shell--skip-environment-variables): New function.
* test/lisp/shell-tests.el (shell-skip-environment-variables):
Test new function.
=2D--
 lisp/shell.el            | 22 +++++++++++++++++-----
 test/lisp/shell-tests.el | 17 +++++++++++++++++
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/lisp/shell.el b/lisp/shell.el
index e1936ff1119..fff7bdd4d71 100644
=2D-- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -1385,12 +1385,24 @@ shell-dynamic-complete-command

 (defun shell-command-completion ()
   "Return the completion data for the command at point, if any."
-  (let ((filename (comint-match-partial-filename)))
+  (let ((filename (comint-match-partial-filename))
+        (pt (point)))
     (if (and filename
-	     (save-match-data (not (string-match "[~/]" filename)))
-	     (eq (match-beginning 0)
-		 (save-excursion (shell-backward-command 1) (point))))
-	(shell--command-completion-data))))
+	         (save-match-data (not (string-match "[~/]" filename)))
+	         (eq (match-beginning 0)
+		         (save-excursion
+                   ;; Go back to beginning of command
+                   (shell-backward-command 1)
+                   ;; Skip any potential environment variables
+                   (shell--skip-environment-variables pt)
+                   (point))))
+	    (shell--command-completion-data))))
+
+(defun shell--skip-environment-variables (pt)
+  "Move forward up to PT through any present environment variables."
+  (while (re-search-forward "=3D" pt t)
+    (skip-syntax-forward "^ " pt)
+    (skip-syntax-forward " " pt)))

 (defun shell--command-completion-data ()
   "Return the completion data for the command at point."
diff --git a/test/lisp/shell-tests.el b/test/lisp/shell-tests.el
index 9bdf6b1c0eb..f07166d5995 100644
=2D-- a/test/lisp/shell-tests.el
+++ b/test/lisp/shell-tests.el
@@ -95,4 +95,21 @@ shell-directory-tracker-cd
       (should (not (equal start-dir list-buffers-directory)))
       (should (string-prefix-p list-buffers-directory start-dir)))))

+(ert-deftest shell-skip-environment-variables ()
+  (with-temp-buffer
+    (shell-mode)
+    (insert "FOO=3DBAR BAZ=3D QUUX=3Dabc=3Ddef whoami")
+    (let ((pt (point)))
+      (shell-backward-command 1)
+      (shell--skip-environment-variables pt))
+    (should (looking-at-p "whoami"))
+
+    (shell-backward-command 1)
+    (delete-line)
+    (insert "echo")
+    (let ((pt (point)))
+      (shell-backward-command 1)
+      (shell--skip-environment-variables pt))
+    (should (looking-at-p "echo"))))
+
 ;;; shell-tests.el ends here
=2D-
2.43.0


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#70198; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Apr 2024 13:51:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 04 09:51:32 2024
Received: from localhost ([127.0.0.1]:60910 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rsNV5-0008A6-Gl
	for submit <at> debbugs.gnu.org; Thu, 04 Apr 2024 09:51:32 -0400
Received: from lists.gnu.org ([2001:470:142::17]:51850)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jidanni@HIDDEN>) id 1rsNUz-00089W-UO
 for submit <at> debbugs.gnu.org; Thu, 04 Apr 2024 09:51:30 -0400
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 <jidanni@HIDDEN>)
 id 1rsNUn-0008Jm-Cg
 for bug-gnu-emacs@HIDDEN; Thu, 04 Apr 2024 09:51:14 -0400
Received: from cyan.elm.relay.mailchannels.net ([23.83.212.47])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <jidanni@HIDDEN>)
 id 1rsNUk-0002QT-Eg
 for bug-gnu-emacs@HIDDEN; Thu, 04 Apr 2024 09:51:13 -0400
X-Sender-Id: dreamhost|x-authsender|jidanni@HIDDEN
Received: from relay.mailchannels.net (localhost [127.0.0.1])
 by relay.mailchannels.net (Postfix) with ESMTP id 1F276901A8E
 for <bug-gnu-emacs@HIDDEN>; Thu,  4 Apr 2024 13:51:05 +0000 (UTC)
Received: from pdx1-sub0-mail-a316.dreamhost.com (unknown [127.0.0.6])
 (Authenticated sender: dreamhost)
 by relay.mailchannels.net (Postfix) with ESMTPA id E68F3902609
 for <bug-gnu-emacs@HIDDEN>; Thu,  4 Apr 2024 13:51:04 +0000 (UTC)
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1712238664; a=rsa-sha256;
 cv=none;
 b=yPsospQX3x5bW15vsshAtHbjoo0e3FMor473JompG44AlUI0ZXGS7b8kV70uRu8LfJNXsO
 LilE0Kn9T+aVSO1XLInbauQU06srVbEi3wsc4QSmHYpP3ZYv+94SB8jRos296OoN9cU2FB
 4K4wnTFCKvtZWVVydHvdacLGbx2yTNpeZF6k2tEYgOhS4WP8Ej1ILlbhyNVZ1AFbQ5NFs3
 Dz6lZiS5J1h8fMCIoftbfGh3QHblBBaRD246X1mnevZoZuROJDmVB2K7RZGK4AEpsdUMOK
 1XOQK/ebaWHL+Byw5MeT/cMmlcEUoziT9dmAFtz4mAzSQ0q7TB27nBYKJr/KBQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
 d=mailchannels.net; s=arc-2022; t=1712238664;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 dkim-signature; bh=om54/l9cDLQesgMKDnB2SFtClcaozQm4M7t8MCZh/yc=;
 b=R5dqS+mCLqO2scc11DjFwZbVr4q9LK39DNGI8mfnqa6SUaFtQGdSiMP4JSVsOJ4BgYLs4l
 LSvDCo7GYf/qVHMCB06YVbv/RcG22SwEtY+cSFgOP4r3DeG5g3YuZ0nTr+2bDB4oVovm/d
 qJXhjYyZEzRXBgLv9KWXvaJp5sPEZcVEGYBqkB/aIX9S7XxYEd3pf1syd6O9Tosuov8+xC
 /MiRC9l4kGUR3SPk2jDC7Q/JADMSZ2O2gQ8jG6wI+LCaED45J3FAQEYTGgZTtEW+6G+GrW
 5WIISkQL1wxWyTiMSj9FDY0yNccwskUnouti9FwxaNnyo39FRkzDOSzAZyh2nw==
ARC-Authentication-Results: i=1; rspamd-86f86f958-whfbb;
 auth=pass smtp.auth=dreamhost smtp.mailfrom=jidanni@HIDDEN
X-Sender-Id: dreamhost|x-authsender|jidanni@HIDDEN
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@HIDDEN
X-MailChannels-Auth-Id: dreamhost
X-Tank-Well-Made: 4c440a6f53a5f5e6_1712238664984_1783576204
X-MC-Loop-Signature: 1712238664984:1363627617
X-MC-Ingress-Time: 1712238664984
Received: from pdx1-sub0-mail-a316.dreamhost.com (pop.dreamhost.com
 [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384)
 by 100.102.225.137 (trex/6.9.2); Thu, 04 Apr 2024 13:51:04 +0000
Received: from jidanni.org (1-165-201-185.dynamic-ip.hinet.net [1.165.201.185])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest
 SHA256) (No client certificate requested)
 (Authenticated sender: jidanni@HIDDEN)
 by pdx1-sub0-mail-a316.dreamhost.com (Postfix) with ESMTPSA id 4V9NLc5ZjKz9w
 for <bug-gnu-emacs@HIDDEN>; Thu,  4 Apr 2024 06:51:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jidanni.org;
 s=dreamhost; t=1712238664;
 bh=om54/l9cDLQesgMKDnB2SFtClcaozQm4M7t8MCZh/yc=;
 h=Date:From:To:Subject:Content-Type;
 b=rmwn25JLaG4swSujLa4qxnOe7qJ1qmvXfpcoZgREpC1rqjXV2tfcWLCsDPCA+3fui
 aGSkeM2SpmJiaQgon0cllmyggz+6kogUsaUuZkdAQey1aQmBysUrfznWR1bHn0nrY3
 ryUUocU00IO4Bc2pmjumA5py/SL0Q6jWoO6eMXvKYK5iQRISYdBLKEo6I1Qbhu39lE
 wKMIB/G1PbI2EyBTh9M5meC5H1ovjWXtmeYN2ztFqz6EW8jk6u16d3d9bmyLxlifG0
 FWjdB+wj3ZjO4fFo19ceus80KTxn0BaitaytkEmymx48fqLxvHKw1z2SzWtgAOEIvC
 E4Im7Y5/I9Dwg==
Date: Thu, 4 Apr 2024 21:51:01 +0800
From: Dan Jacobson <jidanni@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: M-x shell: deal with environment variables present when tab expanding
Message-ID: <Zg6wRQ1kVfgwALNU@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Received-SPF: pass client-ip=23.83.212.47; envelope-from=jidanni@HIDDEN;
 helo=cyan.elm.relay.mailchannels.net
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

In M-x shell
$ dat<TAB>
expands to date.
Alas, unlike bash readline,
$ LC_ALL=C dat<TAB>
doesn't yet.

emacs-version "29.3"




Acknowledgement sent to Dan Jacobson <jidanni@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#70198; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 10 Jul 2024 18:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.