[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 29f828cc82 061/146: Reorder
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 29f828cc82 061/146: Reorder |
Date: |
Sun, 9 Jan 2022 20:57:42 -0500 (EST) |
branch: externals/cape
commit 29f828cc8298912f738f4e027b0ff445368b6a4b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Reorder
---
cape.el | 96 ++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/cape.el b/cape.el
index ef1b8b4536..84051448e4 100644
--- a/cape.el
+++ b/cape.el
@@ -314,6 +314,54 @@
(completion-extra-properties extra))
(completion-in-region (car bounds) (cdr bounds) table)))
+(cl-defun cape--table-with-properties (table &key category sort)
+ "Create completion TABLE with properties.
+CATEGORY is the optional completion category.
+SORT is an optional sort function."
+ (lambda (str pred action)
+ (if (eq action 'metadata)
+ `(metadata (category . ,category)
+ (display-sort-function . ,sort)
+ (cycle-sort-function . ,sort))
+ (complete-with-action action table str pred))))
+
+(defun cape--input-valid-p (old-input new-input cmp)
+ "Return non-nil if the NEW-INPUT is valid in comparison to OLD-INPUT.
+The CMP argument determines how the new input is compared to the old input.
+- never: Never treat the input as valid.
+- prefix/nil: The old input is a prefix of the new input.
+- equal: The old input is equal to the new input.
+- substring: The old input is a substring of the new input."
+ ;; Treat input as not changed if it contains space to allow
+ ;; Orderless completion style filtering.
+ (or (string-match-p "\\s-" new-input)
+ (pcase-exhaustive cmp
+ ('never nil)
+ ((or 'prefix 'nil) (string-prefix-p old-input new-input))
+ ('equal (equal old-input new-input))
+ ('substring (string-match-p (regexp-quote old-input) new-input)))))
+
+(cl-defun cape--cached-table (beg end fun &key valid category sort)
+ "Create caching completion table.
+BEG and END are the input bounds.
+FUN is the function which computes the candidates.
+VALID is the input comparator, see `cape--input-valid-p'.
+CATEGORY is the optional completion category.
+SORT is an optional sort function."
+ (let ((input 'init)
+ (beg (copy-marker beg))
+ (end (copy-marker end t))
+ (table nil))
+ (lambda (str pred action)
+ (if (eq action 'metadata)
+ `(metadata (category . ,category)
+ (display-sort-function . ,sort)
+ (cycle-sort-function . ,sort))
+ (let ((new-input (buffer-substring-no-properties beg end)))
+ (when (or (eq input 'init) (not (cape--input-valid-p input new-input
valid)))
+ (setq table (funcall fun new-input) input new-input)))
+ (complete-with-action action table str pred)))))
+
(defvar cape--file-properties
(list :annotation-function (lambda (s) (if (string-suffix-p "/" s) " Folder"
" File"))
:company-kind (lambda (s) (if (string-suffix-p "/" s) 'folder 'file)))
@@ -359,38 +407,6 @@
(cape--table-with-properties obarray :category
'symbol)
cape--symbol-properties))
-(cl-defun cape--table-with-properties (table &key category sort)
- "Create completion TABLE with properties.
-CATEGORY is the optional completion category.
-SORT is an optional sort function."
- (lambda (str pred action)
- (if (eq action 'metadata)
- `(metadata (category . ,category)
- (display-sort-function . ,sort)
- (cycle-sort-function . ,sort))
- (complete-with-action action table str pred))))
-
-(cl-defun cape--cached-table (beg end fun &key valid category sort)
- "Create caching completion table.
-BEG and END are the input bounds.
-FUN is the function which computes the candidates.
-VALID is the input comparator, see `cape--input-valid-p'.
-CATEGORY is the optional completion category.
-SORT is an optional sort function."
- (let ((input 'init)
- (beg (copy-marker beg))
- (end (copy-marker end t))
- (table nil))
- (lambda (str pred action)
- (if (eq action 'metadata)
- `(metadata (category . ,category)
- (display-sort-function . ,sort)
- (cycle-sort-function . ,sort))
- (let ((new-input (buffer-substring-no-properties beg end)))
- (when (or (eq input 'init) (not (cape--input-valid-p input new-input
valid)))
- (setq table (funcall fun new-input) input new-input)))
- (complete-with-action action table str pred)))))
-
(defvar cape--dabbrev-properties
(list :annotation-function (lambda (_) " Dabbrev")
:company-kind (lambda (_) 'text))
@@ -694,22 +710,6 @@ VALID is the input comparator, see `cape--input-valid-p'."
(complete-with-action action table str pred)))
,@plist)))))
-(defun cape--input-valid-p (old-input new-input cmp)
- "Return non-nil if the NEW-INPUT is valid in comparison to OLD-INPUT.
-The CMP argument determines how the new input is compared to the old input.
-- never: Never treat the input as valid.
-- prefix/nil: The old input is a prefix of the new input.
-- equal: The old input is equal to the new input.
-- substring: The old input is a substring of the new input."
- ;; Treat input as not changed if it contains space to allow
- ;; Orderless completion style filtering.
- (or (string-match-p "\\s-" new-input)
- (pcase-exhaustive cmp
- ('never nil)
- ((or 'prefix 'nil) (string-prefix-p old-input new-input))
- ('equal (equal old-input new-input))
- ('substring (string-match-p (regexp-quote old-input) new-input)))))
-
;;;###autoload
(defun cape-capf-with-properties (capf &rest properties)
"Return a new CAPF with additional completion PROPERTIES.
- [elpa] externals/cape d098cc3cba 023/146: Update README, (continued)
- [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, 2022/01/09
- [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 <=
- [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
- [elpa] externals/cape 16ef21309b 076/146: Improve cape-dabbrev, ELPA Syncer, 2022/01/09
- [elpa] externals/cape edb2be3b71 092/146: Version 0.3, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 08877dbf75 096/146: Improve comments, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b5485b8878 031/146: cape-ispell-capf: Compute candidates later, ELPA Syncer, 2022/01/09
- [elpa] externals/cape dc26e9f7ab 049/146: cape-dict-capf: Load the dict lazily, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 2bcdd7bfe5 052/146: cape-file-capf: Require directory as prefix (Fix #9), ELPA Syncer, 2022/01/09