Re: Vim plugins

Subject: Re: Vim plugins

Date: Fri, 10 Aug 2012 10:13:55 +0200

To: Sepp Tannhuber, notmuch@notmuchmail.org

Cc:

From: Anton Khirnov


On Thu, 9 Aug 2012 09:49:19 +0100 (BST), Sepp Tannhuber <sepp.tannhuber@yahoo.de> wrote:
> Dear Anton,
> 
> for some reason the file did not exist here. Perhaps I deleted it accidentally. So I cloned the
> repository again. And there it is.
> Now I'm trying if it is useful for me. I changed some code that I can use python-ranger to
> attach files:
> ##########
> function! s:NM_compose_attach()
> 
> if filereadable('/tmp/chosendir')
> silent !ranger --choosefiles=/tmp/chosenfiles --choosedir=/tmp/chosendir "$(cat /tmp/chosendir)"
> else
> silent !ranger --choosefiles=/tmp/chosenfiles --choosedir=/tmp/chosendir
> endif
> if filereadable('/tmp/chosenfiles')
> let attachments = readfile('/tmp/chosenfiles')
> call system('rm /tmp/chosenfiles')
> for attach in attachments
> python nm_vim.get_current_buffer().attach(vim.eval('attach'))
> endfor
> call append(10, map(attachments, '"Attach: ".escape(v:val," \t\\")'))
> redraw!
> endif
> endfunction
> ##########
> It's even possible to mark and attach multiple files at once.
> 

Looks useful, but needs more work I think.
First, I think it should be a new function, so there are separate
'attach one file'/'attach multiple files' commands.
Second, using hardcoded filenames would break horribly with multiple
instances of the client running.

> Is it possible suppress the message returned by
>     python nm_vim.get_current_buffer()?
>  

What message?

> And do you have an idea what's the reason for the following message?
> 
> ##########
> :call <SNR>33_NM_folders_show_search('')       Exception in thread Thread-1:                                
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
>     self.run()
>   File "/usr/lib/python2.7/threading.py", line 504, in run
>     self.__target(*self.__args, **self.__kwargs)
>   File "/home/sepp/.vim/plugin/nm_vim.py", line 195, in _refresh_thread
>     authors, subj, tags)).encode('utf-8')
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
> ##########
> 

Should be fixed now.

-- 
Anton Khirnov

Thread: