all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: Alan Mackenzie <acm@muc.de>, Eli Zaretskii <eliz@gnu.org>
Cc: 58634@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#58634: Long delay with blank screen whilst loading desktop at emacs startup
Date: Fri, 21 Oct 2022 12:09:37 -0700	[thread overview]
Message-ID: <CADwFkmnf1ijf61L0srcPHDrOorCy_7BywiKUipZc=G9Zzr3PmQ@mail.gmail.com> (raw)
In-Reply-To: <Y1KTQAQis91wvwVV@ACM>

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

Alan Mackenzie <acm@muc.de> writes:

> My current idea is to count the buffers in desktop-save, and to output a
> message:
>
>     Restoring buffers: 127/166
>
> as we restore the buffers.  We already count the buffers as we load
> them.

Yes, this would be useful.  It is bad to not see any progress while the
desktop is loading, for several reasons.  One of them is that you
usually expect to see some kind of indication of progress during
long-running operations.

I wrote up some code to show such a counter myself about a year and a
half ago, and I'm attaching the patch here in case it is of any help.
Maybe you could take some inspiration from it Alan, or maybe not.

I honestly can't remember why I didn't propose it back then.  Maybe I
felt like it should be possible to find a more elegant solution?  I
can't remember.  In any case, if the patch still applies it should at
the very least work, I hope.

[-- Attachment #2: 0001-New-option-to-show-progress-as-desktop-file-loads.patch --]
[-- Type: text/x-diff, Size: 3637 bytes --]

From eb94b5598b102290cccf6aee70182100e861dff5 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 26 Jan 2020 08:41:53 +0100
Subject: [PATCH] New option to show progress as desktop file loads

* lisp/desktop.el (desktop-save-adds-progress-reporter): New option.
(desktop-save): Save a 'progress-reporter' into the desktop file if
the above option is non-nil.
* etc/NEWS: Announce the above option.
---
 etc/NEWS        |  6 ++++++
 lisp/desktop.el | 37 +++++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index c3a71ade8a..fa27431245 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -87,6 +87,12 @@ line numbers that were previously jumped to.
 \f
 * Changes in Specialized Modes and Packages in Emacs 28.1
 
+** Desktop
+
+*** New option to show progress as desktop file loads.
+Customize the new user option 'desktop-save-adds-progress-reporter' to
+enable it. Read the documentation of that option for more details.
+
 ---
 ** The sb-image.el library is now marked obsolete.
 This file was a compatibility kludge which is no longer needed.
diff --git a/lisp/desktop.el b/lisp/desktop.el
index 9538bb4a34..b634fcbca4 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -306,6 +306,20 @@ desktop-save-hook
   :type 'hook
   :group 'desktop)
 
+(defcustom desktop-save-adds-progress-reporter nil
+  "If non-nil, add a progress reporter to saved desktop files.
+This can be used to show progress while a desktop file is
+loading.
+
+Note that this will not take effect until you run `desktop-save'
+at least once with this option enabled, and then `desktop-load'
+that saved file.
+
+Once a desktop file has had been saved with progress reporters,
+it is on unconditionally on subsequent loads of that file."
+  :type 'boolean
+  :version "28.1")
+
 (defcustom desktop-globals-to-save
   '(desktop-missing-file-warning
     tags-file-name
@@ -1113,11 +1127,17 @@ desktop-save
 	     (int-to-string (- (length kill-ring) (length kill-ring-yank-pointer)))
 	     " kill-ring))\n"))
 
-	  (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n")
-	  (dolist (l (mapcar #'desktop-buffer-info (buffer-list)))
-	    (let ((base (pop l)))
-	      (when (apply #'desktop-save-buffer-p l)
-		(insert "("
+          (let ((buffers (seq-filter (lambda (l) (apply #'desktop-save-buffer-p (cdr l)))
+                                     (mapcar #'desktop-buffer-info (buffer-list))))
+                (i 0))
+	    (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n")
+            (when desktop-save-adds-progress-reporter
+              (insert "(let ((reporter\n")
+              (insert (format "       (make-progress-reporter \"Restoring buffers...\" %s %s )))\n\n"
+                              0 (length buffers))))
+            (dolist (l buffers)
+	      (let ((base (pop l)))
+	        (insert "("
 			(if (or (not (integerp eager))
 				(if (zerop eager)
 				    nil
@@ -1131,7 +1151,12 @@ desktop-save
 		  (setcar (nthcdr 1 l) base))
 		(dolist (e l)
 		  (insert "\n  " (desktop-value-to-string e)))
-		(insert ")\n\n"))))
+		(insert ")\n")
+                (when desktop-save-adds-progress-reporter
+                  (setq i (1+ i))
+                  (insert (format "  (progress-reporter-update reporter %s)\n\n" i)))))
+            (when desktop-save-adds-progress-reporter
+              (insert "(progress-reporter-done reporter))\n")))
 
 	  (setq default-directory desktop-dirname)
 	  ;; When auto-saving, avoid writing if nothing has changed since the last write.
-- 
2.35.1


  parent reply	other threads:[~2022-10-21 19:09 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 13:28 bug#58634: Long delay with blank screen whilst loading desktop at emacs startup Alan Mackenzie
2022-10-19 15:49 ` Eli Zaretskii
2022-10-19 19:11   ` Andrea Corallo
2022-10-19 19:58     ` Alan Mackenzie
2022-10-20  5:20       ` Eli Zaretskii
2022-10-20 10:55         ` Alan Mackenzie
2022-10-20 13:07           ` Eli Zaretskii
2022-10-20 15:28             ` Alan Mackenzie
2022-10-20 16:28               ` Eli Zaretskii
2022-10-21  8:59                 ` Alan Mackenzie
2022-10-21 11:28                   ` Eli Zaretskii
2022-10-21 12:40                     ` Alan Mackenzie
2022-10-21 13:22                       ` Eli Zaretskii
2022-10-21 14:15                         ` Alan Mackenzie
2022-10-21 15:23                           ` Eli Zaretskii
2022-10-21 15:42                             ` Alan Mackenzie
2022-10-21 15:57                               ` Eli Zaretskii
2022-10-21 17:15                                 ` Alan Mackenzie
2022-10-21 18:12                                   ` Eli Zaretskii
2022-10-21 19:01                                     ` Alan Mackenzie
2022-10-21 19:14                                       ` Eli Zaretskii
2022-10-21 20:11                                         ` Alan Mackenzie
2022-10-22  6:26                                           ` Eli Zaretskii
2022-10-22 12:20                                             ` Alan Mackenzie
2022-10-22 13:11                                               ` Eli Zaretskii
2022-10-23 15:22                                                 ` Alan Mackenzie
2022-10-23 16:23                                                   ` Eli Zaretskii
2022-10-23 18:58                                                     ` Alan Mackenzie
2022-10-23 19:11                                                       ` Eli Zaretskii
2022-10-26 16:35                                                         ` Alan Mackenzie
2022-10-26 16:38                                                           ` Eli Zaretskii
2022-10-26 19:39                                                           ` Stefan Kangas
2022-10-27  5:19                                                             ` Eli Zaretskii
2022-10-21 19:09                       ` Stefan Kangas [this message]
2022-10-22 17:46                     ` Juri Linkov
2022-10-22 18:33                       ` 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='CADwFkmnf1ijf61L0srcPHDrOorCy_7BywiKUipZc=G9Zzr3PmQ@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=58634@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    /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.