Commits

ZyX_I committed af43c43

Made warn echo just the same message as throw, but in several lines

Comments (0)

Files changed (2)

 4. Features                                                  *frawor-features*
 
 warn : function ({msgid}, ...) + s:g._messages → {message}     *frawor-f-warn*
-        Echoes message `Frawor:{plid}:{message}' where {message} is obtained by 
-        getting {msgid} out of `s:g._messages' (s:g is a dictionary that is 
-        passed as last but one argument to FraworRegister). If more then one 
-        argument is present, then {message} and that arguments will be passed to 
-        |printf()|. Warn function return formatted message. {plid} is an id of 
-        a plugin that uses this function. Semicolon and backslash in {plid} will 
-        be escaped.
+        Echoes message `Frawor:{plid}:{msgid}:{message}' where {message} is 
+        obtained by getting {msgid} out of `s:g._messages' (s:g is a dictionary 
+        that is passed as last but one argument to FraworRegister). If more then 
+        one argument is present, then {message} and that arguments will be 
+        passed to |printf()|. Warn function returns the whole message echoed. 
+        {plid} is an id of a plugin that uses this function. Semicolon and 
+        backslash in {plid} and {msgid} will be escaped.
 throw : function ({msgid}, ...) → exception                   *frawor-f-throw*
         Calls |frawor-f-warn| and throws an exception with text 
         `Frawor:{plid}:{msgid}:{message}' where {message} is a value returned by 
     if a:0
         let message=call('printf', [message]+a:000)
     endif
+    let message='Frawor:'.escape(a:plugdict.id, '\:').':'.
+                \escape(a:msgid, '\:').':'.message
     echohl ErrorMsg
-    echomsg 'Frawor:'.escape(a:plugdict.id, '\:').':'.message
+    for msgline in split(message, "\n", 1)
+        if empty(msgline)
+            echomsg " "
+        else
+            echomsg msgline
+        endif
+    endfor
     echohl None
     return message
 endfunction
 call s:F._frawor.newfeature('warn', {'cons': s:F.warn})
 "▶1 throw feature
 function s:F.throw(plugdict, msgid, ...)
-    let throwmsg='Frawor:'.escape(a:plugdict.id, '\:').':'.
-                \escape(a:msgid, '\:').':'.
-                \call(s:F.warn, [a:plugdict, a:msgid]+a:000, {})
-    throw throwmsg
+    throw call(s:F.warn, [a:plugdict, a:msgid]+a:000, {})
 endfunction
 call s:F._frawor.newfeature('throw', {'cons': s:F.throw})