Function: ansi-color-filter-region
ansi-color-filter-region is a byte-compiled function defined in
ansi-color.el.gz.
Signature
(ansi-color-filter-region BEGIN END)
Documentation
Filter out all ANSI control sequences from region BEGIN to END.
Every call to this function will set and use the buffer-local variable
ansi-color-context-region to save position. This information will be
used for the next call to ansi-color-apply-on-region. Specifically,
it will override BEGIN, the start of the region. Set
ansi-color-context-region to nil if you don't want this.
Source Code
;; Defined in /usr/src/emacs/lisp/ansi-color.el.gz
(defun ansi-color-filter-region (begin end)
"Filter out all ANSI control sequences from region BEGIN to END.
Every call to this function will set and use the buffer-local variable
`ansi-color-context-region' to save position. This information will be
used for the next call to `ansi-color-apply-on-region'. Specifically,
it will override BEGIN, the start of the region. Set
`ansi-color-context-region' to nil if you don't want this."
(let* ((end-marker (copy-marker end))
(context (ansi-color--ensure-context
'ansi-color-context-region begin))
(start (cadr context)))
(save-excursion
(goto-char start)
;; Delete escape sequences.
(while (re-search-forward ansi-color-control-seq-regexp end-marker t)
(delete-region (match-beginning 0) (match-end 0)))
;; save context, add the remainder of the string to the result
(set-marker start (point))
(while (re-search-forward ansi-color--control-seq-fragment-regexp
end-marker t))
(if (and (/= (point) start)
(= (point) end-marker))
(set-marker start (match-beginning 0))
(set-marker start nil)))))