about summary refs log tree commit diff stats
path: root/ranger/api/commands.py
diff options
context:
space:
mode:
authorjoe <joebodo@gmail.com>2012-04-13 14:30:20 -0400
committerhut <hut@lavabit.com>2012-06-07 01:45:38 +0200
commit20f386e57398a16146a6e58f2b6ba349ed9248dd (patch)
tree9e2f8b541370a5b2e54442951eb5f1ac76969de1 /ranger/api/commands.py
parentf893d2feb5daa44ea7f0f1fdddcedc789d82644c (diff)
downloadranger-20f386e57398a16146a6e58f2b6ba349ed9248dd.tar.gz
Extended aliases
Diffstat (limited to 'ranger/api/commands.py')
-rw-r--r--ranger/api/commands.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index c3317939..97ef415c 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -23,9 +23,15 @@ class CommandContainer(object):
 	def __getitem__(self, key):
 		return self.commands[key]
 
-	def alias(self, new, old):
+	def alias(self, name, full_command):
 		try:
-			self.commands[new] = self.commands[old]
+			cmd = type(name, (AliasCommand, ), dict())
+			cmd._based_function = name
+			cmd._function_name = name
+			cmd._object_name = name
+			cmd._line = full_command
+			self.commands[name] = cmd
+
 		except:
 			pass
 
@@ -317,3 +323,11 @@ class FunctionCommand(Command):
 				self.fm.notify("Bad arguments for %s.%s: %s, %s" %
 						(self._object_name, self._function_name,
 							repr(args), repr(keywords)), bad=True)
+
+class AliasCommand(Command):
+	_based_function = None
+	_object_name = ""
+	_function_name = "unknown"
+	_line = ""
+	def execute(self):
+		self.fm.execute_console(self._line)