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

Re: patch: perl syntax folding independent of coding style

Expand Messages
  • Erik Falor
    ... Not to be uber-nitpicky, but what do you folks think about changing all of the variables that control the script s behavior (ie. perl_include_pod,
    Message 1 of 8 , Nov 5, 2008
    • 0 Attachment
      On Wed, Nov 5, 2008 at 1:20 PM, Benjamin Fritz <fritzophrenic@...> wrote:

      On Wed, Nov 5, 2008 at 1:18 PM, Frew <frioux@...> wrote:
      >>
      >> Two bugs that I've found while using this patch with real perl code:
      >>
      >> 1) Commented-out lines can end a fold region
      >> 2) The closing brace in code like $abc{def} ends fold regions
      >>
      >> Bug 1 is fixed by adding a skip group to the perlSubFold and
      >> perlBlockFold definitions: skip="#.*"
      >> Bug 2 is something I will try to fix later unless someone beats me to
      >> it.
      >>
      >> I have yet to see any feedback or developments on this other than an
      >> "I'll look at it" from the script maintainer. Has anyone tried this?
      >
      > I just found this and patched the file.  Maybe I patched it
      > incorrectly (I don't have patch handy atm) but it seems to fold
      > anything with { and }, that is, if I do this:
      >
      > sub foo {
      >   $blah->bar($self->{test});
      >
      >   more..
      > }
      >
      > just the first two lines get folded.
      >
      > Hope that helps some.
      >
      > -fREW
      >

      That does help some, it falls into bug (2) that I listed, which I
      suspect is very common.

      Unfortunately, I am very much a beginner at perl, and am not very
      familiar with the syntax, so it may take me a little while. I suspect
      the best way to proceed might be to just make another group that folds
      all {...} blocks that aren't the special cases like if, sub, etc. I'll
      try to get to it sometime this month, unless someone else fixes it
      first of course :-)


      So far, so good.

      Not to be uber-nitpicky, but what do you folks think about changing all of the variables that control the script's behavior (ie. perl_include_pod, perl_fold, etc.) from globals to buffer-locals?  

      I like to set parameters such as these from from my after/ftplugin/*.vim files so as to keep my .vimrc neat and trim.  Similarly, I think it is better (at least aesthetically) to not clutter the global namespace with variables that only apply to particular buffers.

      Food for thought,

      Erik


      --
      Erik Falor
      Registered Linux User #445632 http://counter.li.org

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---

    • Tony Mechelynck
      ... Maybe buffer-local, and if undefined at plugin load, default to the global variable (if any) of the same name? Best regards, Tony. -- I walked on toward
      Message 2 of 8 , Nov 5, 2008
      • 0 Attachment
        On 06/11/08 00:48, Erik Falor wrote:
        >
        >
        > On Wed, Nov 5, 2008 at 1:20 PM, Benjamin Fritz <fritzophrenic@...
        > <mailto:fritzophrenic@...>> wrote:
        >
        >
        > On Wed, Nov 5, 2008 at 1:18 PM, Frew <frioux@...
        > <mailto:frioux@...>> wrote:
        > >>
        > >> Two bugs that I've found while using this patch with real perl code:
        > >>
        > >> 1) Commented-out lines can end a fold region
        > >> 2) The closing brace in code like $abc{def} ends fold regions
        > >>
        > >> Bug 1 is fixed by adding a skip group to the perlSubFold and
        > >> perlBlockFold definitions: skip="#.*"
        > >> Bug 2 is something I will try to fix later unless someone beats
        > me to
        > >> it.
        > >>
        > >> I have yet to see any feedback or developments on this other than an
        > >> "I'll look at it" from the script maintainer. Has anyone tried this?
        > >
        > > I just found this and patched the file. Maybe I patched it
        > > incorrectly (I don't have patch handy atm) but it seems to fold
        > > anything with { and }, that is, if I do this:
        > >
        > > sub foo {
        > > $blah->bar($self->{test});
        > >
        > > more..
        > > }
        > >
        > > just the first two lines get folded.
        > >
        > > Hope that helps some.
        > >
        > > -fREW
        > >
        >
        > That does help some, it falls into bug (2) that I listed, which I
        > suspect is very common.
        >
        > Unfortunately, I am very much a beginner at perl, and am not very
        > familiar with the syntax, so it may take me a little while. I suspect
        > the best way to proceed might be to just make another group that folds
        > all {...} blocks that aren't the special cases like if, sub, etc. I'll
        > try to get to it sometime this month, unless someone else fixes it
        > first of course :-)
        >
        >
        > So far, so good.
        >
        > Not to be uber-nitpicky, but what do you folks think about changing all
        > of the variables that control the script's behavior (ie.
        > perl_include_pod, perl_fold, etc.) from globals to buffer-locals?
        >
        > I like to set parameters such as these from from my after/ftplugin/*.vim
        > files so as to keep my .vimrc neat and trim. Similarly, I think it is
        > better (at least aesthetically) to not clutter the global namespace with
        > variables that only apply to particular buffers.
        >
        > Food for thought,
        >
        > Erik
        >
        >
        > --
        > Erik Falor
        > Registered Linux User #445632 http://counter.li.org

        Maybe buffer-local, and if undefined at plugin load, default to the
        global variable (if any) of the same name?

        Best regards,
        Tony.
        --
        I walked on toward Ploughwright, thinking about feces. What a lot we
        had found out about the prehistoric past from the study of fossilized
        dung of long-vanished animals. A miraculous thing, really; a recovery
        from the past from what was carelessly rejected. And in the Middle
        Ages, how concerned people who lived close to the world of nature were
        with the feces of animals. And what a variety of names they had for
        them: the Crotels of a Hare, the Friants of a Boar, the Spraints of
        an Otter, the Werderobe of a Badger, the Waggying of a Fox, the Fumets
        of a Deer. Surely there might be some words for the material so near
        to the heart of Ozy Froats [an academic studying feces] than shit?
        What about the Problems of a President, the Backward Passes of a
        Footballer, the Deferrals of a Dean, the Odd Volumes of a Librarian,
        the Footnotes of a Ph.D., the Low Grades of a Freshman, the Anxieties
        of an Untenured Professor?
        -- Robertson Davies, "The Rebel Angels"

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Benjamin Fritz
        ... Actually the fix was fairly easy. Most of the code was already there. I fixed bug 2 as follows: * Force behavior as if perl_extended_vars was set if
        Message 3 of 8 , Nov 7, 2008
        • 0 Attachment
          On Nov 5, 2:20 pm, "Benjamin Fritz" <fritzophre...@...> wrote:
          > On Wed, Nov 5, 2008 at 1:18 PM, Frew <fri...@...> wrote:
          >
          > >> Two bugs that I've found while using this patch with realperlcode:
          >
          > >> 1) Commented-out lines can end a fold region
          > >> 2) The closing brace in code like $abc{def} ends fold regions
          >
          > >> Bug 1 is fixed by adding a skip group to the perlSubFold and
          > >> perlBlockFold definitions: skip="#.*"
          > >> Bug 2 is something I will try to fix later unless someone beats me to
          > >> it.
          >
          > >> I have yet to see any feedback or developments on this other than an
          > >> "I'll look at it" from the script maintainer. Has anyone tried this?
          >
          > > I just found this and patched the file. Maybe I patched it
          > > incorrectly (I don't have patch handy atm) but it seems to fold
          > > anything with { and }, that is, if I do this:
          >
          > > sub foo {
          > > $blah->bar($self->{test});
          >
          > > more..
          > > }
          >
          > > just the first two lines get folded.
          >
          > > Hope that helps some.
          >
          > > -fREW
          >
          > That does help some, it falls into bug (2) that I listed, which I
          > suspect is very common.
          >
          > Unfortunately, I am very much a beginner atperl, and am not very
          > familiar with thesyntax, so it may take me a little while. I suspect
          > the best way to proceed might be to just make another group that folds
          > all {...} blocks that aren't the special cases like if, sub, etc. I'll
          > try to get to it sometime this month, unless someone else fixes it
          > first of course :-)

          Actually the fix was fairly easy. Most of the code was already there.
          I fixed bug 2 as follows:

          * Force behavior as if perl_extended_vars was set if perl_fold is set.
          * Add an "extend" keyword to quote/match/string/substitution groups

          I also fixed another bug where some character was required to occur on
          the same line as a BEGIN, END, etc. or sub block after the opening
          keyword for the group to match.

          See attached patch, which is (so far as I know) bug free (or at least,
          doesn't introduce any bugs). I may have missed some
          string/quote/match/etc. groups, though...there are quite a few.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Benjamin Fritz
          ... One more bugfix, for this test case (note this was also present in the unpatched file): if (1) { my %arr=( a = hello , b = goodbye ); print $arr{ a };
          Message 4 of 8 , Nov 7, 2008
          • 0 Attachment
            On Fri, Nov 7, 2008 at 10:57 AM, Benjamin Fritz <fritzophrenic@...> wrote:
            > See attached patch, which is (so far as I know) bug free (or at least,
            > doesn't introduce any bugs). I may have missed some
            > string/quote/match/etc. groups, though...there are quite a few.
            >

            One more bugfix, for this test case (note this was also present in the
            unpatched file):

            if (1)
            {
            my %arr=('a'=>"hello",'b'=>"goodbye");
            print $arr{'a'};
            print "\n";
            print $arr {'b'};
            print "\n";
            print ${arr}{'a'};
            print "\n";
            print ${arr} {'b'};
            print "\n";
            }

            --~--~---------~--~----~------------~-------~--~----~
            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.