From 71a5fa56a40fe447a5670aef9800711b93553e25 Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 3 Feb 2017 01:14:19 +0100 Subject: Fix alias macro expansion Fixes #732 --- ranger/api/commands.py | 7 +++++-- ranger/core/actions.py | 13 ++++++++----- 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 -- cgit 1.4.1-2-gfad0 043d0cf6bb7'>root/036call_reply.cc
blob: 8d3f1395329ab93e9e4cd7bfb3cadf17ddbebd4f (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
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