mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
fix(eshell): don't error if command manpages has no SYNOPSIS
Fix: #6867 Ref: tom-tan/esh-help#7
This commit is contained in:
@ -218,7 +218,27 @@ Emacs versions < 29."
|
||||
|
||||
(use-package! esh-help
|
||||
:after eshell
|
||||
:config (setup-esh-help-eldoc))
|
||||
:config
|
||||
(setup-esh-help-eldoc)
|
||||
;; HACK: Fixes tom-tan/esh-help#7.
|
||||
(defadvice! +eshell-esh-help-eldoc-man-minibuffer-string-a (cmd)
|
||||
"Return minibuffer help string for the shell command CMD.
|
||||
Return nil if there is none."
|
||||
:override #'esh-help-eldoc-man-minibuffer-string
|
||||
(if-let* ((cache-result (gethash cmd esh-help-man-cache)))
|
||||
(unless (eql 'none cache-result)
|
||||
cache-result)
|
||||
(let ((str (split-string (esh-help-man-string cmd) "\n")))
|
||||
(if (equal (concat "No manual entry for " cmd) (car str))
|
||||
(ignore (puthash cmd 'none esh-help-man-cache))
|
||||
(puthash cmd
|
||||
(-some->> str
|
||||
(--drop-while (not (string-match-p "^SYNOPSIS$" it)))
|
||||
(nth 1)
|
||||
(funcall (lambda (s)
|
||||
(let ((idx (string-match "[^\s\t]" s)))
|
||||
(substring s idx)))))
|
||||
esh-help-man-cache))))))
|
||||
|
||||
|
||||
(use-package! eshell-did-you-mean
|
||||
|
Reference in New Issue
Block a user