From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#36103: 24.5; Blank spaces around parentheses in history expansion in shell mode Date: Tue, 3 Oct 2023 07:54:34 -0300 Message-ID: <1606cc4b-0247-860d-5706-7b9c631b8a4f@gmail.com> References: <5fb3dec3-3c48-9a49-cc50-8f68981978af@cs.upc.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32475"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Cc: Enric =?UTF-8?Q?Rodr=C3=ADguez?= Carbonell , Lars Ingebrigtsen , Noam Postavsky , relson@osagesoftware.com To: 36103@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 03 12:56:06 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 1qnd4P-00086j-Vg for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Oct 2023 12:56:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnd46-0006Ez-Lv; Tue, 03 Oct 2023 06:55:46 -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 1qnd45-0006E0-Bb for bug-gnu-emacs@gnu.org; Tue, 03 Oct 2023 06:55:45 -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 1qnd45-0003dR-3K for bug-gnu-emacs@gnu.org; Tue, 03 Oct 2023 06:55:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qnd4L-0000Yg-Mi for bug-gnu-emacs@gnu.org; Tue, 03 Oct 2023 06:56:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <5fb3dec3-3c48-9a49-cc50-8f68981978af@cs.upc.edu> Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Oct 2023 10:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36103 X-GNU-PR-Package: emacs Original-Received: via spool by 36103-submit@debbugs.gnu.org id=B36103.16963305042039 (code B ref 36103); Tue, 03 Oct 2023 10:56:01 +0000 Original-Received: (at 36103) by debbugs.gnu.org; 3 Oct 2023 10:55:04 +0000 Original-Received: from localhost ([127.0.0.1]:38923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qnd3P-0000Wo-Qm for submit@debbugs.gnu.org; Tue, 03 Oct 2023 06:55:04 -0400 Original-Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:48251) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qnd3N-0000W8-EG for 36103@debbugs.gnu.org; Tue, 03 Oct 2023 06:55:02 -0400 Original-Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c724577e1fso5671785ad.0 for <36103@debbugs.gnu.org>; Tue, 03 Oct 2023 03:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696330478; x=1696935278; darn=debbugs.gnu.org; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Vjv0GAaTHsckSSYtmOTpcEVSK4UQqbXgfEJp0FsM+tc=; b=PKs2Q0q1UvktV3giPFRDv+imlQOxPDH/UryGLw1O/r0MhVXioypiavZ1YjH18e1LQy MZt8f6PnXyaQOvngZh7WufsutJMnexmyB7TzxM/OPMz4GzMgxSluhL/UsajwS/xVWILA Qr6nIj2CAm69xORYzpauiXohNAM3EC27vWGcUj/gworSW+mbxA77gNUmHDH67pVD4RgN igXCajxTlXUbDfRcUNGQtdGXeU9FOKzCI53KdNaXSv1TpZU+Y1g6ydivKEc0nUMJOsiI HkA+hOyOKzMguI4bTYGNYVCNUFambj/+YAVh9YmGThgZwdeCaC876ehYvFLxwv2pjD+R GymA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696330478; x=1696935278; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Vjv0GAaTHsckSSYtmOTpcEVSK4UQqbXgfEJp0FsM+tc=; b=Lsq+RjHe7ASF9YVfIrQ1N1WivlKZjMIQ4NeW/Nl98DoZ9whLNBYzLUc1MACSrXPVKj JMLYkhZcI6zY2J4qPX6vOOrfk/noj9vwlwg03z8T86eGXzi9FYmiWZuxilCth0zFDqxN b+wjWe/PU9TJpAhp/3RCtf3ySCy+QzYsJj82JuIAecM5wfvLTyiR6vT37YQ1Ac5nq2Vp mUOFRKyISITkrX8lpzwiaUGZYoNqIMVCwGWFGopTCO8IO6UdYvY41MwiJpMCtNwOGPHK nbp92CytS8DkCbYREF/u6Why2pqfTbXRju83iPIkDdNRutdzyJ5eE4vDXT9IuT7Nz8Ld E0zg== X-Gm-Message-State: AOJu0YwLnagPSQCM+LRJTWFG1lSUkPToYUPWLY8h3YIRUD6t2iC4xoZz wPmrwowtPP+FJerCEFnvn49IaDI5r3DH0A== X-Google-Smtp-Source: AGHT+IH4LWa6rQWB/JbmbKKjopeRdpyK5bTMguQCu0wu+aAnfEQ4M1smqH6DaZvK200kebtMm2ElPg== X-Received: by 2002:a17:902:efd6:b0:1c5:e1b7:1c13 with SMTP id ja22-20020a170902efd600b001c5e1b71c13mr11195294plb.3.1696330477748; Tue, 03 Oct 2023 03:54:37 -0700 (PDT) Original-Received: from [192.168.0.234] ([152.168.142.156]) by smtp.gmail.com with ESMTPSA id iw15-20020a170903044f00b001c75f94b0b0sm1196581plb.213.2023.10.03.03.54.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Oct 2023 03:54:37 -0700 (PDT) Content-Language: en-US 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:271706 Archived-At: Noam Postavsky writes: > Enric Rodríguez Carbonell writes: > >> $ for file in $(ls); do echo $file; done > >> $ !for > >> M-x comint-replace-by-expanded-history > >> $ for file in $ ( ls ) ; do echo $file ; done >> >> The blank spaces around the parentheses should not be there. >> Because of these blank spaces, this command cannot be executed, >> as "$ (" should be "$(". > > Yes, the problem is in comint-arguments which attempts to parse a shell > line into separate arguments, using just a bunch of regexps.  This is > doomed to failure I think.  But the alternative would be a full blown > shell parser, so I don't know how feasible it will be to fix this bug. > It's been with us a long time. I just wanted to point out that since we now have treesitter support for bash, this bug might be easier to fix, at least partially... A first idea (trying to be backward-compatible and non-intrusive) is to define a new variable, comint-arguments-function, turn the current comint-arguments function into a comint-arguments-default function, and set comint-arguments-function to that by default.  From now on, comint-arguments would just call the comint-arguments-function and return whatever that returns. Then, shell.el can set comint-arguments-function to a new function, that, if there is treesitter support for the program being run by shell (bash or sh, AFAICS), tries to do a better job than comint-arguments as of now.  If there's no treesitter support, or something fails, then it can just punt to comint-arguments-default-function.