GNU bug report logs -
#25270
eshell -- programmatically send input -- feature request
Previous Next
Full log
Message #11 received at 25270 <at> debbugs.gnu.org (full text, mbox):
On 5/13/2022 7:02 AM, Lars Ingebrigtsen wrote:
> Keith David Bershatsky <esq <at> lawlist.com> writes:
>
>> As far as I am aware, users of eshell have been limited to sending
>> input programmatically by inserting the command into the eshell buffer
>> (at the command prompt) and then executing `eshell-send-input`. Some
>> users (like myself) may feel that such a solution is lo-tech -- i.e.,
>> not very eloquent.
>
> [...]
>
>> The following is an example of how this new feature might be implemented:
>>
>> SAMPLE USAGE: (eshell-send-input nil nil nil "ls -la /")
>>
>> (require 'eshell)
>>
>> (defun eshell-send-input (&optional use-region queue-p no-newline input-string-a)
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> I think this makes sense, but I'm not very familiar with eshell
> internals, so I've added Jim to the CCs; perhaps he has some comments.
Hm, I think it's reasonable to have something similar to
`comint-send-string' for Eshell, but I'm not quite sure what the best
way to do this would be. I think a separate function, like
`eshell-send-string', would probably be a nicer API, since it could be
called like `comint-send-string'.
Also, for the code posted in the original message, I'm not sure the
changes to `eshell-parse-command' are needed. It should already let you
pass a command string to it. Maybe this is because there's an issue with
how `eshell-parse-command' temporarily inserts COMMAND into the buffer
(see the FIXME comment in the code in the original message)? If there
is, we'd probably have to think quite a bit more about how to resolve it.
Some background: I think it would be pretty risky to try to perform
Eshell argument parsing anywhere *but* in the contents of the current
Eshell buffer, as in `eshell-parse-arguments--temp-buffer' in the
original message. See `eshell-with-temp-command' in Emacs 29 (which is
what the FIXME comment morphed into), in particular this part:
;; Since parsing relies partly on buffer-local state
;; (e.g. that of `eshell-parse-argument-hook'), we need to
;; perform the parsing in the Eshell buffer.
Basically, Eshell is extremely flexible, and argument parsing is handled
by `eshell-parse-argument-hook', which can do all sorts of things to
change how arguments are parsed, and may even be buffer-local to a
particular Eshell instance. Parsing Eshell arguments anywhere but the
"target" Eshell buffer is asking for trouble.
I'll see if I can put together a patch along the above line in the next
couple weeks.
This bug report was last modified 3 years and 31 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.