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,49 +115,61 @@
(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))
(thing-at-point 'sexp t))) (re-search-forward "^\\s-*(doom! " nil t))
((save-excursion (thing-at-point 'sexp t)))
(require 'smartparens) ((save-excursion
(ignore-errors (require 'smartparens)
(sp-beginning-of-sexp) (ignore-errors
(unless (eq (char-after) ?\() (sp-beginning-of-sexp)
(backward-char)) (unless (eq (char-after) ?\()
(let ((sexp (sexp-at-point))) (backward-char))
(when (memq (car-safe sexp) '(featurep! require!)) (let ((sexp (sexp-at-point)))
(format "%s %s" (nth 1 sexp) (nth 2 sexp))))))) (when (memq (car-safe sexp) '(featurep! require!))
((and buffer-file-name (format "%s %s" (nth 1 sexp) (nth 2 sexp)))))))
(when-let* ((mod (doom-module-from-path buffer-file-name))) ((and buffer-file-name
(format "%s %s" (car mod) (cdr mod))))) (when-let* ((mod (doom-module-from-path buffer-file-name)))
((when-let* ((mod (cdr (assq major-mode doom--module-mode-alist)))) (format "%s %s" (car mod) (cdr mod)))))
(format "%s %s" ((when-let* ((mod (cdr (assq major-mode doom--module-mode-alist))))
(symbol-name (car mod)) (format "%s %s"
(symbol-name (cadr mod)))))))) (symbol-name (car mod))
(list (completing-read "Describe module: " (symbol-name (cadr mod)))))))
(cl-loop for (module . sub) in (reverse (hash-table-keys doom-modules)) (module-string
collect (format "%s %s" module sub)) (completing-read
nil t nil nil module)))) "Describe module: "
(cl-destructuring-bind (category submodule) (cl-loop for path in (doom-module-load-path 'all)
(mapcar #'intern (split-string module " ")) for (cat . mod) = (doom-module-from-path path)
(unless (doom-module-p category submodule) for format = (format "%s %s" cat mod)
(error "'%s' isn't a valid module" module)) if (doom-module-p cat mod)
(let ((doc-path (doom-module-path category submodule "README.org"))) collect format
(unless (file-exists-p doc-path) else
(error "There is no documentation for this module")) collect (propertize format 'face 'font-lock-comment-face))
(find-file doc-path)))) 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)
(error "There is no documentation for this module (%s)" doc-path))
(find-file doc-path)))
;;;###autoload ;;;###autoload
(defun doom/describe-active-minor-mode (mode) (defun doom/describe-active-minor-mode (mode)