help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Start emacs without opening a window (X11)


From: Tassilo Horn
Subject: Re: Start emacs without opening a window (X11)
Date: Tue, 11 Sep 2007 14:54:17 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux)

Sebastian Kaps <seb@toyland.sauerland.de> writes:

Hi Sebastian,

> Is there a possibility to start Emacs without opening a window?  I
> want to start the Emacs server from my .emacs and then use only
> emacsclient to pop up a new window.

If you use the current development version of emacs which includes
multi-tty, then you can use these two scripts.

--8<---------------cut here---------------start------------->8---
#!/bin/bash
#
# Usage: emacs-preload <name> [<waitp>]
#
# Preloads the Emacs instance called NAME in a detached screen session.  Does
# nothing if the instance is already running.  If WAITP is non-empty, the
# function waits until the server starts up and creates its socket; otherwise
# it returns immediately.

name="$1"
waitp="$2"
screendir="/var/run/screen/S-$USER"
serverdir="/tmp/emacs$UID"
emacs=/usr/bin/emacs

if [ -z "$name" ]; then 
    echo "Usage: preload_emacs <name> [<waitp>]" >&2
    exit 1
fi

if [ ! -e "$screendir"/*."$name" ]; then
    if [ -e "$serverdir/$name" ]; then
        # Delete leftover socket (for the wait option)
        rm "$serverdir/$name"
    fi
    screen -d -m -S "$name" "$emacs" -nw --eval "(setq server-name \"$name\")" 
--funcall server-start
fi

if [ ! -z "$waitp" ]; then
    while [ ! -e "$serverdir/$name" ]; do
        sleep 1;
    done
fi
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
#!/bin/bash
# Usage: connect-emacs <name> <args>...
#
# Connects to the Emacs instance called NAME.  Starts up the instance if it is
# not already running.  The rest of the arguments are passed to emacsclient.

name="$1"
shift

if [ -z "$name" ]; then
    echo "Usage: connect_emacs <name> <args>..." >&2
    exit 1
fi

# Startup that emacs if it's not running!
emacs-preload "$name" wait

/usr/bin/emacsclient -s "$name" "$@"
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo


reply via email to

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