From e56e4fbcfc41e788f085660a64ad85a6024dfa25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Mon, 25 Nov 2024 15:35:29 +0100 Subject: [PATCH 1/2] Make fake_bind compatible to runic. See https://github.com/fredrikekre/Runic.jl/issues/107#issuecomment-2498098108 --- src/runner/PlutoRunner/src/bonds.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/runner/PlutoRunner/src/bonds.jl b/src/runner/PlutoRunner/src/bonds.jl index 3bf792a6c..863fbddd9 100644 --- a/src/runner/PlutoRunner/src/bonds.jl +++ b/src/runner/PlutoRunner/src/bonds.jl @@ -133,16 +133,16 @@ end """ Will be inserted in saved notebooks that use the @bind macro, make sure that they still contain legal syntax when executed as a vanilla Julia script. Overloading `Base.get` for custom UI objects gives bound variables a sensible value. -Also turns off JuliaFormatter formatting to avoid issues with the formatter trying to change code that the user does not control. See https://domluna.github.io/JuliaFormatter.jl/stable/#Turn-off/on-formatting +Also turns off Runic and JuliaFormatter formatting to avoid issues with the formatter trying to change code that the user does not control. See https://domluna.github.io/JuliaFormatter.jl/stable/#Turn-off/on-formatting or https://github.com/fredrikekre/Runic.jl?tab=readme-ov-file#toggle-formatting """ -const fake_bind = """macro bind(def, element) - #! format: off +const fake_bind = """#! format: off +macro bind(def, element) quote local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end local el = \$(esc(element)) global \$(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) el end - #! format: on -end""" +end +#! format: on""" From efa5abc63855775ff2fc5df241f92e1e8f75e721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Fri, 10 Jan 2025 14:19:46 +0100 Subject: [PATCH 2/2] Just return quote in fake_bind instead of wrapping the whole macro into format off/on --- src/runner/PlutoRunner/src/bonds.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runner/PlutoRunner/src/bonds.jl b/src/runner/PlutoRunner/src/bonds.jl index 863fbddd9..3145d4834 100644 --- a/src/runner/PlutoRunner/src/bonds.jl +++ b/src/runner/PlutoRunner/src/bonds.jl @@ -135,14 +135,16 @@ end Will be inserted in saved notebooks that use the @bind macro, make sure that they still contain legal syntax when executed as a vanilla Julia script. Overloading `Base.get` for custom UI objects gives bound variables a sensible value. Also turns off Runic and JuliaFormatter formatting to avoid issues with the formatter trying to change code that the user does not control. See https://domluna.github.io/JuliaFormatter.jl/stable/#Turn-off/on-formatting or https://github.com/fredrikekre/Runic.jl?tab=readme-ov-file#toggle-formatting """ -const fake_bind = """#! format: off +const fake_bind = """ macro bind(def, element) - quote + #! format: off + return quote local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end local el = \$(esc(element)) global \$(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) el end + #! format: on end -#! format: on""" +"""