Subject: Re: bug#75142: 31.0.50; package-refresh-contents is not async when using interactively.

From: Philip Kaludercic <[email-masked]>
Date: Fri, 31 Jan 2025 07:55:55 +0000

[email-masked] writes:

>> [email-masked] writes:
>>
>>>> Ping! Did someone try the patch, and if so, did it give good results?
>>>
>>> It works but gives no indication of what its doing to the user, and
>>> doesn't notify when its done.
>>
>> That is easy to fix, what do you think about:
>
> That works.

Great, if there are no objections I'd push

>From 6ead0be930dff721ee575f17f89917dbcfe0fd1e Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <[email-masked]>
Date: Fri, 31 Jan 2025 08:55:02 +0100
Subject: [PATCH] Refresh package list without blocking

* lisp/emacs-lisp/package.el (package-refresh-contents): Run
asynchronously when invoked interactively.
* etc/NEWS: Mention the change.
---
 etc/NEWS                   | 4 ++++
 lisp/emacs-lisp/package.el | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 22cf8c636c2..9e50d61f6bf 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -951,6 +951,10 @@ removing packages.
 When invoked with a prefix argument, 'package-install-selected-packages'
 will not prompt the user for confirmation before installing packages.
 
+---
+*** 'package-refresh-contents' runs asynchronously
+Refreshing the package index will not block when invoked interactively.
+
 ** Xref
 
 ---
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index be8dc3f8377..3bc63abcce9 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1847,8 +1847,11 @@ package-refresh-contents
 inform Emacs about the latest versions of all packages it offers,
 and make them available for download.
 Optional argument ASYNC specifies whether to perform the
-downloads in the background."
-  (interactive)
+downloads in the background.  This is always the case when the command
+is invoked interactively."
+  (interactive (list t))
+  (when async
+    (message "Refreshing package contents..."))
   (unless (file-exists-p package-user-dir)
     (make-directory package-user-dir t))
   (let ((default-keyring (expand-file-name "package-keyring.gpg"
-- 
2.47.2

to master.

> --
> tusharhero