From: Mauro Aranda <maurooaranda@gmail.com>
To: 36103@debbugs.gnu.org
Cc: "Enric Rodríguez Carbonell" <erodri@cs.upc.edu>,
"Lars Ingebrigtsen" <larsi@gnus.org>,
"Noam Postavsky" <npostavs@gmail.com>,
relson@osagesoftware.com
Subject: bug#36103: 24.5; Blank spaces around parentheses in history expansion in shell mode
Date: Tue, 3 Oct 2023 07:54:34 -0300 [thread overview]
Message-ID: <1606cc4b-0247-860d-5706-7b9c631b8a4f@gmail.com> (raw)
In-Reply-To: <5fb3dec3-3c48-9a49-cc50-8f68981978af@cs.upc.edu>
Noam Postavsky <npostavs@gmail.com> writes:
> Enric Rodríguez Carbonell <erodri@cs.upc.edu> 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.
next prev parent reply other threads:[~2023-10-03 10:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 11:03 bug#36103: 24.5; Blank spaces around parentheses in history expansion in shell mode Enric Rodríguez Carbonell
2019-06-06 1:02 ` Noam Postavsky
2023-10-03 10:54 ` Mauro Aranda [this message]
2023-10-07 13:39 ` Mauro Aranda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1606cc4b-0247-860d-5706-7b9c631b8a4f@gmail.com \
--to=maurooaranda@gmail.com \
--cc=36103@debbugs.gnu.org \
--cc=erodri@cs.upc.edu \
--cc=larsi@gnus.org \
--cc=npostavs@gmail.com \
--cc=relson@osagesoftware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).