def compose_tbl_filename(
        key_names, key_indices=None,
        prefix='tbl', suffix='txt',
        var_separator='.', idx_separator='-'):
    """compose a file name based on key names

    Parameters
    ----------
    key_names : list of str
        A list of key names
    key_indices : list of str
        A list of key indices, which can be a number, ``None``, a
        wildcard ``*``, a wildcards in parentheses ``(*)``, a back
        reference ``\\n`` (``n`` is a number),
        e.g., ``(1, None, '*', '(*)', '\\1')``
    prefix : str, default ``tbl``
        A prefix of a file name
    suffix : str, default ``txt``
        A suffix of a file name (filename extension)
    var_separator : str, default '.'
        A separator between key names
    idx_separator : str, default '-'
        A separator between a key name and a key index

    Returns
    -------
    str
        A file name

    """

    if not key_names:
        return prefix + '.' + suffix # e.g. "tbl.txt"

    if key_indices is None:
        colidxs = key_names
        # e.g., ('var1', 'var2', 'var3'),

        middle = var_separator.join(colidxs)
        # e.g., 'var1.var2.var3'

        ret = prefix + var_separator + middle + '.' + suffix
        # e.g., 'tbl.var1.var2.var3.txt'

        return ret

    # e.g.,
    # key_names = ('var1', 'var2', 'var3', 'var4', 'var5'),
    # key_indices = (1, None, '*', '(*)', '\\1')

    idx_str = key_indices
    # e.g., (1, None, '*', '(*)', '\\1')

    idx_str = ['w' if i == '*' else i for i in idx_str]
    # e..g, [1, None, 'w', '(*)', '\\1']

    idx_str = ['wp' if i == '(*)' else i for i in idx_str]
    # e.g., [1, None, 'w', 'wp', '\\1']

    idx_str = ['b{}'.format(i[1:]) if isinstance(i, str) and i.startswith('\\') else i for i in idx_str]
    # e.g., [1, None, 'w', 'wp', 'b1']

    idx_str = ['' if i is None else '{}{}'.format(idx_separator, i) for i in idx_str]
    # e.g., ['-1', '', '-w', '-wp', '-b1']

    colidxs = [n + i for n, i in zip(key_names, idx_str)]
    # e.g., ['var1-1', 'var2', 'var3-w', 'var4-wp', 'var5-b1']

    middle = var_separator.join(colidxs)
    # e.g., 'var1-1.var2.var3-w.var4-wp.var5-b1'

    ret =  prefix + var_separator + middle + '.' + suffix
    # e.g., tbl.var1-1.var2.var3-w.var4-wp.var5-b1.txt

    return ret