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

How to set highlight options only to plugin?

Expand Messages
  • Sean
    Hello, It is possible to save/restore highlight settings in a plugin? In general, the logic for regular option is: (1) save the option: (for example: let
    Message 1 of 6 , Feb 28, 2009
    • 0 Attachment
      Hello,

      It is possible to save/restore highlight settings in a plugin?

      In general, the logic for regular option is:
      (1) save the option: (for example: let s:saved_cpo=&cpo)
      (2) set the option for plugin only (for example: set cpo&vim)
      " do whatever within plugin
      (3) restore the option (for example, let &cpo=s:saved_cpo)

      The highlight setting seems special. What is the step (1) and (2) for
      highlight setting?
      (1) save highlight option (How ?)
      (2) highlight lCursor guibg=green
      (3) restore highlight option (How ?)


      Thanks

      Sean

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Matt Wozniski
      ... I don t think I understand the question... ... What would you expect that example to do? ~Matt --~--~---------~--~----~------------~-------~--~----~ You
      Message 2 of 6 , Feb 28, 2009
      • 0 Attachment
        On Sat, Feb 28, 2009 at 6:50 PM, Sean wrote:
        > It is possible to save/restore highlight settings in a plugin?

        I don't think I understand the question...

        > (1) save highlight option (How ?)
        > (2) highlight lCursor guibg=green
        > (3) restore highlight option (How ?)

        What would you expect that example to do?

        ~Matt

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • vimim
        ... Basically, I want to know if it is possible to do (1) and (3) below (1) let s:saved_highlight=&ICursor (2) highlight lCursor guibg=green (3)
        Message 3 of 6 , Feb 28, 2009
        • 0 Attachment
          On Feb 28, 4:11 pm, Matt Wozniski <m...@...> wrote:
          > On Sat, Feb 28, 2009 at 6:50 PM, Sean wrote:
          > > It is possible to save/restore highlight settings in a plugin?
          >
          > I don't think I understand the question...
          >
          > >     (1) save highlight option  (How ?)
          > >     (2) highlight lCursor guibg=green
          > >     (3) restore highlight option  (How ?)
          >
          > What would you expect that example to do?
          >
          > ~Matt


          Basically, I want to know if it is possible to do (1) and (3) below

          (1) let s:saved_highlight=&ICursor
          (2) highlight lCursor guibg=green
          (3) &ICursor=s:saved_highlight

          Step (2) is correct, and is what I want, from within my plugin.
          However, I don't want to set it permanently for all vim session.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Matt Wozniski
          ... You want the lCursor highlight to be set to green while your plugin is being sourced, and reset to the default after your plugin is done being loaded?
          Message 4 of 6 , Feb 28, 2009
          • 0 Attachment
            On Sat, Feb 28, 2009 at 9:15 PM, vimim wrote:
            > On Feb 28, 4:11 pm, Matt Wozniski wrote:
            >> On Sat, Feb 28, 2009 at 6:50 PM, Sean wrote:
            >> > It is possible to save/restore highlight settings in a plugin?
            >>
            >> I don't think I understand the question...
            >>
            >> >     (1) save highlight option  (How ?)
            >> >     (2) highlight lCursor guibg=green
            >> >     (3) restore highlight option  (How ?)
            >>
            >> What would you expect that example to do?
            >
            > Basically, I want to know if it is possible to do (1) and (3) below
            >
            > (1) let s:saved_highlight=&ICursor
            > (2) highlight lCursor guibg=green
            > (3) &ICursor=s:saved_highlight
            >
            > Step (2) is correct, and is what I want, from within my plugin.
            > However, I don't want to set it permanently for all vim session.

            You want the lCursor highlight to be set to green while your plugin is
            being sourced, and reset to the default after your plugin is done
            being loaded? That's what that pseudocode looks like it should do.
            And that's nonsensical; the cursor would never be redisplayed while
            the script is being sourced.

            ~Matt

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Tony Mechelynck
            ... The following is untested, but I think that (in a filetype-plugin or similar) it will do what you want. (Redirection to a variable may require Vim version
            Message 5 of 6 , Feb 28, 2009
            • 0 Attachment
              On 01/03/09 03:15, vimim wrote:
              >
              >
              > On Feb 28, 4:11 pm, Matt Wozniski<m...@...> wrote:
              >> On Sat, Feb 28, 2009 at 6:50 PM, Sean wrote:
              >>> It is possible to save/restore highlight settings in a plugin?
              >> I don't think I understand the question...
              >>
              >>> (1) save highlight option (How ?)
              >>> (2) highlight lCursor guibg=green
              >>> (3) restore highlight option (How ?)
              >> What would you expect that example to do?
              >>
              >> ~Matt
              >
              >
              > Basically, I want to know if it is possible to do (1) and (3) below
              >
              > (1) let s:saved_highlight=&ICursor
              > (2) highlight lCursor guibg=green
              > (3)&ICursor=s:saved_highlight
              >
              > Step (2) is correct, and is what I want, from within my plugin.
              > However, I don't want to set it permanently for all vim session.

              The following is untested, but I think that (in a filetype-plugin or
              similar) it will do what you want. (Redirection to a variable may
              require Vim version 7.)

              function SetGreenLCursor()
              redir => b:save_lch
              silent hi lCursor
              redir END
              let b:save_lch = substitute (b:save_lch, '\<xxx\>', '', '')
              hi lCursor ctermbg=green guibg=green
              endfunction
              function RestoreGreenCursor()
              if exists('b:save_lch')
              exe 'hi' b:save_lch
              unlet b:save_lch
              else
              echoerr 'Trying to restore cursor before saving'
              endif
              endfunction
              call SetGreenCursor() " first time: we have already entered the buffer
              au BufEnter <buffer> call SetGreenCursor()
              au BufLeave <buffer> call RestoreGreenCursor()


              Best regards,
              Tony.
              --
              Endless Loop: n., see Loop, Endless.
              Loop, Endless: n., see Endless Loop.
              -- Random Shack Data Processing Dictionary

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • John Beckett
              ... You will find plenty of amazing code in a previously-featured tip: http://vim.wikia.com/wiki/Highlight_multiple_words John
              Message 6 of 6 , Feb 28, 2009
              • 0 Attachment
                Sean wrote:
                > It is possible to save/restore highlight settings in a plugin?

                You will find plenty of amazing code in a previously-featured tip:
                http://vim.wikia.com/wiki/Highlight_multiple_words

                John


                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              Your message has been successfully submitted and would be delivered to recipients shortly.