* Executing init script after launching eshell
@ 2012-03-27 7:58 C K Kashyap
2012-03-27 8:53 ` Tom Willemsen
0 siblings, 1 reply; 5+ messages in thread
From: C K Kashyap @ 2012-03-27 7:58 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
Hi All,
Here's what I'd like to be doing - When I start emacs, I typically open up
multiple eshells to do different kinds of compilation etc. Is there a way
to retain the "session" in such a manner that all open eshells are also
retained.
As a workaround I was attempting to write a script that would open up the
necessary eshells -
(progn
(eshell)
(rename-buffer "b1")
(insert "cd path1\n")
(eshell)
(rename-buffer "b2")
(insert "cd path2\n")
)
The problem is that I am not able to cd into the right place in eshell
using (insert "cd path1\n") !!!
Regards,
Kashyap
[-- Attachment #2: Type: text/html, Size: 725 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Executing init script after launching eshell
2012-03-27 7:58 Executing init script after launching eshell C K Kashyap
@ 2012-03-27 8:53 ` Tom Willemsen
2012-03-27 10:26 ` C K Kashyap
0 siblings, 1 reply; 5+ messages in thread
From: Tom Willemsen @ 2012-03-27 8:53 UTC (permalink / raw)
To: C K Kashyap; +Cc: help-gnu-emacs
Hey Kashyap,
On Tue 27 Mar 2012 09:58:46 AM CEST, C K Kashyap wrote:
> Hi All,
>
> Here's what I'd like to be doing - When I start emacs, I typically open up
> multiple eshells to do different kinds of compilation etc. Is there a way
> to retain the "session" in such a manner that all open eshells are also
> retained.
>
> As a workaround I was attempting to write a script that would open up the
> necessary eshells -
>
> (progn
> (eshell)
> (rename-buffer "b1")
> (insert "cd path1\n")
> (eshell)
> (rename-buffer "b2")
> (insert "cd path2\n")
> )
Maybe the following could work, it seems to do what you want when I try
it here.
(progn
(let ((default-directory "path1"))
(eshell t)
(rename-buffer "b1"))
(let ((default-directory "path2"))
(eshell t)
(rename-buffer "b2")))
I don't know if using `default-directory' like that is such a great
idea, but it looks slightly better than the result of:
(progn
(eshell t)
(eshell/cd "path1")
(eshell-send-input)
(eshell t)
(eshell/cd "path2")
(eshell-send-input))
> The problem is that I am not able to cd into the right place in eshell
> using (insert "cd path1\n") !!!
That seems to be because you don't use `eshell-send-input'
Hope it helps in some small way.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Executing init script after launching eshell
2012-03-27 8:53 ` Tom Willemsen
@ 2012-03-27 10:26 ` C K Kashyap
2012-03-27 11:21 ` Tom Willemsen
0 siblings, 1 reply; 5+ messages in thread
From: C K Kashyap @ 2012-03-27 10:26 UTC (permalink / raw)
To: Tom Willemsen; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 790 bytes --]
Thanks Tom
Maybe the following could work, it seems to do what you want when I try
> it here.
>
> (progn
> (let ((default-directory "path1"))
> (eshell t)
> (rename-buffer "b1"))
> (let ((default-directory "path2"))
> (eshell t)
> (rename-buffer "b2")))
>
>
This is a working solution for me.
> (progn
> (eshell t)
> (eshell/cd "path1")
> (eshell-send-input)
> (eshell t)
> (eshell/cd "path2")
> (eshell-send-input))
>
>
The above snippet does not seem to work for me. Could you please explain
the below lines ?
(eshell t) -> This opens up a new eshell
(eshell/cd "path1") - ?????
(eshell-send-input) - I am guessing the command in the previous step gets
passed on using this command.
> Hope it helps in some small way.
>
Absolutely helps!!!
Regards,
Kashyap
[-- Attachment #2: Type: text/html, Size: 1465 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Executing init script after launching eshell
2012-03-27 10:26 ` C K Kashyap
@ 2012-03-27 11:21 ` Tom Willemsen
2012-03-27 13:13 ` C K Kashyap
0 siblings, 1 reply; 5+ messages in thread
From: Tom Willemsen @ 2012-03-27 11:21 UTC (permalink / raw)
To: C K Kashyap; +Cc: help-gnu-emacs
Hey Kashyap,
On Tue 27 Mar 2012 12:26:37 PM CEST, C K Kashyap wrote:
> Thanks Tom
>
> Maybe the following could work, it seems to do what you want when I try
> > it here.
> >
> > (progn
> > (let ((default-directory "path1"))
> > (eshell t)
> > (rename-buffer "b1"))
> > (let ((default-directory "path2"))
> > (eshell t)
> > (rename-buffer "b2")))
> >
> >
> This is a working solution for me.
Excellent!
> > (progn
> > (eshell t)
> > (eshell/cd "path1")
> > (eshell-send-input)
> > (eshell t)
> > (eshell/cd "path2")
> > (eshell-send-input))
> >
> >
> The above snippet does not seem to work for me. Could you please explain
> the below lines ?
>
> (eshell t) -> This opens up a new eshell
> (eshell/cd "path1") - ?????
> (eshell-send-input) - I am guessing the command in the previous step gets
> passed on using this command.
The `eshell/cd' function is what is executed when you type 'cd' into
eshell, unless you have changed this. It doesn't change what you see in
eshell though, so the `eshell-send-input' should send an empty command,
which resets the eshell prompt and should show you that it's actually in
the right directory. Perhaps I got it wrong here, I use `eshell-reset'
in one of my keybindings, but I though send-input was perhaps clearer to
use here, sorry.
It also doesn't rename the buffers, so it was wrong anyway, I only know
that just sending a `\n' character to an eshell buffer doesn't execute
the command, but `eshell-send-input' does, or should. At least that's
what I noticed when messing around with sending commands
programmatically.
> > Hope it helps in some small way.
> >
>
> Absolutely helps!!!
Awesome!
Regards,
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-27 13:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-27 7:58 Executing init script after launching eshell C K Kashyap
2012-03-27 8:53 ` Tom Willemsen
2012-03-27 10:26 ` C K Kashyap
2012-03-27 11:21 ` Tom Willemsen
2012-03-27 13:13 ` C K Kashyap
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.