about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-14 03:10:22 +0100
committerhut <hut@lavabit.com>2010-01-14 03:10:22 +0100
commit832b516c52e74b7180c0e5fc5d5c2d995d1aacf6 (patch)
tree277e0c437edfc2edfa6c164f79b70d10b90fd4dc /ranger
parent4e9450f955e763a4d301645ab11201834d8a0ccc (diff)
downloadranger-832b516c52e74b7180c0e5fc5d5c2d995d1aacf6.tar.gz
keyapi: allow bind to act as a function decorator
Diffstat (limited to 'ranger')
-rw-r--r--ranger/keyapi.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/ranger/keyapi.py b/ranger/keyapi.py
index c8c60b77..546a0641 100644
--- a/ranger/keyapi.py
+++ b/ranger/keyapi.py
@@ -22,7 +22,13 @@ from ranger.container.bookmarks import ALLOWED_KEYS as ALLOWED_BOOKMARK_KEYS
 
 def make_abbreviations(command_list):
 	def bind(*args):
-		command_list.bind(args[-1], *args[:-1])
+		lastarg = args[-1]
+		if hasattr(lastarg, '__call__'):
+			# do the binding
+			command_list.bind(lastarg, *args[:-1])
+		else:
+			# act as a decorator
+			return lambda fnc: command_list.bind(fnc, *args)
 	
 	def hint(*args):
 		command_list.hint(args[-1], *args[:-1])