From: Jim Porter <jporterbugs@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>,
Keith David Bershatsky <esq@lawlist.com>
Cc: 25270@debbugs.gnu.org
Subject: bug#25270: eshell -- programmatically send input -- feature request
Date: Sun, 15 May 2022 22:46:47 -0700 [thread overview]
Message-ID: <9f52fe73-30ef-edf9-1d5b-2bf134e69dac@gmail.com> (raw)
In-Reply-To: <87tu9tsf78.fsf@gnus.org>
On 5/13/2022 7:02 AM, Lars Ingebrigtsen wrote:
> Keith David Bershatsky <esq@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.
next prev parent reply other threads:[~2022-05-16 5:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-25 19:00 bug#25270: eshell -- programmatically send input -- feature request Keith David Bershatsky
2022-05-13 14:02 ` Lars Ingebrigtsen
2022-05-16 5:46 ` Jim Porter [this message]
2022-05-16 12:13 ` Lars Ingebrigtsen
2022-05-16 17:33 ` Jim Porter
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9f52fe73-30ef-edf9-1d5b-2bf134e69dac@gmail.com \
--to=jporterbugs@gmail.com \
--cc=25270@debbugs.gnu.org \
--cc=esq@lawlist.com \
--cc=larsi@gnus.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.