# Path: ranger.py
# ARGV = sys.argv[1:sys.argv.index('--')] if '--' in sys.argv else sys.argv[1:]


import os
import re
import ranger
        import logging
    import doctest
    import sys
from ranger import MACRO_DELIMITER, MACRO_DELIMITER_ESC
from ranger.core.shared import FileManagerAware
from ranger.ext.lazy_property import lazy_property
from ranger.api import LinemodeBase, hook_init, hook_ready, register_linemode  # COMPAT
        from os.path import dirname, basename, expanduser, join
        from os.path import dirname, basename, expanduser, join
        from ranger.ext.get_executables import get_executables
# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.

# TODO: Add an optional "!" to all commands and set a flag if it's there

from __future__ import (absolute_import, division, print_function)




__all__ = ['Command', 'LinemodeBase', 'hook_init', 'hook_ready', 'register_linemode']  # COMPAT


_SETTINGS_RE = re.compile(r'^\s*([^\s]+?)=(.*)$')
_ALIAS_LINE_RE = re.compile(r'(\s+)')


def _command_init(cls):
    # Escape macros for tab completion
    if cls.resolve_macros:
        tab_old = cls.tab

        def tab(self, tabnum):
            results = tab_old(self, tabnum)
            if results is None:
                return None
            elif isinstance(results, str):
                return results.replace(MACRO_DELIMITER, MACRO_DELIMITER_ESC)
            elif hasattr(results, '__iter__'):

# Path: ranger.py
# ARGV = sys.argv[1:sys.argv.index('--')] if '--' in sys.argv else sys.argv[1:]


# Path: ranger/api/commands.py
import os
import re
import ranger
        import logging
    import doctest
    import sys
from ranger import MACRO_DELIMITER, MACRO_DELIMITER_ESC
from ranger.core.shared import FileManagerAware
from ranger.ext.lazy_property import lazy_property
from ranger.api import LinemodeBase, hook_init, hook_ready, register_linemode  # COMPAT
        from os.path import dirname, basename, expanduser, join
        from os.path import dirname, basename, expanduser, join
        from ranger.ext.get_executables import get_executables

# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.

# TODO: Add an optional "!" to all commands and set a flag if it's there

from __future__ import (absolute_import, division, print_function)




__all__ = ['Command', 'LinemodeBase', 'hook_init', 'hook_ready', 'register_linemode']  # COMPAT


_SETTINGS_RE = re.compile(r'^\s*([^\s]+?)=(.*)$')
_ALIAS_LINE_RE = re.compile(r'(\s+)')


def _command_init(cls):
    # Escape macros for tab completion
    if cls.resolve_macros:
        tab_old = cls.tab

        def tab(self, tabnum):
            results = tab_old(self, tabnum)
            if results is None:
                return None
            elif isinstance(results, str):
                return results.replace(MACRO_DELIMITER, MACRO_DELIMITER_ESC)
            elif hasattr(results, '__iter__'):

                return (result.replace(MACRO_DELIMITER, MACRO_DELIMITER_ESC) for result in results)