4646 :type 'boolean
4747 :package-version '(cider . " 1.15.0" ))
4848
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+
4960(defconst cider-cheatsheet-hierarchy
5061 '((" Documentation"
5162 (" REPL"
@@ -582,15 +593,15 @@ With a prefix argument FLAT, represent each candidate as a full path to var."
582593 (paths (mapcar (lambda (sections ) (string-join sections " > " )) hierarchy))
583594 (path (completing-read " Select path: " paths))
584595 (var (car (last (split-string path " > " )))))
585- (cider-doc-lookup var))
596+ (funcall cider-cheatsheet-default-action-function var))
586597 (let ((hierarchy cider-cheatsheet-hierarchy))
587598 (while (stringp (caar hierarchy))
588599 (let* ((sections (mapcar #'car hierarchy))
589600 (section (completing-read " Select section: " sections)))
590601 (setq hierarchy (map-elt hierarchy section))))
591602 (let* ((vars (seq-mapcat #'cider-cheatsheet--expand-vars hierarchy))
592603 (var (completing-read " Select var: " vars)))
593- (cider-doc-lookup var)))))
604+ (funcall cider-cheatsheet-default-action-function var)))))
594605
595606(cl-defun cider-cheatsheet--insert-hierarchy (hierarchy &optional (level 0 ))
596607 " 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."
604615 (insert-text-button var
605616 'var var
606617 'action (lambda (btn )
607- (cider-doc-lookup (button-get btn 'var )))
618+ (funcall cider-cheatsheet-default-action-function
619+ (button-get btn 'var )))
608620 'help-echo (format " Show documentation for %s " var))
609621 (insert " \n " )))))
610622
0 commit comments