bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36103: 24.5; Blank spaces around parentheses in history expansion in


From: Mauro Aranda
Subject: bug#36103: 24.5; Blank spaces around parentheses in history expansion in shell mode
Date: Tue, 3 Oct 2023 07:54:34 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1

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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]