I'd like to make my up-arrow key from within eshell be eshell-previous-matching-input-from-input, as it is, when point is at point-max, but be previous-line otherwise. I've written
(defun my-up-arrow-in-eshell() (interactive)
(if (= (point) (point-max))
(eshell-previous-matching-input-from-input)
; else
(previous-line)
)
)
(add-hook 'eshell-mode-hook
(lambda ()
(define-key eshell-mode-map (kbd "<up>") 'my-up-arrow-in-eshell)))
but that's not right, as eshell-previous-matching-input-from-input requires an argument. I can hardcode that to a 0, but that works for a single press of the up-arrow key (when at point-max). I want it to work just like out of the box, when at point-max. What do I give for the argument?
You can use
(call-interactively #'eshell-previous-matching-input-from-input)to have the argument interpreted according to itsinteractiveform, eg.Alternatively, you could add your own argument and pass it along, eg.
A final option could be a conditional binding (see (elisp)Extended Menu Items), where
eshell-previous-matching-input-from-inputis bound when the point is atpoint-max