@@ -117,9 +117,6 @@ REPL.REPLDisplay(repl::MiniREPL) = repl.display
117117 # from the front-end.
118118 comms:: Dict{String, Comm} = Dict {String, Comm} ()
119119
120- postexecute_hooks:: Vector{Function} = Function[]
121- preexecute_hooks:: Vector{Function} = Function[]
122- posterror_hooks:: Vector{Function} = Function[]
123120 shutdown:: Function = exit
124121
125122 # the following constants need to be initialized in init().
@@ -405,7 +402,10 @@ history
405402# Similar to the ipython kernel, we provide a mechanism by
406403# which modules can register thunk functions to be called after
407404# executing an input cell, e.g. to "close" the current plot in Pylab.
408- # Modules should only use these if isdefined(Main, IJulia) is true.
405+
406+ const _preexecute_hooks = Function[]
407+ const _postexecute_hooks = Function[]
408+ const _posterror_hooks = Function[]
409409
410410function _pop_hook! (f, hooks)
411411 hook_idx = findlast (isequal (f), hooks)
@@ -422,29 +422,31 @@ end
422422Push a function `f()` onto the end of a list of functions to
423423execute after executing any notebook cell.
424424"""
425- push_postexecute_hook (f:: Function ; kernel= _default_kernel) = push! (kernel. postexecute_hooks, f)
425+ push_postexecute_hook (f:: Function ) = push! (IJulia. _postexecute_hooks, f)
426+
426427"""
427428 pop_postexecute_hook(f::Function)
428429
429430Remove a function `f()` from the list of functions to
430431execute after executing any notebook cell.
431432"""
432- pop_postexecute_hook (f:: Function ; kernel = _default_kernel ) = _pop_hook! (f, kernel . postexecute_hooks )
433+ pop_postexecute_hook (f:: Function ) = _pop_hook! (f, IJulia . _postexecute_hooks )
433434
434435"""
435436 push_preexecute_hook(f::Function)
436437
437438Push a function `f()` onto the end of a list of functions to
438439execute before executing any notebook cell.
439440"""
440- push_preexecute_hook (f:: Function ; kernel= _default_kernel) = push! (kernel. preexecute_hooks, f)
441+ push_preexecute_hook (f:: Function ) = push! (IJulia. _preexecute_hooks, f)
442+
441443"""
442444 pop_preexecute_hook(f::Function)
443445
444446Remove a function `f()` from the list of functions to
445447execute before executing any notebook cell.
446448"""
447- pop_preexecute_hook (f:: Function ; kernel = _default_kernel ) = _pop_hook! (f, kernel . preexecute_hooks )
449+ pop_preexecute_hook (f:: Function ) = _pop_hook! (f, IJulia . _preexecute_hooks )
448450
449451# similar, but called after an error (e.g. to reset plotting state)
450452"""
@@ -453,14 +455,15 @@ pop_preexecute_hook(f::Function; kernel=_default_kernel) = _pop_hook!(f, kernel.
453455Remove a function `f()` from the list of functions to
454456execute after an error occurs when a notebook cell is evaluated.
455457"""
456- push_posterror_hook (f:: Function ; kernel= _default_kernel) = push! (kernel. posterror_hooks, f)
458+ push_posterror_hook (f:: Function ) = push! (IJulia. _posterror_hooks, f)
459+
457460"""
458461 pop_posterror_hook(f::Function)
459462
460463Remove a function `f()` from the list of functions to
461464execute after an error occurs when a notebook cell is evaluated.
462465"""
463- pop_posterror_hook (f:: Function ; kernel = _default_kernel ) = _pop_hook! (f, kernel . posterror_hooks )
466+ pop_posterror_hook (f:: Function ) = _pop_hook! (f, IJulia . _posterror_hooks )
464467
465468# ######################################################################
466469
0 commit comments