From f561eed4d654345dba68d38bf47ab7637db536fb Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Fri, 6 Feb 2026 22:31:30 +0100 Subject: [PATCH] Add separate user option to prevent repetitive package suggestions * lisp/emacs-lisp/package-activate.el (package-autosuggest-style): Remove option 'once' and defer to new user option. (package-autosuggest-once): Add new option. (package--suggestion-applies-p) (package--autosuggest-after-change-mode): Respect new user option. --- lisp/emacs-lisp/package-activate.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/package-activate.el b/lisp/emacs-lisp/package-activate.el index f00831c9ba2..cc73860708d 100644 --- a/lisp/emacs-lisp/package-activate.el +++ b/lisp/emacs-lisp/package-activate.el @@ -542,15 +542,20 @@ the `Version:' header." You can set this value to `mode-line' (default) to indicate the availability of a package suggestion in the minor mode, `always' to prompt the user in the minibuffer every time a suggestion is available -in a `fundamental-mode' buffer, `once' to do only prompt the user once -for each suggestion or `message' to just display a message hinting at -the existence of a suggestion." +in a `fundamental-mode' buffer, or `message' to just display a message +hinting at the existence of a suggestion. If you only wish to be +reminded of package suggestions once every session, consider customizing +the `package-autosuggest-once' user option." :type '(choice (const :tag "Indicate in mode line" mode-line) (const :tag "Always prompt" always) - (const :tag "Prompt only once" once) (const :tag "Indicate with message" message)) :group 'package) +(defcustom package-autosuggest-once nil + "Non-nil means not to repeat package suggestions." + :type 'boolean + :group 'package) + (defvar package--autosuggest-database 'unset "A list of package suggestions. Each entry in the list is of a form suitable to for @@ -578,7 +583,7 @@ mode name differ, then an optional forth element MAJOR-MODE can indicate what command to invoke to enable the package." (pcase sug ((or (guard (not (eq major-mode 'fundamental-mode))) - (guard (and (memq package-autosuggest-style '(once mode-line)) + (guard (and package-autosuggest-once (not (memq (car sug) package--autosuggest-suggested)))) `(,(pred package-installed-p) . ,_)) nil) @@ -653,13 +658,15 @@ This function should be added to `after-change-major-mode-hook'." '((package-autosuggest-mode package--autosugest-line-format)))) (force-mode-line-update t)) - ((or 'once 'always) + ('always (package-autosuggest avail)) ('message (message (substitute-command-keys (format "Found suggested packages: %s. Install using \\[package-autosuggest]" - pkgs))))))) + pkgs))) + (dolist (rec avail) + (add-to-list 'package--autosuggest-suggested (car rec))))))) (define-minor-mode package-autosuggest-mode "Enable the automatic suggestion and installation of packages."