* eshell and jobs
@ 2003-01-28 17:27 Michael Spittel
2003-01-28 17:39 ` David Kastrup
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Michael Spittel @ 2003-01-28 17:27 UTC (permalink / raw)
Dear Emacsers
I've just fallen in love with eshell, and it is now an important
part of my daily life :-), but I have a question I was wondering if
any of you eshell master's could help me solve. (nudge nudge Kai) :-)
When I'm running a job, eshell has the courtesy to tell me that the
job is done by reporting at the bottom of the screen (command line?),
that the job is finished.
I was wondering, is there a way to make that output goto a buffer with
a name of my choosing (e.g. *eshell.job.finished*)?
The reason I ask is that I would like it to actually tell me the job
is done, but in a separate window. I assume that once I can redirect
eshells message to a buffer, all I have to do is add it to my
special-dispaly-buffer-names to get it to tell me it is done in a
separate window, like such:
(setq special-display-buffer-names
'(
("*Calendar*"
(top . 580) (left . 1) (width . 82) (height . 10)
(menu-bar-lines . 0)
(font . "lucidasanstypewriter-12" )
(foreground-color . "black") (background-color . "slate gray"))
("*Process List*"
(top . 580) (left . 1) (width . 82) (height . 10)
(menu-bar-lines . 0)
(font . "lucidasanstypewriter-12" )
(foreground-color . "black") (background-color . "light steel blue"))
("*eshell.job.finished"
(top . 580) (left . 600) (width . 58) (height . 10)
(menu-bar-lines . 0)
(font . "lucidasanstypewriter-12" )
(foreground-color . "black") (background-color . "cornflower blue"))
)
)
If its of any relevance, I'm using the latest eshell, emacs v20.7 on a
the latest red hat.
thanks in advanced,
mike
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-28 17:27 eshell and jobs Michael Spittel
@ 2003-01-28 17:39 ` David Kastrup
2003-01-28 18:17 ` Michael Spittel
2003-01-29 7:20 ` Kai Großjohann
2003-01-30 20:29 ` John Wiegley
2 siblings, 1 reply; 16+ messages in thread
From: David Kastrup @ 2003-01-28 17:39 UTC (permalink / raw)
Michael Spittel <mspittel@kite.ssc.wisc.edu> writes:
> If its of any relevance, I'm using the latest eshell, emacs v20.7 on a
> the latest red hat.
Why would you want to do that? The latest RedHat comes with
Emacs-21.2.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-28 17:27 eshell and jobs Michael Spittel
2003-01-28 17:39 ` David Kastrup
@ 2003-01-29 7:20 ` Kai Großjohann
2003-01-29 13:16 ` eshell and jobs. THANK YOU KAI Michael Spittel
` (2 more replies)
2003-01-30 20:29 ` John Wiegley
2 siblings, 3 replies; 16+ messages in thread
From: Kai Großjohann @ 2003-01-29 7:20 UTC (permalink / raw)
Michael Spittel <mspittel@kite.ssc.wisc.edu> writes:
> (nudge nudge Kai) :-)
I'm listening, but I'm afraid I can't help. I don't know how to
redirect the output of a command to a buffer.
Hm. But I have this:
(defun eshell/ec (&rest args)
"Use `compile' to do background makes."
(if (eshell-interactive-output-p)
(let ((compilation-process-setup-function
(list 'lambda nil
(list 'setq 'process-environment
(list 'quote (eshell-copy-environment))))))
(compile (eshell-flatten-and-stringify args))
(pop-to-buffer compilation-last-buffer))
(throw 'eshell-replace-command
(let ((l (eshell-stringify-list (eshell-flatten-list args))))
(eshell-parse-command (car l) (cdr l))))))
(put 'eshell/ec 'eshell-no-numeric-conversions t)
This this code, you can do
ec ls -l
and the output of ls -l will go to a separate buffer. It's not the
same as redirection, but maybe it's good enough?
--
Ambibibentists unite!
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs. THANK YOU KAI
2003-01-29 7:20 ` Kai Großjohann
@ 2003-01-29 13:16 ` Michael Spittel
2003-01-29 15:52 ` eshell and jobs Kai Großjohann
2003-01-29 19:11 ` Stefan Monnier <foo@acm.com>
2 siblings, 0 replies; 16+ messages in thread
From: Michael Spittel @ 2003-01-29 13:16 UTC (permalink / raw)
Kai,
Thank you for your reply. Your code worked brilliantly!!!
Thank you very very much.
cheers,
mike
ps, Not knowing lisp, can you briefly explain what the code does?
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> Michael Spittel <mspittel@kite.ssc.wisc.edu> writes:
>
> > (nudge nudge Kai) :-)
>
> I'm listening, but I'm afraid I can't help. I don't know how to
> redirect the output of a command to a buffer.
>
> Hm. But I have this:
>
> (defun eshell/ec (&rest args)
> "Use `compile' to do background makes."
> (if (eshell-interactive-output-p)
> (let ((compilation-process-setup-function
> (list 'lambda nil
> (list 'setq 'process-environment
> (list 'quote (eshell-copy-environment))))))
> (compile (eshell-flatten-and-stringify args))
> (pop-to-buffer compilation-last-buffer))
> (throw 'eshell-replace-command
> (let ((l (eshell-stringify-list (eshell-flatten-list args))))
> (eshell-parse-command (car l) (cdr l))))))
> (put 'eshell/ec 'eshell-no-numeric-conversions t)
>
> This this code, you can do
>
> ec ls -l
>
> and the output of ls -l will go to a separate buffer. It's not the
> same as redirection, but maybe it's good enough?
> --
> Ambibibentists unite!
--
-Mike Spittel
--------------------------------------------------------------------
Michael Ludwig Spittel O (=> Center for Demography and Ecology
Tel: (608) 256-7742 )/\_,_[__] University of Wisconsin-Madison
Fax: (608) 262-8400 T>_ | | 1180 Observatory DR.
Email: mspittel@ssc.wisc.edu + + Madison, WI 53706
--------------------------------------------------------------------
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-29 7:20 ` Kai Großjohann
2003-01-29 13:16 ` eshell and jobs. THANK YOU KAI Michael Spittel
@ 2003-01-29 15:52 ` Kai Großjohann
2003-01-29 16:20 ` Romain FRANCOISE
2003-01-29 18:54 ` Kevin Rodgers
2003-01-29 19:11 ` Stefan Monnier <foo@acm.com>
2 siblings, 2 replies; 16+ messages in thread
From: Kai Großjohann @ 2003-01-29 15:52 UTC (permalink / raw)
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
A code explanation was requested. I basically copied from
eshell/make, so I don't fully grok it. Here comes what I know:
> (defun eshell/ec (&rest args)
If you type "foo" at an eshell prompt, eshell will look for the Lisp
function eshell/foo first thing and run that if it exists.
> "Use `compile' to do background makes."
> (if (eshell-interactive-output-p)
It seems the `then' branch here is what is normally invoked. I have
no idea what the `else' branch does. John, are you listening?
> (let ((compilation-process-setup-function
> (list 'lambda nil
> (list 'setq 'process-environment
> (list 'quote (eshell-copy-environment))))))
This copies the current environment so that `compile' will pick it up.
> (compile (eshell-flatten-and-stringify args))
To see what compile does, type M-x compile RET and enter some shell
command. The eshell-flatten-and-stringify just takes the rest of the
command line args and munges them until they are what `compile'
expects. (I think `compile' expects just a single string, so I guess
that eshell-flatten-and-stringify concats all args, separated with
spaces.)
> (pop-to-buffer compilation-last-buffer))
Make sure to display the *compilation* buffer.
> (throw 'eshell-replace-command
> (let ((l (eshell-stringify-list (eshell-flatten-list args))))
> (eshell-parse-command (car l) (cdr l))))))
Can anyone explain what this might mean?
> (put 'eshell/ec 'eshell-no-numeric-conversions t)
It seems that eshell can recognize numbers and do something with
them. But what?
--
Ambibibentists unite!
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-29 15:52 ` eshell and jobs Kai Großjohann
@ 2003-01-29 16:20 ` Romain FRANCOISE
2003-01-29 16:41 ` Michael Spittel
2003-01-29 18:54 ` Kevin Rodgers
1 sibling, 1 reply; 16+ messages in thread
From: Romain FRANCOISE @ 2003-01-29 16:20 UTC (permalink / raw)
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> It seems the `then' branch here is what is normally invoked. I have
> no idea what the `else' branch does.
It's for cases when we're not supposed to output something on the
command line, e.g. when called for a file redirection, or something. Or
in eshell scripts. Or when called non-interactively, or by another
function. John will know better. :)
Anyway, what it does in eshell/make is to tell Eshell to use the real
make ("*make") instead of the Emacs compile interface in such cases.
>> (throw 'eshell-replace-command
>> (let ((l (eshell-stringify-list (eshell-flatten-list args))))
>> (eshell-parse-command (car l) (cdr l))))))
> Can anyone explain what this might mean?
If not called with output focus, just return the command, separating the
command itself from its arguments. Not sure if it really works though.
:)
>> (put 'eshell/ec 'eshell-no-numeric-conversions t)
> It seems that eshell can recognize numbers and do something with
> them. But what?
If Eshell recognizes numbers in the argument list, it passes them as
numbers to Lisp functions (not as strings).
,----
| From esh-util.el:
|
| NOTE: If you find that numeric conversions are intefering with the
| specification of filenames (for example, in calling `find-file', or
| some other Lisp function that deals with files, not numbers), add the
| following in your .emacs file:
|
| (put 'find-file 'eshell-no-numeric-conversions t)
|
| Any function with the property `eshell-no-numeric-conversions' set to
| a non-nil value, will be passed strings, not numbers, even when an
| argument matches `eshell-number-regexp'."
`----
The usual No Expert(tm) disclaimer applies, of course.
--
Romain FRANCOISE <romain@orebokech.com> | There are doors that let you
it's a miracle -- http://orebokech.com/ | in.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-29 15:52 ` eshell and jobs Kai Großjohann
2003-01-29 16:20 ` Romain FRANCOISE
@ 2003-01-29 18:54 ` Kevin Rodgers
1 sibling, 0 replies; 16+ messages in thread
From: Kevin Rodgers @ 2003-01-29 18:54 UTC (permalink / raw)
Kai Großjohann wrote:
> kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
>> (let ((compilation-process-setup-function
>> (list 'lambda nil
>> (list 'setq 'process-environment
>> (list 'quote (eshell-copy-environment))))))
>
> This copies the current environment so that `compile' will pick it up.
I think this is a little more readable:
(let ((compilation-process-setup-function
`(lambda ()
(setq process-environment
(quote ,(eshell-copy-environment))))))
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-29 7:20 ` Kai Großjohann
2003-01-29 13:16 ` eshell and jobs. THANK YOU KAI Michael Spittel
2003-01-29 15:52 ` eshell and jobs Kai Großjohann
@ 2003-01-29 19:11 ` Stefan Monnier <foo@acm.com>
2003-01-30 20:28 ` John Wiegley
2 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2003-01-29 19:11 UTC (permalink / raw)
Cc: John Wiegley
>>>>> "Kai" == Kai Großjohann <kai.grossjohann@uni-duisburg.de> writes:
> (let ((compilation-process-setup-function
> (list 'lambda nil
> (list 'setq 'process-environment
> (list 'quote (eshell-copy-environment))))))
The variable is not buffer-local and it doesn't seem to be let-bound
while compilation-process-setup-function is run, so I suspect that
this code might end up modifying the global value of process-environment.
Since this is copied more or less verbatim from eshell/em-unix.el,
maybe John can explain why it is safe to do thing this way ?
Stefan "who'd also use ` and , rather than `list'."
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-28 17:27 eshell and jobs Michael Spittel
2003-01-28 17:39 ` David Kastrup
2003-01-29 7:20 ` Kai Großjohann
@ 2003-01-30 20:29 ` John Wiegley
2003-01-30 21:03 ` Michael Spittel
2 siblings, 1 reply; 16+ messages in thread
From: John Wiegley @ 2003-01-30 20:29 UTC (permalink / raw)
>>>>> Michael Spittel <mspittel@kite.ssc.wisc.edu> writes:
> When I'm running a job, eshell has the courtesy to tell me that the
> job is done by reporting at the bottom of the screen (command line?),
> that the job is finished.
>
> I was wondering, is there a way to make that output goto a buffer with
> a name of my choosing (e.g. *eshell.job.finished*)?
You will have to rewrite `eshell-remove-process-entry', so that it
inserts something into a buffer rather than calling message. For
example:
(defun eshell-remove-process-entry (entry)
"Record the process ENTRY as fully completed."
(if (and (eshell-processp (car entry))
(nth 2 entry)
eshell-done-messages-in-minibuffer)
(with-current-buffer (get-buffer-create "*eshell.job.finished*")
(insert (format "[%s]+ Done %s" (process-name (car entry))
(process-command (car entry))))))
(setq eshell-process-list
(delq entry eshell-process-list)))
John
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-30 20:29 ` John Wiegley
@ 2003-01-30 21:03 ` Michael Spittel
2003-01-30 21:56 ` John Wiegley
0 siblings, 1 reply; 16+ messages in thread
From: Michael Spittel @ 2003-01-30 21:03 UTC (permalink / raw)
Thank you for your response John.
Actually, when I inserted Kai's original suggested code in my .emacs
file, (see below), in eshell all I had to do was type
ec program inputfile &
and eshell gave me the fact that the jobs was running in a buffer called
*compilation*. When it was done, it then told me in that same buffer
that the job was completed.
Kai's suggested code-------snip here-----------
(defun eshell/ec (&rest args)
"Use `compile' to do background makes."
(if (eshell-interactive-output-p)
(let ((compilation-process-setup-function
(list 'lambda nil
(list 'setq 'process-environment
(list 'quote (eshell-copy-environment))))))
(compile (eshell-flatten-and-stringify args))
(pop-to-buffer compilation-last-buffer))
(throw 'eshell-replace-command
(let ((l (eshell-stringify-list (eshell-flatten-list args))))
(eshell-parse-command (car l) (cdr l))))))
(put 'eshell/ec 'eshell-no-numeric-conversions t)
----------end of snip-------
But when I put in the code you suggested into my .emacs, eshell still
told me the job was done in the command line, and it did not create a
new buffer by the name of *eshell.job.finished*. In other words, it
behaved as the eshell we all know and love :-)
I know I'm going to show my utter ignorance for elisp in the following
question, but is there anything inherently 'wrong' with using the code
that Kai suggested?
thanks
mike
John Wiegley <johnw@gnu.org> writes:
> You will have to rewrite `eshell-remove-process-entry', so that it
> inserts something into a buffer rather than calling message. For
> example:
>
> (defun eshell-remove-process-entry (entry)
> "Record the process ENTRY as fully completed."
> (if (and (eshell-processp (car entry))
> (nth 2 entry)
> eshell-done-messages-in-minibuffer)
> (with-current-buffer (get-buffer-create "*eshell.job.finished*")
> (insert (format "[%s]+ Done %s" (process-name (car entry))
> (process-command (car entry))))))
> (setq eshell-process-list
> (delq entry eshell-process-list)))
>
> John
--
-Mike Spittel
--------------------------------------------------------------------
Michael Ludwig Spittel O (=> Center for Demography and Ecology
Tel: (608) 256-7742 )/\_,_[__] University of Wisconsin-Madison
Fax: (608) 262-8400 T>_ | | 1180 Observatory DR.
Email: mspittel@ssc.wisc.edu + + Madison, WI 53706
--------------------------------------------------------------------
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: eshell and jobs
2003-01-30 21:03 ` Michael Spittel
@ 2003-01-30 21:56 ` John Wiegley
2003-01-30 22:25 ` Michael Spittel
2003-01-31 14:34 ` Kai Großjohann
0 siblings, 2 replies; 16+ messages in thread
From: John Wiegley @ 2003-01-30 21:56 UTC (permalink / raw)
>>>>> Michael Spittel <mspittel@kite.ssc.wisc.edu> writes:
> But when I put in the code you suggested into my .emacs, eshell
> still told me the job was done in the command line, and it did not
> create a new buffer by the name of *eshell.job.finished*. In other
> words, it behaved as the eshell we all know and love :-)
Make sure the code snippit is evaluated *after* eshell is loaded,
not before...
> I know I'm going to show my utter ignorance for elisp in the
> following question, but is there anything inherently 'wrong' with
> using the code that Kai suggested?
Nope, not if you don't mind typing "ec" before your commands. I use
a similar command called "start", which disowns the process so that
it doesn't die if Emacs should go away.
John
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2003-01-31 14:34 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-28 17:27 eshell and jobs Michael Spittel
2003-01-28 17:39 ` David Kastrup
2003-01-28 18:17 ` Michael Spittel
2003-01-29 7:20 ` Kai Großjohann
2003-01-29 13:16 ` eshell and jobs. THANK YOU KAI Michael Spittel
2003-01-29 15:52 ` eshell and jobs Kai Großjohann
2003-01-29 16:20 ` Romain FRANCOISE
2003-01-29 16:41 ` Michael Spittel
2003-01-29 18:54 ` Kevin Rodgers
2003-01-29 19:11 ` Stefan Monnier <foo@acm.com>
2003-01-30 20:28 ` John Wiegley
2003-01-30 20:29 ` John Wiegley
2003-01-30 21:03 ` Michael Spittel
2003-01-30 21:56 ` John Wiegley
2003-01-30 22:25 ` Michael Spittel
2003-01-31 14:34 ` Kai Großjohann
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).