Subject: bug#43983: [PATCH] Improve package install/delete button action

From: tsuucat <[email-masked]>
Date: Wed, 14 Oct 2020 04:46:42 +0900

Hi, current package-install-button-action and package-delete-button-action have
some problems so I made a patch.

If user clicks [Install] button, the *Help* buffer is reverted and shows the package is
"available obsolete" in first line.
(steps)
1. emacs -Q
2. M-x list-packages
3. M-x package-refresh-contents
3. Click “ztree” package
4. Click [Install]
(steps end)
I think this is not good for user experience. The buffer shoud shows the package is
“installed” in first line.

And then if user clicks [Delete] button an error happens.
(steps)
1. (Install ztree like above)
2. Type q
3. Click “ztree” package which is marked as installed
4. Click [Delete]
(steps end)
(backstace)
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("\\`https?:" nil nil)
  package--with-response-buffer-1(nil #f(compiled-function () #<bytecode 0x1fe0b74a2895>) :file "ztree-readme.txt" :async nil :error-function #f(compiled-function () #<bytecode 0x1fe0b589df81>) :noerror t)
  describe-package-1(#s(package-desc :name ztree :version (20191108 2234) :summary "Text mode directory tree" :reqs ((cl-lib (0))) :kind nil :archive nil :dir "/(path/to)/test-home/.emacs...." :extras ((:url . "https://github.com/fourier/ztree") (:maintainer "Alexey Veretennikov" . "[email-masked]") (:authors ("Alexey Veretennikov" . "[email-masked]")) (:keywords "files" "tools") (:commit . "0a5b25f364490a58ef7371534a39c75d11f54132")) :signed nil))
  describe-package(#s(package-desc :name ztree :version (20191108 2234) :summary "Text mode directory tree" :reqs ((cl-lib (0))) :kind nil :archive nil :dir "/(path/to)/test-home/.emacs...." :extras ((:url . "https://github.com/fourier/ztree") (:maintainer "Alexey Veretennikov" . "[email-masked]") (:authors ("Alexey Veretennikov" . "[email-masked]")) (:keywords "files" "tools") (:commit . "0a5b25f364490a58ef7371534a39c75d11f54132")) :signed nil))
  apply(describe-package #s(package-desc :name ztree :version (20191108 2234) :summary "Text mode directory tree" :reqs ((cl-lib (0))) :kind nil :archive nil :dir "/(path/to)/test-home/.emacs...." :extras ((:url . "https://github.com/fourier/ztree") (:maintainer "Alexey Veretennikov" . "[email-masked]") (:authors ("Alexey Veretennikov" . "[email-masked]")) (:keywords "files" "tools") (:commit . "0a5b25f364490a58ef7371534a39c75d11f54132")) :signed nil))
  help-mode-revert-buffer(nil t)
  revert-buffer(nil t)
  package-delete-button-action(#<marker (moves after insertion) at 483 in *Help*>)
  button-activate(#<marker (moves after insertion) at 483 in *Help*> t)
  push-button(94 t)
  push-button((mouse-2 (#<window 99 on *Help*> 94 (452 . 42) 1086759856 nil 94 (64 . 2) nil (2 . 10) (7 . 20))))
a  funcall-interactively(push-button (mouse-2 (#<window 99 on *Help*> 94 (452 . 42) 1086759856 nil 94 (64 . 2) nil (2 . 10) (7 . 20))))  call-interactively(push-button nil nil)
  command-execute(push-button)
(backstace end)
This is because package-delete-button-action’s revert-buffer runs describe-package 
with old package-desc which archive field is nil.

Running describe-package with just package name instead of revert-buffer fixes 
these problems.

Thanks.

--
tsuucat