From aac843511be1617cd330c8ef9982475efb8c7270 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 10 Oct 2019 21:30:09 -0400 Subject: [PATCH] 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. --- modules/editor/evil/autoload/ex.el | 40 +++++++++++++----------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/modules/editor/evil/autoload/ex.el b/modules/editor/evil/autoload/ex.el index 939bad426..d7437e4cb 100644 --- a/modules/editor/evil/autoload/ex.el +++ b/modules/editor/evil/autoload/ex.el @@ -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 "") (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))))))