diff options
author | Noam Postavsky <npostavs@gmail.com> | 2017-06-03 22:15:19 -0400 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2017-06-27 20:34:14 -0400 |
commit | 2d992690de5bcb2036eeb4d2854761596b863704 (patch) | |
tree | 8a200ae5194707445c0da6f9efc46b39aa04465f /lisp/eshell | |
parent | 4a5653cd2859308ada4bbf5ffc9fb9b283eef31a (diff) | |
download | emacs-2d992690de5bcb2036eeb4d2854761596b863704.tar.gz |
Don't read eshell/which output from *Help* buffer (Bug#26894)
* lisp/help-fns.el (help-fns--analyse-function)
(help-fns-function-description-header): New functions, extracted from
describe-function-1.
(describe-function-1): Use them.
* lisp/eshell/esh-cmd.el (eshell/which): Use
`help-fns-function-description-header' instead of
`describe-function-1'.
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/esh-cmd.el | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 86e7b83c281..24342208771 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -1148,6 +1148,8 @@ be finished later after the completion of an asynchronous subprocess." ;; command invocation +(declare-function help-fns-function-description-header "help-fns") + (defun eshell/which (command &rest names) "Identify the COMMAND, and where it is located." (dolist (name (cons command names)) @@ -1164,25 +1166,17 @@ be finished later after the completion of an asynchronous subprocess." (concat name " is an alias, defined as \"" (cadr alias) "\""))) (unless program - (setq program (eshell-search-path name)) - (let* ((esym (eshell-find-alias-function name)) - (sym (or esym (intern-soft name)))) - (if (and (or esym (and sym (fboundp sym))) - (or eshell-prefer-lisp-functions (not direct))) - (let ((desc (let ((inhibit-redisplay t)) - (save-window-excursion - (prog1 - (describe-function sym) - (message nil)))))) - (setq desc (if desc (substring desc 0 - (1- (or (string-match "\n" desc) - (length desc)))) - ;; This should not happen. - (format "%s is defined, \ -but no documentation was found" name))) - (if (buffer-live-p (get-buffer "*Help*")) - (kill-buffer "*Help*")) - (setq program (or desc name)))))) + (setq program + (let* ((esym (eshell-find-alias-function name)) + (sym (or esym (intern-soft name)))) + (if (and (or esym (and sym (fboundp sym))) + (or eshell-prefer-lisp-functions (not direct))) + (or (with-output-to-string + (require 'help-fns) + (princ (format "%s is " sym)) + (help-fns-function-description-header sym)) + name) + (eshell-search-path name))))) (if (not program) (eshell-error (format "which: no %s in (%s)\n" name (getenv "PATH"))) |