How can I prevent emacs from freezing when source buffer selection has auto save data?

I use emacs in daemon mode and I also have a initial-buffer-choice variable. Sometimes emacs breaks when I edit the file that I use for initial-buffer-choice. In this case, when I start emacs with --daemon, it will hang with a message:

"todo.org has auto save data; consider M-x recover-this-file"

Since I basically run the daemon from the init script, I cannot confirm or deny this dialog, so the daemon hangs forever. How can I bypass the notification about automatic data saving in this case? I do not mind losing automatically save data if necessary.

Here is my attempt to do this:

(defadvice command-line
  (around my-command-line-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 'command-line)

. - . , "" , .

: emacs-daemon, . initial-buffer-choice. -, , , , command-line, , , , desktop.el.

+5
3

, , , Emacs --daemon, initial-buffer-choice (.. find-file-noselect "~/.../todo.org" [. ... lisp/startup.el > ]) , (setq auto-save-default nil). , [.. (setq auto-save-default nil) , initial-buffer-choice], , (, todo.org). , (setq initial-buffer-choice t) (setq auto-save-default nil) init.el .emacs ( ) - , , , emacs-startup-hook to (kill-buffer "*scratch*") (find-file "~/.../todo.org") - , find-file ( find-file-noselect [. ... lisp/files.el]).

+1

, .emacs:

(setq auto-save-default nil)

(, ) - , , :

(find-file-noselect FILENAME &optional NOWARN RAWFILE WILDCARDS)

, NOWARN ( ).

: EmacsWiki

, . .emacs:

(defun find-file (filename &optional wildcards)
  (interactive
   (find-file-read-args "Find file: "
                        (confirm-nonexistent-file-or-buffer)))

  ; the "t" here is normally set to "nil", this should solve the problem
  (let ((value (find-file-noselect filename t nil wildcards)))  
    (if (listp value)
    (mapcar 'switch-to-buffer (nreverse value))
      (switch-to-buffer value))))

EDIT: , .

, , emacs-startup-hook (kill-buffer "*scratch*") (find-file "~/.../todo.org").

+1

"... , M-x recover-this-file" - , , . , , emacs (directory-files) . , (rename-file).

, .

The real question is how to debug server problems in emacs. Debug and edebug are pretty pointless in server mode. It’s best to trace everything to a file (something like logging).

0
source

All Articles