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

Re: Set different highlighting for Search versus current quickfix error

Expand Messages
  • Benjamin R. Haskell
    ... In case you are (or anyone else is) interested in changing the source, the hard-coding happens at line 2007 of src/quickfix.c¹: 2006:
    Message 1 of 12 , Sep 4, 2013
    • 0 Attachment
      On Wed, 4 Sep 2013, Paul wrote:

      > It seems to be hard coded. Apparently not easy to circumvent:
      > http://stackoverflow.com/questions/13220073/vim-highlight-quickfix-selected-line-with-color-different-than-search
      >

      In case you are (or anyone else is) interested in changing the source,
      the hard-coding happens at line 2007 of src/quickfix.c¹:

      2006: msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
      2007: ? hl_attr(HLF_L) : hl_attr(HLF_D));

      HLF_L is the C constant for the "L"ast search highlighting. So, it's
      not hardcoded to "Search", per se, but rather whatever is in the "l:"
      key of the 'highlight' setting (default "l:Search"). It is,
      unfortunately, linked to actual search highlighting -- i.e. you can't
      have different highlight groups for searching and the active quickfix
      line.

      It's slightly odd that all the other colors in the quickfix window are
      overrideable. The following four groups are defined in
      $VIMRUNTIME/syntax/qf.vim² (default link listed in parens):

      qfFileName (Directory)
      qfSeparator (no default)
      qfLineNr (LineNr)
      qfError (Error)

      --
      Best,
      Ben

      ¹: https://code.google.com/p/vim/source/browse/src/quickfix.c#2007
      ²: Based on that file, it's also clear that quickfix highlighting will
      fail on a filename containing a pipe (blech).

      --
      --
      You received this message from the "vim_use" 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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Paul
      ... Thanks, Ben. Maybe one day. It s been 10 (or more) years since I coded in C++, so it wouldn t be an afternoon jaunt through the code for me. -- -- You
      Message 2 of 12 , Sep 5, 2013
      • 0 Attachment
        On Thursday, September 5, 2013 1:37:12 AM UTC-4, Benjamin R. Haskell wrote:
        > In case you are (or anyone else is) interested in changing the source,
        > the hard-coding happens at line 2007 of src/quickfix.c¹:

        Thanks, Ben. Maybe one day. It's been 10 (or more) years since I coded in C++, so it wouldn't be an afternoon jaunt through the code for me.

        --
        --
        You received this message from the "vim_use" 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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Charles Campbell
        ... Sorry, Tony -- I need to differ with you on this. syntax/qf.vim is a syntax file; it is not a colorscheme, and it is unnecessary to modify or alter any
        Message 3 of 12 , Sep 5, 2013
        • 0 Attachment
          Tony Mechelynck wrote:
          > On 05/09/13 01:12, Paul wrote:
          >> On Wednesday, September 4, 2013 6:44:24 PM UTC-4, Tony Mechelynck wrote:
          >>> On 04/09/13 23:51, Paul wrote:
          >>>> The GUI highlighting for the current quickfix item seems to be the
          >>>> same as whatever I set the Search group to. Is there a way to have
          >>>> a different guibg color?
          >>>
          >>> ...With me it doesn't: I just did a :helpgrep, and the current quickfix
          >>> item didn't get _any_ highlighting: with the cursor on it,
          >>>
          >>> :echomsg synIDattr(synID(line("."),col("."),0),"name")
          >>> synIDattr(synIDtrans(synID(line("."),col("."),0)),"name")
          >>> synIDattr(synID(line("."),col("."),1),"name")
          >>> synIDattr(synIDtrans(synID(line("."),col("."),1)),"name")
          >>>
          >>> ...didn't display anything. Or if it did, it was because there was
          >>> some highlighted syntax item (such as between |bars|) just under the
          >>> cursor.
          >>>
          >>> I'm using gvim 7.4.16 (Huge) with GTK2/GNOME2 GUI.
          >>
          >> I'm using vim 7.3 on Windows 7. When I issue:
          >>
          >> :echomsg synIDattr(synID(line("."),col("."),0),"name")
          >> :echomsg synIDattr(synIDtrans(synID(line("."),col("."),0)),"name")
          >> :echomsg synIDattr(synID(line("."),col("."),1),"name")
          >> :echomsg synIDattr(synIDtrans(synID(line("."),col("."),1)),"name")
          >>
          >> I get:
          >>
          >> qfFileName
          >> Directory
          >> qfFileName
          >> Directory
          >>
          >> It's interesting that you don't see the current quickfix item
          >> highlighted. I thought that maybe I set something to turn on
          >> quickfix highlighting, but I can't seem to find the switch. I
          >> searched the web and the quickfix help to see if quickfix is
          >> *suppose* to highlight the current item by default, but didn't find
          >> indications of that either.
          >>
          >
          > I get the same as you do if I do :copen first. What I referred to was
          > the current quickfix item as found _in the text_ by :cnext, with no
          > quickfix window actually open.
          >
          > I see this item as blue on white, and doing ":verbose hi qfFileName"
          > in the quickfix window gives
          >
          > qfFileName xxx links to Directory
          > Last set from /usr/local/share/vim/vim74/syntax/qf.vim
          >
          > The Search highlight, OTOH, is black on yellow. Not at all the same
          > thing for me, which makes me ask: Which colorscheme are you using?
          >
          > To link qfFileName to something else, or to define specific colours
          > for it, just use a new or modified colorscheme.
          >
          > To modify a colorscheme, first copy it to ~/.vim/colors/ (for *x
          > systems) or to ~/vimfiles/colors (for Windows), change its name, and
          > modify it there (including setting g:colors_name to the new name);
          > then alter the calling line so that it calls the new name. It is not
          > possible to invoke colorschemes recursively (or at least, I tried and
          > didn't succeed).
          Sorry, Tony -- I need to differ with you on this.

          syntax/qf.vim is a syntax file; it is not a colorscheme, and it is
          unnecessary to modify or alter any colorschemes.

          Instead, if you wish to override qfFileName, etc, put your alterations into

          $HOME/after/syntax/qf.vim

          Therein, you may put things such as

          hi link qfFileName Special
          hi qfSeparator guifg=SeaGreen1 guibg=orange3

          Doing so will override syntax/qf.vim's selection of default colors.

          Regards,
          Chip Campbell

          --
          --
          You received this message from the "vim_use" 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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Tony Mechelynck
          ... hm, yes, that would also work; but usually I prefer not to meddle with a syntax script if the syntax analysis is OK but the choice of colours is not to my
          Message 4 of 12 , Sep 5, 2013
          • 0 Attachment
            On 05/09/13 17:42, Charles Campbell wrote:
            > Tony Mechelynck wrote:
            >> On 05/09/13 01:12, Paul wrote:
            >>> On Wednesday, September 4, 2013 6:44:24 PM UTC-4, Tony Mechelynck wrote:
            >>>> On 04/09/13 23:51, Paul wrote:
            >>>>> The GUI highlighting for the current quickfix item seems to be the
            >>>>> same as whatever I set the Search group to. Is there a way to have
            >>>>> a different guibg color?
            >>>>
            >>>> ...With me it doesn't: I just did a :helpgrep, and the current quickfix
            >>>> item didn't get _any_ highlighting: with the cursor on it,
            >>>>
            >>>> :echomsg synIDattr(synID(line("."),col("."),0),"name")
            >>>> synIDattr(synIDtrans(synID(line("."),col("."),0)),"name")
            >>>> synIDattr(synID(line("."),col("."),1),"name")
            >>>> synIDattr(synIDtrans(synID(line("."),col("."),1)),"name")
            >>>>
            >>>> ...didn't display anything. Or if it did, it was because there was
            >>>> some highlighted syntax item (such as between |bars|) just under the
            >>>> cursor.
            >>>>
            >>>> I'm using gvim 7.4.16 (Huge) with GTK2/GNOME2 GUI.
            >>>
            >>> I'm using vim 7.3 on Windows 7. When I issue:
            >>>
            >>> :echomsg synIDattr(synID(line("."),col("."),0),"name")
            >>> :echomsg synIDattr(synIDtrans(synID(line("."),col("."),0)),"name")
            >>> :echomsg synIDattr(synID(line("."),col("."),1),"name")
            >>> :echomsg synIDattr(synIDtrans(synID(line("."),col("."),1)),"name")
            >>>
            >>> I get:
            >>>
            >>> qfFileName
            >>> Directory
            >>> qfFileName
            >>> Directory
            >>>
            >>> It's interesting that you don't see the current quickfix item
            >>> highlighted. I thought that maybe I set something to turn on
            >>> quickfix highlighting, but I can't seem to find the switch. I
            >>> searched the web and the quickfix help to see if quickfix is
            >>> *suppose* to highlight the current item by default, but didn't find
            >>> indications of that either.
            >>>
            >>
            >> I get the same as you do if I do :copen first. What I referred to was
            >> the current quickfix item as found _in the text_ by :cnext, with no
            >> quickfix window actually open.
            >>
            >> I see this item as blue on white, and doing ":verbose hi qfFileName"
            >> in the quickfix window gives
            >>
            >> qfFileName xxx links to Directory
            >> Last set from /usr/local/share/vim/vim74/syntax/qf.vim
            >>
            >> The Search highlight, OTOH, is black on yellow. Not at all the same
            >> thing for me, which makes me ask: Which colorscheme are you using?
            >>
            >> To link qfFileName to something else, or to define specific colours
            >> for it, just use a new or modified colorscheme.
            >>
            >> To modify a colorscheme, first copy it to ~/.vim/colors/ (for *x
            >> systems) or to ~/vimfiles/colors (for Windows), change its name, and
            >> modify it there (including setting g:colors_name to the new name);
            >> then alter the calling line so that it calls the new name. It is not
            >> possible to invoke colorschemes recursively (or at least, I tried and
            >> didn't succeed).
            > Sorry, Tony -- I need to differ with you on this.
            >
            > syntax/qf.vim is a syntax file; it is not a colorscheme, and it is
            > unnecessary to modify or alter any colorschemes.
            >
            > Instead, if you wish to override qfFileName, etc, put your alterations into
            >
            > $HOME/after/syntax/qf.vim
            >
            > Therein, you may put things such as
            >
            > hi link qfFileName Special
            > hi qfSeparator guifg=SeaGreen1 guibg=orange3
            >
            > Doing so will override syntax/qf.vim's selection of default colors.
            >
            > Regards,
            > Chip Campbell
            >
            hm, yes, that would also work; but usually I prefer not to meddle with a
            syntax script if the syntax analysis is OK but the choice of colours is
            not to my taste. A colour scheme can change the colours any which way,
            it may replace yellow by pink in one highlight group, remove a highlight
            link in one place, add one in another place… Anything that involves only
            colours can be done by a colorscheme, provided that the different
            colours you want to set belong to different highlight groups, at least
            before taking highlight links into account.

            I already have my own ~/.vim/colors/almost-default.vim (which sets only
            the colours which I want different from the default) so for me it is
            easy to tweak this or that highlight definition by putting all colour
            changes in this one place.


            Best regards,
            Tony.
            --
            `Lasu' Releases SAG 0.3 -- Freeware Book Takes Paves For New World Order
            by staff writers

            ...
            The SAG is one of the major products developed via the Information
            Superhighway, the brain child of Al Gore, US Vice President. The ISHW
            is being developed with massive govenment funding, since studies show
            that it already has more than four hundred users, three years before
            the first prototypes are ready. Asked whether he was worried about the
            foreign influence in an expensive American Dream, the vice president
            said, ``Finland? Oh, we've already bought them, but we haven't told
            anyone yet. They're great at building model airplanes as well. And _ I
            can spell potato.'' House representatives are not mollified, however,
            wanting to see the terms of the deal first, fearing another Alaska.
            Rumors about the SAG release have imbalanced the American stock
            market for weeks. Several major publishing houses reached an all time
            low in the New York Stock Exchange, while publicly competing for the
            publishing agreement with Mr. Wirzenius. The negotiations did not work
            out, tough. ``Not enough dough,'' says the author, although spokesmen
            at both Prentice-Hall and Playboy, Inc., claim the author was incapable
            of expressing his wishes in a coherent form during face to face talks,
            preferring to communicate via e-mail. ``He kept muttering something
            about jiffies and pegs,'' they say.
            ...
            -- Lars Wirzenius <wirzeniu@...>
            [comp.os.linux.announce]

            --
            --
            You received this message from the "vim_use" 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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.