46
46
:type 'boolean
47
47
:package-version '(cider . " 1.15.0" ))
48
48
49
+ (defcustom cider-cheatsheet-default-action-function #'cider-doc-lookup
50
+ " Function to use on a var when it is selected.
51
+
52
+ By default, documentation for a var is displayed using `cider-doc-lookup`,
53
+ but it can also be set to `cider-clojuredocs-lookup` to show documentation
54
+ from ClojureDocs or any other function accepting a var as an argument."
55
+ :type '(choice (const cider-doc-lookup)
56
+ (const cider-clojuredocs-lookup)
57
+ function)
58
+ :package-version '(cider . " 1.15.0" ))
59
+
49
60
(defconst cider-cheatsheet-hierarchy
50
61
'((" Documentation"
51
62
(" REPL"
@@ -582,15 +593,15 @@ With a prefix argument FLAT, represent each candidate as a full path to var."
582
593
(paths (mapcar (lambda (sections ) (string-join sections " > " )) hierarchy))
583
594
(path (completing-read " Select path: " paths))
584
595
(var (car (last (split-string path " > " )))))
585
- (cider-doc-lookup var))
596
+ (funcall cider-cheatsheet-default-action-function var))
586
597
(let ((hierarchy cider-cheatsheet-hierarchy))
587
598
(while (stringp (caar hierarchy))
588
599
(let* ((sections (mapcar #'car hierarchy))
589
600
(section (completing-read " Select section: " sections)))
590
601
(setq hierarchy (map-elt hierarchy section))))
591
602
(let* ((vars (seq-mapcat #'cider-cheatsheet--expand-vars hierarchy))
592
603
(var (completing-read " Select var: " vars)))
593
- (cider-doc-lookup var)))))
604
+ (funcall cider-cheatsheet-default-action-function var)))))
594
605
595
606
(cl-defun cider-cheatsheet--insert-hierarchy (hierarchy &optional (level 0 ))
596
607
" Insert HIERARCHY with visual indentation for LEVEL."
@@ -604,7 +615,8 @@ With a prefix argument FLAT, represent each candidate as a full path to var."
604
615
(insert-text-button var
605
616
'var var
606
617
'action (lambda (btn )
607
- (cider-doc-lookup (button-get btn 'var )))
618
+ (funcall cider-cheatsheet-default-action-function
619
+ (button-get btn 'var )))
608
620
'help-echo (format " Show documentation for %s " var))
609
621
(insert " \n " )))))
610
622
0 commit comments