emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/coterm ef99471848: Use string-replace instead of stripp


From: ELPA Syncer
Subject: [elpa] externals/coterm ef99471848: Use string-replace instead of stripping CR's in the buffer
Date: Tue, 30 Aug 2022 16:57:31 -0400 (EDT)

branch: externals/coterm
commit ef994718487abe2004aaf38a63660c76c224cfb1
Author: Miha Rihtaršič <miha@kamnitnik.top>
Commit: Miha Rihtaršič <miha@kamnitnik.top>

    Use string-replace instead of stripping CR's in the buffer
    
    This is more performant as it avoids excessively adding undo entries for 
each
    CR.
---
 coterm.el | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/coterm.el b/coterm.el
index 883d3ca7ab..75e97327f7 100644
--- a/coterm.el
+++ b/coterm.el
@@ -667,15 +667,6 @@ non-nil. Set it to nil to invalidate the cache."
 (defvar coterm-t-after-insert-hook nil
   "Hook run after inserting process output.")
 
-(defun coterm--comint-strip-CR (_)
-  "Remove all \\r characters from last output."
-  (save-excursion
-    (goto-char comint-last-output-start)
-    (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
-      (while (progn (skip-chars-forward "^\r")
-                    (< (point) pmark))
-        (delete-char 1)))))
-
 (defun coterm--init ()
   "Initialize current buffer for coterm."
   (when-let ((process (get-buffer-process (current-buffer))))
@@ -686,7 +677,6 @@ non-nil. Set it to nil to invalidate the cache."
     (setq coterm--t-scroll-end coterm--t-height)
 
     (setq-local comint-inhibit-carriage-motion t)
-    (add-hook 'comint-output-filter-functions #'coterm--comint-strip-CR nil t)
     (coterm-auto-char-mode)
     (coterm-auto-char-lighter-mode)
 
@@ -917,7 +907,11 @@ Synchronise PROCESS's mark beforehand and insert at its 
position.
 NEWLINES is the number of newlines STR contains.  Unless it is
 zero, insertion must happen at the end of accessible portion of
 buffer and the scrolling region must begin at the top of the
-terminal screen."
+terminal screen.
+
+This function also converts all occuences of \"\\r\\n\" into
+\"\\n\" in STR before inserting it."
+  (setq str (string-replace "\r" "" str))
   (unless (zerop coterm--t-row-off)
     (setq coterm--t-col-off (coterm--t-col))
     (goto-char (point-max)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]