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

Re: [vim] ANNC: v15 of engspchk

Expand Messages
  • Charles E. Campbell
    ... Hello! The problem with these matches isn t that they don t work in isolation, its that matches have a lower syntax highlighting priority than do keywords.
    Message 1 of 20 , Sep 2, 2002
    • 0 Attachment
      On Sun, Sep 01, 2002 at 09:18:04PM -0400, Steve Hall wrote:
      > From: "Benji Fisher" <benji@...>
      > >
      > > Steve Hall wrote:
      > > > * Repeated word checking....
      > > How do these fail? I prefer yet another variant:
      > >
      > > /\<\(\k\+\)\_s\+\1\>
      > >
      >
      > Do they work for you? That's encouraging.
      >
      > I am actually using these in an engspchk variant...
      ---------------------------------------------------------------------

      Hello!

      The problem with these matches isn't that they don't work in
      isolation, its that matches have a lower syntax highlighting
      priority than do keywords. A correctly spelled word is
      recognized as a GoodWord (keyword) before the match looking
      for repeated words gets a chance.

      Regards,
      Chip Campbell

      --
      Charles E Campbell, Jr, PhD _ __ __
      Goddard Space Flight Center / /_/\_\_/ /
      cec@... /_/ \/_//_/
      PGP public key: http://www.erols.com/astronaut/pgp.html
    • Benji Fisher
      ... How can we get around this? The obvious solution is not to use :syn keyword at all, just use :syn match . This would probably lead to a big
      Message 2 of 20 , Sep 2, 2002
      • 0 Attachment
        "Charles E. Campbell" wrote:
        >
        > On Sun, Sep 01, 2002 at 09:18:04PM -0400, Steve Hall wrote:
        > > From: "Benji Fisher" <benji@...>
        > > >
        > > > Steve Hall wrote:
        > > > > * Repeated word checking....
        > > > How do these fail? I prefer yet another variant:
        > > >
        > > > /\<\(\k\+\)\_s\+\1\>
        > > >
        > >
        > > Do they work for you? That's encouraging.
        > >
        > > I am actually using these in an engspchk variant...
        > ---------------------------------------------------------------------
        >
        > Hello!
        >
        > The problem with these matches isn't that they don't work in
        > isolation, its that matches have a lower syntax highlighting
        > priority than do keywords. A correctly spelled word is
        > recognized as a GoodWord (keyword) before the match looking
        > for repeated words gets a chance.

        How can we get around this? The obvious solution is not to use ":syn
        keyword" at all, just use ":syn match". This would probably lead to a big
        performance hit. Is there a more clever situation? Maybe use the above pattern
        to define a syntax region, so that keywords are not recognized within the
        region? (I have never used ":syn region" myself, so I hope Chip or some other
        syntax guru will either flesh this idea out or put it out of its misery.)

        HTH --Benji Fisher
      • Charles E. Campbell
        ... That is something we definitely don t want to do. ... One thing that I do for is use a match to recognizes all potential words; the match
        Message 3 of 20 , Sep 3, 2002
        • 0 Attachment
          On Mon, Sep 02, 2002 at 09:15:49PM -0400, Benji Fisher wrote:
          > How can we get around this? The obvious solution is not to use ":syn
          > keyword" at all, just use ":syn match". This would probably lead to a big
          > performance hit.

          That is something we definitely don't want to do.

          > Is there a more clever situation?

          One thing that I do for <vim.vim> is use a match to recognizes all
          potential words; the match contains the keyword list.

          syn match MatchMaker "\k\+" contains=GoodWord,BadWord

          Then the double-word match syntax would be able to use
          priority and thus take effect. This approach would also result
          in a performance hit, although not as bad as making all the
          GoodWords matches.

          Alternatively one could recognize the double-word ahead of the
          keyword recognition:

          syn match DoubleWord "\s\(\k\+\)\_s\+\1\>"ms=s+1

          Thus the DoubleWord starts its recognition pass on a leading
          whitespace. Of course lines which begin with double-words
          like like this one would not be found.

          > Maybe use the above pattern
          > to define a syntax region, so that keywords are not recognized within the
          > region?

          Keywords have top priority over both matches *and* regions.

          Regards,
          Chip Campbell

          --
          Charles E Campbell, Jr, PhD _ __ __
          Goddard Space Flight Center / /_/\_\_/ /
          cec@... /_/ \/_//_/
          PGP public key: http://www.erols.com/astronaut/pgp.html
        • digitect@mindspring.com
          From: Charles E. Campbell ... Not sure I understand why it needs to begin with whitespace. All of the possibilities so far use
          Message 4 of 20 , Sep 3, 2002
          • 0 Attachment
            From: "Charles E. Campbell" <cec@...>
            >
            > On Mon, Sep 02, 2002 at 09:15:49PM -0400, Benji Fisher wrote:
            > >
            > > How can we get around this?....Is there a more clever situation?
            >
            > Alternatively one could recognize the double-word ahead of the
            > keyword recognition:
            >
            > syn match DoubleWord "\s\(\k\+\)\_s\+\1\>"ms=s+1
            >
            > Thus the DoubleWord starts its recognition pass on a leading
            > whitespace. Of course lines which begin with double-words like like
            > this one would not be found.

            Not sure I understand why it needs to begin with whitespace. All of
            the possibilities so far use the "\<" word beginning to define the
            start of the pattern:

            " Bram Moolenaar:
            "syntax match BadWord "\(\<\k\+\>\)\s\+\1"
            " Preben Peppe Guldberg:
            "syntax match BadWord "\(\<\k\+\>\)\s\+\1\>"
            " Gary Holloway:
            "syntax match BadWord "\(\<\k\+\>\)\(\_s\+\<\1\>\)\+"
            " Rober Montante:
            "syntax match BadWord "\(\<\w\+\>\)\_s*\1\>"
            " Benji Fisher:
            "syntax match BadWord "\<\(\k\+\)\_s\+\1\>"
            " Steve Hall:
            "syntax match BadWord "\(\<\k\+\>\)\s\+\1"

            Wouldn't that suffice?


            Steve Hall [ digitect@... ]
          • Preben 'Peppe' Guldberg
            ... I think that should read ... hs=s+1 ... Hi :-) ... Try the following commands in turn and watch the result Maps to execute some vim ex commands. With
            Message 5 of 20 , Sep 3, 2002
            • 0 Attachment
              Thus wrote digitect@... (digitect@...) on [020903]:
              > From: "Charles E. Campbell" <cec@...>

              > > syn match DoubleWord "\s\(\k\+\)\_s\+\1\>"ms=s+1

              I think that should read "..."hs=s+1

              > > Thus the DoubleWord starts its recognition pass on a leading
              > > whitespace. Of course lines which begin with double-words like like
              > > this one would not be found.

              > Not sure I understand why it needs to begin with whitespace. All of
              > the possibilities so far use the "\<" word beginning to define the
              > start of the pattern:

              > " Preben Peppe Guldberg:
              > "syntax match BadWord "\(\<\k\+\>\)\s\+\1\>"

              Hi :-)

              > Wouldn't that suffice?

              Try the following commands in turn and watch the result

              " Maps to execute some vim ex commands.
              " With "mapleader=','", use ",@@" to execute.
              nmap <Leader>@@ yy:@"<CR>
              vmap <Leader>@@ y:@"<CR>
              "
              " Syntax items
              syn clear
              syn match Todo "\<\(\k\+\)\s\+\1\>"
              syn keyword Special good bad ugly
              syn match Error "\s\(\k\+\)\s\+\1\>"hs=s+1
              "
              " Example text:
              "
              " good good bad ugly ugly

              Note that the order of the Todo and Special lines don't matter. Keywords
              win over matches and regions at any time.

              Peppe
              --
              Preben 'Peppe' Guldberg __/-\__ "Before you criticize someone, walk
              peppe@... (o o) a mile in his shoes. That way, if
              -----------------------oOOo (_) oOOo-- he gets angry, he'll be a mile away
              http://www.xs4all.nl/~peppe/ - and barefoot." --Sarah Jackson
            • Charles E. Campbell
              ... In a word, no. It would suffice to pick up two identically misspelled words in a row, but here we re considering correctly spelled words that are doubled
              Message 6 of 20 , Sep 3, 2002
              • 0 Attachment
                On Tue, Sep 03, 2002 at 11:57:15AM -0400, digitect@... wrote:
                > Not sure I understand why it needs to begin with whitespace. All of
                > the possibilities so far use the "\<" word beginning to define the
                > start of the pattern:
                >
                > " Bram Moolenaar:
                > "syntax match BadWord "\(\<\k\+\>\)\s\+\1"
                > " Preben Peppe Guldberg:
                > "syntax match BadWord "\(\<\k\+\>\)\s\+\1\>"
                > " Gary Holloway:
                > "syntax match BadWord "\(\<\k\+\>\)\(\_s\+\<\1\>\)\+"
                > " Rober Montante:
                > "syntax match BadWord "\(\<\w\+\>\)\_s*\1\>"
                > " Benji Fisher:
                > "syntax match BadWord "\<\(\k\+\)\_s\+\1\>"
                > " Steve Hall:
                > "syntax match BadWord "\(\<\k\+\>\)\s\+\1"
                >
                > Wouldn't that suffice?
                ---------------------------------------------------------------------

                In a word, no.

                It would suffice to pick up two identically misspelled words in a row,
                but here we're considering correctly spelled words that are doubled
                up. The misspelled words get caught as misspellings anyway.

                Consider the next line:

                one one is not two.

                At the point of the first "o", the word "one" is immediately
                identified as a GoodWord by the list of keywords. None of the matches
                given above then get a chance to identify "one one".

                The leading whitespace in the pattern allows the syntax highlighting
                to try out the match on a blank, which none of the keywords will do,
                and so the match gets a sporting chance to do its thing. Obviously
                this won't catch the "one one" in my example because there's no
                leading blank.

                The alternative method would work better; ie., have all words recognized
                as part of some match ("\<\w\+\>") which contains GoodWord's and
                BadWords. The doubled-word syntax matches then have a shot at
                identifying doubled words. There'll be a speed penalty because the
                word-recognizer pattern will be used almost everywhere.

                Regards,
                Chip Campbell

                --
                Charles E Campbell, Jr, PhD _ __ __
                Goddard Space Flight Center / /_/\_\_/ /
                cec@... /_/ \/_//_/
                PGP public key: http://www.erols.com/astronaut/pgp.html
              Your message has been successfully submitted and would be delivered to recipients shortly.