summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2017-02-03 01:14:19 +0100
committernfnty <git@nfnty.se>2017-02-03 01:16:29 +0100
commit71a5fa56a40fe447a5670aef9800711b93553e25 (patch)
treed8c4be42b4144a96c1ed684e4d093dea224624de
parentbf080d7a110eb9741a143bc8529a55d91862ec0d (diff)
downloadranger-71a5fa56a40fe447a5670aef9800711b93553e25.tar.gz
Fix alias macro expansion
Fixes #732
-rw-r--r--ranger/api/commands.py7
-rw-r--r--ranger/core/actions.py13
2 files changed, 13 insertions, 7 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index b7497b61..1997cde5 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -104,10 +104,13 @@ class Command(FileManagerAware):
     _setting_line = None
 
     def __init__(self, line, quantifier=None):
-        self.line = line
-        self.args = line.split()
+        self.init_line(line)
         self.quantifier = quantifier
         self.quickly_executed = False
+
+    def init_line(self, line):
+        self.line = line
+        self.args = line.split()
         try:
             self.firstpart = line[:line.rindex(' ') + 1]
         except ValueError:
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index c30c48a2..f17ed01d 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -226,22 +226,25 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
         if cmd_class is None:
             self.notify("Command not found: `%s'" % command_name, bad=True)
             return
-        cmd = cmd_class(string)
-        if cmd.resolve_macros and _MacroTemplate.delimiter in string:
+        cmd = cmd_class(string, quantifier=quantifier)
+
+        if cmd.resolve_macros and _MacroTemplate.delimiter in cmd.line:
             macros = dict(('any%d' % i, key_to_string(char))
                           for i, char in enumerate(wildcards if wildcards is not None else []))
             if 'any0' in macros:
                 macros['any'] = macros['any0']
             try:
-                string = self.substitute_macros(string, additional=macros,
-                                                escape=cmd.escape_macros_for_shell)
+                line = self.substitute_macros(cmd.line, additional=macros,
+                                              escape=cmd.escape_macros_for_shell)
             except ValueError as ex:
                 if ranger.args.debug:
                     raise
                 else:
                     return self.notify(ex)
+            cmd.init_line(line)
+
         try:
-            cmd_class(string, quantifier=quantifier).execute()
+            cmd.execute()
         except Exception as ex:  # pylint: disable=broad-except
             if ranger.args.debug:
                 raise