How to Stop Emacs from Opening a New Daemon

I finally got around to upgrading to the the newest stable release of Emacs. There were a few things I wanted to be able to do and rather than use outdated methods I decided it was time to upgrade to Emacs 23. I ran into a few hitches along the way but after getting them resolved I went about setting up the Emacs daemon to load quietly in the background and start using multiple emacs clients under different GNU Screen windows. I had a bit of a time figuring out how to make it so it wouldn’t try to start up another server each time I logged in via SSH or created a new Screen. I never really found a one stop answer for this, rather it was a combination of several suggestions I saw. So here’s what I came up with for my ~/.bashrc:

# Boot up the Emacs Daemon                                                                                                                                                                                 
function emacs_is_running() {                                                                                                                                                                              
    ps -ef | grep "emacs --daemon" | grep -v grep > /dev/null                                                                                                                                              
}                                                                                                                                                                                                          

# Debug                                                                                                                                                                                                           
if emacs_is_running; then                                                                                                                                                                                  
    echo Emacs daemon already running                                                                                                                                                                      
else                                                                                                                                                                                                       
    echo Launching emacs daemon                                                                                                                                                                            
    emacs --daemon                                                                                                                                                                                         
fi                                                                                                                                                                                                         
                                                                                                                                                                                                           
                                                                                                                                                                                                          
# Fix Typos, Add Shortcuts...                                                                                                                                                                                               
alias e="emacsclient -c -a nano"                                                                                                                                                                           
alias emac="emacsclient -c -a nano"                                                                                                                                                                           
alias emacs="emacsclient -c -a nano"                                                                                                                                                                       
alias emasc="emacsclient -c -a nano"        
alias pico="emacsclient -c"                                                                                                                                                                               
EDITOR="emacsclient -c -a nano"                                                                                                                                                                            
VISUAL="emacsclient -c -a nano"                                                                                                                                                                            

Tags: , , , , , , ,

  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

3 Responses to “How to Stop Emacs from Opening a New Daemon”

  1. Aris Bezas says:

    Hi Brad,

    I found from your message at http://ashutoshmehra.net/blog/2009/04/aha-emacs-23/. Did you really manage to make transparent background and solid text at Emacs 23. I am trying to do it long time now without result. If you find some time please answer me.

    Thanks in advance

  2. FettesPS says:

    @Aris – Yeah I did for a long time. Though it’s now been a couple of years since I used emacs on a regular basis, as I’m now at a job that uses Visual Studio. In anyways, you’ll want to use the terminal to enable transparency, not emacs. And that all depends on what you’re using for a terminal.

  3. Aris Bezas says:

    @FetterPS thanks for your reply. I quess I can’t switch to Terminal because I need Emacs for my live visual performances (snippets, osc, org-mode etc). I am still waiting a transparent background and solid text at Emacs 23. Have a nice day, and if you found a solution for please inform me.

Leave a Reply