My intention is to use bm.el
Visible Bookmarks for each prompt as I press RET. I have managed to achieve this to a some degree.. Please comment on my code, below, if it is missing some important issue: eg. I have no idea if I need to handle the args beyond just passing them on to the default function.
When I press RET on an empty command line, I do not want to bookmark that line. How can I intercept the command line content before passing contol on to the default function eshell-send-input
?
(defun eshell-send-input-zAp (&optional use-region queue-p no-newline)
"eshell-send-input, customized to add bm-bookmark to prompt line"
(interactive)
(bm-bookmark-add)
(eshell-send-input use-region queue-p no-newline))
(add-hook 'eshell-mode-hook
#'(lambda ()
(define-key eshell-mode-map
[return]
'eshell-send-input-zAp)))
Your code looks decent. If you read the code of eshell-send-input
, you'll see how to get the current input.
Also read up on interactive arguments. "P"
is required to pass the user-region on to eshell-send-input
.
(defun eshell-send-input-zAp (&optional use-region queue-p no-newline)
"eshell-send-input, customized to add bm-bookmark to prompt line"
(interactive "*P")
(unless (string-equal (eshell-get-old-input use-region) "")
(bm-bookmark-add))
(eshell-send-input use-region queue-p no-newline))