Fix evil change/delete operators in eshell buffers
evil-{change,delete}{,-line} now jump to the prompt before trying to modify the buffer.
This commit is contained in:
parent
4e2beb8b7e
commit
177bf2a9de
2 changed files with 26 additions and 25 deletions
|
@ -13,34 +13,33 @@
|
|||
(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))))
|
||||
(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)))))
|
||||
(save-restriction
|
||||
(narrow-to-region eshell-last-output-end (point-max))
|
||||
(evil-change (max beg (point-min))
|
||||
(if (eq type 'line) (point-max) (min (or end (point-max)) (point-max)))
|
||||
type register yank-handler delete-func)))
|
||||
|
||||
;;;###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))
|
||||
(+eshell/evil-change beg end type register yank-handler #'evil-delete-line))
|
||||
|
||||
;;;###autoload (autoload '+eshell/evil-delete "tools/eshell/autoload/evil" nil t)
|
||||
(evil-define-operator +eshell/evil-delete (beg end type register yank-handler)
|
||||
"Like `evil-delete' but will not delete/copy the prompt."
|
||||
(interactive "<R><x><y>")
|
||||
(save-restriction
|
||||
(narrow-to-region eshell-last-output-end (point-max))
|
||||
(evil-delete (if beg (max beg (point-min)) (point-min))
|
||||
(if (eq type 'line) (point-max) (min (or end (point-max)) (point-max)))
|
||||
type register yank-handler)))
|
||||
|
||||
;;;###autoload (autoload '+eshell/evil-delete-line "tools/eshell/autoload/evil" nil t)
|
||||
(evil-define-operator +eshell/evil-delete-line (_beg end type register yank-handler)
|
||||
"Change to end of line."
|
||||
:motion nil
|
||||
:keep-visual t
|
||||
(interactive "<R><x>")
|
||||
(+eshell/evil-delete (point) end type register yank-handler))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue