From: Daniel Colascione Date: Sat, 8 Mar 2025 00:22:56 +0000 (-0800) Subject: Stop term-erase-in-line disturbing markers X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a00df7be05957de3e67155093e57862957b67af2;p=emacs.git Stop term-erase-in-line disturbing markers * lisp/term.el (term-erase-in-line): do nothing if there's nothing to do; insert new newlines before deleting old ones. (cherry picked from commit 062c6ab3dd5a1ce85fb7cb0fc84b65aa2cf60369) --- diff --git a/lisp/term.el b/lisp/term.el index 0048e0c6908..2773dcb6ba6 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -4019,19 +4019,24 @@ The top-most line is line 0." (wrapped (and (zerop (term-horizontal-column)) (not (zerop (term-current-column)))))) (term-vertical-motion 1) - (delete-region saved-point (point)) - ;; wrapped is true if we're at the beginning of screen line, - ;; but not a buffer line. If we delete the current screen line - ;; that will make the previous line no longer wrap, and (because - ;; of the way Emacs display works) point will be at the end of - ;; the previous screen line rather then the beginning of the - ;; current one. To avoid that, we make sure that current line - ;; contain a space, to force the previous line to continue to wrap. - ;; We could do this always, but it seems preferable to not add the - ;; extra space when wrapped is false. - (when wrapped - (insert ? )) - (insert ?\n) + ;; Do nothing if we have nothing to delete + (unless (and (eq saved-point (1- (point))) + (eq (char-before) ?\n) + (not wrapped)) + ;; Insert before deletion to preserve markers. + ;; wrapped is true if we're at the beginning of screen line, + ;; but not a buffer line. If we delete the current screen line + ;; that will make the previous line no longer wrap, and (because + ;; of the way Emacs display works) point will be at the end of + ;; the previous screen line rather then the beginning of the + ;; current one. To avoid that, we make sure that current line + ;; contain a space, to force the previous line to continue to wrap. + ;; We could do this always, but it seems preferable to not add the + ;; extra space when wrapped is false. + (when wrapped + (insert-before-markers ? )) + (insert-before-markers ?\n) + (delete-region saved-point (point))) (put-text-property saved-point (point) 'font-lock-face 'default) (goto-char saved-point))))