Zim

Merge lp:~johannes-reinhardt/zim/fixes into lp:~jaap.karssenberg/zim/pyzim

Proposed by Johannes Reinhardt
Status: Merged
Merged at revision: not available
Proposed branch: lp:~johannes-reinhardt/zim/fixes
Merge into: lp:~jaap.karssenberg/zim/pyzim
Diff against target: 115 lines (+45/-2)
5 files modified
zim/gui/pageview.py (+26/-0)
zim/notebook.py (+3/-0)
zim/parsing.py (+14/-0)
zim/plugins/linkmap/__init__.py (+1/-1)
zim/plugins/linkmap/gui.py (+1/-1)
To merge this branch: bzr merge lp:~johannes-reinhardt/zim/fixes
Reviewer Review Type Date Requested Status
Jaap Karssenberg Approve
Review via email: mp+21412@code.launchpad.net

Description of the change

Fixes lp:492656 and handles trivial renames and moves correctly

To post a comment you must log in.
lp:~johannes-reinhardt/zim/fixes updated
218. By Johannes Reinhardt

much nicer linkmap layout when using fpd

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Somehow I missed this branch being proposed for a new merge - otherwise would have included them in 0.45 / 0.46. Will include these fixes in trunk with the next round.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) :
review: Approve
lp:~johannes-reinhardt/zim/fixes updated
219. By Johannes Reinhardt

* Update to release 0.46
* Updated to release 0.45

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'zim/gui/pageview.py'
2--- zim/gui/pageview.py 2010-03-14 19:22:51 +0000
3+++ zim/gui/pageview.py 2010-03-15 23:54:24 +0000
4@@ -143,6 +143,9 @@
5 ('recursive_checklist', 'bool', 'Editing',
6 _('Checking a checkbox also change any sub-items'), False),
7 # T: option in preferences dialog
8+ ('auto_reformat', 'bool', 'Editing',
9+ _('Reformat wiki markup on the fly'), False),
10+ # T: option in preferences dialog
11 )
12
13 _is_zim_tag = lambda tag: hasattr(tag, 'zim_type')
14@@ -173,6 +176,12 @@
15 | /[^/\s]
16 )\S*$''', re.X | re.U) # ~xxx/ or ~name/xxx or ../xxx or ./xxx or /xxx
17
18+markup_re = {'style-strong' : Re(r'(\*{2})(.*)\1'),
19+ 'style-emphasis' : Re(r'(\/{2})(.*)\1'),
20+ 'style-mark' : Re(r'(_{2})(.*)\1'),
21+ 'style-pre' : Re(r'(\'{2})(.*)\1'),
22+ 'style-strike' : Re(r'(~{2})(.*)\1')}
23+
24 # These sets adjust to the current locale - so not same as "[a-z]" ..
25 # Must be kidding - no classes for this in the regex engine !?
26 _classes = {
27@@ -2362,6 +2371,23 @@
28 apply_link(file_re[0])
29 elif self.preferences['autolink_camelcase'] and camelcase_re.match(word):
30 apply_link(camelcase_re[0])
31+ elif self.preferences['auto_reformat']:
32+ handled = False
33+ linestart = buffer.get_iter_at_line(end.get_line())
34+ partial_line = linestart.get_slice(end)
35+ for style,re in markup_re.items():
36+ if not re.search(partial_line) == None:
37+ matchstart = linestart.copy()
38+ matchstart.forward_chars(re.start())
39+ matchend = linestart.copy()
40+ matchend.forward_chars(re.end())
41+ if filter(_is_not_indent_tag,buffer.iter_get_zim_tags(matchstart)) \
42+ or filter(_is_not_indent_tag,buffer.iter_get_zim_tags(matchend)):
43+ continue
44+ buffer.delete(matchstart,matchend)
45+ buffer.insert_with_tags_by_name(matchstart,re[2],style)
46+ handled_here = True
47+ break
48 else:
49 handled = False
50
51
52=== modified file 'zim/notebook.py'
53--- zim/notebook.py 2010-03-14 19:22:51 +0000
54+++ zim/notebook.py 2010-03-15 23:54:24 +0000
55@@ -841,6 +841,9 @@
56 raise LookupError, 'Page does not exist: %s' % path.name
57 assert not page.modified, 'BUG: moving a page with uncomitted changes'
58
59+ if path == newpath:
60+ return
61+
62 self.emit('move-page', path, newpath, update_links)
63 logger.debug('Move %s to %s (%s)', path, newpath, update_links)
64
65
66=== modified file 'zim/parsing.py'
67--- zim/parsing.py 2010-03-10 20:21:40 +0000
68+++ zim/parsing.py 2010-03-15 23:54:24 +0000
69@@ -219,6 +219,20 @@
70 result.append(item)
71 return result
72
73+ def start(self,group=0):
74+ '''Return the indices of the start of the substring matched by group;
75+ group defaults to zero (meaning the whole matched substring). Return -1 if
76+ group exists but did not contribute to the match. See re.matchobject for
77+ details'''
78+ return self.m.start(group)
79+
80+ def end(self,group=0):
81+ '''Return the indices of the end of the substring matched by group;
82+ group defaults to zero (meaning the whole matched substring). Return -1 if
83+ group exists but did not contribute to the match. See re.matchobject for
84+ details'''
85+ return self.m.end(group)
86+
87 # Some often used regexes
88 is_url_re = Re('^(\w[\w\+\-\.]+)://')
89 # scheme "://"
90
91=== modified file 'zim/plugins/linkmap/__init__.py'
92--- zim/plugins/linkmap/__init__.py 2010-03-08 20:15:35 +0000
93+++ zim/plugins/linkmap/__init__.py 2010-03-15 23:54:24 +0000
94@@ -34,7 +34,7 @@
95
96 @classmethod
97 def check_dependencies(klass):
98- return [('GraphViz',Application(('dot',)).tryexec())]
99+ return [('GraphViz',Application(('fdp',)).tryexec())]
100
101 def disconnect(self):
102 pass
103
104=== modified file 'zim/plugins/linkmap/gui.py'
105--- zim/plugins/linkmap/gui.py 2009-08-13 13:21:00 +0000
106+++ zim/plugins/linkmap/gui.py 2010-03-15 23:54:24 +0000
107@@ -51,7 +51,7 @@
108 self.vbox.add(hbox)
109
110 self.xdotview = xdot.DotWidget()
111- self.xdotview.set_filter('neato')
112+ self.xdotview.set_filter('fdp')
113 self.xdotview.set_dotcode(linkmap.get_dotcode())
114 self.xdotview.connect('clicked', self.on_node_clicked)
115 hbox.add(self.xdotview)