emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 227e996: Improve ansi-color filtering of unrecogniz


From: Daniel Colascione
Subject: [Emacs-diffs] master 227e996: Improve ansi-color filtering of unrecognized escape sequences
Date: Tue, 04 Aug 2015 03:06:15 +0000

branch: master
commit 227e996946d4629fa8f6d665564a37668290c87f
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    Improve ansi-color filtering of unrecognized escape sequences
    
    * lisp/ansi-color.el (ansi-color-drop-regexp): Recognize mode-setting
    escape sequences.
    (ansi-color-filter-apply): Filter out unrecognized escape sequences
    (ansi-color-apply): Filter out unrecognized escape sequences
---
 lisp/ansi-color.el |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 5088c3d..2f3b506 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -154,7 +154,7 @@ foreground and background colors, respectively."
   "Regexp that matches SGR control sequences.")
 
 (defconst ansi-color-drop-regexp
-  "\033\\[\\([ABCDsuK]\\|[12][JK]\\|=[0-9]+[hI]\\|[0-9;]*[Hf]\\)"
+  
"\033\\[\\([ABCDsuK]\\|[12][JK]\\|=[0-9]+[hI]\\|[0-9;]*[Hf]\\|\\?[0-9]+[hl]\\)"
   "Regexp that matches ANSI control sequences to silently drop.")
 
 (defconst ansi-color-parameter-regexp "\\([0-9]*\\)[m;]"
@@ -261,7 +261,11 @@ This function can be added to 
`comint-preoutput-filter-functions'."
     ;; find the next escape sequence
     (while (setq end (string-match ansi-color-regexp string start))
       (setq result (concat result (substring string start end))
-           start (match-end 0)))
+            start (match-end 0)))
+    ;; eliminate unrecognized escape sequences
+    (while (string-match ansi-color-drop-regexp string)
+      (setq string
+            (replace-match "" nil nil string)))
     ;; save context, add the remainder of the string to the result
     (let (fragment)
       (if (string-match "\033" string start)
@@ -327,6 +331,10 @@ This function can be added to 
`comint-preoutput-filter-functions'."
     (when codes
       (put-text-property start (length string)
                          'font-lock-face (ansi-color--find-face codes) string))
+    ;; eliminate unrecognized escape sequences
+    (while (string-match ansi-color-drop-regexp string)
+      (setq string
+            (replace-match "" nil nil string)))
     ;; save context, add the remainder of the string to the result
     (let (fragment)
       (if (string-match "\033" string start)



reply via email to

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