[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 8fd6c17a01 033/146: Add cape-capf-buster
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 8fd6c17a01 033/146: Add cape-capf-buster |
Date: |
Sun, 9 Jan 2022 20:57:40 -0500 (EST) |
branch: externals/cape
commit 8fd6c17a01f80d7ccefd5a03d2347dad27e6ebc5
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add cape-capf-buster
See discussion in https://github.com/minad/corfu/issues/71
---
cape.el | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/cape.el b/cape.el
index b5b52839ef..aa58f62d18 100644
--- a/cape.el
+++ b/cape.el
@@ -618,5 +618,31 @@ This feature is experimental."
:exit-function (lambda (x _status) (cape--company-call
backend 'post-completion x))))))))
name))
+(defun cape-capf-buster (capf &optional cmp)
+ "Return transformed CAPF where the cache is busted on input change.
+The CMP argument determines how the new input is compared to the old input.
+- prefix/nil: Preserve cache when the old input is a prefix of the new input.
+- equal: Preserve cache when the old input is equal to the new input.
+- substring: Preserve cache when the old input is a substring of the new
input."
+ (lambda ()
+ (pcase (funcall capf)
+ (`(,beg ,end ,table . ,plist)
+ (let* ((start (copy-marker beg))
+ (input (buffer-substring-no-properties start (point))))
+ `(,beg ,end
+ ,(lambda (str pred action)
+ (let ((new-input (buffer-substring-no-properties start
(point))))
+ (unless (or
+ (pcase-exhaustive cmp
+ ((or 'prefix 'nil) (not (string-prefix-p input
new-input)))
+ ('equal (equal new-input input))
+ ('substring (not (string-match-p (regexp-quote
input) new-input))))
+ (string-match-p "\\s-" new-input))
+ (pcase (funcall capf)
+ (`(,_beg ,_end ,new-table . ,_plist)
+ (setq table new-table input new-input)))))
+ (complete-with-action action table str pred))
+ ,@plist))))))
+
(provide 'cape)
;;; cape.el ends here
- [elpa] externals/cape b1f57d79ba 009/146: Improve ispell, (continued)
- [elpa] externals/cape b1f57d79ba 009/146: Improve ispell, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ae136b6ba4 010/146: Improve dabbrev lazy loading, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0cc116b29c 012/146: Implement company adapter (See #1), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 845f3483f1 019/146: company-merge-capfs: Add support for :company-prefix-length, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 31acb66152 021/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape adb54fc562 020/146: Add missing autoload, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d098cc3cba 023/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ff5b19afc0 025/146: Add missing omit-nulls, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a54a512030 030/146: cape-merge-capfs: Compute candidates later, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0bdc6ae05c 034/146: README: Mention cape-capf-buster, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8fd6c17a01 033/146: Add cape-capf-buster,
ELPA Syncer <=
- [elpa] externals/cape 90ad5d68d5 037/146: Extract cape--cached-table, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 04a332c5fe 036/146: Extract cape--input-changed-p, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 882b9d9e79 042/146: Rename cape-merge-capfs, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 9111ad5101 043/146: Ensure that dabbrev is initialized properly, ELPA Syncer, 2022/01/09
- [elpa] externals/cape af4268549c 055/146: Dabbrev: Use equality check, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 29f828cc82 061/146: Reorder, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 80ca6abfd5 063/146: Add cape-line, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 52c86daf8c 062/146: Version 0.2, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8643892a6d 066/146: Minor refactoring, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0fdbf4f5c3 073/146: cape-line: Implement capf, ELPA Syncer, 2022/01/09