- (unwind-protect
- (let ((eshell-non-interactive-p t))
- ;; Enable `eshell-mode' only in this minibuffer.
- (minibuffer-with-setup-hook 'eshell-mode
- (add-hook 'minibuffer-exit-hook 'eshell-add-command-to-history)
- (add-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
- (unless command
- (setq command (read-from-minibuffer "Emacs shell command: ")))))
- (remove-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
- (remove-hook 'minibuffer-exit-hook 'eshell-add-command-to-history))
+ (let ((eshell-non-interactive-p t))
+ ;; Enable `eshell-mode' only in this minibuffer.
+ (minibuffer-with-setup-hook #'(lambda ()
+ (eshell-mode)
+ (eshell-return-exits-minibuffer))
+ (unless command
+ (setq command (read-from-minibuffer "Emacs shell command: "))
+ (eshell-add-input-to-history command))))