Ingo Karkat wrote:
> On 26-Feb-09 4:21, Bram Moolenaar wrote: > > Ingo Karkat wrote: > >> According to the help, v:warningmsg contains the last given warning > >> message. > >> I've encountered multiple VIM warnings which do not update this variable: > >> > >> vim -N -u NONE > >> :setl ro > >> :normal! oFoobar > >> W10: Warning: Changing a readonly file-- INSERT -- > >> :echo v:warningmsg > >> > >> " I would have expected that v:warningmsg now contains W10: ... > >> /Foo > >> search hit BOTTOM, continuing at TOP > >> :echo v:warningmsg > >> search hit BOTTOM, continuing at TOP > >> " OK here, the wrapscan message sets v:warningmsg as expected. > >> :w foo > >> W10: Warning: Changing a readonly file > >> :echo v:warningmsg > >> search hit BOTTOM, continuing at TOP > >> " v:warningmsg not set, still contains the old warning. > >> :normal! oMore text > >> :!echo "Changed" >> foo > >> [No write since last change] > >> W12: Warning: File "foo" has changed and the buffer was changed in Vim as > >> well > >> See ":help W12" for more info. > >> [O]K, (L)oad File: > >> :echo v:warningmsg > >> search hit BOTTOM, continuing at TOP > >> " It's not just W10, W12 also doesn't set v:warningmsg. > >> > >> I can reproduce this with VIM 7.2.127 on Linux and the default VIM 7.0 > >> - 7.2 on Windows. > > > > I'll add it to the todo list. Note that you need to mention every > > message you are missing, there probably is no generic solution. > > Actually, the only (!) message that sets v:warningmsg is the "search hit > BOTTOM, > continuing at TOP" (and its reverse) warning. > > While grepping through the source code, I found out that there are different > kinds of warning: With or without highlighting, with /W\d\+:/ prefix and/or > prefixed with "Warning:", echoed to the command line or (in some (correct) > cases) to stderr. Many purported warnings are actually echoed as errors, BTW. > Thus, I actually found surprisingly few warnings that should be stored in > v:warningmsg. > > Attached patch adds the setting of v:warningmsg for: > - W10: Warning: Changing a readonly file > - The W11, W12, W13, W16 "file has changed" warnings > - W17: Arabic requires UTF-8, do ':set encoding=utf-8' (just for > completeness' > sake, not sure why someone would be interested in this) > > Please review the patch, my C is a bit rusty, and I'm not well versed in the > string types and message translation macros used in the sources. Thanks for the patch. I'll look into it later. -- hundred-and-one symptoms of being an internet addict: 159. You get excited whenever discussing your hard drive. /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
