Thursday, July 19, 2012

Re: vim Utl plugin: how to render a linked doc file

stefan:

I think the way autocmd works might make it hard for Utl to implement
the external link (to files) feature...

*what autocmd did in my case*
autocmd FileReadPost *.doc %!antiword "%"

so when open abc.doc, vim
1) select all(%) content(gg to G), and
2) replace selected texts with output of ext-program "antiword abc.doc".
3) at this moment, the files on the disk is still binary MS-word doc,
but only its content was rendered to be displayed in vim in text.
4) now Utl come to work, it still (I guess) check the original binary
abc.doc (MS-word format) in hard disk.
5) since Utl got no match out of the binary file, it displays nothing.

I'm not sure how to solve the issue, the solutions I can think of are:
1) not mark ms-word doc as RO in autocmd, instead, write it after
rendered, this will overide/lose the original word doc. but this will
make the rendered text visible to Utl plugin...

2) make Utl be able to search keywords out of the autocmd-rendered text
in the buffer(vs. on the disk), not sure this is possible?

any thought?

I really think it will greatly extend current Utl features if this is
well implemented -- you can link whatever docs(MS-word, pdf, html,
rtf,etc) that is convertable (via antiword, pdf2txt ,html2txt, catdoc,
etc) in vim!


regards
ping

On 06/27/2012 03:21 AM, stefan.bittner@bf-consulting.de wrote:
> Hi,
>
> sorry for the late answer.
>
> If I test with a MS Word document, having in my .vimrc file:
>
> let g:utl_cfg_hdl_mt_application_msword="VIM"
>
> but without these autocmd commands, then I get the Word file displayed
> inside Vim when I open it with :Utl . It is of course displayed as
> binary data since the .doc is binary data.
>
> Now, when I use these autocmd command, but replacing antiword with
> notepad since I have no antiword installed:
>
> autocmd BufReadPre *.doc set ro
> autocmd FileReadPre *.doc set ro
> autocmd BufReadPre *.doc set hlsearch!
> autocmd BufReadPost *.doc %!notepad "%"
> autocmd FileReadPost *.doc %!notepad "%"
>
> I get a .doc file displayed in Notepad, ending up inside Vim with an
> empty buffer as you described.
>
> So I guess you should modify your autocmd in order not to open the file
> externally (in antiword/notepad) but rather filter it and feed it back
> into Vim.
>
> I think Utl is not part of your problem.
>
> Regards,
> Stefan
>
>
>
>> -------- Original-Nachricht --------
>> Betreff: Re: vim Utl plugin: how to render a linked doc file
>> Datum: Thu, 14 Jun 2012 15:59:43 -0400
>> Von: ping <songpingemail@gmail.com>
>> An: Stefan Bittner <stefan.bittner@bf-consulting.de>, vim-use
>> Mailingliste <vim_use@googlegroups.com>
>>
>>
>>
>> hi Stefan:
>> sorry I don't know why but somehow email from you were put into SPAM
>> here...
>> please see my comments in lines to better answer you.
>> please let me know if you have any advice.
>>
>> On 06/04/2012 12:12 PM, Stefan Bittner wrote:
>>> Hi,
>>>
>>> as I understand your usage, files with an extension ".doc" are not
>>> Microsoft-Word documents, but rather text files like a .txt extension.
>> *no that is not the case. ".doc" IS MS docs, I use following autocmd to
>> open MS-word docs in vim and it works just fine:
>>
>> "doc to text
>> autocmd BufReadPre *.doc set ro
>> autocmd FileReadPre *.doc set ro
>> autocmd BufReadPre *.doc set hlsearch!
>> autocmd BufReadPost *.doc %!antiword "%"
>> autocmd FileReadPost *.doc %!antiword "%"
>>
>> so my goal here is , instead of launch an external handler APP(MS
>> office or OOO suite), I want Utl to try open the
>> MS word doc ,via using these autocmd to render it, all from inside vim
>> -- either in a new buffer in same window or a new tab.*
>>
>>>
>>> What happens is that some extensions (as ".doc" is) are hard coded
>>> into Vim which means, that utl.vim is looking for a handler that
>>> deals with the document. In your case no one is defined.
>>>
>>> In order to display files, for which a handler is involved, in Vim,
>>> you can provide a handler variable with the special value "VIM". In
>>> your case you should put the following line into you .vimrc file:
>>>
>>> let g:utl_cfg_hdl_mt_application_msword="VIM"*
>>> *
>> *I put this in .vimrc and restart it, still not working.
>> it seems open a new empty buffer.*
>>
>>>
>>> Hope that helps,
>>> Regards,
>>>
>>> Stefan
>>>
>>> Am 31.05.2012 20:31, schrieb ping:
>>>> stefen:
>>>> I'm using vim Utl plugin and enjoy it.
>>>> http://www.vim.org/scripts/script.php?script_id=293
>>>> but today I run into an issue here.
>>>> so if I use this in my text:
>>>>
>>>> 7 habit <url:books/7\ habits\ of\ highly\ effective\
>>>> people.txt>
>>>>
>>>> it works. it will jump into the folder books and open linked file
>>>> in current window for me.
>>>>
>>>> while if I use this:
>>>>
>>>> 7 habit <url:books/7\ habits\ of\ highly\ effective\
>>>> people.doc>
>>>>
>>>> it report:
>>>> No handler for media type application/msword defined yet. Entering
>>>> Setup now. <RETURN>
>>>>
>>>> and i f I return it goes to the Utl help.
>>>>
>>>> I already have these setup in my vimrc file:
>>>>
>>>> "doc to text
>>>> autocmd BufReadPre *.doc set ro
>>>> autocmd FileReadPre *.doc set ro
>>>> autocmd BufReadPre *.doc set hlsearch!
>>>> autocmd BufReadPost *.doc %!antiword "%"
>>>> autocmd FileReadPost *.doc %!antiword "%"
>>>>
>>>> so if I :open/:read a doc file it will be automatically rendered
>>>> into vim.
>>>>
>>>> is there anything missed here?
>>>>
>>>> copy to the vim google group if anyone else knows how-to.
>>>>
>>>> thanks!
>>>>
>>>
>
>

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: