Re: [RFC] vim plugin rewrite II

Subject: Re: [RFC] vim plugin rewrite II

Date: Thu, 19 Apr 2012 19:36:56 +0300

To: anton@khirnov.net

Cc: notmuch@notmuchmail.org

From: Felipe Contreras


On Wed, Apr 18, 2012 at 5:42 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Wed, Apr 18, 2012 at 5:21 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> On Sat, Jan 14, 2012 at 9:54 AM,  <anton@khirnov.net> wrote:
>>> branch vim. Simply copy vim/plugin/{nm_vim.py,notmuch-vimpy.vim} to the
>>> vim plugins dir and vim/syntax/{nm_vimpy*} to the vim syntax dir and run
>>> :NMVimpy() in vim. You'll need vim with python support and
>>> python-notmuch bindings.
>>
>> I gave this a try, copying those files makes vim crash for me.
>>
>> I probably need to install notmuch's python bindings, but either way
>> it shouldn't crash.
>
> All right, with the bindings it works, but if it cannot find the
> database, it crashes too.
>
> And this slows by 5 times the startup time of vim for me:
>
> vim -c 'quit'  0.47s user 0.02s system 99% cpu 0.501 total
> vim -c 'quit'  0.08s user 0.01s system 96% cpu 0.092 total
>
> It is interesting, but I personally I would not use if it's going to
> slow vim for everything else, there must be a way to solve that. Also,
> would be nice if you rebased your branch on top of the latest release.

I fixed the issue this way:

--- notmuch-vimpy.vim	2012-04-18 22:38:16.193358898 +0300
+++ notmuch-vimpy-mod.vim	2012-04-19 17:07:19.390693437 +0300
@@ -29,11 +29,7 @@
     finish
 endif

-" init the python layer
-let s:python_path = expand('<sfile>:p:h')
-python import sys
-exec "python sys.path += [r'" . s:python_path . "']"
-python import vim, nm_vim
+let s:notmuch_loaded = 1

 command! NMVimpy call NMVimpy()

@@ -815,7 +811,11 @@
 " --- command handler {{{1

 function! NMVimpy()
-    call <SID>NM_cmd_folders(g:nm_vimpy_folders)
+	let s:python_path = expand('<sfile>:p:h')
+	python import sys
+	exec "python sys.path += [r'" . s:python_path . "']"
+	python import vim, nm_vim
+	call <SID>NM_cmd_folders(g:nm_vimpy_folders)
 endfunction

 "Custom foldtext() for show buffers, which indents folds to
@@ -859,5 +859,3 @@
     python nm_vim.vim_get_tags()
     return prefix . substitute(taglist, "\n", "\n" . prefix, "g")
 endfunction
-
-let s:notmuch_loaded = 1

I was seriously considering to concentrate on this plugin instead of
the current one, but I'm afraid every little error causes a crash,
even when a subprocess fails (e.g. msmtp), so it's not really usable
for me. Not to mention that it's really hard to debug, because every
bug causes a crash, and sometimes I get random crashes with no
information about what caused it at all.

I am starting to work on a version that uses ruby, and it doesn't seem
to have these issues, but lets see. I'm still not sure if we should
depend on ruby/python bindings, maybe there's a way to make them
optional.

Anyway, if you find a way to improve the crash issues, let me know, so
far it's the only real issue I see with this plug-in.

Cheers.

-- 
Felipe Contreras

Thread: