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

Re: [patch] Allow 'highlight' command to add to existing terminal attributes.

Expand Messages
  • Bram Moolenaar
    ... I like the idea, but I would prefer to use += and -=, just like :set. Also, can you write a test for correct behavior? The documentation should mention
    Message 1 of 5 , Dec 2, 2012
    • 0 Attachment
      so8res wrote:

      > With this patch you can do the following:
      >
      > syntax match Foo 'foo'
      > highlight Foo cterm=bold ctermfg=red
      > highlight Foo cterm+italic
      >
      > and now Foo is both bold and italic.
      >
      > Motivation:
      >
      > http://stackoverflow.com/questions/13640538/vim-syntax-files-add-to-cterm
      >
      > This makes it far easier to use terminal attributes on nested syntax
      > regions, e.g. to add bold to text that is already underlined without
      > losing the color.
      >
      > The patch also allows terminal attributes to be removed.

      I like the idea, but I would prefer to use += and -=, just like :set.

      Also, can you write a test for correct behavior?

      The documentation should mention what happens when trying to remove a
      value that isn't there. Is it a warning, error, or ignored?

      The error for unexpected plus sign should be put in a function instead
      of writing that code several times.


      --
      I AM THANKFUL...
      ...for the taxes that I pay because it means that I am employed.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • So8res
      ... Done. ... Added += and -= tests to test51. I ve split the src/ diff into a src/syntax.c diff and a src/testdir/ diff. Let me know if you prefer the
      Message 2 of 5 , Dec 2, 2012
      • 0 Attachment
        > I like the idea, but I would prefer to use += and -=, just like :set.

        Done.

        > Also, can you write a test for correct behavior?

        Added += and -= tests to test51.

        I've split the "src/" diff into a "src/syntax.c" diff and a "src/testdir/" diff. Let me know if you prefer the diffs split up differently in the future.

        > The documentation should mention what happens when trying to remove a
        >
        > value that isn't there. Is it a warning, error, or ignored?

        It's ignored. I think this is the correct behavior, it allows you to do

        highlight Unbold term-=bold

        and apply it to any syntax group without worrying about whether or not it will apply.

        Docs have been updated.

        > The error for unexpected plus sign should be put in a function instead
        >
        > of writing that code several times.

        I extracted it into a function. It's not the cleanest, because the block of code has to set the local 'error' variable and do a break. I took the route of least replication.

        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • So8res
        Unfortunately, this doesn t address my StackOverflow question entirely, nor does it make it possible to avoid the workaround mentioned. This patch allows you
        Message 3 of 5 , Dec 2, 2012
        • 0 Attachment
          Unfortunately, this doesn't address my StackOverflow question entirely, nor does it make it possible to avoid the workaround mentioned.

          This patch allows you to update a single highlight group, but it does not allow you to create a modifier highlight group. In other words, if you have

          highlight Italic cterm=italic
          highlight Bold cterm+=bold

          then even if you match 'Bold' inside 'Italic' you only get the 'Bold' highlighting, not a combination of the two.

          I'd like to add a new highlight type of the form

          highlight modifier Bold cterm=bold

          which (in this example) would continue highlighting with the previous matchgroup but *add* the bold terminal attribute.

          This feature is a bit more involved than the above patch -- Bram, would you accept such a feature? I don't want to waste my efforts.

          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • So8res
          Correction -- it would have to be a new syntax type, not a new highlight type. You d have syntax modifier region bold start= * end= * highlight Bold
          Message 4 of 5 , Dec 2, 2012
          • 0 Attachment
            Correction -- it would have to be a new syntax type, not a new highlight type. You'd have

            syntax modifier region bold start='\*' end='\*'
            highlight Bold cterm=bold

            This would involve modifying text to have both a base highlight group and an arbitrary number of syntax modifiers active. Thoughts?

            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          Your message has been successfully submitted and would be delivered to recipients shortly.