From: Leo <sdl.web@gmail.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#7089: 23.2; slow ansi-color-apply
Date: Thu, 23 Sep 2010 11:38:05 +0100 [thread overview]
Message-ID: <m17hichhiq.fsf@cam.ac.uk> (raw)
In-Reply-To: <m1k4mchlc2.fsf@cam.ac.uk>
The following version fixed some glitches in setting ansi-color-context.
Also I have received an email from Alex that welcomes the improvement.
Let me know if I should send a patch in.
(defun ansi-color-apply* (string)
"A more efficient implementation of `ansi-color-apply' (which see)."
(let ((face (car ansi-color-context))
start end fragment escape-sequence)
;; If context was saved and is a string, prepend it.
(if (cadr ansi-color-context)
(setq string (concat (cadr ansi-color-context) string)
ansi-color-context nil))
(prog1
(with-temp-buffer
(insert string)
(setq start (point-min-marker))
(goto-char start)
(while (re-search-forward ansi-color-drop-regexp nil t)
(replace-match ""))
(goto-char start)
;; Find the next escape sequence.
(while (re-search-forward ansi-color-regexp nil t)
(setq end (match-beginning 0))
(when face
(put-text-property start end 'ansi-color t)
(put-text-property start end 'face face))
(setq start (copy-marker (match-end 0)))
(setq escape-sequence (match-string 1))
(replace-match "")
(setq face (ansi-color-apply-sequence escape-sequence face)))
;; search for the possible start of a new escape sequence
(if (re-search-forward "\033" nil t)
(setq fragment
(delete-and-extract-region (match-beginning 0)
(point-max))))
;; if the rest of the string should have a face, put it there
(when face
(put-text-property start (point-max) 'ansi-color t)
(put-text-property start (point-max) 'face face))
;; return the string
(buffer-string))
;; save context; NB: ansi-color-context is buffer-local so set it after
;; return to the original buffer
(if (or face fragment)
(setq ansi-color-context (list face fragment))
(setq ansi-color-context nil)))))
Leo
next prev parent reply other threads:[~2010-09-23 10:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-23 9:15 bug#7089: 23.2; slow ansi-color-apply Leo
2010-09-23 10:38 ` Leo [this message]
2010-10-28 2:38 ` Stefan Monnier
2010-10-28 4:03 ` Leo
2010-10-31 19:10 ` Stefan Monnier
2010-11-01 16:23 ` Leo
2010-11-25 14:30 ` Leo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m17hichhiq.fsf@cam.ac.uk \
--to=sdl.web@gmail.com \
--cc=bug-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.