tools/eshell: major refactor & update

This commit is contained in:
Henrik Lissner 2018-03-23 18:17:59 -04:00
parent 691c914a15
commit 38a5e73e2e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 69 additions and 95 deletions

View file

@ -9,3 +9,42 @@
(+eshell/open command)
(+eshell/open-popup command)))
;;;###autoload (autoload '+eshell/evil-change "tools/eshell/autoload/evil" nil t)
(evil-define-operator +eshell/evil-change (beg end type register yank-handler delete-func)
"Like `evil-change' but will not delete/copy the prompt."
(interactive "<R><x><y>")
(let ((delete-func (or delete-func #'evil-delete))
(nlines (1+ (evil-count-lines beg end)))
(opoint (save-excursion
(goto-char beg)
(evil-collection-eshell-next-prompt)
(point))))
(unless (eq evil-want-fine-undo t)
(evil-start-undo-step))
(when (get-text-property beg 'read-only)
(save-excursion
(goto-char beg)
(evil-collection-eshell-next-prompt)
(setq beg (point))))
(funcall delete-func beg end type register yank-handler)
(cond
((eq type 'line)
(goto-char eshell-last-output-end)
(when (get-text-property (point) 'read-only)
(evil-collection-eshell-next-prompt))
(evil-append 1))
((eq type 'block) (evil-insert 1 nlines))
(t
(evil-insert 1)))))
;;;###autoload (autoload '+eshell/evil-change-line "tools/eshell/autoload/evil" nil t)
(evil-define-operator +eshell/evil-change-line (beg end type register yank-handler)
"Change to end of line."
:motion evil-end-of-line
(interactive "<R><x><y>")
(when (get-text-property beg 'read-only)
(save-excursion
(goto-char beg)
(evil-collection-eshell-next-prompt)
(setq beg (point))))
(evil-change beg end type register yank-handler #'evil-delete-line))