diff options
Diffstat (limited to 'examples/plugin_new_macro.py')
-rw-r--r-- | examples/plugin_new_macro.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/plugin_new_macro.py b/examples/plugin_new_macro.py index 8dbe435d..1c69b841 100644 --- a/examples/plugin_new_macro.py +++ b/examples/plugin_new_macro.py @@ -4,18 +4,20 @@ # date in commands that allow macros. You can test it with the command # ":shell echo %date; read" -# Save the original macro function +import time + import ranger.core.actions -old_get_macros = ranger.core.actions.Actions._get_macros -# Define a new macro function -import time +# Save the original macro function +GET_MACROS_OLD = ranger.core.actions.Actions._get_macros # pylint: disable=protected-access +# Define a new macro function def get_macros_with_date(self): - macros = old_get_macros(self) + macros = GET_MACROS_OLD(self) macros['date'] = time.strftime('%m/%d/%Y') return macros + # Overwrite the old one -ranger.core.actions.Actions._get_macros = get_macros_with_date +ranger.core.actions.Actions._get_macros = get_macros_with_date # pylint: disable=protected-access |