diff options
author | toonn <toonn@toonn.io> | 2018-09-06 15:33:00 +0200 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2018-09-06 15:33:00 +0200 |
commit | f12b7fc43fa1420b016e06be76f306d6a2834a8b (patch) | |
tree | 870d1e9e0b4ee8090945fb7c6fa4e6a8f8b73dc0 | |
parent | cc6d9a0b19d250215b822342436e8e81e71c4b4d (diff) | |
parent | 07cc58396035d1c25871632d8ee14cad08dbe69a (diff) | |
download | ranger-f12b7fc43fa1420b016e06be76f306d6a2834a8b.tar.gz |
Merge branch 'anypathmacro'
-rw-r--r-- | ranger/core/actions.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 83cfcc08..73c9fa51 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -240,10 +240,25 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m 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 [])) + def any_macro(i, char): + return ('any{:d}'.format(i), key_to_string(char)) + + def anypath_macro(i, char): + try: + val = self.fm.bookmarks[key_to_string(char)] + except KeyError: + self.notify('No bookmark defined for `{}`'.format( + key_to_string(char)), bad=True) + val = MACRO_FAIL + return ('any_path{:d}'.format(i), val) + + macros = dict(f(i, char) for f in (any_macro, anypath_macro) + for i, char in enumerate(wildcards if wildcards + is not None else [])) if 'any0' in macros: macros['any'] = macros['any0'] + if 'any_path0' in macros: + macros['any_path'] = macros['any_path0'] try: line = self.substitute_macros(cmd.line, additional=macros, escape=cmd.escape_macros_for_shell) |