Fix :h[elp] ex command
To now open documentation for ex commands, otherwise falling back to apropos. If BANG, then searches Doom's (yet to be published) manual.
This commit is contained in:
parent
82167ab48a
commit
aac843511b
1 changed files with 17 additions and 23 deletions
|
@ -155,30 +155,24 @@ buffers."
|
|||
|
||||
;;;###autoload (autoload '+evil:help "editor/evil/autoload/ex" nil t)
|
||||
(evil-define-command +evil:help (&optional bang query)
|
||||
"Look up help documentation for QUERY in Emacs documentation.
|
||||
"Look up documentation for QUERY.
|
||||
|
||||
If BANG, search Doom documentation."
|
||||
If QUERY is in the format of an ex command, it will map it to the underlying
|
||||
function and open its documentation with `helpful-function'. Otherwise, it will
|
||||
search for it with `apropos'.
|
||||
|
||||
If QUERY is empty, this runs the equivalent of 'M-x apropos'. If BANG is
|
||||
non-nil, a search is preformed against Doom's manual (wiht `doom/help-search')."
|
||||
(interactive "<!><a>")
|
||||
(if bang
|
||||
(doom/help-search query)
|
||||
(cond ((or (null query) (string-empty-p (string-trim query)))
|
||||
(call-interactively
|
||||
(or (command-remapping #'apropos)
|
||||
#'apropos)))
|
||||
((string-match-p "^ *:[a-z]" query)
|
||||
(let* ((modules
|
||||
(cl-loop for path in (doom-module-load-path 'all)
|
||||
for (cat . mod) = (doom-module-from-path path)
|
||||
for format = (format "%s %s" cat mod)
|
||||
if (doom-module-p cat mod)
|
||||
collect (propertize format 'module (list cat mod))
|
||||
else if (and cat mod)
|
||||
collect (propertize format
|
||||
'face 'font-lock-comment-face
|
||||
'module (list cat mod))))
|
||||
(module (completing-read "Describe module: " modules nil t query))
|
||||
(key (get-text-property 0 'module module)))
|
||||
(doom/help-modules (car key) (cdr key))))
|
||||
((and (string-match-p "\\(?:SPC\\|[CMsSH]-[^ ]\\|<[^>]+>\\)" query)
|
||||
(helpful-key (kbd (string-trim query)))))
|
||||
((apropos query t)))))
|
||||
(save-match-data
|
||||
(cond ((or (null query) (string-empty-p (string-trim query)))
|
||||
(call-interactively
|
||||
(or (command-remapping #'apropos)
|
||||
#'apropos)))
|
||||
((string-match "^ *:\\([^ ]+\\)$" query)
|
||||
(helpful-function
|
||||
(evil-ex-completed-binding (match-string 1 query))))
|
||||
((message "Searching for %S, this may take a while..." query)
|
||||
(apropos query t))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue