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

Re: syntax/man.vim: manSubHeading is a bit too general?

Expand Messages
  • Nikolai Weibull
    ... Yes, and it may be more correct as well, at least in the first and last instance. However, the second part may also contain a space, so l isn t correct
    Message 1 of 8 , Apr 9, 2007
    • 0 Attachment
      On 4/9/07, Ian Tegebo <ian.tegebo@...> wrote:
      > On 4/9/07, Nikolai Weibull <now@...> wrote:

      > > ^ \{3\}[a-z][a-z ]*[a-z]$
      > I hope nobody minds if I take this opportunity to ask a question about
      > vim's pattern matching.
      >
      > After reading |pattern| I wonder if the following is more efficient:
      >
      > syn match manSubHeading '^ \{3\}\l\l\?\l$'

      Yes, and it may be more correct as well, at least in the first and
      last instance. However, the second part may also contain a space, so
      \l isn't correct there; and I don't know where you get that \? from.
      This is the correct pattern:

      ^ \{3}\l[[:alpha:] ]*\l$

      (I also noticed that the apparently accepted "\{m\}" is being used in
      this file instead of the documented "\{m}")

      One can of course ask oneself if a subsection heading must consist of
      at least two letters. I'm guessing that the intent was to force the
      line to end with a non-space:

      ^ \{3}\l\%([[:alpha:] ]*\l\)\=$

      In fact, I'd prefer it be written as

      ^ \{3}\a\%([[:alpha:] ]*\a\)\=$

      as 'syn case ignore' is on, \l and \a will be the same. However, \a
      meshes better with [:alpha:] and may, depending on how all this is
      implemented, be a miniscule amount faster.

      > Taken from |pattern|:
      >
      > - Matching with a collection can be slow, because each character in
      > the text has to be compared with each character in the collection.
      > Use one of the other atoms above when possible. Example: "\d" is
      > much faster than "[0-9]" and matches the same characters
      >
      > Do people find this to make a different for moderate file sizes, e.g.
      > the man page for 'less' being ~2000 lines?

      Probably not.

      nikolai
    • Charles E Campbell Jr
      ... (snip) The pattern you ve provided isn t matching the same thing. The current one: start the line with exactly three spaces or tabs, followed by a lower
      Message 2 of 8 , Apr 10, 2007
      • 0 Attachment
        Ian Tegebo wrote:

        > On 4/9/07, Nikolai Weibull <now@...> wrote:
        >
        >> The manSubHeading is defined as
        >>
        >> syn match manSubHeading "^\s\{3\}[a-z][a-z ]*[a-z]$"
        >>
        >> This will, however, match more lines than I think is intended. It
        >> will, for example, match the line
        >>
        >> \t returns are what are recorded and compared with the data git keeps
        >>
        >> where "\t" is a horizontal tabulation. I'm guessing that the actual
        >> regex should be
        >>
        >> ^ \{3\}[a-z][a-z ]*[a-z]$
        >
        > I hope nobody minds if I take this opportunity to ask a question about
        > vim's pattern matching.
        >
        > After reading |pattern| I wonder if the following is more efficient:
        >
        > syn match manSubHeading '^ \{3\}\l\l\?\l$'

        (snip)

        The pattern you've provided isn't matching the same thing.
        The current one: start the line with exactly three spaces or tabs,
        followed by a lower case character, followed by any number of
        lower case characters or spaces, up to a lower case character
        at the end-of-line.

        example: <space><tab><space>aaaa aaa aaaaaa

        Nikolai W's modifies that to "start the line with exactly three spaces"; the
        rest is the same.

        example: <space><space><space>aaa aaaaaa aaa

        Yours: start the line with exactly three spaces, followed by two or three
        lower case characters, which then terminates the line.

        example: <space><space><space>aa

        > Do people find this to make a different for moderate file sizes, e.g.
        > the man page for 'less' being ~2000 lines?


        Depends on the line lengths. Your pattern would terminate quite
        quickly on each line, as only 5 or 6 characters may be at the beginning
        of matching lines; anything more is a mismatch. The original and NW's
        both examine the entire line; so if every line had 1GB of characters, these
        two patterns would take considerably longer than yours.

        Regards,
        Chip Campbell
      • Charles E Campbell Jr
        ... Whoops -- yes, you re quite right. Sorry bout that... Chip Campbell
        Message 3 of 8 , Apr 10, 2007
        • 0 Attachment
          Nikolai Weibull wrote:

          > On 4/9/07, Charles E Campbell Jr <drchip@...> wrote:
          >
          >> In this case, by looking at syntax/man.vim, its: Gautam H. Mudunuri
          >> <gmudunur AT informatica.com>.
          >
          >
          > Actually, this was actually the wrong maintainer. Gautam was the
          > previous maintainer of this file. Nam SungHyun <namsh@...>
          > maintains it now.

          Whoops -- yes, you're quite right. Sorry 'bout that...

          Chip Campbell
        Your message has been successfully submitted and would be delivered to recipients shortly.