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

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

Expand Messages
  • Nikolai Weibull
    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
    Message 1 of 8 , Apr 9 1:28 PM
    • 0 Attachment
      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]$

      but I'm not sure; I haven't been able to find a reference for the
      display of manual pages.

      Anyone have any insight into this issue?

      nikolai
    • Charles E Campbell Jr
      ... I suggest bringing up syntax highlighting issues for a specific filetype with the syntax highlighting file s maintainer. In this case, by looking at
      Message 2 of 8 , Apr 9 1:34 PM
      • 0 Attachment
        Nikolai Weibull 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]$
        >
        > but I'm not sure; I haven't been able to find a reference for the
        > display of manual pages.
        >
        > Anyone have any insight into this issue?

        I suggest bringing up syntax highlighting issues for a specific filetype
        with the syntax highlighting file's maintainer.
        In this case, by looking at syntax/man.vim, its: Gautam H. Mudunuri
        <gmudunur AT informatica.com>.

        Regards,
        Chip Campbell
      • Nikolai Weibull
        ... Or, as the file mentions four lines down, Johannes Tanzler , who was responsible for this particular rule. However, I reasoned
        Message 3 of 8 , Apr 9 2:27 PM
        • 0 Attachment
          On 4/9/07, Charles E Campbell Jr <drchip@...> wrote:
          > Nikolai Weibull 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.

          > > Anyone have any insight into this issue?

          > I suggest bringing up syntax highlighting issues for a specific filetype
          > with the syntax highlighting file's maintainer.
          > In this case, by looking at syntax/man.vim, its: Gautam H. Mudunuri
          > <gmudunur AT informatica.com>.

          Or, as the file mentions four lines down, Johannes Tanzler
          <johannes.tanzler@...>, who was responsible for this particular
          rule. However, I reasoned that someone with better knowledge than
          myself of the output format of manual pages could jump in and correct
          me or, better yet, confirm my change. I would then be in a position
          to post a patch to the maintainer. If the maintainer or the person
          responsible for this particular rule has subscribed to this list, then
          they would also benefit from this discussion. Sure, I could have
          Cc:ed the responsible parties right away, but I figured that if they
          don't subscribe to this list they don't want bothersome emails about
          syntax-highlighting definitions that don't have a conclusion to an
          issue at hand.

          Some further digging has revealed that what manSubHeading tries to
          match is lines marked as ".SS", that is "Subsection Heading", and that
          groff and nroff formats these lines with an indent of three spaces, so
          my initial suspicion was correct. I'll therefore contact the
          appropriate parties with a unified diff.

          nikolai
        • Nikolai Weibull
          ... Actually, this was actually the wrong maintainer. Gautam was the previous maintainer of this file. Nam SungHyun maintains it now.
          Message 4 of 8 , Apr 9 2:29 PM
          • 0 Attachment
            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.

            nikolai
          • Ian Tegebo
            ... 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
            Message 5 of 8 , Apr 9 2:37 PM
            • 0 Attachment
              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$'

              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?

              --
              Ian Tegebo
            • 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 6 of 8 , Apr 9 2:55 PM
              • 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 7 of 8 , Apr 10 6:44 AM
                • 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 8 of 8 , Apr 10 7:06 AM
                  • 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.