Description
Sometimes in my code I would like to use a macro on a block of code without indenting it. For example, I want to go from
const CONST = 1
function foo(x)
x + CONST
end
to this:
@mymacro begin
const CONST = 1
function foo(x)
x + CONST
end
end
This could be something like DispatchDoctor.jl @stable
or Base.@assume_effects
, which can operate on entire code blocks.
Now, if I have the formatter turned on, this will turn into
@mymacro begin
const CONST = 1
function foo(x)
x + CONST
end
end
This is of course valid, but I would like to disable it for the code block. I want the @mymacro begin
to just sit at the top level without affecting the rest of the code. (It's kind of like how module A ... end
doesn't indent everything in the contents.)
The only workaround at the moment is to use #! format: off
for the entire code block. This works but it prevents me from using JuliaFormatter.jl for internal code.
Thus, @domluna, I was wondering if there could be a special command to ignore the increased indentation for a single block? Happy to help add it if you can point me to where to edit.