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

    vertico-repeat: Do not store overly long selected candidates in history
---
 extensions/vertico-repeat.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/extensions/vertico-repeat.el b/extensions/vertico-repeat.el
index 6dc44bf5b9..bda99966bd 100644
--- a/extensions/vertico-repeat.el
+++ b/extensions/vertico-repeat.el
@@ -65,7 +65,8 @@
 
 (defcustom vertico-repeat-transformers
   (list #'vertico-repeat--filter-empty
-        #'vertico-repeat--filter-commands)
+        #'vertico-repeat--filter-commands
+        #'vertico-repeat--remove-long)
   "List of functions to apply to history element before saving."
   :type '(repeat function)
   :group 'vertico)
@@ -86,6 +87,13 @@
   "Filter SESSION if input is empty."
   (and (cadr session) (not (equal (cadr session) "")) session))
 
+(defun vertico-repeat--remove-long (session)
+  "Remove overly long candidate from SESSION."
+  (when-let ((cand (caddr session))
+             ((and (stringp cand) (length> cand 200))))
+    (setf (cddr session) (cdddr session)))
+  session)
+
 (defun vertico-repeat--save-input ()
   "Save current minibuffer input."
   (setq vertico-repeat--input (minibuffer-contents-no-properties)))

Reply via email to