On Wed, Jun 10, 2009 at 12:20 AM, Christian Brabandt wrote:
>> > 1. How do I put all modified buffers to archive?- Ultimately I'd like
>> > to either map the command or add to a GUI menu.
>
> Here we go:
>
> set hidden
> let archive=[]
> bufdo if &modified | call add(archive, shellescape(expand("%"),1))| endif
>
> if len(archive) > 0
> exe "!tar -cvjf archive.tar.bz2 " . join(archive, " ")
> endif
>
First I'd like to clarify why I asked again. I asked how to perform
said things from ex prompt. I have tried and tested the answers I got
from ex prompt. Re. this question the first answer I got worked well -
alas I didn't/don't have sufficient knowledge to modify it to do what
I wanted (archive).
Now, I guess you mean by your answer that I should add a function to
.vimrc. I did that and added:
function! Archive_all_modified_buffers()
set hidden
let archive=[]
bufdo if &modified | call add(archive, shellescape(expand("%"),1))| endif
if len(archive) > 0
exe "!tar -cvjf archive.tar.bz2 " . join(archive, " ")
endif
endfunction
Then I called it (call Archive_all...). It seemed to work on all the
(modified?) buffers but I didn't see the archive.tar.bz2 file being
created. Nor could I find it in my account.
>> > 2. How do check in all buffers that pass a shell test (meaning
>> > $test
>> > buffer returns $? value of 0)?
>> > Specifically. All files that pass cleartool ct ls buffer | grep
>> > CHECKEDOUT (i.e. they are checked out) will have the check in command
>> > executed on them: cleartool ci -nc buffer.
>
> As Tony said, something like this should work:
>
> bufdo exe "!test -f " . expand("%") ." > /dev/null"
> \ | if !v:shell_error
> \ | echo "passed"
> \ | endif
>
>
Yes. I tried Tony's suggestion from ex prompt and got an error
(reported it earlier in thread).
This time I added his suggestion as a function and it works perfectly well :)
I added:
function! Perform_Shell_Test_all__buffers()
bufdo exe "!test -f " . expand("%") ." > /dev/null"
\ | if !v:shell_error
\ | echo "passed"
\ | endif
endfunction
function! CheckIn_all__buffers()
bufdo exe "!ct ls " . expand("%") ." | grep -i checkedout > /dev/null"
\ | if !v:shell_error
\ | echo "file is checked out"
\ | exe "!ci " . expand("%")
\ | endif
endfunction
They both work well. (ci is aliased the cleartool ci -nc).
Thanks,
Yosi
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---