Merge lp:~vr123456/leo-editor/detect_urls into lp:leo-editor/old-trunk

Proposed by Viktor Ransmayr
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vr123456/leo-editor/detect_urls
Merge into: lp:leo-editor/old-trunk
Diff against target: 162 lines (+45/-20)
2 files modified
leo/plugins/detect_urls.py (+34/-9)
leo/plugins/leoPluginsRef.leo (+11/-11)
To merge this branch: bzr merge lp:~vr123456/leo-editor/detect_urls
Reviewer Review Type Date Requested Status
The Leo editor team Pending
Review via email: mp+17100@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Viktor Ransmayr (vr123456) wrote :

I have made one more improvement, that I think is important.

I have introduced an explicit 'init' function, so that info
about the plugin is published, when the cmd 'print-plugins-info'
is executed.

I have used the style found in plugin 'maximizeNewWindows.py'.

Please check especially the section << version history >>
and my 'version' choice. - I do not know if there is any
established convention, that I should follow ...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'leo/plugins/detect_urls.py'
2--- leo/plugins/detect_urls.py 2010-01-09 13:50:47 +0000
3+++ leo/plugins/detect_urls.py 2010-01-10 15:58:16 +0000
4@@ -3,8 +3,7 @@
5 #@<< docstring >>
6 #@+node:vpe.20060426084738:<< docstring >>
7 """
8-Colorizes URLs everywhere in node's body on node selection
9-or saving.
10+Colorizes URLs everywhere in node's body on node selection or saving.
11
12 Double click on any URL launches it in default browser.
13
14@@ -16,13 +15,45 @@
15 #@nl
16 #@@language python
17 #@@tabwidth -4
18+
19+__version__ = "0.3"
20+#@<< version history >>
21+#@+node:RV20090910.20100110154407.7439:<< version history >>
22+#@+at
23+#
24+# Originally written by ???
25+#
26+# 0.1 ???: Initial version.
27+#
28+# 0.2 VR: Detect URLs with protocol type 'file' and detect a new URL also
29+# after a save operation.
30+#
31+# 0.3 VR: Display info about this plugin, when executing cmd
32+# 'print-plugins-info'.
33+#@-at
34+#@-node:RV20090910.20100110154407.7439:<< version history >>
35+#@nl
36+#@<< imports >>
37+#@+node:RV20090910.20100110154407.7437:<< imports >>
38 import leo.core.leoGlobals as g
39 import leo.core.leoPlugins as leoPlugins
40 import re
41-#VR20100108: url_regex = re.compile(r"""(http|https|ftp)://[^\s'"]+[\w=/]""")
42+#@-node:RV20090910.20100110154407.7437:<< imports >>
43+#@nl
44+
45 url_regex = re.compile(r"""(http|https|file|ftp)://[^\s'"]+[\w=/]""")
46
47 #@+others
48+#@+node:RV20090910.20100110154407.7438:init()
49+def init():
50+ ok = not g.app.unitTesting
51+ if ok:
52+ leoPlugins.registerHandler("bodydclick1", openURL)
53+ leoPlugins.registerHandler("select2", colorizeURLs)
54+ leoPlugins.registerHandler("save2", colorizeURLs)
55+ g.plugin_signon(__name__)
56+ return ok
57+#@-node:RV20090910.20100110154407.7438:init()
58 #@+node:vpe.20060305064323.5:openURL()
59 def openURL(tag,keywords):
60 c = keywords.get("c")
61@@ -69,11 +100,5 @@
62 n += len(line) + 1
63 #@-node:vpe.20060426062042:colorizeURLs()
64 #@-others
65-
66-if 1:
67- leoPlugins.registerHandler("bodydclick1", openURL)
68- leoPlugins.registerHandler("select2", colorizeURLs)
69- leoPlugins.registerHandler("save2", colorizeURLs) #VR20100108
70- g.plugin_signon(__name__)
71 #@-node:ekr.20060506070443.1:@thin detect_urls.py
72 #@-leo
73
74=== modified file 'leo/plugins/leoPluginsRef.leo'
75--- leo/plugins/leoPluginsRef.leo 2010-01-09 19:51:52 +0000
76+++ leo/plugins/leoPluginsRef.leo 2010-01-10 15:58:16 +0000
77@@ -3,7 +3,7 @@
78 <leo_file>
79 <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/>
80 <globals body_outline_ratio="0.5">
81- <global_window_position top="48" left="25" height="692" width="996"/>
82+ <global_window_position top="48" left="10" height="692" width="1024"/>
83 <global_log_window_position top="0" left="0" height="0" width="0"/>
84 </globals>
85 <preferences/>
86@@ -32,9 +32,9 @@
87 <v t="ekr.20090430075506.4"><vh>Notes &amp; to-do</vh>
88 <v t="ekr.20090430075506.3"><vh>@thin leoPluginNotes.txt</vh></v>
89 </v>
90-<v t="edream.110203113231.618"><vh>Plugins</vh>
91+<v t="edream.110203113231.618" a="E"><vh>Plugins</vh>
92 <v t="EKR.20040517090508"><vh> Enable plugins using @enabled-plugins nodes</vh></v>
93-<v t="ekr.20050303051035"><vh> Templates: these show recommended ways of defining plugins.</vh>
94+<v t="ekr.20050303051035" a="E"><vh> Templates: these show recommended ways of defining plugins.</vh>
95 <v t="ekr.20041114102139"><vh>Notes</vh>
96 <v t="ekr.20041114103913"><vh>About comments in the style guide</vh></v>
97 <v t="ekr.20041114102139.1"><vh>About the root node</vh></v>
98@@ -64,7 +64,7 @@
99 <v t="ekr.20091118065749.5261"><vh>@thin ctagscompleter.py</vh></v>
100 <v t="ville.20091204224145.5355"><vh>@thin codewisecompleter.py</vh></v>
101 </v>
102-<v t="ekr.20040722135402.1"><vh>Body pane</vh>
103+<v t="ekr.20040722135402.1" a="E"><vh>Body pane</vh>
104 <v t="edream.110403140857.8"><vh>@thin color_markup.py</vh></v>
105 <v t="ekr.20060506070443.1"><vh>@thin detect_urls.py</vh></v>
106 <v t="edream.110203113231.753"><vh>@thin image.py</vh></v>
107@@ -364,7 +364,7 @@
108 <v t="edream.110203113231.873"><vh>@thin at_folder.py</vh></v>
109 <v t="ekr.20040915085351"><vh>@thin at_produce.py</vh></v>
110 <v t="ktenney.20041211072654.1"><vh>@thin at_view.py</vh></v>
111-<v t="tbrown.20091029123555.5319" descendentVnodeUnknownAttributes="7d71005803000000302e3571017d710258040000007465737471037d710458050000005f6564697471057d7106580400000074686973710758120000006f6b20686f77206120626f757420746869737108737373732e"><vh>@thin attrib_edit.py</vh></v>
112+<v t="tbrown.20091029123555.5319" descendentVnodeUnknownAttributes="7d71005503302e3571017d710258040000007465737471037d710458050000005f6564697471057d7106580400000074686973710758120000006f6b20686f77206120626f757420746869737108737373732e"><vh>@thin attrib_edit.py</vh></v>
113 <v t="mork.20041020082242.1"><vh>@thin base64Packager.py</vh></v>
114 <v t="tbrown.20070322113635"><vh>@thin bookmarks.py</vh></v>
115 <v t="ekr.20060807103814.1"><vh>@thin datenodes.py</vh></v>
116@@ -801,8 +801,7 @@
117 </v>
118 <v t="ekr.20100103093121.5329"
119 marks="vivainio2.20091008133028.5823,vivainio2.20091008140054.14555,ville.20091008210853.7616,ville.20091023181249.5264,vivainio2.20091008133028.5825,ville.20091023181249.5266,"><vh>@thin stickynotes.py</vh></v>
120-<v t="ekr.20100103093121.5339"
121-marks="vivainio2.20091008133028.5823,vivainio2.20091008140054.14555,ville.20091008210853.7616,ville.20091023181249.5264,vivainio2.20091008133028.5825,ville.20091023181249.5266,"><vh>@thin stickynotes_plus.py</vh></v>
122+<v t="ekr.20100103093121.5339"><vh>@thin stickynotes_plus.py</vh></v>
123 <v t="ekr.20070119094733.1"><vh>@thin dtest.py</vh></v>
124 </v>
125 <v t="ekr.20061023142737"><vh>UNL plugin</vh>
126@@ -814,7 +813,7 @@
127 </v>
128 <v t="rogererens.20041013082304"><vh>@thin UNL.py</vh></v>
129 </v>
130-<v t="ekr.20040915073259"><vh>Windows</vh>
131+<v t="ekr.20040915073259" a="E"><vh>Windows</vh>
132 <v t="tbrown.20090322083202.1"><vh>NOTE: todo.py is qt verion of cleo.py (which is tk)</vh></v>
133 <v t="tbrown.20090119215428.2"><vh>@thin todo.py</vh></v>
134 <v t="ekr.20050227071948"><vh> cleo</vh>
135@@ -861,7 +860,7 @@
136 <v t="pap.20041020001240"><vh>@thin footprints.py</vh></v>
137 </v>
138 <v t="mork.20041018162155.1"><vh>@thin EditAttributes.py</vh></v>
139-<v t="ekr.20040915073259.1"><vh>@thin maximizeNewWindows.py</vh></v>
140+<v t="ekr.20040915073259.1" a="E"><vh>@thin maximizeNewWindows.py</vh></v>
141 <v t="mork.20041022155742.1"><vh>@thin nodebar.py</vh></v>
142 <v t="edream.110203113231.924"><vh>@thin redirect_to_log.py</vh></v>
143 <v t="ekr.20040915075530"><vh>@thin UASearch.py</vh></v>
144@@ -870,7 +869,8 @@
145 <v t="ekr.20060506070443.1"></v>
146 <v t="ville.20090310191936.10"><vh>@thin colorize_headlines.py</vh></v>
147 <v t="ville.20090314215508.4"><vh>@thin quicksearch.py</vh></v>
148-<v t="ville.20091008210853.5241"><vh>@thin stickynotes.py</vh></v>
149+<v t="ville.20091008210853.5241"
150+marks="vivainio2.20091008133028.5823,vivainio2.20091008140054.14555,ville.20091008210853.7616,ville.20091023181249.5264,vivainio2.20091008133028.5825,ville.20091023181249.5266,"><vh>@thin stickynotes.py</vh></v>
151 </v>
152 </v>
153 </vnodes>
154@@ -4496,7 +4496,7 @@
155 <t tx="ekr.20041114103913.1">PLEASE define each function or method in a separate node! To make this work,
156 just put @others in the root of your plugin as shown. Note that @others may be
157 nested, as shown in class myClass.</t>
158-<t tx="ekr.20041211035618" str_leo_pos="2"></t>
159+<t tx="ekr.20041211035618" str_leo_pos="2,3,1"></t>
160 <t tx="ekr.20041231134702"># This is called from plugins_menu plugin.
161
162 # It should only be defined if the extension has been registered.

Subscribers

People subscribed via source and target branches

to status/vote changes: