summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix/colors.scm19
1 files changed, 16 insertions, 3 deletions
diff --git a/guix/colors.scm b/guix/colors.scm
index 543f4c3ec50..6603642d249 100644
--- a/guix/colors.scm
+++ b/guix/colors.scm
@@ -137,6 +137,13 @@ that subsequent output will not have any colors in effect."
137 "Return true if PORT is a tty. Memoize the result." 137 "Return true if PORT is a tty. Memoize the result."
138 (isatty? port))) 138 (isatty? port)))
139 139
140(define dumb-terminal?
141 (mlambdaq ()
142 "Return #t if TERM=dumb or if TERM is not set. Memoize the result."
143 (match (getenv "TERM")
144 ((or "dumb" #f) #t)
145 (_ #f))))
146
140(define (color-output? port) 147(define (color-output? port)
141 "Return true if we should write colored output to PORT." 148 "Return true if we should write colored output to PORT."
142 (and (not (getenv "NO_COLOR")) 149 (and (not (getenv "NO_COLOR"))
@@ -236,10 +243,16 @@ documented at
236 "Return true if PORT is a terminal that supports hyperlink escapes." 243 "Return true if PORT is a terminal that supports hyperlink escapes."
237 ;; Note that terminals are supposed to ignore OSC escapes they don't 244 ;; Note that terminals are supposed to ignore OSC escapes they don't
238 ;; understand (this is the case of xterm as of version 349, for instance.) 245 ;; understand (this is the case of xterm as of version 349, for instance.)
239 ;; However, Emacs comint as of 26.3 does not ignore it and instead lets it 246 ;;
240 ;; through, hence the 'INSIDE_EMACS' special case below. 247 ;; Emacs users can add 'ansi-osc-compilation-filter' to
248 ;; 'compilation-filter-hook' to propertize the hyperlinks, in that case,
249 ;; remember to set TERM to something other than the default. For example, a
250 ;; user of 'M-x shell' that is using Bash, may create a
251 ;; '~/.emacs.d/init_bash.sh' file with 'export TERM=eterm-color'. For the
252 ;; compilation filters to affect 'M-x shell', one can enable
253 ;; 'compilation-shell-minor-mode'.
241 (and (isatty?* port) 254 (and (isatty?* port)
242 (not (getenv "INSIDE_EMACS")))) 255 (not (dumb-terminal?))))
243 256
244(define* (file-hyperlink file #:optional (text file)) 257(define* (file-hyperlink file #:optional (text file))
245 "Return TEXT with escapes for a hyperlink to FILE." 258 "Return TEXT with escapes for a hyperlink to FILE."