DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Run Emacs Or Emacsclient

01.21.2007
| 3817 views |
  • submit to reddit
        Automatically run emacs or emacsclient if emacs is already launched.

#!/bin/sh

EMACS="/usr/bin/emacs"
EMACSCLIENT="/usr/bin/emacsclient"

$EMACSCLIENT $@ 2> /dev/null
if [ $? -ne 0 ]; then
   exec $EMACS $@
fi

Put this in your ~/.emacs.el :
;; start emacs server
(server-start)