Refactor cmds!!
+ No longer depends on general.el + Each branch is now anaphoric (binds `it` to the return value of the predicate)
This commit is contained in:
parent
1a7536cbd1
commit
76636d4a98
1 changed files with 12 additions and 3 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue