Merge lp:~mbp/zeitgeist-datasources/vim into lp:zeitgeist-datasources/0.8

Proposed by Martin Pool
Status: Merged
Merge reported by: Siegfried Gevatter
Merged at revision: not available
Proposed branch: lp:~mbp/zeitgeist-datasources/vim
Merge into: lp:zeitgeist-datasources/0.8
Diff against target: 80 lines (+24/-14)
1 file modified
vim/zeitgeist.vim (+24/-14)
To merge this branch: bzr merge lp:~mbp/zeitgeist-datasources/vim
Reviewer Review Type Date Requested Status
Siegfried Gevatter Approve
Review via email: mp+60780@code.launchpad.net

Description of the change

zeitgeist's vim integration wasn't working for me, I think because it had got stuck talking to a dead daemon.

To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote :

Thank you for your merge request!

However reconnecting is something the Python API should handle transparently. In fact, it already does so, but the first request triggering each reconnection still fails; this is bug #736176 and should be fixed in Zeitgeist (Python API) itself.

Revision history for this message
Seif Lotfy (seif) wrote :

Well the fix also includes some issue with wrong data passed to the
Zeitgeist plugin to generate events. He fixed both and until we have a
proper solution i think we should merge it.

On Thu, May 12, 2011 at 6:06 PM, Siegfried Gevatter <email address hidden>wrote:

> Thank you for your merge request!
>
> However reconnecting is something the Python API should handle
> transparently. In fact, it already does so, but the first request triggering
> each reconnection still fails; this is bug #736176 and should be fixed in
> Zeitgeist (Python API) itself.
> --
> https://code.launchpad.net/~mbp/zeitgeist-dataproviders/vim/+merge/60780
> Your team Zeitgeist Data-Sources Team is requested to review the proposed
> merge of lp:~mbp/zeitgeist-dataproviders/vim into
> lp:zeitgeist-dataproviders.
>

Revision history for this message
Siegfried Gevatter (rainct) wrote :

OK, merged into trunk since we can't ship an extensions which spells the name of our own project incorrectly! ;)

Thanks Martin!

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

there is a bit of a bug in this that it complains if the file can't be
opened. i'll send you another patch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'vim/zeitgeist.vim'
2--- vim/zeitgeist.vim 2011-01-16 14:16:33 +0000
3+++ vim/zeitgeist.vim 2011-05-12 13:29:22 +0000
4@@ -2,17 +2,26 @@
5 "Author : Jonathan Lambrechts <jonathanlambrechts@gmail.com>
6 "Installation : drop this file in a vim plugin folder ($HOME/.vim/plugin,/usr/share/vim/vim72/plugin, ...). Vim should be compiled with python enabled.
7
8-function! ZeigtgeistLog(filename,use_id)
9+function! ZeitgeistLog(filename, vim_use_id)
10 python << endpython
11+use_id = vim.eval("a:vim_use_id")
12 filename = vim.eval("a:filename")
13-if zeitgeistclient is not None and filename:
14+precond = os.getuid() != 0 and os.getenv('DBUS_SESSION_BUS_ADDRESS') != None
15+if got_zeitgeist and precond and filename:
16+ # We reconnect on every attempt so that we cope cleanly with the zeitgeist
17+ # server failing and being restarted; the Python client library will currently
18+ # just throw away messages to a dead server (as of 2011-05-12).
19+ zeitgeistclient = ZeitgeistClient()
20 use = {
21 "read" : Interpretation.ACCESS_EVENT,
22 "new" : Interpretation.CREATE_EVENT,
23- "write" : Interpretation.MODIFY_EVENT} [vim.eval("a:use_id")]
24+ "write" : Interpretation.MODIFY_EVENT} [use_id]
25
26- f = gio.File(filename)
27 try:
28+ f = gio.File(filename)
29+ except gio.Error:
30+ pass
31+ else:
32 fi = f.query_info(gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)
33 uri = f.get_uri()
34 mimetype = fi.get_content_type()
35@@ -24,6 +33,7 @@
36 origin=unicode(uri.rpartition("/")[0]),
37 mimetype=unicode(mimetype)
38 )
39+ # print "subject: %r" % subject
40 event = Event.new_for_values(
41 timestamp=int(time.time()*1000),
42 interpretation=unicode(use),
43@@ -31,9 +41,9 @@
44 actor="application://gvim.desktop",
45 subjects=[subject,]
46 )
47+ # print "event: %r" % event
48 zeitgeistclient.insert_event(event)
49- except RuntimeError, e:
50- pass
51+ # print "insert done"
52 endpython
53 endfunction
54
55@@ -45,17 +55,17 @@
56 import gio
57 from zeitgeist.client import ZeitgeistClient
58 from zeitgeist.datamodel import Subject, Event, Interpretation, Manifestation
59-
60- precond = os.getuid() != 0 and os.getenv('DBUS_SESSION_BUS_ADDRESS') != None
61- zeitgeistclient = ZeitgeistClient() if precond else None
62+ got_zeitgeist = True
63 except RuntimeError, e:
64- zeitgeistclient = None
65+ got_zeitgeist = False
66 except ImportError, e:
67- zeitgeistclient = None
68+ got_zeitgeist = False
69 endpython
70 augroup zeitgeist
71 au!
72-au BufRead * call ZeigtgeistLog (expand("%:p"), "read")
73-au BufNewFile * call ZeigtgeistLog (expand("%:p"), "new")
74-au BufWrite * call ZeigtgeistLog (expand("%:p"), "write")
75+au BufRead * call ZeitgeistLog (expand("%:p"), "read")
76+au BufNewFile * call ZeitgeistLog (expand("%:p"), "new")
77+au BufWrite * call ZeitgeistLog (expand("%:p"), "write")
78 augroup END
79+
80+" vim: sw=2

Subscribers

People subscribed via source and target branches