diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2025-04-06 13:24:05 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2025-04-06 14:11:47 +0200 |
| commit | dee10bbddbd3ed572ed87a2b42cd7f0b2a454aca (patch) | |
| tree | 9b92b45fac2af812b2a406cd73fecff37f8d3ab0 | |
| parent | 101002411e6266b719fc252ce02f1418782d552f (diff) | |
Automatically save corfu-history
| -rw-r--r-- | CHANGELOG.org | 3 | ||||
| -rw-r--r-- | extensions/corfu-history.el | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org index 89c4efe..f05413d 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -7,6 +7,9 @@ - =corfu-history-duplicate= and =corfu-history-decay=: New customization options to adjust the rank of duplicate history elements, such that they appear earlier in the completion list. +- =corfu-history-mode=: Ensure that the =corfu-history= is saved if =savehist-mode= is + enabled. Automatically add =corfu-history= to + =savehist-minibuffer-history-variables=. * Version 2.0 (2025-03-28) 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))) |
