def set_hook(self, name, hook, priority=50, str_key=None, re_key=None):
    "set_hook(name,hook) -> sets an internal IPython hook.\n\n        IPython exposes some of its internal API as user-modifiable hooks.  By\n        adding your function to one of these hooks, you can modify IPython's\n        behavior to call at runtime your own routines."
    f = types.MethodType(hook, self)
    if (str_key is not None):
        sdp = self.strdispatchers.get(name, StrDispatch())
        sdp.add_s(str_key, f, priority)
        self.strdispatchers[name] = sdp
        return
    if (re_key is not None):
        sdp = self.strdispatchers.get(name, StrDispatch())
        sdp.add_re(re.compile(re_key), f, priority)
        self.strdispatchers[name] = sdp
        return
    dp = getattr(self.hooks, name, None)
    if (name not in IPython.core.hooks.__all__):
        print(("Warning! Hook '%s' is not one of %s" % (name, IPython.core.hooks.__all__)))
    if (name in IPython.core.hooks.deprecated):
        alternative = IPython.core.hooks.deprecated[name]
        raise ValueError('Hook {} has been deprecated since IPython 5.0. Use {} instead.'.format(name, alternative))
    if (not dp):
        dp = IPython.core.hooks.CommandChainDispatcher()
    try:
        dp.add(f, priority)
    except AttributeError:
        dp = f
    setattr(self.hooks, name, dp)
set_hook(name,hook) -> sets an internal IPython hook.

IPython exposes some of its internal API as user-modifiable hooks.  By
adding your function to one of these hooks, you can modify IPython's
behavior to call at runtime your own routines.
def set_hook(self, name, hook, priority=50, str_key=None, re_key=None):
    "set_hook(name,hook) -> sets an internal IPython hook.\n\n        IPython exposes some of its internal API as user-modifiable hooks.  By\n        adding your function to one of these hooks, you can modify IPython's\n        behavior to call at runtime your own routines."
    f = types.MethodType(hook, self)
    if (str_key is not None):
        sdp = self.strdispatchers.get(name, StrDispatch())
        sdp.add_s(str_key, f, priority)
        self.strdispatchers[name] = sdp
        return
    if (re_key is not None):
        sdp = self.strdispatchers.get(name, StrDispatch())
        sdp.add_re(re.compile(re_key), f, priority)
        self.strdispatchers[name] = sdp
        return
    dp = getattr(self.hooks, name, None)
    if (name not in IPython.core.hooks.__all__):
        print(("Warning! Hook '%s' is not one of %s" % (name, IPython.core.hooks.__all__)))
    if (name in IPython.core.hooks.deprecated):
        alternative = IPython.core.hooks.deprecated[name]
        raise ValueError('Hook {} has been deprecated since IPython 5.0. Use {} instead.'.format(name, alternative))
    if (not dp):
        dp = IPython.core.hooks.CommandChainDispatcher()
    try:
        dp.add(f, priority)
    except AttributeError:
        dp = f
    setattr(self.hooks, name, dp)