summary refs log tree commit diff stats
path: root/doc/examples/plugin_hello_world.py
blob: a803e21bc1c5fb4341306b271c1163676bd5824c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Compatible with ranger 1.6.*
#
# 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 safe.
    return old_hook_ready(fm)

# Finally, "monkey patch" the existing hook_ready function with our replacement:
ranger.api.hook_ready = hook_ready
05-25 22:27:19 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-05-25 22:27:19 -0700 1459' href='/akkartik/mu/commit/html/063list.mu.html?h=hlt&id=c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008'>c5ffb6e1 ^
d44123ca ^

c5ffb6e1 ^
d44123ca ^
c5ffb6e1 ^


























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