summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-03-22 19:04:14 +0000
committerjao <jao@gnu.org>2021-03-22 19:04:14 +0000
commitc59571c7222511fdd0b0b33bb19155e732bee8e4 (patch)
tree9738edfd261888f7bb40d82cc4c068aa773f154c
parent24924040c6189db824b2ff32a74f5ca3b124c151 (diff)
downloadelibs-c59571c7222511fdd0b0b33bb19155e732bee8e4.tar.gz
elibs-c59571c7222511fdd0b0b33bb19155e732bee8e4.tar.bz2
properly recursive embark action indicator (ah, the riches)
-rw-r--r--consult.org31
1 files changed, 19 insertions, 12 deletions
diff --git a/consult.org b/consult.org
index 027e60d..7dcf80b 100644
--- a/consult.org
+++ b/consult.org
@@ -202,16 +202,22 @@
(setq jao-embark--excluded
'(embark-collect-snapshot embark-collect-live embark-export
- embark-become embark-isearch nil))
+ embark-keymap-help embark-become embark-isearch nil))
- (defun jao-embark--bind-desc (descs x)
+ (defun jao-embark--key-str (k)
+ (if (numberp k) (single-key-description k) (key-description k)))
+
+ (defun jao-embark--bind-desc (descs x prefix)
(let ((k (car x)) (c (cdr x)))
- (cond ((memq c jao-embark--excluded) descs)
+ (cond ((keymapp c)
+ (let ((cds (jao-embark--keymap-descs c (jao-embark--key-str k))))
+ (cons (max (or (car cds) 0) (or (car descs) 0))
+ (cons (max (or (cadr cds) 0) (or (cadr descs) 0))
+ (append (cddr descs) (cddr cds))))))
+ ((memq c jao-embark--excluded) descs)
((symbolp c)
- (let* ((desc (if (numberp k)
- (single-key-description k)
- (key-description k)))
- (desc (format "%s" desc))
+ (let* ((desc (jao-embark--key-str k))
+ (desc (format "%s%s" (or prefix "") desc))
(doc (car (split-string
(or (ignore-errors (documentation c)) "")
"\n")))
@@ -219,10 +225,11 @@
(cons (max (length desc) (car descs))
(cons (max (length fun) (cadr descs))
(cons (list desc fun doc) (cddr descs))))))
- (t descs))))
+ (t (message "i've skipped %S" x) descs))))
- (defun jao-embark--keymap-descs (k)
- (seq-reduce #'jao-embark--bind-desc (cdr (keymap-canonicalize k)) '(0 0)))
+ (defun jao-embark--keymap-descs (k prefix)
+ (seq-reduce `(lambda (descs x) (jao-embark--bind-desc descs x ,prefix))
+ (cdr (keymap-canonicalize k)) '(0 0)))
(defun jao-embark--dstr (d)
(let ((s (cadr d))) (if (string-prefix-p "embark" s) "" s)))
@@ -232,7 +239,7 @@
(read-only-mode -1)
(setq-local cursor-type nil)
(delete-region (point-min) (point-max))
- (let* ((descs (jao-embark--keymap-descs keymap))
+ (let* ((descs (jao-embark--keymap-descs keymap ""))
(fmt (format "%%-%ds %%-%ds %%s\n" (cadr descs) (car descs))))
(seq-each (lambda (desc)
(insert (format fmt
@@ -240,7 +247,7 @@
(propertize (car desc) 'face 'embark-keybinding)
(propertize (caddr desc) 'face 'italic))))
(seq-sort-by 'jao-embark--dstr 'string-greaterp (cddr descs))))
- (if target (insert (format "Action for '%s'" target)) (delete-char -1))
+ (if target (insert (format "\nAction for '%s'" target)) (delete-char -1))
(read-only-mode 1)
(let ((display-buffer-alist
(append display-buffer-alist jao-embark--default-display)))