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

Re: Global cpo_save

Expand Messages
  • Bram Moolenaar
    ... I ll fix vim.vim and matchparen.vim. Sorry I didn t notice this mistake before. I ll leave hamster.vim to David. -- How To Keep A Healthy Level Of
    Message 1 of 7 , Sep 3, 2008
    View Source
    • 0 Attachment
      Bill McCarthy wrote:

      > Hello Vim Developers,
      >
      > I noticed a global variable that doesn't appear to be
      > intentionally set. The variable `cpo_save' undecorated and
      > outside a function is implicitly global.
      >
      > Unfortunately `verbose let' does not reveal where it is set.
      > I found three places - there could be more:
      >
      > vim72/ftplugin/hamster.vim
      > vim72/ftplugin/vim.vim
      > vim72/plugin/matchparen.vim
      >
      > The solution is to (1) prefix with `s:', (2) unlet, or (3)
      > do both.

      I'll fix vim.vim and matchparen.vim. Sorry I didn't notice this mistake
      before.

      I'll leave hamster.vim to David.

      --
      How To Keep A Healthy Level Of Insanity:
      15. Five days in advance, tell your friends you can't attend their
      party because you're not in the mood.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Bill McCarthy
      ... Thanks! Most scripts follow the same scheme, starting with let s:cpo_save = &cpo adjust cpo and end with let &cpo = s:cpo_save unlet s:cpo_save Besides
      Message 2 of 7 , Sep 3, 2008
      View Source
      • 0 Attachment
        On Wed 3-Sep-08 3:12pm -0600, Bram Moolenaar wrote:
        > Bill McCarthy wrote:

        >> I noticed a global variable that doesn't appear to be
        >> intentionally set. The variable `cpo_save' undecorated and
        >> outside a function is implicitly global.
        >>
        >> Unfortunately `verbose let' does not reveal where it is set.
        >> I found three places - there could be more:
        >>
        >> vim72/ftplugin/hamster.vim
        >> vim72/ftplugin/vim.vim
        >> vim72/plugin/matchparen.vim
        >>
        >> The solution is to (1) prefix with `s:', (2) unlet, or (3)
        >> do both.

        > I'll fix vim.vim and matchparen.vim. Sorry I didn't notice this mistake
        > before.
        >
        > I'll leave hamster.vim to David.

        Thanks!

        Most scripts follow the same scheme, starting with

        let s:cpo_save = &cpo
        " adjust cpo

        and end with

        let &cpo = s:cpo_save
        unlet s:cpo_save

        Besides the 3 I mentioned, ftplugin/abaqus.vim fails to

        unlet s:cpo_save

        A very minor oversight.

        --
        Best regards,
        Bill



        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Bill McCarthy
        ... Thanks for your and Ben s comments. Of course simply adding an unlet doesn t solve the problem. The problem is that a global is used. If you had a
        Message 3 of 7 , Sep 3, 2008
        View Source
        • 0 Attachment
          On Tue 2-Sep-08 11:41pm -0600, Tony Mechelynck wrote:
          > On 03/09/08 06:11, Bill McCarthy wrote:

          >> I noticed a global variable that doesn't appear to be
          >> intentionally set. The variable `cpo_save' undecorated and
          >> outside a function is implicitly global.
          >>
          >> Unfortunately `verbose let' does not reveal where it is set.
          >> I found three places - there could be more:
          >>
          >> vim72/ftplugin/hamster.vim
          >> vim72/ftplugin/vim.vim
          >> vim72/plugin/matchparen.vim
          >>
          >> The solution is to (1) prefix with `s:', (2) unlet, or (3)
          >> do both.

          > In this case, the above precautions are prudent, but only really
          > necessary if those scripts can interrupt each other, which I don't think
          > can happen in this case. I believe that in the first two cases above,
          > prefixing with b: might also be a valid solution.

          Thanks for your and Ben's comments. Of course simply adding
          an "unlet" doesn't solve the problem. The problem is that a
          global is used. If you had a global that stored Captain
          Paul Olsen's SAV(E)ings - it gets wiped out. Globals should be
          used very sparingly and only when necessary.

          Yes, `b:' would be an adequate alternate - although IMHO
          `s:' is more natural. And please `unlet' - I know nobody is
          running a 64k machine anymore, but why waste space?

          --
          Best regards,
          Bill



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