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

Re: problems setting up makeprg and makeef

Expand Messages
  • FlashBurn
    ... I think I know where the problem is. It is the spaces in the path. The error.err file is created. But when vim tries to open there it sees spaces in it,
    Message 1 of 9 , Mar 6, 2013
    View Source
    • 0 Attachment
      On Wednesday, March 6, 2013 4:13:28 PM UTC-5, Gary Johnson wrote:
      > On 2013-03-06, FlashBurn wrote:
      >
      > > I have setup a vim script to do the following
      >
      > >
      >
      > > " Setup the project home directory.
      >
      > > let s:project_path = 'C:\Documents and Settings\user\Projects\myproject\trunk'
      >
      > >
      >
      > > " Setup the project home directory such that Vim can understand it. It will
      >
      > > " escape white spaces.
      >
      > > let s:vim_project_path = fnameescape(s:project_path)
      >
      > > " cd to the project directory.
      >
      > > set cd=s:vim_project_path
      >
      >
      >
      > This is not doing what you think it's doing.
      >
      >
      >
      > 'cd' is an abbreviation for 'cdpath'. You are setting the value of
      >
      > the 'cdpath' option, not changing directory.
      >
      >
      >
      > Even if setting the value of 'cd' to the desired path was the right
      >
      > thing to do, your command won't do that because the :set command
      >
      > does not take variable names.
      >
      >
      >
      > The right command to use is this:
      >
      >
      >
      > :exe 'cd' s:vim_project_path
      >
      >
      >
      > The :exe command expands its arguments, then executes the result.
      >
      > See
      >
      >
      >
      > :help :exe
      >
      > :help :cd
      >
      >
      >
      > > " Setup make command such that shell can understand it.
      >
      > > " Path to make.exe.
      >
      > > let &makeprg = shellescape(s:project_path.'\tools\make.exe')
      >
      > > " Use makefile from 'src\makefile'.
      >
      > > let &makeprg .= ' -f '.shellescape(s:project_path.'\src\makefile')
      >
      > > " Change to a directory 'src' before running make.
      >
      > > let &makeprg .= ' --directory '.shellescape(s:project_path.'\src')
      >
      > >
      >
      > > " Setup the file where the output of ':make' will be redirected.
      >
      > > let &makeef = shellescape(s:project_path.'\src\error.err')
      >
      > >
      >
      > > But for some reason whenever I run :make, I'm getting the following error
      >
      > >
      >
      > > E40: Can't open errofile :C:/Documents and Settings/user/Projects/myproject/trunk/src/error.err"
      >
      > >
      >
      > > I looked at help for E40 but nothing really can explain why this is happening.
      >
      > >
      >
      > > Now if my makeef is setup as follows
      >
      > > let &makeef = ""
      >
      > >
      >
      > > Then Windows redirects the output to a temporary file and there
      >
      > > are no issues. I'd like to be able to store the output in a given
      >
      > > file not in a temporary file.
      >
      > >
      >
      > > Does anybody know what is the issue and how it can be fixed?
      >
      > >
      >
      > > Any help is appreciated.
      >
      >
      >
      > I don't use Windows very much. What you've shown looks good to me.
      >
      >
      >
      > The contents of the E40 message suggests that the file name was
      >
      > built correctly. Are you sure you have write permission in that
      >
      > directory? (I wonder if that message means the file cannot be
      >
      > opened for writing or cannot be opened for reading, e.g., doesn't
      >
      > exist.)
      >
      >
      >
      > Regards,
      >
      > Gary

      I think I know where the problem is.
      It is the spaces in the path. The error.err file is created. But when vim tries to open there it sees spaces in it, that's why it can't open it. The solution, I decided to use is the 8dot3 path. Thanks for the help everyone.

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ben Fritz
      ... That s an acceptable workaround, I think. But maybe it should be supported if it actually isn t. I personally avoid using paths with spaces whenever
      Message 2 of 9 , Mar 6, 2013
      View Source
      • 0 Attachment
        On Wednesday, March 6, 2013 3:49:11 PM UTC-6, FlashBurn wrote:
        >
        > I think I know where the problem is.
        > It is the spaces in the path. The error.err file is created. But when vim tries to open there it sees spaces in it, that's why it can't open it. The solution, I decided to use is the 8dot3 path. Thanks for the help everyone.

        That's an acceptable workaround, I think. But maybe it should be supported if it actually isn't. I personally avoid using paths with spaces whenever possible, especially now that I'm on Windows 7 and can use C:\Users instead of "C:\Documents and Settings".

        To make it even nicer for yourself, Vim can automatically build the 8.3 path for you. See:

        :help fnamemodify()
        :help filename-modifiers

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • FlashBurn
        ... Well, I keep finding more problems with my script. It turns out it works find if there are no errors during compilation. Once compiler detects and error
        Message 3 of 9 , Mar 7, 2013
        View Source
        • 0 Attachment
          On Wednesday, March 6, 2013 5:16:31 PM UTC-5, Ben Fritz wrote:
          > On Wednesday, March 6, 2013 3:49:11 PM UTC-6, FlashBurn wrote:
          > >
          > > I think I know where the problem is.
          > > It is the spaces in the path. The error.err file is created. But when vim tries to open there it sees spaces in it, that's why it can't open it. The solution, I decided to use is the 8dot3 path. Thanks for the help everyone.
          >
          > That's an acceptable workaround, I think. But maybe it should be supported if it actually isn't. I personally avoid using paths with spaces whenever possible, especially now that I'm on Windows 7 and can use C:\Users instead of "C:\Documents and Settings".
          >
          > To make it even nicer for yourself, Vim can automatically build the 8.3 path for you. See:
          >
          > :help fnamemodify()
          > :help filename-modifiers

          Well, I keep finding more problems with my script. It turns out it works find if there are no errors during compilation. Once compiler detects and error during compilation something interesting is happening. It tries to open the error.err file and generates the following error:
          shell returned2
          E303: Unable to open swap file for "and Settings\user\Projects\MyProject\trunk\src\myfile.c
          "and Settings\user\Projects\MyProject\trunk\src\myfile.c,60 Error"[New DIRECTORY]

          Does anybody know what is going on and how I can fix it? Any help is appreciated.

          Here is my project setup script:

          Here is my modified script, using Ben's advice for 8dot3 file path generation.
          " Setup the project home directory.
          let s:project_path = 'C:\Documents and Settings\user\Projects\MyProject\trunk'
          let s:project_path_8dot3 = fnamemodify(s:project_path, ':8')

          " Setup the project home directory.
          let s:vim_project_path = fnameescape(s:project_path)
          set cd=s:project_path_8dot3

          " Setup make command.
          " 1. Use makefile from 'src\makefile'.
          " 2. Change to a 'src' directory before running make.
          let &makeprg = s:project_path_8dot3.'\tools\make.exe'
          let &makeprg .= ' -f '.s:project_path_8dot3.'\src\makefile'
          let &makeprg .= ' --directory '.s:project_path_8dot3.'\src'

          " Setup the file where the output of ':make' will be redirected.
          let &makeef = s:project_path_8dot3.'\src\error.err'

          --
          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Ben Fritz
          ... As Gary mentioned, this set cd= line is NOT doing what you seem to think it is doing. Fix this first, it looks like your make program is outputting paths
          Message 4 of 9 , Mar 7, 2013
          View Source
          • 0 Attachment
            On Thursday, March 7, 2013 9:43:46 AM UTC-6, FlashBurn wrote:
            > On Wednesday, March 6, 2013 5:16:31 PM UTC-5, Ben Fritz wrote:
            > > On Wednesday, March 6, 2013 3:49:11 PM UTC-6, FlashBurn wrote:
            > > >
            > > > I think I know where the problem is.
            > > > It is the spaces in the path. The error.err file is created. But when vim tries to open there it sees spaces in it, that's why it can't open it. The solution, I decided to use is the 8dot3 path. Thanks for the help everyone.
            > >
            > > That's an acceptable workaround, I think. But maybe it should be supported if it actually isn't. I personally avoid using paths with spaces whenever possible, especially now that I'm on Windows 7 and can use C:\Users instead of "C:\Documents and Settings".
            > >
            > > To make it even nicer for yourself, Vim can automatically build the 8.3 path for you. See:
            > >
            > > :help fnamemodify()
            > > :help filename-modifiers
            >
            > Well, I keep finding more problems with my script. It turns out it works find if there are no errors during compilation. Once compiler detects and error during compilation something interesting is happening. It tries to open the error.err file and generates the following error:
            > shell returned2
            > E303: Unable to open swap file for "and Settings\user\Projects\MyProject\trunk\src\myfile.c
            > "and Settings\user\Projects\MyProject\trunk\src\myfile.c,60 Error"[New DIRECTORY]
            >
            > Does anybody know what is going on and how I can fix it? Any help is appreciated.
            >
            > Here is my project setup script:
            >
            > Here is my modified script, using Ben's advice for 8dot3 file path generation.
            > " Setup the project home directory.
            > let s:project_path = 'C:\Documents and Settings\user\Projects\MyProject\trunk'
            > let s:project_path_8dot3 = fnamemodify(s:project_path, ':8')
            >
            > " Setup the project home directory.
            > let s:vim_project_path = fnameescape(s:project_path)
            > set cd=s:project_path_8dot3

            As Gary mentioned, this "set cd=" line is NOT doing what you seem to think it is doing. Fix this first, it looks like your make program is outputting paths with spaces, and I don't know whether Vim will be able to handle those very well.

            >
            > " Setup make command.
            > " 1. Use makefile from 'src\makefile'.
            > " 2. Change to a 'src' directory before running make.
            > let &makeprg = s:project_path_8dot3.'\tools\make.exe'
            > let &makeprg .= ' -f '.s:project_path_8dot3.'\src\makefile'
            > let &makeprg .= ' --directory '.s:project_path_8dot3.'\src'
            >
            > " Setup the file where the output of ':make' will be redirected.
            > let &makeef = s:project_path_8dot3.'\src\error.err'

            You may need to set the 'errorformat' option as well.

            If I were you, when I'm all done, I'd consider making this a compiler plugin. See :help write-compiler-plugin.

            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Gary Johnson
            ... This looks like a problem with your errorformat . The compiler found an error at line 60 of myfile.c, but your errorformat is incorrectly parsing that
            Message 5 of 9 , Mar 7, 2013
            View Source
            • 0 Attachment
              On 2013-03-07, FlashBurn wrote:

              > Well, I keep finding more problems with my script. It turns out it
              > works find if there are no errors during compilation. Once
              > compiler detects and error during compilation something
              > interesting is happening. It tries to open the error.err file and
              > generates the following error:
              > shell returned2
              > E303: Unable to open swap file for "and Settings\user\Projects\MyProject\trunk\src\myfile.c
              > "and Settings\user\Projects\MyProject\trunk\src\myfile.c,60 Error"[New DIRECTORY]
              >
              > Does anybody know what is going on and how I can fix it? Any help
              > is appreciated.

              This looks like a problem with your 'errorformat'. The compiler
              found an error at line 60 of myfile.c, but your 'errorformat' is
              incorrectly parsing that message so that Vim tries to jump to an
              error in a file named
              "and Settings\user\Projects\MyProject\trunk\src\myfile.c,60 Error".

              Regards,
              Gary

              --
              --
              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@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Ben Fritz
              ... I agree, but I think getting the cd command correct might actually fix this problem, because possibly the OP s make program will not output the full path
              Message 6 of 9 , Mar 7, 2013
              View Source
              • 0 Attachment
                On Thursday, March 7, 2013 12:51:46 PM UTC-6, Gary Johnson wrote:
                > On 2013-03-07, FlashBurn wrote:
                >
                > > shell returned2
                >
                > > E303: Unable to open swap file for "and Settings\user\Projects\MyProject\trunk\src\myfile.c
                >
                > > "and Settings\user\Projects\MyProject\trunk\src\myfile.c,60 Error"[New DIRECTORY]
                >
                > >
                >
                > > Does anybody know what is going on and how I can fix it? Any help
                >
                > > is appreciated.
                >
                >
                >
                > This looks like a problem with your 'errorformat'. The compiler
                >
                > found an error at line 60 of myfile.c, but your 'errorformat' is
                >
                > incorrectly parsing that message so that Vim tries to jump to an
                >
                > error in a file named
                >
                > "and Settings\user\Projects\MyProject\trunk\src\myfile.c,60 Error".
                >

                I agree, but I think getting the "cd" command correct might actually fix this problem, because possibly the OP's make program will not output the full path if it's already running from a directory within that path. But that might be wishful thinking on my part.

                Note that E303 can be caused on Windows 7 because Vim looks in C:\Temp and C:\TMP rather than $TEMP and $TMP for swap files by default; you can fix this by modifying your 'directory' option. But, Vim will still be looking in the wrong location for the file itself. And, Windows 7 has "C:\Users\blah" instead of "C:\Documents and Settings\blah" so it's not as likely to be the cause in this case.

                --
                --
                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@....
                For more options, visit https://groups.google.com/groups/opt_out.
              Your message has been successfully submitted and would be delivered to recipients shortly.