Subject: bug#17693: PATCH

From: Jun Hao <[email-masked]>
Date: Fri, 20 May 2016 00:23:32 +0800

Hi,

Please see the simple patch in the attachment. I can still repro this
issue with latest dev branch. I think the original workaround is not
working since the repro step is using -q which doesn't set
after-init-hook. Let me know if this fix the issue

-- 
Thanks - Jun
>From 4fce83e29ef772b61be276cdaf3e7b12088b417c Mon Sep 17 00:00:00 2001
From: Jun Hao <[email-masked]>
Date: Fri, 20 May 2016 00:05:25 +0800
Subject: [PATCH] * lisp/desktop.el: Disable restore frameset if in non-graphic
 display.

Fixes: debbugs:17693
---
 lisp/desktop.el | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/lisp/desktop.el b/lisp/desktop.el
index 822db05..dba3277 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -1163,7 +1163,7 @@ This function also sets `desktop-dirname' to nil."
   "Restore the state of a set of frames.
 This function depends on the value of `desktop-saved-frameset'
 being set (usually, by reading it from the desktop)."
-  (when (desktop-restoring-frameset-p)
+  (when (and (display-graphic-p) (desktop-restoring-frameset-p))
     (frameset-restore desktop-saved-frameset
 		      :reuse-frames (eq desktop-restore-reuses-frames t)
 		      :cleanup-frames (not (eq desktop-restore-reuses-frames 'keep))
@@ -1634,15 +1634,8 @@ If there are no buffers left to create, kill the timer."
         (setq command-line-args (delete key command-line-args))
         (desktop-save-mode 0)))
     (when desktop-save-mode
-      ;; People don't expect emacs -nw, or --daemon,
-      ;; to create graphical frames (bug#17693).
-      ;; TODO perhaps there should be a separate value
-      ;; for desktop-restore-frames to control this startup behavior?
-      (let ((desktop-restore-frames (and desktop-restore-frames
-                                         initial-window-system
-                                         (not (daemonp)))))
-        (desktop-read)
-        (setq inhibit-startup-screen t)))))
+      (desktop-read)
+      (setq inhibit-startup-screen t))))
 
 (provide 'desktop)
 
-- 
2.8.2