回答:
ソースはこちらです:https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/package.el#L2113。
package-selected-packagesにも依存関係にもないすべてのパッケージを削除します。
(defun package-autoremove ()
"Remove packages that are no more needed.
Packages that are no more needed by other packages in
`package-selected-packages' and their dependencies
will be deleted."
(interactive)
;; If `package-selected-packages' is nil, it would make no sense to
;; try to populate it here, because then `package-autoremove' will
;; do absolutely nothing.
(when (or package-selected-packages
(yes-or-no-p
(format-message
"`package-selected-packages' is empty! Really remove ALL packages? ")))
(let ((removable (package--removable-packages)))
(if removable
(when (y-or-n-p
(format "%s packages will be deleted:\n%s, proceed? "
(length removable)
(mapconcat #'symbol-name removable ", ")))
(mapc (lambda (p)
(package-delete (cadr (assq p package-alist)) t))
removable))
(message "Nothing to autoremove")))))
(defun package--removable-packages ()
"Return a list of names of packages no longer needed.
These are packages which are neither contained in
`package-selected-packages' nor a dependency of one that is."
(let ((needed (cl-loop for p in package-selected-packages
if (assq p package-alist)
;; `p' and its dependencies are needed.
append (cons p (package--get-deps p)))))
(cl-loop for p in (mapcar #'car package-alist)
unless (memq p needed)
collect p)))
package-selected-packages
、パッケージをインストールおよび削除すると自動的に更新されることにも注意してください。通常は、直接変更する必要はありません。自動的に削除されるものがある場合、それらはおそらく、インストールしたものの依存関係として取り込まれ、後で削除されたパッケージです。自動削除のサポートに加えて、この変数は、emacs設定を新しいマシンにコピーし、選択したパッケージリストのすべてをを使用してインストールする場合に使用できpackage-install-selected-packages
ます。
package-selected-packages
。に追加することです」
package-selected-packages
自動削除されないことを意味します。