aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-cmd.el32
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."
1148 1148
1149;; command invocation 1149;; command invocation
1150 1150
1151(declare-function help-fns-function-description-header "help-fns")
1152
1151(defun eshell/which (command &rest names) 1153(defun eshell/which (command &rest names)
1152 "Identify the COMMAND, and where it is located." 1154 "Identify the COMMAND, and where it is located."
1153 (dolist (name (cons command names)) 1155 (dolist (name (cons command names))
@@ -1164,25 +1166,17 @@ be finished later after the completion of an asynchronous subprocess."
1164 (concat name " is an alias, defined as \"" 1166 (concat name " is an alias, defined as \""
1165 (cadr alias) "\""))) 1167 (cadr alias) "\"")))
1166 (unless program 1168 (unless program
1167 (setq program (eshell-search-path name)) 1169 (setq program
1168 (let* ((esym (eshell-find-alias-function name)) 1170 (let* ((esym (eshell-find-alias-function name))
1169 (sym (or esym (intern-soft name)))) 1171 (sym (or esym (intern-soft name))))
1170 (if (and (or esym (and sym (fboundp sym))) 1172 (if (and (or esym (and sym (fboundp sym)))
1171 (or eshell-prefer-lisp-functions (not direct))) 1173 (or eshell-prefer-lisp-functions (not direct)))
1172 (let ((desc (let ((inhibit-redisplay t)) 1174 (or (with-output-to-string
1173 (save-window-excursion 1175 (require 'help-fns)
1174 (prog1 1176 (princ (format "%s is " sym))
1175 (describe-function sym) 1177 (help-fns-function-description-header sym))
1176 (message nil)))))) 1178 name)
1177 (setq desc (if desc (substring desc 0 1179 (eshell-search-path name)))))
1178 (1- (or (string-match "\n" desc)
1179 (length desc))))
1180 ;; This should not happen.
1181 (format "%s is defined, \
1182but no documentation was found" name)))
1183 (if (buffer-live-p (get-buffer "*Help*"))
1184 (kill-buffer "*Help*"))
1185 (setq program (or desc name))))))
1186 (if (not program) 1180 (if (not program)
1187 (eshell-error (format "which: no %s in (%s)\n" 1181 (eshell-error (format "which: no %s in (%s)\n"
1188 name (getenv "PATH"))) 1182 name (getenv "PATH")))