Friday, August 18, 2017

Re: Colored shell commandline confuses ':make' ?

On 08/18 09:36, Christian Brabandt wrote:
>
> On Fr, 18 Aug 2017, tuxic@posteo.de wrote:
>
> > Hi,
> >
> > I ran into a problem and I dont know where to investigate first.
> > Since vim is the first instance, which uncovers the problem, I
> > will start asking here...
> >
> > For my Arduino projects I want to get rid of the Ardyino IDE -- vim is the
> > better choice.
> >
> > Here: https://github.com/sudar/Arduino-Makefile located is a Makefile
> > setup, which can be used to compile Arduino "sketches" into flashable
> > *.hex files.
> >
> > I installed that and it works (beside some syntax errors I have to fix
> > -- mainly because previously the IDE has cheated one in thinking that
> > one writes "real C/++" by providing the prototypes of all functions
> > itsself.
> >
> > But these kind of errors causes the problem now...
> >
> > I start vim like this:
> >
> > vim myfirmware.ino
> >
> > vim starts and displays the contents of the ino-File.
> >
> > The I type
> >
> > : make
> >
> > and hit return. vim jumps into the background and the bare
> > shell becomes visible.
> >
> > The compilations starts and displays some errors -- missing
> > prototypes. But the output is colored by the shell.
> >
> > After compilation ends, vim jumps into the foreground again,
> > displaying:
> > "^[[01m^[[Kmyfirmware.ino" [New File]
> > (45 of 75): ^[[m^[[K ^[[01;31m^[[Kerror: ^[[m^[[K'^[[01m^[[KdisplayTime^[[m^[[K' was not declared in this sc
> > ope
> >
> > And BOOOM! my firmware.ino is no longer displayed. Instead I got a
> > new file which some really weird escape-sequences in its filename.
>
> Yes, the makefile should only output ANSI color codes when it is
> actually writing to the terminal. You would need to tell vim to strip
> aways those ansi escape codes.
>
> A quick google search, reveals how you can get rid of those chars:
> https://unix.stackexchange.com/questions/4527
>
> So something like this perhaps:
>
> set makeprg=make\ \\\|\ sed\ -r\ "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
>
> Okay, quoting might become very ugly. You might want to create a
> wrapperscript like this:
>
> #!/bin/sh
> make | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
>
> and use this for make like :set makeprg=my_make
>
> However, I would still open a ticket at that repository and ask if there
> is a way to build without outputting ansi escape codes
>
> Best,
> Christian
> --
> Wußten Sie schon...
> ... daß Haarspray gegen Glatzen überhaupt keine Wirkung zeigt, da aus
> der Dose keine Haare herauskommen?
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Hi Christian,

Thanks for the hint where to start searching the culprit.
I fixed it myself -- the Arduino makefile defines -fdiagnostic-color
for gcc version > 490. I removed that option and now it works as
exspected.

I will open an issue on the github page next.

Thanks a lot for the support!
Cheers
Meino


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: