parameters: (self,name,hook, priority=50, str_key=None, re_key=None,
                   _warn_deprecated=True)
docstring: 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.
docstring_summary: set_hook(name,hook) -> sets an internal IPython hook.
docstring_tokens: set_hook ( name hook ) - > sets an internal IPython hook .
function: def set_hook(self,name,hook, priority=50, str_key=None, re_key=None,
                   _warn_deprecated=True):
          """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."""
  
          # At some point in the future, this should validate the hook before it
          # accepts it.  Probably at least check that the hook takes the number
          # of args it's supposed to.
  
          f = types.MethodType(hook,self)
  
          # check if the hook is for strdispatcher first
          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 _warn_deprecated and (name in IPython.core.hooks.deprecated):
              alternative = IPython.core.hooks.deprecated[name]
              warn("Hook {} is deprecated. Use {} instead.".format(name, alternative))
  
          if not dp:
              dp = IPython.core.hooks.CommandChainDispatcher()
  
          try:
              dp.add(f,priority)
          except AttributeError:
              # it was not commandchain, plain old func - replace
              dp = f
  
          setattr(self.hooks,name, dp)
function_tokens: def set_hook ( self , name , hook , priority = 50 , str_key = None , re_key = None , _warn_deprecated = True ) : # At some point in the future, this should validate the hook before it # accepts it.  Probably at least check that the hook takes the number # of args it's supposed to. f = types . MethodType ( hook , self ) # check if the hook is for strdispatcher first 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 _warn_deprecated and ( name in IPython . core . hooks . deprecated ) : alternative = IPython . core . hooks . deprecated [ name ] warn ( "Hook {} is deprecated. Use {} instead." . format ( name , alternative ) ) if not dp : dp = IPython . core . hooks . CommandChainDispatcher ( ) try : dp . add ( f , priority ) except AttributeError : # it was not commandchain, plain old func - replace dp = f setattr ( self . hooks , name , dp )