Skip to content

Commit 9762425

Browse files
committed
Bug fixes
1 parent d6a92dc commit 9762425

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/execute_request.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import REPL: helpmode
1616
# use a global array to accumulate "payloads" for the execute_reply message
1717
const execute_payloads = Dict[]
1818

19-
19+
# An array of macros to run on the contents of each cell
2020
const cell_macros = []
2121

2222
function run_cell_code(code)
@@ -31,11 +31,11 @@ function run_cell_code(code)
3131
startswith(line, "@@") || break
3232
mac_call = Meta.parse(line[2:end])
3333
@assert Meta.isexpr(mac_call, :macrocall)
34-
if mac_call.args[1] == Symbol("@nothing")
34+
if mac_call.args[1] == Symbol("@noauto")
3535
do_auto_macros = false
36-
continue
36+
else
37+
push!(cell_macro_calls, mac_call)
3738
end
38-
push!(cell_macro_calls, mac_call)
3939
line_no += 1
4040
end
4141
code = join((@view lines[line_no:end]), '\n')
@@ -46,9 +46,13 @@ function run_cell_code(code)
4646
file = "In[$n]"
4747
line_node = LineNumberNode(line_no, file)
4848
ast = Meta.parse("begin\n$(code)\nend")
49+
# Make block top level
50+
if Meta.isexpr(ast, :block)
51+
ast.head = :toplevel
52+
end
4953
for mac_call in Iterators.reverse(cell_macro_calls)
5054
push!(mac_call.args, ast)
51-
ast = macroexpand(mod, mac_call)
55+
ast = macroexpand(mod, mac_call, recursive=false)
5256
end
5357
if do_auto_macros
5458
if SOFTSCOPE[]
@@ -59,11 +63,6 @@ function run_cell_code(code)
5963
end
6064
end
6165

62-
# Make top level
63-
if ast isa Expr && Meta.isexpr(ast.head, :block)
64-
ast.head = :toplevel
65-
end
66-
6766
# Run
6867
Base.eval(mod, ast)
6968
end
@@ -72,7 +71,7 @@ function _apply_macro(mac, ast, mod)
7271
macro_expr = :(@macro_placehoder $ast)
7372
@assert Meta.isexpr(macro_expr, :macrocall)
7473
macro_expr.args[1] = mac
75-
macroexpand(mod, macro_expr)
74+
macroexpand(mod, macro_expr, recursive=false)
7675
end
7776

7877
function execute_request(socket, msg)

0 commit comments

Comments
 (0)