Smart Percents and TemplateBox Dispatching

WolframTechnology Conference 2024

Jason Harris

jasonh@wolfram.com
Wolfram Research

In this talk, I will provide a detailed presentation of the new smart percent / percent reference functionality introduced in Version 14.1. Following this, I will discuss the TemplateBox mechanisms that underlie this functionality, as well as one of the recent improvements to TemplateBox that enables “template dispatching”.

Discussing the internals of how PercentReferences are represented will involve talking about CellObjects and CellIDs and UUIDs which Percent References use to keep track of what is referencing what. In detail we will cover:

Introduction to Smart Percents / Percent References

The different internal states of Smart Percents

CellObjects and UUID references

Alternative ways to create Smart Percents

TemplateBox review

The TemplateBox representation of Smart Percents

Template Dispatching

Configuring the display of Smart Percents

Concluding Comments

Introduction to Smart Percents / Percent References

Our goal is to have a reference which follows a cell (or maybe a spatial reference) and not strictly an evaluation label.

1+1+e

r+

r+%3

2+

f[]+1

f[2+r+1+1+e]+1

The different internal states of Smart Percents

1+1+e

+1

+3

CellObjects and UUID references

Cells[nb]

SelectionMove[,All,CellContents]

//FullForm

Alternative ways to create Smart Percents

TemplateBox review

Binomial[a,b]//TraditionalForm

(LegendreP[a, b])

RowBox[{"(", 
    GridBox[{{"a"}, {"b"}}], ")"}]//RawBoxes

Smart Percents and Template Dispatching

TemplateDispatching

1+1

TemplateBox[<|
   "ref" -> 8, "InUUID" -> Slot["InUUID"], "OutUUID" -> 
    Slot["OutUUID"], "DisplayCache" -> Slot["DisplayCache"]|>, 
   "PercentReferenceExists_KernelN_InY_OutY"]//RawBoxes

Configuring the display of Smart Percents

Make a new Default.nb style sheet

SystemOpen["/Users/jason/Library/Wolfram/SystemFiles/FrontEnd/StyleSheets/"]

Then we can just save the StyleSheet as a new Default.nb and put it under $UserBaseDirectory and the inheritance magic will make put these defaults in the inheritance chain.

Permitted Paths

Select[CurrentValue[$DefaultFrontEnd, "StyleSheetPath"],MemberQ[#,HoldPattern@$UserBaseDirectory,∞]&]

ToFileName/@

SystemOpen[[[3]]]

Concluding Comments

History Length

Cell Context -> CellGroup

Tooltip Iconize

Many thanks to the internal team here at Wolfram: Noah, Kevin, John, Lou, Ian, Chris, and everyone else.

Related FE Talks

John Fultz: Front End Overview (Today)

Kevin Daily: Updates to Presenter Tools (Today)

Rob Raguet-Schofield: Asset Management (Today)

Noah Hardwicke: Effective Use of Wolfram Language and Notebooks for User Interface Design (Today)

Office Hour: Notebook Front End (Today)

Lou D’Andria: DiffTools Developments (Today)

James Lane: New Graphics Features and Improvements (Tomorrow)

Yuzhu Lu: Texture Support Updates for Mathematica Graphics (Tomorrow)

Jason Abernathy: Tabular Displays (Tomorrow)