From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sahitihi Subject: Re: Fwd: Re: Patch file for colorize module Date: Mon, 4 Jun 2018 13:18:02 +0530 Message-ID: <328742c6-f96f-74b8-68ef-3b165a6199aa@swecha.net> References: <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net> <8573e97d-d107-cde6-cd17-35f4ef6d2de3@swecha.net> <87k1takumm.fsf@elephly.net> <87o9hycwl6.fsf@elephly.net> <87r2mhdeap.fsf@elephly.net> <618c131c-6ba6-e525-aefc-72acca1c910f@swecha.net> <87a7suwtp7.fsf@elephly.net> <149bfb8c-22b5-797d-e88a-ca4077b0a4cc@swecha.net> <87d0xmok8e.fsf@elephly.net> <87k1rsb9ex.fsf@elephly.net> <3e099b0b-e3ec-2bbb-6d10-5b7e48c4dff6@swecha.net> <300fd917-6742-3ef1-044d-4b0f38a44250@swecha.net> <87a7sm4v5j.fsf@elephly.net> <3d5eca09-7730-bd38-265b-7942d0ea16ed@swecha.net> <878t864i59.fsf@elephly.net> <87o9gwpcmx.fsf@elephly.net> <2f71be8d-c672-c66a-0b16-bc3abc748754@swecha.net> <877enjpquf.fsf@elephly.net> <557b30de-5aa2-113f-7e90-a4a23e86bb07@swecha.net> <87602zbrcc.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------6B6A5FEAA18D7D4A66DA3A8A" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPkDv-0007JX-21 for guix-devel@gnu.org; Mon, 04 Jun 2018 03:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPkDq-0002HC-5o for guix-devel@gnu.org; Mon, 04 Jun 2018 03:48:15 -0400 In-Reply-To: <87602zbrcc.fsf@elephly.net> Content-Language: en-US List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel This is a multi-part message in MIME format. --------------6B6A5FEAA18D7D4A66DA3A8A Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ricardo, I used /cond/ conditional=C2=A0 and gave a try. This worked out with following line. I also included string-match which also worked. All I need to look for next step is to use regular expressions instead of string. > You also see that =E2=80=9Cif=E2=80=9D alone is not sufficient here, be= cause you have > more than one expression. You could nest =E2=80=9Cif=E2=80=9D expressi= ons, but that=E2=80=99s > ugly. You can use =E2=80=9Ccond=E2=80=9D instead. =C2=A0=C2=A0 /(cond ((string-match "(starting phase" str) (colorized-disp= lay str '(GREEN))) // //=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((string-prefix?= "succeed" str) (colorized-display str '(GREEN))) // //=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((string-prefix?= "failed" str) (colorized-display str '(GREEN))) // //=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (else (display s= tr target-port) )))/ > Please look at the examples in my previous email again. I used > =E2=80=9Cstring-match=E2=80=9D, =E2=80=9Cmatch:substring=E2=80=9D, and = =E2=80=9Cand=3D>=E2=80=9D, which you may not be > familiar with yet. > I used them individually but I still dint figure out the way it works in the example. I will check that as next one. Thanks!! Sahithi --------------6B6A5FEAA18D7D4A66DA3A8A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi Ricardo,

I used cond conditional  and gave a try. This worked out with following line.

I also included string-match which also worked.

All I need to look for next step is to use regular expressions instead of string.

You also see that “if” alone is not sufficient here, because you have
more than one expression.  You could nest “if” expressions, but that’s
ugly.  You can use “cond” instead.
   (cond ((string-match "(starting phase" str) (colorized-display str '(GREEN)))
          ((string-prefix? "succeed" str) (colorized-display str '(GREEN)))
          ((string-prefix? "failed" str) (colorized-display str '(GREEN)))
          (else (display str target-port) )))

Please look at the examples in my previous email again.  I used
“string-match”, “match:substring”, and “and=>”, which you may not be
familiar with yet.


I used them individually but I still dint figure out the way it works in the example. I will check that as next one.

Thanks!!

Sahithi
--------------6B6A5FEAA18D7D4A66DA3A8A--