From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70198: M-x shell: deal with environment variables present when tab expanding Date: Wed, 10 Jul 2024 20:45:11 +0300 Message-ID: <86wmltm994.fsf@gnu.org> References: <87plrlz06s.fsf@gmx.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5254"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70198@debbugs.gnu.org, jidanni@jidanni.org To: Federico Tedin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 10 19:46:16 2024 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 1sRbOR-00018M-NR for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Jul 2024 19:46:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRbOA-0005rC-T3; Wed, 10 Jul 2024 13:45:58 -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 1sRbO8-0005qw-4b for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2024 13:45:56 -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 1sRbO7-0000aa-Ld for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2024 13:45:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sRbOD-00049s-Qe for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2024 13:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jul 2024 17:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70198 X-GNU-PR-Package: emacs Original-Received: via spool by 70198-submit@debbugs.gnu.org id=B70198.172063353215949 (code B ref 70198); Wed, 10 Jul 2024 17:46:01 +0000 Original-Received: (at 70198) by debbugs.gnu.org; 10 Jul 2024 17:45:32 +0000 Original-Received: from localhost ([127.0.0.1]:57103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sRbNj-00049A-W4 for submit@debbugs.gnu.org; Wed, 10 Jul 2024 13:45:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52906) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sRbNi-00048v-AG for 70198@debbugs.gnu.org; Wed, 10 Jul 2024 13:45:30 -0400 Original-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 ) 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==; In-Reply-To: <87plrlz06s.fsf@gmx.de> (bug-gnu-emacs@gnu.org) 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:288693 Archived-At: > Cc: 70198@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" > > + (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?