summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-12-03 23:26:19 +0100
committerhut <hut@lavabit.com>2012-12-04 23:32:21 +0100
commit32a80ea727d940a5f359a135a4b8d83b77fa0bca (patch)
tree756d40fd432a288bbf8aa4c090a1d12ba29f7bda
parentca1a5d21e6564c022b810c4f52daf61fc4f3ea30 (diff)
downloadranger-32a80ea727d940a5f359a135a4b8d83b77fa0bca.tar.gz
added examples/plugin_hello_world.py
-rw-r--r--examples/plugin_hello_world.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/plugin_hello_world.py b/examples/plugin_hello_world.py
new file mode 100644
index 00000000..187f428e
--- /dev/null
+++ b/examples/plugin_hello_world.py
@@ -0,0 +1,21 @@
+# This is a sample plugin that displays "Hello World" in ranger's console after
+# it started.
+
+# We are going to extend the hook "ranger.api.hook_ready", so first we need
+# to import ranger.api:
+import ranger.api
+
+# Save the previously existing hook, because maybe another module already
+# extended that hook and we don't want to lose it:
+old_hook_ready = ranger.api.hook_ready
+
+# Create a replacement for the hook that...
+def hook_ready(fm):
+  # ...does the desired action...
+  fm.notify("Hello World")
+  # ...and calls the saved hook.  If you don't care about the return value, simply
+  # return the return value of the previous hook to be on the safe side.
+  return old_hook_ready(fm)
+
+# Finally, "monkey patch" the existing hook_ready function with our replacement:
+ranger.api.hook_ready = hook_ready
multiple files' href='/akkartik/mu/commit/edit/008-sandbox-trace.mu?h=hlt&id=a90faae99043042ec5e2d0de21b7dbe0eba29e3a'>a90faae9 ^
294b2ab3 ^
a90faae9 ^
dd30f56d ^
294b2ab3 ^

898f03cc ^
294b2ab3 ^
ceeb92d4 ^
71056d61 ^
a90faae9 ^
fa94f4d9 ^
a90faae9 ^
dd30f56d ^
a90faae9 ^

294b2ab3 ^
6f65d591 ^
55479bc2 ^
a90faae9 ^


dd30f56d ^
294b2ab3 ^

898f03cc ^
294b2ab3 ^
71056d61 ^
a90faae9 ^

dd30f56d ^
71056d61 ^
ceeb92d4 ^
71056d61 ^


a90faae9 ^


dd30f56d ^
a90faae9 ^

294b2ab3 ^
55479bc2 ^
a90faae9 ^


dd30f56d ^
294b2ab3 ^

898f03cc ^
294b2ab3 ^
ceeb92d4 ^
71056d61 ^
a90faae9 ^



6f65d591 ^
e00d4854 ^
dd30f56d ^
a90faae9 ^
294b2ab3 ^








6d12a8c4 ^
a90faae9 ^
a90faae9 ^


294b2ab3 ^
a90faae9 ^
dd30f56d ^
294b2ab3 ^

898f03cc ^
294b2ab3 ^

ceeb92d4 ^
71056d61 ^
a90faae9 ^
fa94f4d9 ^
a90faae9 ^
dd30f56d ^
a90faae9 ^

294b2ab3 ^
a90faae9 ^
fa94f4d9 ^
a90faae9 ^
dd30f56d ^
294b2ab3 ^

898f03cc ^
294b2ab3 ^

71056d61 ^

ceeb92d4 ^
71056d61 ^
9c2421ec ^



6f65d591 ^
9c2421ec ^

294b2ab3 ^


6d12a8c4 ^
9c2421ec ^
9c2421ec ^



294b2ab3 ^
9c2421ec ^

71056d61 ^
ceeb92d4 ^
898f03cc ^
71056d61 ^

9c2421ec ^





294b2ab3 ^
9c2421ec ^



71056d61 ^
ceeb92d4 ^
898f03cc ^
71056d61 ^

a90faae9 ^


2d91279b ^
e2b367dc ^
3d8b137c ^
b4bccf49 ^


2d91279b ^
b4bccf49 ^
4a48bedc ^
ea19d0dc ^
3d8b137c ^
ea5e7fd4 ^


b4bccf49 ^

a90faae9 ^

fa94f4d9 ^
a90faae9 ^
3d8b137c ^


a90faae9 ^
2d91279b ^
a90faae9 ^
3d8b137c ^


a90faae9 ^

2d91279b ^
a90faae9 ^

3d8b137c ^
ea5e7fd4 ^

4e7186fa ^
ea5e7fd4 ^
ada5eb55 ^
a90faae9 ^


2d91279b ^
a90faae9 ^
4a48bedc ^
a90faae9 ^
350ca0c6 ^
3d8b137c ^

a90faae9 ^


2d91279b ^
a90faae9 ^
3d8b137c ^

a90faae9 ^




3d8b137c ^




a90faae9 ^

01ce563d ^
a90faae9 ^
1ead3562 ^
a90faae9 ^




3d8b137c ^
a90faae9 ^
ea19d0dc ^
a90faae9 ^
afdda1ea ^
a90faae9 ^
8beff53e ^
a90faae9 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253