# Pluto "custom cell"

**URL:** <https://discourse.julialang.org/t/pluto-custom-cell/132224>\
**Category:** General Usage\
**Created:** [September 9, 2025, 10:15am UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224 "2025-09-09T10:15:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [September 9, 2025, 10:15am UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/1 "2025-09-09T10:15:07Z")

</div>

I would like to create in my notebook a custom cell, that looks and acts just like normal one, but the code within is parsed to an `Expr` tree that I can examine before Julia runs it. Can that be achieved using Pluto/PlutoUI API? Thanks.

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [September 9, 2025, 12:21pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/2 "2025-09-09T12:21:07Z")

</div>

Why not just write a macro and put `@mymacro` in front of the code in your cell?

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [September 9, 2025, 12:51pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/3 "2025-09-09T12:51:00Z")

</div>

I aim to make it harder for a user of the notebook to mess it up inadvertently. It shouldn’t be possible to remove macro call while editing the cell. Ideally, it shouldn’t be visible to a user.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 9, 2025, 1:58pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/4 "2025-09-09T13:58:33Z")

</div>

BonitoBook let’s you extend the cell editor widget in Julia 😉

> **[Redirecting](https://bonitobook.org/)**

It’s not fully documented yet, but there are a few examples in the intro notebook

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [September 9, 2025, 2:08pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/5 "2025-09-09T14:08:33Z")

</div>

I would prefer to remain within Pluto ecosystem, because porting all existing work into the new notebook format would entail a great deal of work.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [September 9, 2025, 3:38pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/6 "2025-09-09T15:38:15Z")

</div>

I think Pluto generally takes the “transparency” route: no hidden state, no hidden transformations. Even the markdown cells are just `m"..."` string macro calls. I don’t think Pluto allows plugging extra implicit transformation…  
Although ping @fonsp.

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [September 12, 2025, 10:54am UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/7 "2025-09-12T10:54:54Z")

</div>

Hi @Mikhail_Kagalenko !

I’m curious about your project, sounds cool! @aplavin’s comment is correct, we think that Julia’s macro syntax is quite cool and flexible, I think you could use that here!

Like @simeonschaub suggested, you can write a macro like `@inspect`, and you can place it in front of any cell. See e.g. `@steps` in [Turtles – introduction](https://featured.plutojl.org/basic/turtles.html) . You could use a one-letter macro to make it more subtle, like `@x`.

# Future feature?

We are considering a feature called _Filters_ (like snapchat) where a “top-level wrapping macro” like `@steps` or `md"""` can be selected with a GUI, and you only see the inner content in code. This would allow for “markdown cells” and “python cells”, or a “timed cell”, etc. It sounds like this is what you are looking for, but don’t expect this to be released anytime soon.

I’m also considering a “Display transformation” feature, where for any cell, you can write a bit of extra (hidden) code that transforms the cell’s result before displaying it. This allows you to write simple code to show to the reader, with a bit of hidden code to make it display more nicely.

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [September 13, 2025, 3:04pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/8 "2025-09-13T15:04:21Z")

</div>

> [@fonsp](#):
>
> I’m curious about your project, sounds cool!

Hello, thank you for the meaningful answer. I am using `Pluto` together with `PlutoTeachingTools` to check student answers in an exercise notebook. When they are asked to write a function, I want to implement an automatic check that a previously written function is employed, instead of cutting and pasting code. That seems to requre an access to the `Expr` tree for their answer. ( I suppose I could try some hacky check, like substituting an error-generating function in a local scope and testing that an exception is being raised)

> [@fonsp](#):
>
> I’m also considering a “Display transformation” feature, where for any cell, you can write a bit of extra (hidden) code that transforms the cell’s result before displaying it.

That’s exactly what I am looking for. Is that feature coming soon?

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [September 16, 2025, 1:09pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/9 "2025-09-16T13:09:19Z")

</div>

Hey! Yes that sounds like a good use case, I had the similar situation before.

The low-tech solution is to track calls to the function: (if you wrote it yourself)

[https://pluto.land/n/w67bkdb5](https://pluto.land/n/w67bkdb5)

You can make this a bit fancier with a macro in front of `you_should_use_me` that automatically creates the ref.

I also tried to use Julia introspection tools, like `Base.uncompressed_ast(methods(cool)[1])`. This strategy works for simple functions, but I found that when the student function gets more complex (like an anonymous function), then I don’t know how to properly scan the CodeInfo object for usage of your function. I’m a Julia introspection beginner though, so it might make more sense to ask this in a separate thread. You could ask: “is there a way to use Julia’s introspection tools to check whether a function `a` uses a function `b` in its definition?”

I’m sure this is possible, with tools like Cthulu.jl, Infiltrator.jl, or with base Julia functionality. But I’m the wrong person to ask 😅

I don’t have any timeline for the Display Transformation feature. It’s quite a big feature though…

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [September 18, 2025, 3:01pm UTC](https://discourse.julialang.org/t/pluto-custom-cell/132224/10 "2025-09-18T15:01:21Z")

</div>

> [@fonsp](#):
>
> The low-tech solution is to track calls to the function: (if you wrote it yourself)

I don’t write it myself. There’s a sequence of assignments, where a student writes a simple function, then uses it to write a slightly more complex function. The name of a function is fixed,  
so checking for its presence in an expression tree should not be hard.

> You could ask: “is there a way to use Julia’s introspection tools to check whether a function  
> `a` uses a function `b` in its definition?”

[That’s a good idea](https://discourse.julialang.org/t/introspection-for-checking-an-implementation/132495)
