summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2025-04-06 13:24:05 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2025-04-06 14:11:47 +0200
commitdee10bbddbd3ed572ed87a2b42cd7f0b2a454aca (patch)
tree9b92b45fac2af812b2a406cd73fecff37f8d3ab0 /extensions
parent101002411e6266b719fc252ce02f1418782d552f (diff)
Automatically save corfu-history
Diffstat (limited to 'extensions')
-rw-r--r--extensions/corfu-history.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el
index 4280cbe..7120ae8 100644
--- a/extensions/corfu-history.el
+++ b/extensions/corfu-history.el
@@ -30,12 +30,10 @@
;; The recently selected candidates are stored in the `corfu-history' variable.
;; If `history-delete-duplicates' is nil, duplicate elements are ranked higher
;; with exponential decay. In order to save the history across Emacs sessions,
-;; enable `savehist-mode' and add `corfu-history' to
-;; `savehist-additional-variables'.
+;; enable `savehist-mode'.
;;
;; (corfu-history-mode 1)
;; (savehist-mode 1)
-;; (add-to-list 'savehist-additional-variables 'corfu-history)
;;; Code:
@@ -102,6 +100,10 @@ See also `corfu-history-duplicate'."
(cl-defmethod corfu--insert :before (_status &context (corfu-history-mode (eql t)))
(when (>= corfu--index 0)
+ (unless (or (not (bound-and-true-p savehist-mode))
+ (memq 'corfu-history (bound-and-true-p savehist-ignored-variables)))
+ (defvar savehist-minibuffer-history-variables)
+ (add-to-list 'savehist-minibuffer-history-variables 'corfu-history))
(add-to-history 'corfu-history
(substring-no-properties
(nth corfu--index corfu--candidates)))