Created
December 18, 2021 22:21
-
-
Save kchanqvq/1e0cd7b0ec051f1a226182d0f001fbd0 to your computer and use it in GitHub Desktop.
Describe-all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-command-global describe-all () | |
"Prompt for a symbol in any Nyxt-accessible package and describe it in the best way Nyxt can." | |
(let* ((all-symbols | |
(delete-duplicates | |
(apply #'append (loop for package in (remove (find-package "KEYWORD") (list-all-packages)) | |
collect (loop for sym being the external-symbols in package | |
collect sym))))) | |
;; All copied from /nyxt/source/help.lisp with `describe-any' as a reference. | |
(classes (remove-if (lambda (sym) | |
(not (and (find-class sym nil) | |
(mopu:subclassp (find-class sym) (find-class 'standard-object))))) | |
all-symbols)) | |
(slots (alexandria:mappend (lambda (class-sym) | |
(mapcar (lambda (slot) (make-instance 'nyxt::slot | |
:name slot | |
:class-sym class-sym)) | |
(nyxt::class-public-slots class-sym))) | |
classes)) | |
(functions (remove-if (complement #'fboundp) all-symbols)) | |
(variables (remove-if (complement #'boundp) all-symbols))) | |
(prompt | |
:prompt "Describe:" | |
:sources (list (make-instance 'nyxt::variable-source :constructor variables) | |
(make-instance 'nyxt::function-source :constructor functions) | |
(make-instance 'nyxt::user-command-source | |
:actions (list (make-unmapped-command describe-command))) | |
(make-instance 'nyxt::class-source :constructor classes) | |
(make-instance 'nyxt::slot-source :constructor slots))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
credit: @aartaka