* screen & emacs
@ 2011-02-03 4:44 Sam Steingold
2011-02-03 4:58 ` Justin Lilly
2011-02-03 17:24 ` Andreas Schwab
0 siblings, 2 replies; 13+ messages in thread
From: Sam Steingold @ 2011-02-03 4:44 UTC (permalink / raw)
To: emacs-devel
I use gnu screen on a server S to which I connect using ssh from various
client boxes (e.g., a windows desktop D and a linux laptop L).
This is great: I always see the same shell sessions on S regardless
where I connect from.
There is only one problem: I run ssh with ForwardX11=yes, so when I
start emacs on S, I see the usual GUI window on D or L (I still have to
figure out the right setting for DISPLAY for some reason) which is
precisely what I want.
Alas, when I open an emacs on S while connected from D and then go over
to L and ssh to S, then the screen session gets stolen from D and
appears on L, __BUT__ the emacs window (again, emacs is running on S,
but the window is shown on D) stays on D and does not go over to L
automagically.
Is there a way around this (except for "emacs -nw")?
PS. One thing I hate about screen is that it does not terminate
"gracefully" on reboot: it is killed so the bash histories of various
widows are not saved...
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 10.04 (lucid)
http://www.memritv.org http://dhimmi.com http://thereligionofpeace.com
http://pmw.org.il http://mideasttruth.com
MS: Brain off-line, please wait.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 4:44 screen & emacs Sam Steingold
@ 2011-02-03 4:58 ` Justin Lilly
2011-02-03 17:28 ` Sam Steingold
2011-02-03 17:24 ` Andreas Schwab
1 sibling, 1 reply; 13+ messages in thread
From: Justin Lilly @ 2011-02-03 4:58 UTC (permalink / raw)
To: sds, emacs-devel
It seems as if you should be able to run a daemonized emacs. Multiple
clients can then connect to it without stealing each other's
connection.
Then again, it may not work like that, but it is at least something to look at.
-justin
On Wed, Feb 2, 2011 at 11:44 PM, Sam Steingold <sds@gnu.org> wrote:
> I use gnu screen on a server S to which I connect using ssh from various
> client boxes (e.g., a windows desktop D and a linux laptop L).
> This is great: I always see the same shell sessions on S regardless
> where I connect from.
> There is only one problem: I run ssh with ForwardX11=yes, so when I
> start emacs on S, I see the usual GUI window on D or L (I still have to
> figure out the right setting for DISPLAY for some reason) which is
> precisely what I want.
> Alas, when I open an emacs on S while connected from D and then go over
> to L and ssh to S, then the screen session gets stolen from D and
> appears on L, __BUT__ the emacs window (again, emacs is running on S,
> but the window is shown on D) stays on D and does not go over to L
> automagically.
> Is there a way around this (except for "emacs -nw")?
>
> PS. One thing I hate about screen is that it does not terminate
> "gracefully" on reboot: it is killed so the bash histories of various
> widows are not saved...
>
> --
> Sam Steingold (http://sds.podval.org/) on Ubuntu 10.04 (lucid)
> http://www.memritv.org http://dhimmi.com http://thereligionofpeace.com
> http://pmw.org.il http://mideasttruth.com
> MS: Brain off-line, please wait.
>
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 4:44 screen & emacs Sam Steingold
2011-02-03 4:58 ` Justin Lilly
@ 2011-02-03 17:24 ` Andreas Schwab
1 sibling, 0 replies; 13+ messages in thread
From: Andreas Schwab @ 2011-02-03 17:24 UTC (permalink / raw)
To: emacs-devel
Sam Steingold <sds@gnu.org> writes:
> Alas, when I open an emacs on S while connected from D and then go over
> to L and ssh to S, then the screen session gets stolen from D and
> appears on L, __BUT__ the emacs window (again, emacs is running on S,
> but the window is shown on D) stays on D and does not go over to L
> automagically.
> Is there a way around this (except for "emacs -nw")?
You'll have to adjust DISPLAY, because every new ssh session will
allocate a new socket for the X11 forwarding. The display numbers on
the remote side are usually allocated from 10 onwards.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 4:58 ` Justin Lilly
@ 2011-02-03 17:28 ` Sam Steingold
2011-02-03 18:00 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Sam Steingold @ 2011-02-03 17:28 UTC (permalink / raw)
To: Justin Lilly; +Cc: emacs-devel
> * Justin Lilly <whfgva@whfgvayvyyl.pbz> [2011-02-02 23:58:18 -0500]:
>
> It seems as if you should be able to run a daemonized emacs. Multiple
> clients can then connect to it without stealing each other's
> connection.
thanks for the suggestion, I tried "emacs -daemon".
1. For many years I have been running emacs under gdb at all times.
It appears no longer to be an option with -daemon.
2. Unless used with "-c", emacsclient connecting to the daemon under
screen seems to default to "-nw" (or maybe it depends on DISPLAY? - I am
still somewhat confused about the interplay between DISPLAY & ssh/ForwardX11).
I tried that for a while and discovered that M-<left> et al do not work
(I need to do Esc-<left> &c).
3. When Emacs is started as a daemon, it loads .emacs with window-system
set to nil. This means that when the client opens an X window (emacs
frame), it has the settings in .emacs which are "appropriate" for a
terminal, not a GUI. I am not sure how to handle this properly, except
for remove all (when window-system ...) from .emacs.
just for the reference, my original request:
> On Wed, Feb 2, 2011 at 11:44 PM, Sam Steingold <sds@gnu.org> wrote:
>> I use gnu screen on a server S to which I connect using ssh from various
>> client boxes (e.g., a windows desktop D and a linux laptop L).
>> This is great: I always see the same shell sessions on S regardless
>> where I connect from.
>> There is only one problem: I run ssh with ForwardX11=yes, so when I
>> start emacs on S, I see the usual GUI window on D or L (I still have to
>> figure out the right setting for DISPLAY for some reason) which is
>> precisely what I want.
>> Alas, when I open an emacs on S while connected from D and then go over
>> to L and ssh to S, then the screen session gets stolen from D and
>> appears on L, __BUT__ the emacs window (again, emacs is running on S,
>> but the window is shown on D) stays on D and does not go over to L
>> automagically.
>> Is there a way around this (except for "emacs -nw")?
>>
>> PS. One thing I hate about screen is that it does not terminate
>> "gracefully" on reboot: it is killed so the bash histories of various
>> widows are not saved...
--
Sam Steingold (http://sds.podval.org/) on gnu/linux terminal
http://iris.org.il http://www.PetitionOnline.com/tap12009/
http://dhimmi.com http://ffii.org http://thereligionofpeace.com
If you think big enough, you'll never have to do it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 17:28 ` Sam Steingold
@ 2011-02-03 18:00 ` Eli Zaretskii
2011-02-03 19:14 ` Sam Steingold
2011-02-03 18:13 ` Andreas Marschke
2011-02-04 17:01 ` Dan Nicolaescu
2 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2011-02-03 18:00 UTC (permalink / raw)
To: sds; +Cc: justin, emacs-devel
> From: Sam Steingold <sds@gnu.org>
> Date: Thu, 03 Feb 2011 12:28:10 -0500
> Cc: emacs-devel@gnu.org
>
> 1. For many years I have been running emacs under gdb at all times.
> It appears no longer to be an option with -daemon.
What's wrong with "gdb -p PID" after starting "emacs -daemon"? Then
type "continue" inside GDB, and you have the equivalent of what you
are used to.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 17:28 ` Sam Steingold
2011-02-03 18:00 ` Eli Zaretskii
@ 2011-02-03 18:13 ` Andreas Marschke
2011-02-03 20:31 ` Philipp Haselwarter
2011-02-04 17:01 ` Dan Nicolaescu
2 siblings, 1 reply; 13+ messages in thread
From: Andreas Marschke @ 2011-02-03 18:13 UTC (permalink / raw)
To: emacs-devel
Hi!
What you probably want is not just a deamonized Emacs in Screen but
also emacsclients automatically starting. It shouldn't be wrong to
leave the emacsclient on the other machine running.
Another issue may be that your screen won't automagically change the
Display value from the parent shell you started. I know this because I
frequently restart my X.org and find that I cant start X-Apps anymore
afterwards.
Your best shot may be:
- start emacs in screen (I auto-start my emacs each time I start a
screen session) with `-nw' so it keeps in the screen
- run M-x server-start in emacs or give it an `-f server-start' on the
console
- detach the screen
- run from the console that has the X11 forwarding and the correct
display currently something like emacsclient -c
This will start emacsclient which will find your emacs-server and show
show you a window in the current session.
Here is a more elaborate example from both my `.screenrc' and my
`.bashrc':
--------: .bashrc
function emacs()
{
if [ -x /tmp/emacs$UID/server ];then
emacsclient -nw $@
else
screen emacs -nw -f server-start $@
fi
}
This means eachtime I run `emacs' from the shell I either get a client
if it finds a server at `/tmp/emacs$UID/' or start a new session.
Now this has a few caveats as `/tmp/emacs$UID/server' may still be
present even though emacs was roughly kulled in an errornous attempt
to clean up the open and unused shells in your screen session(been
there done that). But its an affordable price to pay for this
convenience.
--------: .screenrc
# Welcome the user:
#echo "welcome :-)"
#echo "I love you today."
msgwait 10
# Uncomment one/some following lines to automatically let
# SCREEN start some programs in the given window numbers:
screen -t MAIL 0 mutt
screen -t MOCP 1 mocp
screen -t FINCH 2 finch
screen -t IRSSI 3 ssh xxtjaxx@ein-elch.de
screen -t EMACS 4 emacs -nw -f server-start -D --debug-init
# screen -t TORRENT 5 rtorrent
----------
This will start a screen automatically at screen no. 4 each time I
initiate a new one. This is such a convenience to have when you use
only one _main_ screen at a time for everything.
If you have an issue with control characters
in screen like 5D or the like because you typed C-<left>. There is a
fix.
http://alioth.debian.org/~twb-guest/Preferences/.screen.el
Happy Hacking!
On Thu, Feb 03, 2011 at 12:28:10PM -0500, Sam Steingold wrote:
> > * Justin Lilly <whfgva@whfgvayvyyl.pbz> [2011-02-02 23:58:18 -0500]:
> >
> > It seems as if you should be able to run a daemonized emacs. Multiple
> > clients can then connect to it without stealing each other's
> > connection.
>
> thanks for the suggestion, I tried "emacs -daemon".
>
> 1. For many years I have been running emacs under gdb at all times.
> It appears no longer to be an option with -daemon.
>
> 2. Unless used with "-c", emacsclient connecting to the daemon under
> screen seems to default to "-nw" (or maybe it depends on DISPLAY? - I am
> still somewhat confused about the interplay between DISPLAY & ssh/ForwardX11).
> I tried that for a while and discovered that M-<left> et al do not work
> (I need to do Esc-<left> &c).
>
> 3. When Emacs is started as a daemon, it loads .emacs with window-system
> set to nil. This means that when the client opens an X window (emacs
> frame), it has the settings in .emacs which are "appropriate" for a
> terminal, not a GUI. I am not sure how to handle this properly, except
> for remove all (when window-system ...) from .emacs.
>
> just for the reference, my original request:
>
> > On Wed, Feb 2, 2011 at 11:44 PM, Sam Steingold <sds@gnu.org> wrote:
> >> I use gnu screen on a server S to which I connect using ssh from various
> >> client boxes (e.g., a windows desktop D and a linux laptop L).
> >> This is great: I always see the same shell sessions on S regardless
> >> where I connect from.
> >> There is only one problem: I run ssh with ForwardX11=yes, so when I
> >> start emacs on S, I see the usual GUI window on D or L (I still have to
> >> figure out the right setting for DISPLAY for some reason) which is
> >> precisely what I want.
> >> Alas, when I open an emacs on S while connected from D and then go over
> >> to L and ssh to S, then the screen session gets stolen from D and
> >> appears on L, __BUT__ the emacs window (again, emacs is running on S,
> >> but the window is shown on D) stays on D and does not go over to L
> >> automagically.
> >> Is there a way around this (except for "emacs -nw")?
> >>
> >> PS. One thing I hate about screen is that it does not terminate
> >> "gracefully" on reboot: it is killed so the bash histories of various
> >> widows are not saved...
>
> --
> Sam Steingold (http://sds.podval.org/) on gnu/linux terminal
> http://iris.org.il http://www.PetitionOnline.com/tap12009/
> http://dhimmi.com http://ffii.org http://thereligionofpeace.com
> If you think big enough, you'll never have to do it.
>
--
Cheers,
Andreas Marschke
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 18:00 ` Eli Zaretskii
@ 2011-02-03 19:14 ` Sam Steingold
2011-02-03 19:25 ` Chad Brown
2011-02-11 7:10 ` Kevin Rodgers
0 siblings, 2 replies; 13+ messages in thread
From: Sam Steingold @ 2011-02-03 19:14 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: justin, emacs-devel
> * Eli Zaretskii <ryvm@tah.bet> [2011-02-03 20:00:22 +0200]:
>
>> From: Sam Steingold <sds@gnu.org>
>> Date: Thu, 03 Feb 2011 12:28:10 -0500
>> Cc: emacs-devel@gnu.org
>>
>> 1. For many years I have been running emacs under gdb at all times.
>> It appears no longer to be an option with -daemon.
>
> What's wrong with "gdb -p PID" after starting "emacs -daemon"? Then
> type "continue" inside GDB, and you have the equivalent of what you
> are used to.
thanks for the tip!
--
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://palestinefacts.org http://pmw.org.il http://memri.org
http://camera.org http://openvotingconsortium.org http://jihadwatch.org
The early bird may get the worm, but the second mouse gets the cheese.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 19:14 ` Sam Steingold
@ 2011-02-03 19:25 ` Chad Brown
2011-02-03 19:54 ` Sam Steingold
2011-02-11 7:10 ` Kevin Rodgers
1 sibling, 1 reply; 13+ messages in thread
From: Chad Brown @ 2011-02-03 19:25 UTC (permalink / raw)
To: sds; +Cc: Emacs-Devel devel
From: Sam Steingold <sds@gnu.org>
>
> 1. For many years I have been running emacs under gdb at all times.
> It appears no longer to be an option with -daemon.
I used to do this back in the early days of emacs19 (and especially
under epoch), but I haven't actually seen emacs mysteriously crash in
quite a long time. I'm curious if this is an old habit or if you're
seeing less stability than I am (I don't push emacs nearly as much as
I did when I was programming full-time.)
*Chad
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 19:25 ` Chad Brown
@ 2011-02-03 19:54 ` Sam Steingold
0 siblings, 0 replies; 13+ messages in thread
From: Sam Steingold @ 2011-02-03 19:54 UTC (permalink / raw)
To: Chad Brown; +Cc: Emacs-Devel devel
> * Chad Brown <lnaqebf@ZVG.RQH> [2011-02-03 11:25:11 -0800]:
>
> From: Sam Steingold <sds@gnu.org>
>>
>> 1. For many years I have been running emacs under gdb at all times.
>> It appears no longer to be an option with -daemon.
>
> I used to do this back in the early days of emacs19 (and especially
> under epoch), but I haven't actually seen emacs mysteriously crash in
> quite a long time. I'm curious if this is an old habit or if you're
> seeing less stability than I am (I don't push emacs nearly as much as
> I did when I was programming full-time.)
mostly an old habit which never hurts and sometimes helps:
http://article.gmane.org/gmane.emacs.devel:135126
--
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://truepeace.org http://jihadwatch.org http://www.memritv.org
http://dhimmi.com http://honestreporting.com http://iris.org.il
He who laughs last did not get the joke.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 18:13 ` Andreas Marschke
@ 2011-02-03 20:31 ` Philipp Haselwarter
2011-02-03 20:54 ` Andreas Marschke
0 siblings, 1 reply; 13+ messages in thread
From: Philipp Haselwarter @ 2011-02-03 20:31 UTC (permalink / raw)
To: emacs-devel
Andreas Marschke <xxtjaxx@googlemail.com> writes:
> Hi!
>
---8<---[snipped 20 lines]---8<---
>
> Here is a more elaborate example from both my `.screenrc' and my
> `.bashrc':
> --------: .bashrc
> function emacs()
> {
> if [ -x /tmp/emacs$UID/server ];then
> emacsclient -nw $@
> else
> screen emacs -nw -f server-start $@
> fi
> }
>
---8<---[snipped 91 lines]---8<---
This shouldn't be necessary anymore, I used to use a similar construct,
but there's simpler.
If you run emacsclient with `-a=""' or `--alternate-editor=""', it tries
to connect to the server first, and if it fails to connect, starts
it. This way, you never end up trying to start several daemons at once
etc:
.bashrc:
--8<---------------cut here---------------start------------->8---
alias emacs='emacsclient -a="" -nw'
--8<---------------cut here---------------end--------------->8---
and similarly in your .screenrc:
--8<---------------cut here---------------start------------->8---
screen -t EMACS 4 emacsclient -a="" -nw
--8<---------------cut here---------------end--------------->8---
--
Philipp Haselwarter
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 20:31 ` Philipp Haselwarter
@ 2011-02-03 20:54 ` Andreas Marschke
0 siblings, 0 replies; 13+ messages in thread
From: Andreas Marschke @ 2011-02-03 20:54 UTC (permalink / raw)
To: emacs-devel
Oh thanks for that tipp. Its part of my conf now thanks!
On Thu, Feb 03, 2011 at 09:31:58PM +0100, Philipp Haselwarter wrote:
> Andreas Marschke <xxtjaxx@googlemail.com> writes:
>
> > Hi!
> >
> ---8<---[snipped 20 lines]---8<---
> >
> > Here is a more elaborate example from both my `.screenrc' and my
> > `.bashrc':
> > --------: .bashrc
> > function emacs()
> > {
> > if [ -x /tmp/emacs$UID/server ];then
> > emacsclient -nw $@
> > else
> > screen emacs -nw -f server-start $@
> > fi
> > }
> >
> ---8<---[snipped 91 lines]---8<---
>
> This shouldn't be necessary anymore, I used to use a similar construct,
> but there's simpler.
> If you run emacsclient with `-a=""' or `--alternate-editor=""', it tries
> to connect to the server first, and if it fails to connect, starts
> it. This way, you never end up trying to start several daemons at once
> etc:
> .bashrc:
> --8<---------------cut here---------------start------------->8---
> alias emacs='emacsclient -a="" -nw'
> --8<---------------cut here---------------end--------------->8---
> and similarly in your .screenrc:
> --8<---------------cut here---------------start------------->8---
> screen -t EMACS 4 emacsclient -a="" -nw
> --8<---------------cut here---------------end--------------->8---
>
> --
> Philipp Haselwarter
>
>
--
Cheers,
Andreas Marschke
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 17:28 ` Sam Steingold
2011-02-03 18:00 ` Eli Zaretskii
2011-02-03 18:13 ` Andreas Marschke
@ 2011-02-04 17:01 ` Dan Nicolaescu
2 siblings, 0 replies; 13+ messages in thread
From: Dan Nicolaescu @ 2011-02-04 17:01 UTC (permalink / raw)
To: Justin Lilly; +Cc: emacs-devel
Sam Steingold <sds@gnu.org> writes:
>> 3. When Emacs is started as a daemon, it loads .emacs with window-system
> set to nil. This means that when the client opens an X window (emacs
> frame), it has the settings in .emacs which are "appropriate" for a
> terminal, not a GUI. I am not sure how to handle this properly, except
> for remove all (when window-system ...) from .emacs.
C-h v window-system RET
[snip]
Use of this variable as a boolean is deprecated. Instead,
use `display-graphic-p' or any of the other `display-*-p'
predicates which report frame's specific UI-related capabilities.
So yes, it's time to get rid of (when window-system...)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: screen & emacs
2011-02-03 19:14 ` Sam Steingold
2011-02-03 19:25 ` Chad Brown
@ 2011-02-11 7:10 ` Kevin Rodgers
1 sibling, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2011-02-11 7:10 UTC (permalink / raw)
To: emacs-devel
On 2/3/11 12:14 PM, Sam Steingold wrote:
>> * Eli Zaretskii<ryvm@tah.bet> [2011-02-03 20:00:22 +0200]:
>>
>>> From: Sam Steingold<sds@gnu.org>
>>> Date: Thu, 03 Feb 2011 12:28:10 -0500
>>> Cc: emacs-devel@gnu.org
>>>
>>> 1. For many years I have been running emacs under gdb at all times.
>>> It appears no longer to be an option with -daemon.
>>
>> What's wrong with "gdb -p PID" after starting "emacs -daemon"? Then
>> type "continue" inside GDB, and you have the equivalent of what you
>> are used to.
>
> thanks for the tip!
And the emacs --daemon, gdb -p PID command sequence can be scripted, by using
pgrep to get the emacs PID.
It might be tricky if there happen to be multiple emacs instances running,
though.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-02-11 7:10 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-03 4:44 screen & emacs Sam Steingold
2011-02-03 4:58 ` Justin Lilly
2011-02-03 17:28 ` Sam Steingold
2011-02-03 18:00 ` Eli Zaretskii
2011-02-03 19:14 ` Sam Steingold
2011-02-03 19:25 ` Chad Brown
2011-02-03 19:54 ` Sam Steingold
2011-02-11 7:10 ` Kevin Rodgers
2011-02-03 18:13 ` Andreas Marschke
2011-02-03 20:31 ` Philipp Haselwarter
2011-02-03 20:54 ` Andreas Marschke
2011-02-04 17:01 ` Dan Nicolaescu
2011-02-03 17:24 ` Andreas Schwab
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).