mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
feat(eshell): add help command & lookup handler
Fix: #6867 Co-authored-by: aikrahguzar <aikrahguzar@users.noreply.github.com>
This commit is contained in:
@ -28,3 +28,6 @@ For folks with a habit of using \"emacs\" to open files, even in eshell."
|
||||
"Create a directory then cd into it."
|
||||
(make-directory dir t)
|
||||
(eshell/cd dir))
|
||||
|
||||
;;;###autoload
|
||||
(defalias 'eshell/help #'+eshell-lookup-documentation)
|
||||
|
@ -75,6 +75,21 @@
|
||||
(insert command)
|
||||
(eshell-send-input nil t))))
|
||||
|
||||
;; Adapted from `esh-help-run-help'
|
||||
;;;###autoload
|
||||
(defun +eshell-lookup-documentation (cmd)
|
||||
"Show help for CMD (a shell command or elisp function)."
|
||||
(cond ((eshell-find-alias-function cmd)
|
||||
(always (helpful-callable (eshell-find-alias-function cmd))))
|
||||
((and (or (and (string-match-p "^\\*." cmd)
|
||||
(cl-callf substring cmd 1))
|
||||
(eshell-search-path cmd))
|
||||
(zerop (car (doom-call-process manual-program cmd))))
|
||||
(always (display-buffer (man cmd))))
|
||||
((functionp (intern cmd))
|
||||
(helpful-callable (intern cmd)) t)
|
||||
((user-error "Couldn't find man pages or elisp documentation for %S" cmd))))
|
||||
|
||||
|
||||
;;
|
||||
;;; Commands
|
||||
|
@ -55,6 +55,9 @@ You should use `set-eshell-alias!' to change this.")
|
||||
;;; Packages
|
||||
|
||||
(after! eshell ; built-in
|
||||
(set-lookup-handlers! 'eshell-mode
|
||||
:documentation #'+eshell-lookup-documentation)
|
||||
|
||||
(setq eshell-banner-message
|
||||
'(format "%s %s\n"
|
||||
(propertize (format " %s " (string-trim (buffer-name)))
|
||||
|
Reference in New Issue
Block a user