6

I set up desktop.el so that emacs automatically reopens all files on startup that were left open last time I killed emacs.

Now when I start emacs as a daemon and one of the reopened files has auto-save-data, the daemon displays the usual auto-save-data-message ("...file has auto save data...") and waits for confirmation - but does not continue the initialization. Without confirmation the daemon will stay in this state and new connections (eg via emacsclient -c) are accepted but not processed.

Is there a way to disable confirmations during the daemons startup?

Flow
  • 23,572
  • 15
  • 99
  • 156
Zarza
  • 538
  • 4
  • 6

1 Answers1

2

edit: Updated to match Zarza's working version:

(defadvice desktop-restore-file-buffer
  (around my-desktop-restore-file-buffer-advice)
  "Be non-interactive while starting a daemon."
  (if (and (daemonp)
           (not server-process))
      (let ((noninteractive t))
        ad-do-it)
    ad-do-it))
(ad-activate 'desktop-restore-file-buffer)

(command-line) starts the server process, but only "after loading the user's init file and after processing all command line arguments".

phils
  • 71,335
  • 11
  • 153
  • 198
  • 1
    Thank you Phils, that helped me a lot! I had to change the advice target to make it work, because the suggested function `desktop-read` is wrapped with `(unless noninteractive...`. I changed it to `desktop-restore-file-buffer`: `(defadvice desktop-restore-file-buffer (around my-desktop-restore-file-buffer-advice) (if (and (daemonp) (not server-process)) (let ((noninteractive t)) ad-do-it) ad-do-it) ) (ad-activate 'desktop-restore-file-buffer)` – Zarza Feb 09 '11 at 10:35