@@ -57,6 +57,17 @@ from ClojureDocs or any other function accepting a var as an argument."
57
57
function)
58
58
:package-version '(cider . " 0.15.0" ))
59
59
60
+ (defcustom cider-cheatsheet-select-type 'multi
61
+ " Controls how cheatsheet is displayed when using `cider-cheatsheet-select`.
62
+
63
+ If `multi`, then provide a multi-step selection process where you need to go
64
+ section by section until you find a var.
65
+
66
+ If `path`, then represent each completion candidate as a full path to a var."
67
+ :type '(choice (const multi)
68
+ (const path))
69
+ :package-version '(cider . " 0.15.0" ))
70
+
60
71
(defconst cider-cheatsheet-hierarchy
61
72
'((" Documentation"
62
73
(" REPL"
@@ -583,25 +594,28 @@ This list is supposed to have the following format:
583
594
hierarchy))
584
595
585
596
;;;### autoload
586
- (defun cider-cheatsheet-select (&optional flat )
597
+ (defun cider-cheatsheet-select ()
587
598
" Navigate cheatsheet sections and show documentation for selected var.
588
599
589
- With a prefix argument FLAT, represent each candidate as a full path to var."
590
- (interactive " P" )
591
- (if flat
592
- (let* ((hierarchy (cider-cheatsheet--flatten-hierarchy cider-cheatsheet-hierarchy))
593
- (paths (mapcar (lambda (sections ) (string-join sections " > " )) hierarchy))
594
- (path (completing-read " Select path: " paths))
595
- (var (car (last (split-string path " > " )))))
596
- (funcall cider-cheatsheet-default-action-function var))
597
- (let ((hierarchy cider-cheatsheet-hierarchy))
598
- (while (stringp (caar hierarchy))
599
- (let* ((sections (mapcar #'car hierarchy))
600
- (section (completing-read " Select section: " sections)))
601
- (setq hierarchy (map-elt hierarchy section))))
602
- (let* ((vars (seq-mapcat #'cider-cheatsheet--expand-vars hierarchy))
603
- (var (completing-read " Select var: " vars)))
604
- (funcall cider-cheatsheet-default-action-function var)))))
600
+ Navigates through a multi-step selection process or represents each candidate
601
+ as a full path to a var, depending on the value of `cider-cheatsheet-select-type' ."
602
+ (interactive )
603
+ (cl-case cider-cheatsheet-select-type
604
+ (multi
605
+ (let ((hierarchy cider-cheatsheet-hierarchy))
606
+ (while (stringp (caar hierarchy))
607
+ (let* ((sections (mapcar #'car hierarchy))
608
+ (section (completing-read " Select section: " sections)))
609
+ (setq hierarchy (map-elt hierarchy section))))
610
+ (let* ((vars (seq-mapcat #'cider-cheatsheet--expand-vars hierarchy))
611
+ (var (completing-read " Select var: " vars)))
612
+ (funcall cider-cheatsheet-default-action-function var))))
613
+ (path
614
+ (let* ((hierarchy (cider-cheatsheet--flatten-hierarchy cider-cheatsheet-hierarchy))
615
+ (paths (mapcar (lambda (sections ) (string-join sections " > " )) hierarchy))
616
+ (path (completing-read " Select path: " paths))
617
+ (var (car (last (split-string path " > " )))))
618
+ (funcall cider-cheatsheet-default-action-function var)))))
605
619
606
620
(cl-defun cider-cheatsheet--insert-hierarchy (hierarchy &optional (level 0 ))
607
621
" Insert HIERARCHY with visual indentation for LEVEL."
0 commit comments