diff --git a/CHANGELOG.md b/CHANGELOG.md index 9883c35..ba87d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,15 @@ The format is based on [Keep a Changelog]. * Change how candidates are remembered for Vertico to work with `vertico-directory-enter` and to remember the minibuffer contents when exiting the minibuffer. +* Use `corfu--initial-state` if `corfu--state-vars` is not bound + ([#158], [#159]). [#152]: https://github.com/radian-software/prescient.el/issues/152 [#153]: https://github.com/radian-software/prescient.el/pull/153 [#156]: https://github.com/radian-software/prescient.el/pull/156 +[#158]: https://github.com/radian-software/prescient.el/pull/158 +[#159]: https://github.com/radian-software/prescient.el/pull/159 + ## 6.2 (released 2023-11-23) ### Features diff --git a/corfu-prescient.el b/corfu-prescient.el index 1cd075d..3133dd3 100644 --- a/corfu-prescient.el +++ b/corfu-prescient.el @@ -6,7 +6,7 @@ ;; Homepage: https://github.com/radian-software/prescient.el ;; Keywords: extensions ;; Created: 23 Sep 2022 -;; Package-Requires: ((emacs "27.1") (prescient "6.1.0") (corfu "0.28")) +;; Package-Requires: ((emacs "27.1") (prescient "6.1.0") (corfu "1.1")) ;; SPDX-License-Identifier: MIT ;; Version: 6.2.0 @@ -28,6 +28,11 @@ (require 'prescient) (require 'subr-x) +;; Remove references to `corfu--state-vars' once the next stable +;; version of Corfu is released: +(defvar corfu--state-vars) +(defvar corfu--initial-state) + ;;;; Customization (defgroup corfu-prescient nil @@ -193,8 +198,13 @@ This mode will: ;; after the Corfu pop-up closes. For the toggling vars, it ;; is the commands themselves that make the variables buffer ;; local. - (cl-callf cl-union corfu--state-vars prescient--toggle-vars - :test #'eq)) + (if (boundp 'corfu--state-vars) + (cl-callf cl-union corfu--state-vars prescient--toggle-vars + :test #'eq) + (cl-callf cl-union corfu--initial-state + (mapcar (lambda (k) (cons k (symbol-value k))) + prescient--toggle-vars) + :test #'eq :key #'car))) ;; While sorting might not be enabled in Corfu, it might ;; still be enabled in another UI, such as Selectrum or Vertico. @@ -214,12 +224,17 @@ This mode will: (when (equal (lookup-key corfu-map (kbd "M-s")) prescient-toggle-map) (define-key corfu-map (kbd "M-s") - corfu-prescient--old-toggle-binding)) + corfu-prescient--old-toggle-binding)) (remove-hook 'prescient--toggle-refresh-functions #'corfu-prescient--toggle-refresh) - (cl-callf cl-set-difference corfu--state-vars - prescient--toggle-vars - :test #'eq) + (if (boundp 'corfu--state-vars) + (cl-callf cl-set-difference corfu--state-vars + prescient--toggle-vars + :test #'eq) + (cl-callf cl-set-difference corfu--initial-state + (mapcar (lambda (k) (cons k (symbol-value k))) + prescient--toggle-vars) + :test #'eq :key #'car)) ;; Undo filtering settings. (remove-hook 'corfu-mode-hook diff --git a/stub/corfu.el b/stub/corfu.el index 7947c87..1468486 100644 --- a/stub/corfu.el +++ b/stub/corfu.el @@ -4,7 +4,9 @@ (defvar corfu--candidates nil) (defvar corfu--index nil) +(defvar corfu--initial-state nil) (defvar corfu--input nil) +;; Removed https://github.com/minad/corfu/commit/63d1de2696adcb09a4ea01ba668635364e37a9c2 (defvar corfu--state-vars nil) (defvar corfu-map nil) (defvar corfu-mode nil)