emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: screen & emacs


From: Andreas Marschke
Subject: Re: screen & emacs
Date: Thu, 3 Feb 2011 19:13:48 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

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 address@hidden 
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 <address@hidden> [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 <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]