unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: eshell pipelines
Date: Wed, 13 Aug 2008 15:15:29 +0200	[thread overview]
Message-ID: <87iqu5jbta.fsf@tux.homenetwork> (raw)
In-Reply-To: <87abfhhzq4.fsf_-_@localhorst.mine.nu> (David Hansen's message of "Wed, 13 Aug 2008 14:21:55 +0200")

David Hansen <david.hansen@gmx.net> writes:

> [For emacs-devel: 
>
> In gnu.emacs.help there is a discussion about some little eshell,
> eshell/ls bug.  Processes in a pipeline get a TTY for IO (via
> `start-process').  Quite some programs behave different whether they
> have a TTY or not. 
>
> The other thing is that eshell/ls does not output one file per line
> when in a pipeline (as the usual GNU ls does).]
>
> On Wed, 13 Aug 2008 13:21:00 +0200 Thierry Volpiatto wrote:
>
>> As Lennart said you call ls with -1 arg or you can always call ls with
>> this arg setting it like that:
>>
>> ,----
>> | (setq eshell-ls-initial-args '(-1)) 
>> `----
>>
>> now when you call for example "ls | wc -l" , you will have the
>> good number of lines.
>>
>> It would be cool to have a function to call in some hook to call ls -1
>> only if there is a "|" after ls, this function do that but i need a hook
>> to call it:
>>
>> ,----
>> | (defun eshell-set-ls ()
>> |   (let ((com-line
>> |          (eshell-parse-arguments (re-search-backward "ls") (line-end-position))))
>> |     (if (equal (nth 1 com-line) '(eshell-operator "|"))
>> |         (setq eshell-ls-initial-args '(-1))
>> |         (setq eshell-ls-initial-args nil))))
>> `----
>
> Try the attached patch.  It
>
>  * Starts subprocesses in a (eshell) pipeline using a pipe and not a TTY
>    (this should also give some performance boost).
>
>  * Appends "-1" to eshell/ls if ls is called in a pipeline.
>
> At the time it's feature freeze for Emacs so it will probably take some
> time to make it in there.  Cc: anyways, maybe some old timer can approve
> the two lines.

After some quick tests that work fine.
Thank you.

>
> *** em-ls.el.~1.33.~	2008-06-07 20:14:50.000000000 +0200
> --- em-ls.el	2008-08-13 14:05:43.000000000 +0200
> ***************
> *** 299,304 ****
> --- 299,306 ----
>     (let ((insert-func 'eshell-buffered-print)
>   	(error-func 'eshell-error)
>   	(flush-func 'eshell-flush))
> +     ;; In pipelines use the -1 switch.
> +     (and eshell-in-pipeline-p (push "-1" args))
>       (eshell-do-ls args)))
>   
>   (put 'eshell/ls 'eshell-no-numeric-conversions t)
> *** esh-proc.el.~1.21.~	2008-05-12 20:30:41.000000000 +0200
> --- esh-proc.el	2008-08-13 14:20:38.000000000 +0200
> ***************
> *** 249,260 ****
>   	 proc decoding encoding changed)
>       (cond
>        ((fboundp 'start-process)
> !       (setq proc
> ! 	    (apply 'start-process
> ! 		   (file-name-nondirectory command) nil
> ! 		   ;; `start-process' can't deal with relative
> ! 		   ;; filenames
> ! 		   (append (list (expand-file-name command)) args)))
>         (eshell-record-process-object proc)
>         (set-process-buffer proc (current-buffer))
>         (if (eshell-interactive-output-p)
> --- 249,262 ----
>   	 proc decoding encoding changed)
>       (cond
>        ((fboundp 'start-process)
> !       ;; Don't use a TTY for processes in a pipeline.
> !       (let ((process-connection-type (not eshell-in-pipeline-p)))
> !         (setq proc
> !               (apply 'start-process
> !                      (file-name-nondirectory command) nil
> !                      ;; `start-process' can't deal with relative
> !                      ;; filenames
> !                      (append (list (expand-file-name command)) args))))
>         (eshell-record-process-object proc)
>         (set-process-buffer proc (current-buffer))
>         (if (eshell-interactive-output-p)

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




  reply	other threads:[~2008-08-13 13:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.16366.1218454746.18990.help-gnu-emacs@gnu.org>
2008-08-11 13:30 ` Optimal emacs shell for coding Xah
2008-08-11 15:24   ` Lennart Borgman (gmail)
     [not found]   ` <mailman.16375.1218468298.18990.help-gnu-emacs@gnu.org>
2008-08-11 15:49     ` Xah
2008-08-11 16:47       ` Lennart Borgman (gmail)
     [not found]       ` <mailman.16385.1218473260.18990.help-gnu-emacs@gnu.org>
2008-08-12  8:06         ` Tim X
2008-08-12 12:06           ` Lennart Borgman (gmail)
2008-08-12 18:33             ` Eli Zaretskii
2008-08-12 18:40               ` Lennart Borgman (gmail)
2008-08-12 18:52                 ` Eli Zaretskii
2008-08-12 19:02                   ` Lennart Borgman (gmail)
2008-08-12 19:11                     ` ken
2008-08-12 19:28                       ` Lennart Borgman (gmail)
2008-08-12 19:16                     ` Eli Zaretskii
     [not found]                     ` <mailman.16490.1218568567.18990.help-gnu-emacs@gnu.org>
2008-08-13  1:01                       ` Chris F.A. Johnson
2008-08-13  8:20                       ` Tim X
2008-08-13 11:21                         ` Thierry Volpiatto
2008-08-13 12:21                           ` eshell pipelines (Was: Re: Optimal emacs shell for coding) David Hansen
2008-08-13 13:15                             ` Thierry Volpiatto [this message]
2008-08-12 18:30           ` Optimal emacs shell for coding Eli Zaretskii
2008-08-12 19:14             ` David Hansen
     [not found]             ` <mailman.16492.1218569015.18990.help-gnu-emacs@gnu.org>
2008-08-12 20:08               ` Rupert Swarbrick
2008-08-11 19:18   ` Eli Zaretskii
2008-08-12  8:02   ` Tim X
2008-08-15  9:38     ` M-x terminal-emulator vs M-x term (was: Re: Optimal emacs shell for coding) Jonathan Groll
2008-08-11 13:40 ` Optimal emacs shell for coding Mike Treseler
2008-08-11 16:44   ` weber
2008-08-12  6:33     ` Mike Treseler

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=87iqu5jbta.fsf@tux.homenetwork \
    --to=thierry.volpiatto@gmail.com \
    --cc=help-gnu-emacs@gnu.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.
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).