Loading ...
Sorry, an error occurred while loading the content.

Re: two :make's in a function

Expand Messages
  • A.Politz
    ... You could check if getqflist() is empty or not. In case you have any garbage in it , maybe it is helpfull to filter it first for real errors with something
    Message 1 of 7 , Sep 28 4:27 PM
    • 0 Attachment
      Tom Flynn wrote:

      >hi there,
      >
      >something like this has to have been asked before, but I must not be
      >using the right search terms 'cause i haven't found anything yet.
      >
      >in my project, we have a library and some test programs (some of which
      >exist outside our tree). I have a vim function called Build() that
      >essentially does the following:
      >
      >function! Build()
      > "by default makeprg is set to make -C $(PROJECTDIR)
      > make
      > " XXX if errors, exit out
      > " ????
      > "
      > "save off the current value
      > let s:mkprg = &makeprg
      > "set makeprg to the test dir
      > let &makeprg="make\ -C " . g:ps3dir
      > "build the test program
      > make
      > "restore the value of makeprg
      > let &makeprg=s:mkprg
      >endfunction
      >
      >problem is that if there is an error during the make, it goes right on
      >and executes the second make. I would prefer to check if the first
      >make failed and exit out appropriately. is there anyway to do that?
      >
      >thanks in advance,
      >tom
      >
      >>
      >
      >
      You could check if getqflist() is empty or not. In case
      you have any garbage in it , maybe it is helpfull to filter
      it first for real errors with something like :
      filter(getqflist,'v:val.valid').

      -ap




      --
      Ich hab geträumt, der Krieg wär vorbei.


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Suresh Govindachar
      ... Can t it just be done? What happens if you add the lines: let foo = `make` echo foo and run cases when make succeeds and when make fails? Or doesn t
      Message 2 of 7 , Sep 28 4:33 PM
      • 0 Attachment
        > problem is that if there is an error during the
        > make, it goes right on and executes the second make.
        > I would prefer to check if the first make failed and
        > exit out appropriately. is there anyway to do that?

        Can't it just be done? What happens if you
        add the lines:

        let foo = `make`
        echo foo

        and run cases when make succeeds and when make fails?
        Or doesn't vim-script allow backticks to be used that way?

        --Suresh


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Tom Flynn
        ... not sure, i m still a bit of a noob with vim scripting. the getqflist() looks promising. i ll give that a shot too. thanks for the suggestions! -tom ...
        Message 3 of 7 , Sep 28 4:42 PM
        • 0 Attachment
          On 9/28/07, Suresh Govindachar <sgovindachar@...> wrote:
          >
          >
          > > problem is that if there is an error during the
          > > make, it goes right on and executes the second make.
          > > I would prefer to check if the first make failed and
          > > exit out appropriately. is there anyway to do that?
          >
          > Can't it just be done? What happens if you
          > add the lines:
          >
          > let foo = `make`
          > echo foo

          not sure, i'm still a bit of a noob with vim scripting. the
          getqflist() looks promising. i'll give that a shot too. thanks for
          the suggestions!
          -tom

          >
          > and run cases when make succeeds and when make fails?
          > Or doesn't vim-script allow backticks to be used that way?
          >
          > --Suresh
          >
          >
          > >
          >

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Gary Johnson
          ... No, it doesn t. Even if it did, that would be executing the OS command make , not the vim command :make . The output of the former would not be
          Message 4 of 7 , Sep 28 5:04 PM
          • 0 Attachment
            On 2007-09-28, Suresh Govindachar <sgovindachar@...> wrote:
            >
            > > problem is that if there is an error during the
            > > make, it goes right on and executes the second make.
            > > I would prefer to check if the first make failed and
            > > exit out appropriately. is there anyway to do that?
            >
            > Can't it just be done? What happens if you
            > add the lines:
            >
            > let foo = `make`
            > echo foo
            >
            > and run cases when make succeeds and when make fails?
            > Or doesn't vim-script allow backticks to be used that way?

            No, it doesn't. Even if it did, that would be executing the OS
            command "make", not the vim command ":make". The output of the
            former would not be captured in a quickfix error list.

            I thought that using v:shell_error might help, but the exit status
            of the pipeline

            :!make 2>&1| tee /tmp/v52609/1

            executed when you type

            :make

            is apparently that of tee and not that of make.

            How about putting your :make command in a try/recover block? See

            :help try
            :helpgrep :try

            Regards,
            Gary

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • A.Politz
            ... Even if it did execute vims make, make is not an expression, it is a command and commands have no return value. if
            Message 5 of 7 , Sep 28 5:54 PM
            • 0 Attachment
              Gary Johnson wrote:

              >On 2007-09-28, Suresh Govindachar <sgovindachar@...> wrote:
              >
              >
              >>
              >> > problem is that if there is an error during the
              >> > make, it goes right on and executes the second make.
              >> > I would prefer to check if the first make failed and
              >> > exit out appropriately. is there anyway to do that?
              >>
              >> Can't it just be done? What happens if you
              >> add the lines:
              >>
              >> let foo = `make`
              >> echo foo
              >>
              >> and run cases when make succeeds and when make fails?
              >> Or doesn't vim-script allow backticks to be used that way?
              >>
              >>
              >
              >No, it doesn't. Even if it did, that would be executing the OS
              >command "make", not the vim command ":make".
              >
              Even if it did execute vims make, make is not an expression,
              it is a command and commands have no return value.


              if !empty(filter(getqflist(),'v:val.valid'))
              "Error handling
              endif

              ... should work.

              -ap

              --
              Ich hab geträumt, der Krieg wär vorbei.


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Tom Flynn
              ... and it does! Thank you!! -tom --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For more
              Message 6 of 7 , Sep 28 6:25 PM
              • 0 Attachment
                On 9/28/07, A.Politz <politza@...> wrote:

                >
                > if !empty(filter(getqflist(),'v:val.valid'))
                > "Error handling
                > endif
                >
                > ... should work.

                and it does! Thank you!!
                -tom

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              Your message has been successfully submitted and would be delivered to recipients shortly.