From 80b41c67ab75eb57aa0fb527842f9d3d82002544 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 23 Dec 2023 11:45:38 +0100 Subject: cape--properties-table: Fix condition --- cape.el | 23 +++++++++++++---------- 1 file 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. -- cgit v1.0