guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: Re: Patch file for colorize module


From: Ricardo Wurmus
Subject: Re: Fwd: Re: Patch file for colorize module
Date: Mon, 04 Jun 2018 12:03:02 +0200
User-agent: mu4e 1.0; emacs 26.1

Hi Sahithi,

> I used /cond/ conditional and gave a try. This worked out with
> following line.[…]

Good.

Currently, you have always the same code that runs for any match.
Looking at my example you might be able to figure out how to apply a
different colour to different parts of the strings, e.g. using blue for
the name of the build phase and green for the rest.

You will need to use regular expressions with sufficient match groups.

Here’s the example from my email again:

--8<---------------cut here---------------start------------->8---
  (define str  "My name is Al Jarreau and I’m 76 years old.")
  (define expr "(My name is )(.*)( and I’m )(.*)( years old.)")

These are five match groups and we want to modify the second and fourth,
so we can do this:

(or (and=> (string-match expr str)
           (lambda (m)
             (string-append
              (match:substring m 1)
              (string-upcase (match:substring m 2))
              (match:substring m 3)
              (string-reverse (match:substring m 4))
              (match:substring m 5))))
    ;; Didn’t match, so return unmodified string.
    str)
--8<---------------cut here---------------end--------------->8---

Please make an effort to make the changes in (guix ui) as soon as you
understand how it’s done.

Thanks!

--
Ricardo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]