-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ANSI coloring in REPL buffer is broken #1452
Comments
I think the reason why we use |
This code was mostly copy pasted from Slime. I guess it's time to rework On Saturday, 5 December 2015, Artur Malabarba notifications@github.com
|
I think it does not affect Another hacky but more reliable way is manually to add a hook to overlays created by (defun cider-repl--emit-interactive-output (string face)
"Emit STRING as interactive output using FACE."
(with-current-buffer (cider-current-repl-buffer)
(let ((pos (cider-repl--end-of-line-before-input-start))
(string (replace-regexp-in-string "\n\\'" "" string)))
(cider-repl--emit-output-at-pos (current-buffer) string face pos t)
(ansi-color-apply-on-region pos (point-max))
;; added
(dolist (ov (overlays-at (1- (cider-repl--end-of-line-before-input-start))))
(when (member #'ansi-color-freeze-overlay (overlay-get ov 'modification-hooks)) ; ensure ov is crated by ansi-color
(unless (member #'ansi-color-freeze-overlay (overlay-get ov 'insert-behind-hooks))
(push #'ansi-color-freeze-overlay (overlay-get ov 'insert-behind-hooks)))))))) |
PR welcome. :-) |
[Fix #1452] Fix broken ANSI coloring in the repl
How to reproduce
Cause
This is because new output of interactive-eval extends an overlay for ANSI coloring created before.
The following is a part of output of C-u C-x = at 'r' of 'bar' after evaluating
(println "\u001b[31mbar\u001b[0m")
:Then, the following is new one after evaluating
(println "baz")
:It cannot be probably said that it is due to CIDER because I suspect this is ansi-color's problem.
I think
ansi-color-freeze-overlay
should prevent overlays from being extended at the first place.I've actually confirmed it works by modifying ansi-color to use
insert-behind-hooks
instead ofmodification-hooks
.However, I think it is not so difficult to introduce a workaround for this on CIDER's side.
For example, it seems to work for me to use
insert
instead ofinsert-before-markers
here though I'm not sure whether this cause other problems.(BTW, cider-repl-output-start/cider-repl-output-end seems not to work but it is another issue.)
I'm a novice at elisp (and CIDER internals, of course), so I would be happy if someone investigate this problem further.
The text was updated successfully, but these errors were encountered: