branch: externals/vertico
commit 15fe9b2556d06f6ff7d5d98a520cbbdb36bdf411
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    Automatically save vertico-repeat-history
---
 CHANGELOG.org                | 3 +++
 extensions/vertico-repeat.el | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index c0e06d9240..6d2f0a40f7 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -9,6 +9,9 @@
 - =vertico-sort-history-duplicate= and =vertico-sort-history-decay=: New
   customization options to adjust the rank of duplicate history elements, such
   that they appear earlier in the completion list.
+- =vertico-repeat=: Ensure that the =vertico-repeat-history= is saved if
+  =savehist-mode= is enabled. Automatically add =vertico-repeat-history= to
+  =savehist-minibuffer-history-variables=.
 
 * Version 2.0 (2025-03-11)
 
diff --git a/extensions/vertico-repeat.el b/extensions/vertico-repeat.el
index 308ed3c734..6dc44bf5b9 100644
--- a/extensions/vertico-repeat.el
+++ b/extensions/vertico-repeat.el
@@ -35,8 +35,7 @@
 ;;
 ;; It is necessary to register a minibuffer setup hook, which saves
 ;; the Vertico state for repetition.  In order to save the history
-;; across Emacs sessions, enable `savehist-mode' and add
-;; `vertico-repeat-history' to `savehist-additional-variables'.
+;; across Emacs sessions, enable `savehist-mode'.
 ;;
 ;; (keymap-global-set "M-R" #'vertico-repeat)
 ;; (keymap-set vertico-map "M-P" #'vertico-repeat-previous)
@@ -110,6 +109,10 @@
         (transform vertico-repeat-transformers))
     (while (and transform (setq session (funcall (pop transform) session))))
     (when session
+      (unless (or (not (bound-and-true-p savehist-mode))
+                  (memq 'vertico-repeat-history (bound-and-true-p 
savehist-ignored-variables)))
+        (defvar savehist-minibuffer-history-variables)
+        (add-to-list 'savehist-minibuffer-history-variables 
'vertico-repeat-history))
       (add-to-history 'vertico-repeat-history session))))
 
 (defun vertico-repeat--restore (session)

Reply via email to