Incomplete :echo output in autocmds

122 views
Skip to first unread message

glts

unread,
Nov 27, 2012, 1:49:22 PM11/27/12
to vim...@googlegroups.com
Hello list,

echoing from inside autocommands seems erratic. Consider:

command! Echo1 redraw | echomsg 'First line' | echomsg 'Second line'
command! Echo2 call echo#Echo()

" In file ~/.vim/autoload/echo.vim:
function! echo#Echo()
redraw | echomsg 'First line' | echomsg 'Second line'
endfunction

:Echo1 and :Echo2 do exactly the same thing and they do it right: Output
two lines of text in the messages area. From inside autocommands it's
another story: Sometimes they work, sometimes the output is incomplete.

:Echo1 :Echo2 (autoload)
(from cmd-line) OK OK
ColorScheme OK OK
WinEnter OK* OK*
VimEnter incomplete incomplete**
CursorHold, InsertLeave incomplete incomplete

* OK with :sp and :vsp, but not CTRL-W w
** OK on my Mac (MacVim 7.3 and terminal Vim 7.2)

What is going on here? I'm on Vim 7.3.429 on Ubuntu 12.04.

Thanks, glts

glts

unread,
Dec 8, 2012, 5:33:51 AM12/8/12
to vim...@googlegroups.com
Hi

asking for confirmation of flaky :echo behaviour in autocommands.

In a nutshell: Echoing more than one line from within an autocommand is
unreliable. The message may be shown in its entirety or partly,
depending on what type of event it is attached to.

I tried the following command with a number of autocommand events:

command! Echo redraw | echomsg 'First line' | echomsg 'Second line'

ColorScheme OK
FileType OK
WinEnter (:sp, :vsp) OK
WinEnter (CTRL-W ...) truncated
CursorHold truncated
InsertLeave truncated
FocusGained truncated
QuickFixCmdPost truncated

I would be glad if somebody could confirm what I am seeing, so I can set
this aside as a Vim-problem and not a me-problem.

Thanks, glts

Christian Brabandt

unread,
Dec 8, 2012, 7:07:48 AM12/8/12
to vim...@googlegroups.com
Hi glts!

On Sa, 08 Dez 2012, glts wrote:

> asking for confirmation of flaky :echo behaviour in autocommands.
>
> In a nutshell: Echoing more than one line from within an autocommand is
> unreliable. The message may be shown in its entirety or partly,
> depending on what type of event it is attached to.
>
> I tried the following command with a number of autocommand events:
>
> command! Echo redraw | echomsg 'First line' | echomsg 'Second line'
>
> ColorScheme OK
> FileType OK
> WinEnter (:sp, :vsp) OK
> WinEnter (CTRL-W ...) truncated
> CursorHold truncated
> InsertLeave truncated
> FocusGained truncated
> QuickFixCmdPost truncated

I have seen the issue, but haven't found the problem yet. Is there any
reason, why you are not using :echo?

regards,
Christian
--
Tats�chlich sind es die wichtigsten Momente im Leben, wenn wir allein
sind.
-- Anne Morrow Lindbergh

glts

unread,
Dec 8, 2012, 9:01:29 AM12/8/12
to vim...@googlegroups.com, cbl...@256bit.org
Hi Christian,

thank you for answering.

On Saturday, December 8, 2012 1:07:48 PM UTC+1, Christian Brabandt wrote:
> I have seen the issue, but haven't found the problem yet. Is there any
> reason, why you are not using :echo?

No reason. It doesn't matter, however, as the behaviour is the same
regardless of whether I use :echo or :echomsg. At least with :echomsg
I can see the output via :messages.

glts

Christian Brabandt

unread,
Dec 9, 2012, 9:06:20 AM12/9/12
to vim...@googlegroups.com
Hi glts!

On Sa, 08 Dez 2012, glts wrote:

Hm, strange, but if you define
:command! Echo redraw | echo "First line \nSecond line"
it does not get truncated. So this is at least a workaround.


regards,
Christian
--
Der Fuchs wechselt den Balg, nicht den Charakter.
-- Gaius Suetonius (70 n.Chr.-?)

glts

unread,
Dec 9, 2012, 1:33:04 PM12/9/12
to vim...@googlegroups.com, cbl...@256bit.org
Hi Christian,

On Sunday, December 9, 2012 3:06:20 PM UTC+1, Christian Brabandt wrote:
> Hm, strange, but if you define
> :command! Echo redraw | echo "First line \nSecond line"
> it does not get truncated. So this is at least a workaround.

A poor workaround, unfortunately. It works with :echo but not with
:echomsg, and it isn't possible to highlight the lines (or part of a
line) differently.

I would look into this myself, but honestly I don't know where to start
because messages and autocommands don't seem to have anything to do with
one another ...

glts

Reply all
Reply to author
Forward
0 new messages