[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 202345e954 083/146: cape-capf-with-properties: Add
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 202345e954 083/146: cape-capf-with-properties: Add support for :sort and :category |
Date: |
Sun, 9 Jan 2022 20:57:44 -0500 (EST) |
branch: externals/cape
commit 202345e9547bebe200b207ebdc3facdc5b42360d
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
cape-capf-with-properties: Add support for :sort and :category
---
cape.el | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/cape.el b/cape.el
index f63e6c66b4..9db9945b67 100644
--- a/cape.el
+++ b/cape.el
@@ -324,18 +324,20 @@
(completion-in-region beg end table (plist-get extra :predicate))))
(_ (user-error "%s: No completions" capf))))
-(cl-defun cape--table-with-properties (table &key category (sort t))
+(cl-defun cape--table-with-properties (table &key category (sort t)
&allow-other-keys)
"Create completion TABLE with properties.
CATEGORY is the optional completion category.
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)))))
+ (if (or (not table) (and (not category) sort))
+ table
+ (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.
@@ -753,12 +755,15 @@ If INTERACTIVE is nil the function acts like a capf."
;;;###autoload
(defun cape-capf-with-properties (capf &rest properties)
"Return a new CAPF with additional completion PROPERTIES.
-Completion properties include for example :exclusive, :annotation-function
-and the various :company-* extensions."
+Completion properties include for example :exclusive, :annotation-function and
+the various :company-* extensions. Furthermore a boolean :sort flag and a
+completion :category symbol can be specified."
(lambda ()
(pcase (funcall capf)
(`(,beg ,end ,table . ,plist)
- `(,beg ,end ,table ,@properties ,@plist)))))
+ `(,beg ,end
+ ,(apply #'cape--table-with-properties table properties)
+ ,@properties ,@plist)))))
;;;###autoload
(defun cape-silent-capf (capf)
- [elpa] externals/cape bc1c1ee9fc 140/146: Make cape-tex etc less aggressive, add cape-tex-prefix-required variable, (continued)
- [elpa] externals/cape bc1c1ee9fc 140/146: Make cape-tex etc less aggressive, add cape-tex-prefix-required variable, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8726bc7246 138/146: cape--interactive: Simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ac65f2acdf 048/146: Add autoloads, renamings, README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0a05e51d2a 053/146: Add cape-capf-with-predicate (See #9), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 75cb8c799a 071/146: Unify cape-file and cape-file-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1d72f84b64 046/146: Add cape-capf-with-properties and cape-silent-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 693a376913 054/146: Revert "Add cape-capf-with-predicate (See #9)", ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8a2cc4c7bb 060/146: Add completion categories, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 496bb4a5e4 065/146: Rename function, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ba85197981 075/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 202345e954 083/146: cape-capf-with-properties: Add support for :sort and :category,
ELPA Syncer <=
- [elpa] externals/cape 15491cef1a 087/146: Add link to Emacs, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 659f710682 089/146: Add comment, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ceca3a3d06 077/146: Expand readme, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c57b01e982 091/146: Improve dynamic table support of cape-super-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 7008958b02 078/146: Minor corrections, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 9e4651649b 094/146: Treat company backends as non-interruptible., ELPA Syncer, 2022/01/09
- [elpa] externals/cape c7feeee10b 080/146: Simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 02c9629bc6 081/146: Refactor and simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d3d9d926ac 082/146: Add cape-interactive-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3c44bff1f6 095/146: Minor refactoring, ELPA Syncer, 2022/01/09