bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#55070: 28.1; desktop-load doesn't work in -nw (non-gui) emacs


From: Juri Linkov
Subject: bug#55070: 28.1; desktop-load doesn't work in -nw (non-gui) emacs
Date: Tue, 26 Apr 2022 18:28:18 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

> I think the reason for disabling restoring frames on -nw wasn't because
> of technical reasons, but because of most users not being aware that an
> -nw Emacs can have frames, so they ended up with very confusing setups
> after restoring from desktop.
>
> But this is an issue that's come up again and again, so I think we
> should introduce a new user option to allow desktop to restore frames on
> -nw.  (And that means that we should also apply your patch, I think?)

Indeed, this is what an old comment in desktop.el used to say:

  ;; 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?

So this patch creates such separate values:

diff --git a/lisp/desktop.el b/lisp/desktop.el
index cd581e028b..b46c41e0e4 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -412,7 +412,10 @@ desktop-restore-frames
   "When non-nil, save and restore the frame and window configuration.
 See related options `desktop-restore-reuses-frames',
 `desktop-restore-in-current-display', and `desktop-restore-forces-onscreen'."
-  :type 'boolean
+  :type '(choice (const :tag "Don't restore frames" nil)
+                 (const :tag "Restore frames" t)
+                 (const :tag "Restore only graphical frames" x)
+                 (const :tag "Restore only -nw frames" tty))
   :group 'desktop
   :version "24.4")
 
@@ -1245,7 +1248,13 @@ desktop-lazy-timer
 ;; ----------------------------------------------------------------------------
 (defun desktop-restoring-frameset-p ()
   "True if calling `desktop-restore-frameset' will actually restore it."
-  (and desktop-restore-frames desktop-saved-frameset (display-graphic-p) t))
+  (and (pcase desktop-restore-frames
+         ('x (display-graphic-p))
+         ('tty (not (display-graphic-p)))
+         ('nil nil)
+         (_ t))
+       desktop-saved-frameset
+       t))
 
 (defun desktop-restore-frameset ()
   "Restore the state of a set of frames.
diff --git a/lisp/frameset.el b/lisp/frameset.el
index 05884eed3a..32966376d8 100644
--- a/lisp/frameset.el
+++ b/lisp/frameset.el
@@ -883,8 +883,8 @@ frameset-move-onscreen
   (pcase-let* ((`(,left ,top ,width ,height) (cdadr (frame-monitor-attributes 
frame)))
               (right (+ left width -1))
               (bottom (+ top height -1))
-              (fr-left (frameset-compute-pos (frame-parameter frame 'left) 
left right))
-              (fr-top (frameset-compute-pos (frame-parameter frame 'top) top 
bottom))
+              (fr-left (frameset-compute-pos (or (frame-parameter frame 'left) 
0) left right))
+              (fr-top (frameset-compute-pos (or (frame-parameter frame 'top) 
0) top bottom))
               (ch-width (frame-char-width frame))
               (ch-height (frame-char-height frame))
               (fr-width (max (frame-pixel-width frame) (* ch-width 
(frame-width frame))))

reply via email to

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