narcoleptical
narcoleptical

Reputation: 11

Reload .emacs in emacs server without closing current emacs clients

Background: Using Emacs 24.2.1.

I start Emacs client and server with this alias:

emacsclient -nw -a="" -c "$@"

I want to reload my .emacs file after I update it without having Emacs server terminate current clients. Basically, right now, I would edit the .emacs file using emacsclient. Then, I do M-x load-file. It then asks

The current server still has clients; delete them? (yes or no)

Saying yes would reload the .emacs file but will also terminate all current clients, which forces my client to close since it just got terminated.

Is there a workaround for this?

Upvotes: 1

Views: 705

Answers (1)

steckerhalter
steckerhalter

Reputation: 611

The only place I could find this message in the Emacs source code is in the function server-start:

(defun server-start (&optional leave-dead inhibit-prompt)
 ...
  (when (or (not server-clients)
            ;; Ask the user before deleting existing clients---except
            ;; when we can't get user input, which may happen when
            ;; doing emacsclient --eval "(kill-emacs)" in daemon mode.
            (cond
             ((and (daemonp)
                   (null (cdr (frame-list)))
                   (eq (selected-frame) terminal-frame))
              leave-dead)
             (inhibit-prompt t)
             (t (yes-or-no-p
                 "The current server still has clients; delete them? ")))) ...

I would assume that you are executing server-start somewhere in your .emacs and that this is causing the issue. If that is the case you would remove the expression and reloading .emacs should work as you had expected.

PS: I would have posted a comment but I'm not allowed to do that yet, so I'm writing an answer :)

Upvotes: 1

Related Questions