aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Colascione2015-08-03 20:06:04 -0700
committerDaniel Colascione2015-08-03 20:06:04 -0700
commit227e996946d4629fa8f6d665564a37668290c87f (patch)
treee0fc29d8bbd38d32ec3ab6ecc2459d242b41f85b
parent8a4b8ae32f66b00d0730490240b87e9b9b1cfa51 (diff)
downloademacs-227e996946d4629fa8f6d665564a37668290c87f.tar.gz
emacs-227e996946d4629fa8f6d665564a37668290c87f.zip
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
-rw-r--r--lisp/ansi-color.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 5088c3d7071..2f3b5064348 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -154,7 +154,7 @@ foreground and background colors, respectively."
154 "Regexp that matches SGR control sequences.") 154 "Regexp that matches SGR control sequences.")
155 155
156(defconst ansi-color-drop-regexp 156(defconst ansi-color-drop-regexp
157 "\033\\[\\([ABCDsuK]\\|[12][JK]\\|=[0-9]+[hI]\\|[0-9;]*[Hf]\\)" 157 "\033\\[\\([ABCDsuK]\\|[12][JK]\\|=[0-9]+[hI]\\|[0-9;]*[Hf]\\|\\?[0-9]+[hl]\\)"
158 "Regexp that matches ANSI control sequences to silently drop.") 158 "Regexp that matches ANSI control sequences to silently drop.")
159 159
160(defconst ansi-color-parameter-regexp "\\([0-9]*\\)[m;]" 160(defconst ansi-color-parameter-regexp "\\([0-9]*\\)[m;]"
@@ -261,7 +261,11 @@ This function can be added to `comint-preoutput-filter-functions'."
261 ;; find the next escape sequence 261 ;; find the next escape sequence
262 (while (setq end (string-match ansi-color-regexp string start)) 262 (while (setq end (string-match ansi-color-regexp string start))
263 (setq result (concat result (substring string start end)) 263 (setq result (concat result (substring string start end))
264 start (match-end 0))) 264 start (match-end 0)))
265 ;; eliminate unrecognized escape sequences
266 (while (string-match ansi-color-drop-regexp string)
267 (setq string
268 (replace-match "" nil nil string)))
265 ;; save context, add the remainder of the string to the result 269 ;; save context, add the remainder of the string to the result
266 (let (fragment) 270 (let (fragment)
267 (if (string-match "\033" string start) 271 (if (string-match "\033" string start)
@@ -327,6 +331,10 @@ This function can be added to `comint-preoutput-filter-functions'."
327 (when codes 331 (when codes
328 (put-text-property start (length string) 332 (put-text-property start (length string)
329 'font-lock-face (ansi-color--find-face codes) string)) 333 'font-lock-face (ansi-color--find-face codes) string))
334 ;; eliminate unrecognized escape sequences
335 (while (string-match ansi-color-drop-regexp string)
336 (setq string
337 (replace-match "" nil nil string)))
330 ;; save context, add the remainder of the string to the result 338 ;; save context, add the remainder of the string to the result
331 (let (fragment) 339 (let (fragment)
332 (if (string-match "\033" string start) 340 (if (string-match "\033" string start)