1
$\begingroup$

One of the handy things about TemplateBox is that it can be used to define an alias for a more "natural symbol" (by having an empty list first argument and setting the appearance in a DisplayFunction option). The only drawback to this usage, as far as I can tell, is that when trying to delete the "Symbol" the whole TemplateBox is highlighted forcing a second delete.

So, for example, for some reason my muscle memory has never really taken to @* (or \*) so I'd like to re-define this as per:

SetOptions[EvaluationNotebook[], 
 InputAliases -> {"fc" -> TemplateBox[{},"Composition", DisplayFunction -> ("\[EmptySmallCircle]" &),
     Editable -> False,
     Selectable -> False,
     InterpretationFunction -> ("@*" &),
     SyntaxForm -> "@*"]}] 

but with the cursor placed viz:

enter image description here

on pressing Delete the selection moves to the TemplateBox viz:

enter image description here

Curiously, a left arrow from that cursor position skips the whole TemplateBox so I might expect a delete to equally treat TemplateBox as a whole unit which also seems to be a normal expectation for a "Symbol" with no template slots. Is there an option/workaround to ensure that a TemplateBox "Symbol" is deleted with a single delete?

$\endgroup$
2
$\begingroup$

currently there is no way to achieve the deletion of the TemplateBox via a single delete. Normally the TemplateBox has arguments so the promotion of the selection to the whole of the TemplateBox generally makes sense, however in the no argument case I can see the appeal of just deleting the entire TemplateBox. I'll discuss this with colleagues and maybe implement this in the next cycle. Thanks Ronald!

$\endgroup$
1
  • 1
    $\begingroup$ Excellent. Thanks Jason, there are several examples of other applications of the no-argument case scattered here which might support a justification. Oh and welcome to SE! There is apparently some code-of-conduct boilerplate to communicate but I'll just point to the one about developers implementing all user-requests :) $\endgroup$ Nov 8 '21 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.