From 76636d4a98a6cc23f0a9b5204dced4285990f53d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 11 Feb 2021 15:51:43 -0500 Subject: [PATCH] Refactor cmds!! + No longer depends on general.el + Each branch is now anaphoric (binds `it` to the return value of the predicate) --- core/core-lib.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 54caab026..4b8aec482 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -260,9 +260,18 @@ See `general-key-dispatch' for what other arguments it accepts in BRANCHES." (when (cl-oddp (length branches)) (setq fallback (car (last branches)) branches (butlast branches))) - `(general-predicate-dispatch ,fallback - :docstring ,docstring - ,@branches))) + (let ((defs (cl-loop for (key value) on branches by 'cddr + unless (keywordp key) + collect (list key value)))) + `'(menu-item + ,(or docstring "") nil + :filter (lambda (&optional _) + (let (it) + (cond ,@(mapcar (lambda (pred-def) + `((setq it ,(car pred-def)) + ,(cadr pred-def))) + defs) + (t ,fallback)))))))) (defalias 'kbd! 'general-simulate-key)