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

From: Philip Kaludercic <[email-masked]>
Date: Sat, 04 Jan 2025 12:11:17 +0000

Eli Zaretskii <[email-masked]> writes:

>> Date: Fri, 27 Dec 2024 15:15:38 +0530
>> From: tusharhero--- via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>> 
>> 
>> When running `M-x package-refresh-contents RET', my Emacs session
>> freezes for a long time. But it is possible to run this async, we need
>> to give it an argument. I think when the function should be async, I
>> understand that when using this in emacs lisp program, that maybe not be
>> desirable. So maybe you can have a separate functions for emacs lisp
>> programs, or have different behavior for interactive use.
>
> Philip and Stefan, any comments?

We could also run it async given a prefix argument.  Perhaps it might
even be ok it just allow it to run async whenever it is invoked
interactively?  It doesn't take much to change it, if you want to try it
out:

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index b4a33db1a77..b3c0e7bccfa 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1848,7 +1848,7 @@ package-refresh-contents
 and make them available for download.
 Optional argument ASYNC specifies whether to perform the
 downloads in the background."
-  (interactive)
+  (interactive (list t))
   (unless (file-exists-p package-user-dir)
     (make-directory package-user-dir t))
   (let ((default-keyring (expand-file-name "package-keyring.gpg"