import re


def get_fun_name(line):
    """
    Get function name from a line.
    >>> get_fun_name('function(foo)')
    'foo'
    >>> get_fun_name('function(foo BAR BAZ)')
    'foo'
    >>> get_fun_name('function(foo')
    'foo'
    >>> get_fun_name('set(')
    """
    match = re.match(r'(function|macro)\s*\((\w+)', line)
    if not match:
        return
    return match.groups()[1]