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

Re: Bug in Vim 7.2.438: try, catch and cscope

Expand Messages
  • Gary Johnson
    ... I didn t understand that. What is csfs and what is removing the query type? ... One of the ideas behind the actual plugin is to add the cscope database
    Message 1 of 6 , Jul 1, 2010
    • 0 Attachment
      On 2010-07-01, Bryan Venteicher wrote:
      > > From: "Gary Johnson"
      > > To: "vim dev"
      > > Sent: Tuesday, June 29, 2010 5:40:39 PM
      > > Subject: Bug in Vim 7.2.438: try, catch and cscope
      >
      > > After a recent update, I started noticing erroneous behavior in a
      > > number of my cscope mappings. After some experimenting I discovered
      > > that Vim is failing to execute a "cs find" command when it follows a
      > > "cs add" command in a catch block. This has worked fine for a long
      > > time and through Vim 7.2.148 but stopped working at or before Vim
      > > 7.2.438.
      > >
      > > I boiled my configuration and functions down to the following
      > > plugin.
      > >
      > > ------------------------ cscope.vim ------------------------
      > > set laststatus=2
      > > set cmdheight=10
      > >
      > > set csverb
      > > set csqf=s-
      > >
      > > function! Csfind()
      > > try let x = y
      > > catch /.*/
      > > echo v:exception
      > > cs add cscope.out
      > > cs find s mch_early_init
      > > echo "Here"
      > > endtry endfunction
      > > ------------------------------------------------------------
      > >
      >
      > I wager I altered this when I submitted 7.2.433, adding CScope
      > QuickFixCmd{Pre,Post} autocmd event similar to what already exists
      > for make, grep, etc. If you try to say a :vimgrep in your catch block,
      > that goes no where too, right?
      >
      > A few potential fixes come to mind:
      > - If you're not explicity needing it, remove the query type from 'csfs'
      > in the catch block.

      I didn't understand that. What is 'csfs' and what is removing the
      query type?

      > - Do the 'cs find' bit outside of the catch block.

      One of the ideas behind the actual plugin is to add the cscope
      database without the user having to think about it, but only when
      it's needed. The Csfind() function tries to execute a "cs find"
      command. If that fails because there are no cscope connections, the
      plugin tries to execute "cs add". If that succeeds, another "cs
      find" is attempted.

      The result is that the Csfind() function behaves like "cs find", but
      automatically adds the proper cscope connection the first time it is
      called.

      Therefore, the "cs find" bit logically belongs in the catch block.
      It might be possible to set a flag in the catch block and test it
      later outside the catch block to conditionally execute the "cs
      find" bit, but I'd rather avoid such a kludge if there is another
      way around the bug.

      > - Revert 433. I had been carrying it around as a private patch for a
      > couple of years and find it to very useful.

      I'll try that as soon as I figure out how. I haven't done anything
      fancy with Mercurial yet.

      Thanks for the pointer to the likely problematic change set. I was
      not looking forward to performing a binary search of 291 change
      sets.

      Are you planning on fixing this?

      Regards,
      Gary

      --
      You received this message from the "vim_dev" 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
    • Bryan Venteicher
      ... Fat fingers: csqf . Query type would be s in your example (:cs find {querytype} {name}) Of course, if it is in there in the first place because you want
      Message 2 of 6 , Jul 1, 2010
      • 0 Attachment
        > From: "Gary Johnson" <garyjohn@...>
        > To: "vim dev" <vim_dev@...>
        > Sent: Thursday, July 1, 2010 2:04:42 AM
        > Subject: Re: Bug in Vim 7.2.438: try, catch and cscope

        > On 2010-07-01, Bryan Venteicher wrote:
        > > > From: "Gary Johnson"
        > > > To: "vim dev"
        > > > Sent: Tuesday, June 29, 2010 5:40:39 PM
        > > > Subject: Bug in Vim 7.2.438: try, catch and cscope
        > >
        > > > After a recent update, I started noticing erroneous behavior in a
        > > > number of my cscope mappings. After some experimenting I
        > > > discovered that Vim is failing to execute a "cs find" command when
        > > > it follows a
        > > > "cs add" command in a catch block. This has worked fine for a long
        > > > time and through Vim 7.2.148 but stopped working at or before Vim
        > > > 7.2.438.
        > > >
        > > > I boiled my configuration and functions down to the following
        > > > plugin.
        > > >
        > > > ------------------------ cscope.vim ------------------------
        > > > set laststatus=2
        > > > set cmdheight=10
        > > >
        > > > set csverb
        > > > set csqf=s-
        > > >
        > > > function! Csfind()
        > > > try let x = y
        > > > catch /.*/
        > > > echo v:exception
        > > > cs add cscope.out
        > > > cs find s mch_early_init
        > > > echo "Here"
        > > > endtry endfunction
        > > > ------------------------------------------------------------
        > > >
        > >
        > > I wager I altered this when I submitted 7.2.433, adding CScope
        > > QuickFixCmd{Pre,Post} autocmd event similar to what already exists
        > > for make, grep, etc. If you try to say a :vimgrep in your catch
        > > block, that goes no where too, right?
        > >
        > > A few potential fixes come to mind:
        > > - If you're not explicity needing it, remove the query type from
        > > 'csfs'
        > > in the catch block.
        >
        > I didn't understand that. What is 'csfs' and what is removing the
        > query type?

        Fat fingers: 'csqf'. Query type would be 's' in your example (:cs find {querytype} {name})
        Of course, if it is in there in the first place because you want to use the quickfix
        window for the results of the find in the catch, this really isn't helpful.

        >
        > > - Do the 'cs find' bit outside of the catch block.
        >
        > One of the ideas behind the actual plugin is to add the cscope
        > database without the user having to think about it, but only when
        > it's needed. The Csfind() function tries to execute a "cs find"
        > command. If that fails because there are no cscope connections, the
        > plugin tries to execute "cs add". If that succeeds, another "cs
        > find" is attempted.
        >
        > The result is that the Csfind() function behaves like "cs find", but
        > automatically adds the proper cscope connection the first time it is
        > called.
        >
        > Therefore, the "cs find" bit logically belongs in the catch block.
        > It might be possible to set a flag in the catch block and test it
        > later outside the catch block to conditionally execute the "cs
        > find" bit, but I'd rather avoid such a kludge if there is another
        > way around the bug.

        Yes, I would thinking adding some flag to do the cs add/find.
        You could also :redir ':cs show' to see if a database is loaded.

        >
        > > - Revert 433. I had been carrying it around as a private patch for a
        > > couple of years and find it to very useful.
        >
        > I'll try that as soon as I figure out how. I haven't done anything
        > fancy with Mercurial yet.
        >
        > Thanks for the pointer to the likely problematic change set. I was
        > not looking forward to performing a binary search of 291 change
        > sets.
        >
        > Are you planning on fixing this?

        Off hand, short of backing it out, I don't see a way to fix it, although
        it has been awhile since I poked around the Vim source. It makes Cscope
        behave more like make, grep, etc, which to me, is the a good thing.

        >
        > Regards,
        > Gary
        >
        > -- You received this message from the "vim_dev" 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 from the "vim_dev" 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
      • Gary Johnson
        ... I would like to continue to have the freedom to set csqf to use quickfix or not for each query type as I choose. In the actual plugin, I have more than
        Message 3 of 6 , Jul 1, 2010
        • 0 Attachment
          On 2010-07-01, Bryan Venteicher wrote:
          > > From: "Gary Johnson"
          > > To: "vim dev"
          > > Sent: Thursday, July 1, 2010 2:04:42 AM
          > > Subject: Re: Bug in Vim 7.2.438: try, catch and cscope
          >
          > > On 2010-07-01, Bryan Venteicher wrote:
          > > > > From: "Gary Johnson"
          > > > > To: "vim dev"
          > > > > Sent: Tuesday, June 29, 2010 5:40:39 PM
          > > > > Subject: Bug in Vim 7.2.438: try, catch and cscope
          > > >
          > > > > After a recent update, I started noticing erroneous behavior in a
          > > > > number of my cscope mappings. After some experimenting I
          > > > > discovered that Vim is failing to execute a "cs find" command when
          > > > > it follows a
          > > > > "cs add" command in a catch block. This has worked fine for a long
          > > > > time and through Vim 7.2.148 but stopped working at or before Vim
          > > > > 7.2.438.
          > > > >
          > > > > I boiled my configuration and functions down to the following
          > > > > plugin.
          > > > >
          > > > > ------------------------ cscope.vim ------------------------
          > > > > set laststatus=2
          > > > > set cmdheight=10
          > > > >
          > > > > set csverb
          > > > > set csqf=s-
          > > > >
          > > > > function! Csfind()
          > > > > try let x = y
          > > > > catch /.*/
          > > > > echo v:exception
          > > > > cs add cscope.out
          > > > > cs find s mch_early_init
          > > > > echo "Here"
          > > > > endtry endfunction
          > > > > ------------------------------------------------------------
          > > > >
          > > >
          > > > I wager I altered this when I submitted 7.2.433, adding CScope
          > > > QuickFixCmd{Pre,Post} autocmd event similar to what already exists
          > > > for make, grep, etc. If you try to say a :vimgrep in your catch
          > > > block, that goes no where too, right?
          > > >
          > > > A few potential fixes come to mind:
          > > > - If you're not explicity needing it, remove the query type from
          > > > 'csfs'
          > > > in the catch block.
          > >
          > > I didn't understand that. What is 'csfs' and what is removing the
          > > query type?
          >
          > Fat fingers: 'csqf'. Query type would be 's' in your example (:cs find {querytype} {name})
          > Of course, if it is in there in the first place because you want to use the quickfix
          > window for the results of the find in the catch, this really isn't helpful.

          I would like to continue to have the freedom to set 'csqf' to use
          quickfix or not for each query type as I choose. In the actual
          plugin, I have more than just 's' in 'csqf'. Being able to traverse
          the list of places found by "cs find s" and other query types using
          ^N and ^P (mapped to :cn<CR> and :cp<CR>) is really important to
          me--I use that all the time.

          > > > - Revert 433. I had been carrying it around as a private patch for a
          > > > couple of years and find it to very useful.
          > >
          > > I'll try that as soon as I figure out how. I haven't done anything
          > > fancy with Mercurial yet.

          hg backout --merge -r2152
          hg ci

          I just did that and my plugin is now working fine again.

          > > Are you planning on fixing this?
          >
          > Off hand, short of backing it out, I don't see a way to fix it, although
          > it has been awhile since I poked around the Vim source. It makes Cscope
          > behave more like make, grep, etc, which to me, is the a good thing.

          The desired behavior seems like a good thing, but this side effect
          seems like a bug in the implementation, not a natural consequence of
          the desired behavior.

          Regards,
          Gary

          --
          You received this message from the "vim_dev" 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
        • Bryan Venteicher
          ... Sure. I also frequently use the CScope quickfix window. I find it much handier than the :tjump style results paired with :tn and :tp. ... It is a
          Message 4 of 6 , Jul 1, 2010
          • 0 Attachment
            > From: "Gary Johnson" <garyjohn@...>
            > To: "vim dev" <vim_dev@...>
            > Sent: Thursday, July 1, 2010 3:23:01 AM
            > Subject: Re: Bug in Vim 7.2.438: try, catch and cscope

            > On 2010-07-01, Bryan Venteicher wrote:
            > > > From: "Gary Johnson"
            > > > To: "vim dev"
            > > > Sent: Thursday, July 1, 2010 2:04:42 AM
            > > > Subject: Re: Bug in Vim 7.2.438: try, catch and cscope
            > >
            > > > On 2010-07-01, Bryan Venteicher wrote:
            > > > > > From: "Gary Johnson"
            > > > > > To: "vim dev"
            > > > > > Sent: Tuesday, June 29, 2010 5:40:39 PM
            > > > > > Subject: Bug in Vim 7.2.438: try, catch and cscope
            > > > >
            > > > > > After a recent update, I started noticing erroneous behavior
            > > > > > in a
            > > > > > number of my cscope mappings. After some experimenting I
            > > > > > discovered that Vim is failing to execute a "cs find" command
            > > > > > when it follows a
            > > > > > "cs add" command in a catch block. This has worked fine for a
            > > > > > long time and through Vim 7.2.148 but stopped working at or
            > > > > > before Vim
            > > > > > 7.2.438.
            > > > > >
            > > > > > I boiled my configuration and functions down to the following
            > > > > > plugin.
            > > > > >
            > > > > > ------------------------ cscope.vim ------------------------
            > > > > > set laststatus=2
            > > > > > set cmdheight=10
            > > > > >
            > > > > > set csverb
            > > > > > set csqf=s-
            > > > > >
            > > > > > function! Csfind()
            > > > > > try let x = y
            > > > > > catch /.*/
            > > > > > echo v:exception
            > > > > > cs add cscope.out
            > > > > > cs find s mch_early_init
            > > > > > echo "Here"
            > > > > > endtry endfunction
            > > > > > ------------------------------------------------------------
            > > > > >
            > > > >
            > > > > I wager I altered this when I submitted 7.2.433, adding CScope
            > > > > QuickFixCmd{Pre,Post} autocmd event similar to what already
            > > > > exists for make, grep, etc. If you try to say a :vimgrep in your
            > > > > catch block, that goes no where too, right?
            > > > >
            > > > > A few potential fixes come to mind:
            > > > > - If you're not explicity needing it, remove the query type from
            > > > > 'csfs'
            > > > > in the catch block.
            > > >
            > > > I didn't understand that. What is 'csfs' and what is removing the
            > > > query type?
            > >
            > > Fat fingers: 'csqf'. Query type would be 's' in your example (:cs
            > > find {querytype} {name})
            > > Of course, if it is in there in the first place because you want to
            > > use the quickfix
            > > window for the results of the find in the catch, this really isn't
            > > helpful.
            >
            > I would like to continue to have the freedom to set 'csqf' to use
            > quickfix or not for each query type as I choose. In the actual
            > plugin, I have more than just 's' in 'csqf'. Being able to traverse
            > the list of places found by "cs find s" and other query types using
            > ^N and ^P (mapped to :cn<CR> and :cp<CR>) is really important to
            > me--I use that all the time.

            Sure. I also frequently use the CScope quickfix window. I find it much
            handier than the :tjump style results paired with :tn and :tp.

            > > > > - Revert 433. I had been carrying it around as a private patch
            > > > > for a
            > > > > couple of years and find it to very useful.
            > > >
            > > > I'll try that as soon as I figure out how. I haven't done anything
            > > > fancy with Mercurial yet.
            >
            > hg backout --merge -r2152
            > hg ci
            >
            > I just did that and my plugin is now working fine again.
            >
            > > > Are you planning on fixing this?
            > >
            > > Off hand, short of backing it out, I don't see a way to fix it,
            > > although it has been awhile since I poked around the Vim source. It
            > > makes Cscope
            > > behave more like make, grep, etc, which to me, is the a good thing.
            >
            > The desired behavior seems like a good thing, but this side effect
            > seems like a bug in the implementation, not a natural consequence of
            > the desired behavior.

            It is a consequence of how Vim keeps track if there is currently an
            exception and matching the behavior of make and friends.

            Perhaps something like this is suitable for your script:
            function! Csfind()
            try
            cs add cscope.out
            catch /E568: duplicate cscope database not added/
            catch
            throw v:exception
            endtry

            cs find ...
            endfunction

            >
            > Regards,
            > Gary
            >
            > -- You received this message from the "vim_dev" 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 from the "vim_dev" 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
          Your message has been successfully submitted and would be delivered to recipients shortly.