all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Eric Swenson <eric@swenson.org>, 55070@debbugs.gnu.org
Subject: bug#55070: 28.1; desktop-load doesn't work in -nw (non-gui) emacs
Date: Tue, 26 Apr 2022 18:28:18 +0300	[thread overview]
Message-ID: <86h76fu9q5.fsf@mail.linkov.net> (raw)
In-Reply-To: <87mtg8i1za.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 26 Apr 2022 12:16:25 +0200")

[-- Attachment #1: Type: text/plain, Size: 793 bytes --]

> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: desktop-restore-frames.patch --]
[-- Type: text/x-diff, Size: 2113 bytes --]

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))))

  parent reply	other threads:[~2022-04-26 15:28 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 23:27 bug#55070: 28.1; desktop-load doesn't work in -nw (non-gui) emacs Eric Swenson
2022-04-23  6:13 ` Eli Zaretskii
2022-04-23 13:52   ` Eric Swenson
2022-04-23 14:25     ` Eli Zaretskii
2022-04-23 14:53       ` Eric Swenson
2022-04-23 15:16         ` Eli Zaretskii
2022-04-23 15:39           ` Eric Swenson
2022-04-26  7:58       ` Juri Linkov
2022-04-26 10:16         ` Lars Ingebrigtsen
2022-04-26 11:26           ` Eli Zaretskii
2022-04-26 15:28           ` Juri Linkov [this message]
2022-04-26 16:09             ` Eli Zaretskii
2022-04-26 17:40               ` Juri Linkov
2022-04-26 18:14                 ` Eli Zaretskii
2022-04-27 16:53                   ` Juri Linkov
2022-04-27 17:02                     ` Eric Swenson
2022-04-28  7:01                       ` Juri Linkov
2022-04-28 16:18                         ` Eric Swenson
2022-04-28 17:39                           ` Juri Linkov
2022-04-30  8:42                             ` Eli Zaretskii
2022-05-01 17:25                               ` Juri Linkov
2022-05-03 16:31                                 ` Eli Zaretskii
2022-05-03 17:57                                   ` Juri Linkov
2022-05-03 18:28                                     ` Eli Zaretskii
2022-05-05 16:35                                       ` Juri Linkov
2022-05-05 16:51                                         ` Eli Zaretskii
2022-05-05 18:08                                           ` Juri Linkov
2022-04-27 17:16                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86h76fu9q5.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=55070@debbugs.gnu.org \
    --cc=eric@swenson.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.