From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sahitihi Subject: Re: Fwd: Re: Patch file for colorize module Date: Sun, 3 Jun 2018 19:48:42 +0530 Message-ID: <557b30de-5aa2-113f-7e90-a4a23e86bb07@swecha.net> References: <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net> <7290013c-990d-3f7d-d8db-38e090ed766a@swecha.net> <87zi28kt82.fsf@elephly.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> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------3F09C6F8F124765B31BC2FF7" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPTr4-0004bL-QN for guix-devel@gnu.org; Sun, 03 Jun 2018 10:19:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPTr1-0002xq-Gm for guix-devel@gnu.org; Sun, 03 Jun 2018 10:19:34 -0400 In-Reply-To: <877enjpquf.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. --------------3F09C6F8F124765B31BC2FF7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ricardo, I have worked with different possibilities > Now all you need to do is work on the =E2=80=9Chandle-string=E2=80=9D p= rocedure. > > I suggest using simpler matching procedures at first. To get started > try =E2=80=9Cstring-prefix?=E2=80=9D and use it with the string =E2=80=9C= starting phase=E2=80=9D. This > won=E2=80=99t work with regular expressions, though. String-prefix resulted a boolean output so, I thought of using conditiona= ls. Following is the line I added to=C2=A0 =E2=80=9Chandle-string=E2=80=9D pr= ocedure /(if (string-prefix? "starting phase" str) (colorized-display str '(GREEN)) (display str target-port) )) / > While you *can* use =E2=80=9Cregexp-substitute/global=E2=80=9D, I don=E2= =80=99t think it=E2=80=99s a > good fit here, because we may want to extend the string matching > features, which is difficult to do with =E2=80=9Cregexp-substitute/glob= al=E2=80=9D. > Instead, try to match regular expressions one by one with =E2=80=9Cstri= ng-match=E2=80=9D > and then operate on the match structure it returns. If it returns #f > you can move on to the next expression. If none match you just return > the original string. If one matches you *rebuild* the string, but with= > colours applied. Do I need to write multiple definitions for each expression? '("^starting phase.*" "^phase .* succeeded.*" "^phase .* failed.*") > If you don=E2=80=99t understand this example please look up the procedu= res in > the Guile manual. I dint find this example in procedures, may I overlooked somewhere I recheck it. Thanks! Sahithi --------------3F09C6F8F124765B31BC2FF7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Ricardo,

I have worked with different possibilities
Now all you need to do is work on the “handle-string” procedure.

I suggest using simpler matching procedures at first.  To get started
try “string-prefix?” and use it with the string “starting phase”.  This
won’t work with regular expressions, though.
String-prefix resulted a boolean output so, I thought of using conditionals.
Following is the line I added to  “handle-string” procedure

(if (string-prefix? "starting phase" str) (colorized-display str '(GREEN)) (display str target-port) ))


While you *can* use “regexp-substitute/global”, I don’t think it’s a
good fit here, because we may want to extend the string matching
features, which is difficult to do with “regexp-substitute/global”.
Instead, try to match regular expressions one by one with “string-match”
and then operate on the match structure it returns.  If it returns #f
you can move on to the next expression.  If none match you just return
the original string.  If one matches you *rebuild* the string, but with
colours applied.

Do I need to write multiple definitions for each expression?
'("^starting phase.*"
    "^phase .* succeeded.*"
    "^phase .* failed.*")
If you don’t understand this example please look up the procedures in
the Guile manual.

I dint find this example in procedures, may I overlooked somewhere I recheck it.

Thanks!
Sahithi
--------------3F09C6F8F124765B31BC2FF7--