summaryrefslogtreecommitdiff
path: root/cape.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-12-23 11:45:38 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2023-12-23 11:45:38 +0100
commit80b41c67ab75eb57aa0fb527842f9d3d82002544 (patch)
treed54738b8a49c24f553b8e89094c8846e9f7dab93 /cape.el
parent029d1a6595031a3b7c767652a2ba7907b5b84504 (diff)
cape--properties-table: Fix condition
Diffstat (limited to 'cape.el')
-rw-r--r--cape.el23
1 files changed, 13 insertions, 10 deletions
diff --git a/cape.el b/cape.el
index cb3e982..4e411ae 100644
--- a/cape.el
+++ b/cape.el
@@ -278,16 +278,19 @@ NAME is the name of the Capf, BEG and END are the input markers."
"Create completion TABLE with properties.
CATEGORY is the optional completion category.
SORT should be nil to disable sorting."
- (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))))))
+ ;; The metadata will be overridden if the category is non-nil, if the table is
+ ;; a function table or if sorting should be disabled for a non-nil
+ ;; non-function table.
+ (if (or category (functionp table) (and (not 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))))
+ table))
(defun cape--dynamic-table (beg end fun)
"Create dynamic completion table from FUN with caching.