[Top][All Lists]

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

Re: Start the emacs-server once...

From: Allan Gottlieb
Subject: Re: Start the emacs-server once...
Date: Thu, 21 Aug 2008 10:41:55 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

At Thu, 21 Aug 2008 12:55:00 +0100 Alex Bennee <address@hidden> wrote:

> Hi,
> I want to set-up emacs to start the server once per X sessions (and I
> guess once per screen session once I get multi-tty working). However
> there doesn't seem to be way to check in emacs if the server is
> currently running.
> So far the best I can come up with is having my start-up emacs with the
> args:
> emacs --eval (defvar this-is-the-master t)
> And appropriate hackery in the .emacs. Is there a nicer way to deal with
> this?

I don't know if it is nicer (I suspect it is similar)
but I use the following so that the invocation of emacs is not changed.

;; Use emacsclient/emacsserver
;; Using code from Tassilo Horn so a server started on first emacs only
;; The code should remove the file when the server ends.
;; Sometimes the file remains (why?) so I explicitly invoke the removal
;; function from ~/bin/Xinitialize.
(defvar ajg-server-lock-file "~/.emacs.d/server.lock" "Emacs server lock file.")

(defun ajg-server-start ()
  (shell-command (concat "touch " ajg-server-lock-file))
  (message "Emacs Server started...")
  (setq frame-title-format '("Emacs (Server): %b <%f>")))

(if (and (not (file-exists-p ajg-server-lock-file))
         (not noninteractive))
  (message "Emacs Server NOT started, because lockfile exists.")
  (setq frame-title-format
        '("Emacs: %b <%f>")))

(defun ajg-server-remove-lock-file ()
  (when (boundp 'server-process)
    (shell-command (concat "rm " ajg-server-lock-file))))

;; Remove lock file when emacs server ends
(add-hook 'kill-emacs-hook


reply via email to

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