Miscellaneous

How to Stop Emacs from Opening a New Daemon

June 12, 2011

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"                                                                                                                                                                            

Only registered users can comment.

  1. @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.

  2. @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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.