I am using this command in order to retrieve data stored into c:/
infos.txt at regular interval back to GVim without disturbing main
GVim instance.
exec '!start /MIN cmd /c "vim --servername ' . v:servername . ' --
remote-expr "AnalysisCppInfos('."'c:/infos.txt'". ')"'
The problem is that the call of AnalysisCppInfos( happens only one
time.
I would like a call done each time an event occurs.
Event may be :
. each second
. each time the file is written
. etC..
I wonder why it is called only one time.
Thank you
To repetitively call something (in a Vim compiled with the +autocmd
feature), you may want to harness the CursorHold and/or CursorHoldI
event, which, in Normal mode or Insert mode respectively, will fire once
when 'updatetime' milliseconds (by default 4000) have passed since the
last time you pressed a key. Or (IIUC) you may call the feedkeys()
function from that autocommand in order to trigger it again.
Note that changing this option has a side-effect (which from a different
point of view is the main effect): the swapfile is written (if not yet
done since the last time the file was changed) at the same time the
autocommand fires.
Similarly, "each time the file is written" is the BufWrite event.
(BufWrite is an alias of BufWritePre, "just before writing the file".
There is also a BufWritePost event.)
Best regards,
Tony.
--
Character Density, n.:
The number of very weird people in the office.
On the contrary, I search for an event out of user key.
idem for the feedkeys()
In fact a search for an exaplanation of this feature remote-expr.
Is is cycling ? or one shot ?
I am reading a file that is output by a first cmd.
On Mar 20, 2:30 am, epanda <callingel...@hotmail.fr> wrote:
> Hi,
>
> I am using this command in order to retrieve data stored into c:/
> infos.txt at regular interval back to GVim without disturbing main
> GVim instance.
>
> exec '!start /MIN cmd /c "vim --servername ' . v:servername . ' --
> remote-expr "AnalysisCppInfos('."'c:/infos.txt'". ')"'
>
> The problem is that the call of AnalysisCppInfos( happens only one
> time.
Naturally. You only call it once. The :!start command is to call an
external command, A SINGLE TIME, in an asynchronous process.
>
> I would like a call done each time an event occurs.
> Event may be :
> . each second
> . each time the file is written
> . etC..
>
> I wonder why it is called only one time.
>
If you want it to run more than once, you will need to call in more
than once.
set updatetime=1000
let g:startTime = reltime()
au!
autocmd CursorHold * call s:AnalysisCppCheckInfos("c:/infos.txt")
function! s:AnalysisCppCheckInfos(temp_file_name)
echo "Temps écoulé " . reltimestr(reltime(g:startTime))
endfunc
I see only one time the message.
Which event can I use to call myFunc each constant time?
There isn't one. The closest you can get is to use both CursorHold and
CursorMoved. See the :help entry for each. I believe I may have seen a
way to trick Vim into generating cursor movement with CursorHold, so
that CursorHold would fire repeatedly, but normally it just fires once
after the timeout period.
You may be better off making your EXTERNAL process run forever and
repeatedly call your function, as I suggested previously. You could do
this in a shell script/batch file/whatever you want.
But generaly, I apply my philosophy which consist of using less layer
as soon as possible.
I am already using vim which call and encapsulate cppcheck process, so
that's why I don't want to add another layer just to get repeat call.
I will see what I can do to not overheat CPU load while I using
cppcheck.
Thank you
Yes, Simply call feedkeys in your autocommand and put in some key, that
won't hurt. Something like this may be:
fu! s:Run()
let k_refresh="\x0c" " this is ctrl-l
" Do whatever you want to be done here
echomsg strftime("%H:%M:%S ") . "Autocommand triggered"
call feedkeys(k_refresh, 't')
endfu
augroup RunContinuously
au!
au CursorHold * :call s:Run()
augroup end
I am not sure, how invasive this will be for the user, though.
regards,
Christian
I think you should follow Ben's suggestion to get the job done first
and worry efficiency later.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
On Mar 24, 4:48 am, "Christian Brabandt" <cbli...@256bit.org> wrote:
>
> Yes, Simply call feedkeys in your autocommand and put in some key, that
> won't hurt. Something like this may be:
>
> fu! s:Run()
> let k_refresh="\x0c" " this is ctrl-l
> " Do whatever you want to be done here
> echomsg strftime("%H:%M:%S ") . "Autocommand triggered"
> call feedkeys(k_refresh, 't')
> endfu
>
> augroup RunContinuously
> au!
> au CursorHold * :call s:Run()
> augroup end
>
> I am not sure, how invasive this will be for the user, though.
>
I think it would be pretty invasive. It will make not just the desired
script, but ALL CursorHold events, to fire without end. I imagine some
plugins rely on the fact that CursorHold only fires once after cursor
inactivity, though I don't know any specific ones. Most likely this
will only cause inefficiencies, doing work multiple times instead of
just once, but there might be cases where it actually screws things up.
It is a cool new func I have learned !!!
Meanwhile it is taking all resources, I use it.
Thanks
Christian your solution is working perfectly.
I can writing into the buffer and use Gvim as I want while refresh of
cppcheck progression is done perfectly.
So Thank you , it is perfect.
Epanda