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

error messages and help

Expand Messages
  • Mikolaj Machowski
    Hello, ... inoremap :silent! call TexHelp() nnoremap :silent! call TexHelp() function! TexHelp() if
    Message 1 of 3 , Apr 1, 2003
    • 0 Attachment
      Hello,

      I've made simple wrapper for <F1> key for Latex-suite:
      ----------------------
      inoremap <buffer> <silent> <F1> <C-O>:silent! call TexHelp()<CR>
      nnoremap <buffer> <silent> <F1> :silent! call TexHelp()<CR>

      function! TexHelp()
      if synIDattr(synID(line('.'),col('.')-1,0),"name") =~ "^tex"
      setlocal isk+=\
      let curword = expand("<cword>")
      setlocal isk-=\
      if curword =~ "^\\"
      exe 'help ' . curword
      if v:errmsg =~ "^E149"
      echohl ErrorMsg
      exe 'echo "Sorry, no help for \' . curword . '"'
      echohl None
      let v:errmsg = ''
      endif
      else
      help
      endif
      else
      help
      endif
      endfunction
      ----------------------
      But when there is no help for \item I am getting messages:
      ----------------------
      Error detected while processing function TexHelp:
      line 5:
      E149: Sorry, no help for \item
      ----------------------
      I can supress them totally with silent! but this is not exactly what I want.
      I tried to check v:errmsg and produce my own error but this is not
      possible due to silent!

      From :help :silent
      When [!] is added, error messages will also be skipped, and commands
      and mappings will not be aborted when an error is detected. |v:errmsg|
      is still set.

      I would expect only Vim error messages will be skipped.
      Vim 6.1.422, Linux


      TIA

      Mikolaj

      --
      LaTeX + Vim = http://vim-latex.sourceforge.net/
      Learn Touch Typing with Vim:
      http://vim.sourceforge.net/script.php?script_id=461
    • Benji Fisher
      ... [snip] ... Why not remove the silent! from the mappings (the one after the : , not the ) and add silent or silent! to some lines of the
      Message 2 of 3 , Apr 6, 2003
      • 0 Attachment
        Mikolaj Machowski wrote:
        > Hello,
        >
        > I've made simple wrapper for <F1> key for Latex-suite:
        > ----------------------
        > inoremap <buffer> <silent> <F1> <C-O>:silent! call TexHelp()<CR>
        > nnoremap <buffer> <silent> <F1> :silent! call TexHelp()<CR>
        >
        > function! TexHelp()
        [snip]
        > endfunction
        > ----------------------
        > But when there is no help for \item I am getting messages:
        > ----------------------
        > Error detected while processing function TexHelp:
        > line 5:
        > E149: Sorry, no help for \item
        > ----------------------
        > I can supress them totally with silent! but this is not exactly what I want.
        > I tried to check v:errmsg and produce my own error but this is not
        > possible due to silent!

        Why not remove the "silent!" from the mappings (the one after the ":", not
        the "<silent>") and add "silent" or "silent!" to some lines of the function?

        BTW, don't you want to clear v:errmsg before trying :help ?

        HTH --Benji Fisher
      • Mikolaj Machowski
        ... Aaaargh. I tried it before but didn t work because really stupid fault in if (== instead of =~). ... Thanks. m. -- LaTeX + Vim =
        Message 3 of 3 , Apr 6, 2003
        • 0 Attachment
          On Sun, Apr 06, 2003 at 02:13:18PM -0400, Benji Fisher wrote:
          > Why not remove the "silent!" from the mappings (the one after the ":",
          > not the "<silent>") and add "silent" or "silent!" to some lines of the
          > function?

          Aaaargh. I tried it before but didn't work because really stupid fault
          in if (== instead of =~).

          > BTW, don't you want to clear v:errmsg before trying :help ?

          Thanks.

          m.
          --
          LaTeX + Vim = http://vim-latex.sourceforge.net/
          Vim-list(s) Users Map: (last change 5 Apr)
          http://skawina.eu.org/mikolaj/vimlist
          Are You There?
        Your message has been successfully submitted and would be delivered to recipients shortly.