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

87922Re: Unable to get syntax highlighting to work for root account

Expand Messages
  • Richard Hartmann
    Mar 1, 2008
    • 0 Attachment
      On Sat, Mar 1, 2008 at 4:40 AM, Tony Mechelynck
      <antoine.mechelynck@...> wrote:


      > Beware that obnoxious modelines have been spotted time and again. The most
      > dangerous options are disabled in them, but maybe some dangerous ones have
      > been mistakenly allowed: if you enable them for the superuser, you're on your
      > own. You may get no problems at all, but if bugs bite you, don't say you
      > weren't warned.

      To guard against surprise modelines in files, use:

      " This function will check if VIM finds modelines and, if yes, will let you
      " choose if you want to execute them. Edit default to enable or disable,
      " according to your needs. You can use y and n, as well.
      function s:CheckForModelines()
      " 'default' may only be set to e[nable], d[isable] and, for
      convenience, y[es] or n[o]
      let default = 'e'

      if default != 'e' && default != 'd' && default != 'y' && default != 'n'
      echoerr "Error in function CheckForModelines: Please set
      'default' to 'e', 'd', 'y' or 'n'"
      endif
      if !exists('+modelines') || &modelines < 1 || ( !&modeline &&
      !exists('b:modeline') )
      return -1
      endif
      let m=''
      if &modelines>line('$')
      sil exe '%g/\<vim:\|\<vi:\|\<ex:/let m=m."\n".getline(".")'
      else
      sil exe '1,'.&modelines.'g/\<vim:\|\<vi:\|\<ex:/let
      m=m."\n".getline(".")'
      sil exe '$-'.(&modelines-1).',$g/\<vim:\|\<vi:\|\<ex:/let
      m=m."\n".getline(".")'
      endif
      if strlen(m)
      echo m
      let j = '-'
      while j != 'e' && j != 'd' && j != 'y' && j != 'n' && j != ''
      if default == 'e' || default == 'y'
      let j = input('Modelines found! [E]nable
      [d]isable):','','expression')
      elseif default == 'd' || default == 'n'
      let j = input('Modelines found! [e]nable
      [D]isable):','','expression')
      endif
      endwhile
      let &l:modeline = (j=='e' || j=='y' || (j=='' && (default=='e'
      || default=='y')))
      let b:modeline = 1
      endif
      endfunction
      au BufReadPost * call s:CheckForModelines()


      Richard

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 9 messages in this topic