[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 11bcf51724 064/146: Ensure that cape-line is not s
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 11bcf51724 064/146: Ensure that cape-line is not sorted |
Date: |
Sun, 9 Jan 2022 20:57:43 -0500 (EST) |
branch: externals/cape
commit 11bcf5172431c4acfb7d7e3e3b4a3c31213553e0
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Ensure that cape-line is not sorted
---
cape.el | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/cape.el b/cape.el
index 4c7d1f2dc9..1da77c4b28 100644
--- a/cape.el
+++ b/cape.el
@@ -314,16 +314,18 @@
(completion-extra-properties extra))
(completion-in-region (car bounds) (cdr bounds) table)))
-(cl-defun cape--table-with-properties (table &key category sort)
+(cl-defun cape--table-with-properties (table &key category (sort t))
"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))))
+SORT should be nil to disable sorting."
+ (let ((metadata `(metadata
+ ,@(and category `((category . ,category)))
+ ,@(and (not sort) '((display-sort-function . identity)
+ (cycle-sort-function . identity))))))
+ (lambda (str pred action)
+ (if (eq action 'metadata)
+ metadata
+ (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.
@@ -341,26 +343,24 @@ The CMP argument determines how the new input is compared
to the old 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)
+(cl-defun cape--cached-table (beg end fun &key valid category (sort t))
"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."
+SORT should be nil to disable sorting."
(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)))))
+ (cape--table-with-properties
+ (lambda (str pred action)
+ (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))
+ :category category :sort sort)))
(defvar cape--file-properties
(list :annotation-function (lambda (s) (if (string-suffix-p "/" s) " Folder"
" File"))
@@ -679,7 +679,7 @@ This feature is experimental."
(apply-partially #'cape--company-call
backend 'candidates))
:category backend
:valid (if (cape--company-call backend
'no-cache initial-input) 'never valid)
- :sort (and (cape--company-call backend
'sorted) #'identity))
+ :sort (not (cape--company-call backend
'sorted)))
:exclusive 'no
:company-prefix-length (cdr-safe prefix)
:company-doc-buffer (lambda (x) (cape--company-call backend
'doc-buffer x))
@@ -729,7 +729,8 @@ VALID is the input comparator, see `cape--input-valid-p'."
(puthash line t ht)
(push line lines))))
(setq beg (1+ end))))
- (completion-in-region (line-beginning-position) (point) lines)))
+ (completion-in-region (line-beginning-position) (point)
+ (cape--table-with-properties (nreverse lines) :sort
nil))))
;;;###autoload
(defun cape-capf-with-properties (capf &rest properties)
- [elpa] externals/cape 1d69a06890 117/146: cape-tex/cape-sgml: Add autoloads, (continued)
- [elpa] externals/cape 1d69a06890 117/146: cape-tex/cape-sgml: Add autoloads, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 7f11b354df 124/146: cape-company-capf: Remove symbol restriction, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a6db83b1bd 135/146: Improve repair function, ELPA Syncer, 2022/01/09
- [elpa] externals/cape f26e835929 131/146: README: Do not use hashed symbol, ELPA Syncer, 2022/01/09
- [elpa] externals/cape e23226cb1c 022/146: cape-file-capf: Add company-prefix-length=t after slash (Fix #8), ELPA Syncer, 2022/01/09
- [elpa] externals/cape e2fd7c1cc6 038/146: Minor refactoring, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3beed4f37c 047/146: Use cape--silent, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 12f5ae008c 051/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1b4b739639 059/146: Refactoring, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b63deab5af 058/146: cape--cached-table: Add category, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 11bcf51724 064/146: Ensure that cape-line is not sorted,
ELPA Syncer <=
- [elpa] externals/cape 33850ae000 068/146: Unify cape-dict and cape-dict-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 241dde47ca 070/146: Unify cape-keyword and cape-keyword-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape eaa408779e 072/146: cape-symbol: Implement capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape eff4f34841 084/146: Add cape-noninterruptible-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape fd8828cff3 100/146: Make cape--company-call more robust, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1d0d3abbd1 102/146: Use namespaced symbol, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 4aec140c08 109/146: Minor cleanup, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b3e2850fcf 108/146: Add unwind-protect, ELPA Syncer, 2022/01/09
- [elpa] externals/cape e81e3cfd4e 112/146: Indent, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b895c8cf28 114/146: cape-capf-case-fold: Add dont-fold, ELPA Syncer, 2022/01/09