Skip to content
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

How to use? #9

Open
jcguu95 opened this issue Jan 14, 2023 · 2 comments
Open

How to use? #9

jcguu95 opened this issue Jan 14, 2023 · 2 comments

Comments

@jcguu95
Copy link

jcguu95 commented Jan 14, 2023

I'm not sure how to use it effectively. I think I set everything up, but the following still didn't work:

CL-USER> (format t "\\033[31;1;4mHello\\033[0m")
\033[31;1;4mHello\033[0m

It emits the escape code to the standard output (repl).

@PuercoPop
Copy link
Owner

PuercoPop commented Jan 15, 2023

@jcguu95 To verify things are working you can use cl-ansi-text, which is what prove used to colorize its output if prove:*enable-colors* is bound to t.

(ql:quickload "cl-ansi-text") 
(cl-ansi-text:with-color (:green) (format t "hello world"))

However I haven't used this package since I discovered that xterm-color covers the sly-mrepl (which is based in comint-mode) and more! I recommend you use that instead. This should be enough to get sly-mrepl to understand terminal colors:

(require 'xterm-color)
(add-hook 'comint-preoutput-filter-functions 'xterm-color-filter t)
(setq comint-output-filter-functions
          (remove 'ansi-color-process-output comint-output-filter-functions))

@jcguu95
Copy link
Author

jcguu95 commented Jan 15, 2023

Thank you! (cl-ansi-text:with-color (:green) (format t "hello world")) does give me a text in green. However, I still can't find a way for the coloring to work for outputs from external programs. E.g.

(with-input-from-string (s "Highlighted text.") 
  (uiop:run-program "grep text" :input s :output t :error-output t))

I will take a look at 'xterm-color when I have time. It would still be nice to know how to work that around for your module, since it is the default supported lang contrib in doom emacs. Thanks again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants