Subject: bug#46351: 28.0.50; Add convenient way to bypass Eshell's own pipelining

From: Michael Albinus <[email-masked]>
Date: Mon, 08 Feb 2021 11:28:54 +0100

Sean Whitton <[email-masked]> writes:

Hi Sean,

>> Applying your patch, I get the compiler warning
>>
>> --8<---------------cut here---------------start------------->8---
>>   ELC      eshell/esh-mode.elc
>>
>> In end of data:
>> eshell/esh-mode.el:1114:1: Warning: the function ‘(setf buffer-substring)’ is
>>     not known to be defined.
>> --8<---------------cut here---------------end--------------->8---
>
> Hrm, I can't reproduce this, but looking at the docs, I think that the
> problem is a missing (require 'cl-lib).  Would you mind seeing whether
> that eliminates the warning at your end?

Yes, that helps.

>> And using it in eshell, there is
>>
>> --8<---------------cut here---------------start------------->8---
>> ~/src/emacs $ !! cat ~/.emacs | grep albinus
>> !!: command not found
>> --8<---------------cut here---------------end--------------->8---
>
> You need to add eshell-expand-to-eshell-shell-command to
> eshell-expand-input-functions and (optionally)
> eshell-restore-unexpanded-input to eshell-input-filter-functions.  Or
> maybe (the first of) these should be added by default?  What do you think?
>
> For testing you can type these forms into an Eshell buffer:
>
> (add-hook 'eshell-expand-input-functions #'eshell-expand-to-eshell-shell-command nil t)
> (add-hook 'eshell-input-filter-functions #'eshell-restore-unexpanded-input nil t)

That works. Maybe we could add it to the defaults. But at least I would
like to see it documented in the eshell manual, otherwise nobody will
know the effect of "!!".

And I have the impression, that the eshell history is not preserved any
longer, when I have applied these settings.

>> I wanted to see, whether this works also for remote directories. Have
>> you tested this?
>
> Yes, I have, and it works (I did cat largefile >file and confirmed it's
> much faster when prefixed with !!, of course because the data doesn't
> get copied to the local machine).

It doesn't work for me. The reason is a little bit subtle: you use
`shell-file-name' in order to call a remote shell. In my case, it is
"/usr/local/bin/tcsh", which doesn't exist on the remote machine I've
used for testing.

Maybe you can base your implementation on `shell-command'? This should
know, how to handle a connection-local `shell-file-name'.

Best regards, Michael.