describe-module: shows all modules, dim disabled

Shows all modules, whether or not they are enabled and dims disabled
modules.
This commit is contained in:
Henrik Lissner 2018-06-15 15:51:05 +02:00
parent a500bfb0a0
commit 58601488d9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -115,20 +115,22 @@
(describe-function fn)))) (describe-function fn))))
;;;###autoload ;;;###autoload
(defun doom/describe-module (module) (defun doom/describe-module (category module)
"Open the documentation of MODULE (a string that represents the category and "Open the documentation of CATEGORY MODULE.
submodule in the format, e.g. ':feature evil').
Defaults to either a) the module at point (in init.el), b) the module derived CATEGORY is a keyword and MODULE is a symbol. e.g. :feature and 'evil.
from a `featurep!' or `require!' call, c) the module that the current file is
in, or d) the module associated with the current major mode (see Automatically selects a) the module at point (in private init files), b) the
module derived from a `featurep!' or `require!' call, c) the module that the
current file is in, or d) the module associated with the current major mode (see
`doom--module-mode-alist')." `doom--module-mode-alist')."
(interactive (interactive
(let ((module (let* ((module
(cond ((and buffer-file-name (cond ((and buffer-file-name
(eq major-mode 'emacs-lisp-mode) (eq major-mode 'emacs-lisp-mode)
(string= (file-name-nondirectory buffer-file-name) (file-in-directory-p buffer-file-name doom-private-dir)
"init.el") (save-excursion (goto-char (point-min))
(re-search-forward "^\\s-*(doom! " nil t))
(thing-at-point 'sexp t))) (thing-at-point 'sexp t)))
((save-excursion ((save-excursion
(require 'smartparens) (require 'smartparens)
@ -145,19 +147,29 @@ in, or d) the module associated with the current major mode (see
((when-let* ((mod (cdr (assq major-mode doom--module-mode-alist)))) ((when-let* ((mod (cdr (assq major-mode doom--module-mode-alist))))
(format "%s %s" (format "%s %s"
(symbol-name (car mod)) (symbol-name (car mod))
(symbol-name (cadr mod)))))))) (symbol-name (cadr mod)))))))
(list (completing-read "Describe module: " (module-string
(cl-loop for (module . sub) in (reverse (hash-table-keys doom-modules)) (completing-read
collect (format "%s %s" module sub)) "Describe module: "
nil t nil nil module)))) (cl-loop for path in (doom-module-load-path 'all)
(cl-destructuring-bind (category submodule) for (cat . mod) = (doom-module-from-path path)
(mapcar #'intern (split-string module " ")) for format = (format "%s %s" cat mod)
(unless (doom-module-p category submodule) if (doom-module-p cat mod)
(error "'%s' isn't a valid module" module)) collect format
(let ((doc-path (doom-module-path category submodule "README.org"))) else
collect (propertize format 'face 'font-lock-comment-face))
nil t nil nil module))
(key (split-string module-string " ")))
(list (intern (car key))
(intern (cadr key)))))
(cl-check-type category symbol)
(cl-check-type module symbol)
(or (doom-module-p category module)
(error "'%s %s' isn't a valid module" category module))
(let ((doc-path (doom-module-path category module "README.org")))
(unless (file-exists-p doc-path) (unless (file-exists-p doc-path)
(error "There is no documentation for this module")) (error "There is no documentation for this module (%s)" doc-path))
(find-file doc-path)))) (find-file doc-path)))
;;;###autoload ;;;###autoload
(defun doom/describe-active-minor-mode (mode) (defun doom/describe-active-minor-mode (mode)