From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sahitihi Subject: Re: Fwd: Re: Patch file for colorize module Date: Thu, 7 Jun 2018 01:19:33 +0530 Message-ID: <91773c8b-3072-2a82-dca3-cbeb5adf826d@swecha.net> References: <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.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> <328742c6-f96f-74b8-68ef-3b165a6199aa@swecha.net> <87zi0a3m3t.fsf@elephly.net> <07c93c07-2172-6bf1-6188-88830c1d8b4c@swecha.net> <87o9gpyq4t.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------083CD37DB3AE61312AD093AA" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQeRs-0004xy-6b for guix-devel@gnu.org; Wed, 06 Jun 2018 15:50:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQeRo-0006Dm-4W for guix-devel@gnu.org; Wed, 06 Jun 2018 15:50:24 -0400 In-Reply-To: <87o9gpyq4t.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. --------------083CD37DB3AE61312AD093AA Content-Type: multipart/alternative; boundary="------------4EC0FD08CCE1C3B3B6F197FD" --------------4EC0FD08CCE1C3B3B6F197FD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ricardo, Please find my changes in the patch file attached. > (Generally, you really shouldn=E2=80=99t be developing things as > =E2=80=9Croot=E2=80=9D.) > This time I din't do it as root. > For this commit a message like this would be appropriate: Added a appropriate commit message. > Please always add a so-called docstring for all defined procedures. Please bear me for this time. I din't add this yet. > You have probably noticed that this looks rather repetitive at this > point. Maybe we can think of a better way to express what colours > should be applied. The match group numbers are monotonically > increasing, so maybe we can avoid repeated statements of this kind and > simply iterate over a list of colours=E2=80=A6 I have an idea already;= how > about you? :) I have an idea about making a using filter-string and lists. Not sure about functionality but that seems fine. :-P > Another thing that=E2=80=99s worth thinking about now is the next step:= > how can we *optionally* hide all lines between these build system > notices about started and completed build phases? I din't think of it yet. Will do it in mean process. > One more thing: the fact that handle-string didn=E2=80=99t do the right= thing > indicates that you didn=E2=80=99t test the changes well enough. To tes= t them, > please locally modify =E2=80=9Cguix/scripts/build.scm=E2=80=9D and/or > =E2=80=9Cguix/scripts/package.scm=E2=80=9D to make it use your colourfu= l port instead of > the default, as discussed on IRC and in previous emails. I made changes to /guix/scripts/build.scm=C2=A0 /but that din/t workout. = That resulted me colourless outputs as before. :-( Thanks! Sahithi --------------4EC0FD08CCE1C3B3B6F197FD Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi Ricardo,

Please find my changes in the patch file attached.

  (Generally, you really shouldn’t be developing things as
“root”.)

This time I din't do it as root.
For this commit a message like this would be appropriate:
Added a appropriate commit message.
Please always add a so-called docstring for all defined procedures.
Please bear me for this time. I din't add this yet.
You have probably noticed that this looks rather repetitive at this
point.  Maybe we can think of a better way to express what colours
should be applied.  The match group numbers are monotonically
increasing, so maybe we can avoid repeated statements of this kind and
simply iterate over a list of colours…  I have an idea already; how
about you?  :)

I have an idea about making a using filter-string and lists. Not sure about functionality but that seems fine. :-P
Another thing that’s worth thinking about now is the next step:
how can we *optionally* hide all lines between these build system
notices about started and completed build phases?
I din't think of it yet. Will do it in mean process.
One more thing: the fact that handle-string didn’t do the right thing
indicates that you didn’t test the changes well enough.  To test them,
please locally modify “guix/scripts/build.scm” and/or
“guix/scripts/package.scm” to make it use your colourful port instead of
the default, as discussed on IRC and in previous emails.
I made changes to guix/scripts/build.scm  but that din/t workout. That resulted me colourless outputs as before. :-(


Thanks!
Sahithi
--------------4EC0FD08CCE1C3B3B6F197FD-- --------------083CD37DB3AE61312AD093AA Content-Type: text/x-patch; name="0002-guix-Add-coloring-soft-port.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-guix-Add-coloring-soft-port.patch" =46rom ee2ccccf26b05093cc3227a37b96196ec3a29182 Mon Sep 17 00:00:00 2001 From: Sahithi Yarlagadda Date: Thu, 7 Jun 2018 00:07:34 +0530 Subject: [PATCH 2/2] guix: Add coloring soft port. * guix/ui.scm (handle-string): New procedures. (colorful-build-output-port): New variable. --- guix/ui.scm | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) mode change 100644 =3D> 100755 guix/ui.scm diff --git a/guix/ui.scm b/guix/ui.scm old mode 100644 new mode 100755 index 3a36daadc..51a1c4a46 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -109,8 +109,7 @@ warning info guix-main - colorize-string - guix-colorful-port)) + colorful-build-output-port)) =20 ;;; Commentary: ;;; @@ -1632,43 +1631,43 @@ be reset such that subsequent output will not hav= e any colors in effect." str (color 'RESET))) =20 -(define target-port (current-output-port)) =20 (define (handle-string str) (or (and=3D> (string-match "^(starting phase)(.*)" str) (lambda (m) (string-append - (colorized-display (match:substring m 1) '(BLUE)) - (colorized-display (match:substring m 2) '(GREEN))))) + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN))))) =20 - (and=3D> (string-match "^(phase)(.*) (succeeded)(.*)" str) + (and=3D> (string-match "^(phase) (.*) (succeeded after) (.*) (sec= onds)" str) (lambda (m) (string-append - (colorized-display (match:substring m 1) '(BLUE)) - (colorized-display (match:substring m 2) '(GREEN)) - (colorized-display (match:substring m 3) '(BLUE)) - (colorized-display (match:substring m 4) '(GREEN))))) + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(BLUE)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(BLUE))))) =20 - (and=3D> (string-match "^(phase)(.*) (failed)(.*)" str) + (and=3D> (string-match "^(phase)(.*) (failed after) (.*) (seconds= )" str) (lambda (m) (string-append - (colorized-display (match:substring m 1) '(BLUE)) - (colorized-display (match:substring m 2) '(GREEN)) - (colorized-display (match:substring m 3) '(BLUE)) - (colorized-display (match:substring m 4) '(GREEN))))) + (colorize-string (match:substring m 1) '(RED)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(RED)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(RED))))) =20 ;; Didn=E2=80=99t match, so return unmodified string. - str) - (display str target-port)) + (display str current-error-port))) =20 -(define guix-colorful-port +(define colorful-build-output-port (make-soft-port (vector - (lambda (c) (write c target-port)) + (lambda (c) (write c current-error-port)) handle-string - (lambda () (display "." target-port)) + (lambda () (display "." current-error-port)) (lambda () (char-upcase (read-char))) - (lambda () (display "@" target-port))) + (lambda () (display "@" current-error-port))) "rw")) =20 ;;; ui.scm ends here --=20 2.11.0 --------------083CD37DB3AE61312AD093AA--