MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Remove MakeExpression settings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118583] Re: Remove MakeExpression settings
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Tue, 3 May 2011 05:48:41 -0400 (EDT)

For MakeBoxes rules, I prefer to attach the rules to custom heads using
UpSetDelayed or TagSetDelayed.  That allows all of the MakeBoxes rules for a
given head to be easily aggregated.

I'm not aware of any similar sort of trick for MakeExpression if you're adding
rules to one of the built-in forms, but if you're using MakeExpression to work
on boxes which would not have been interpretable otherwise, there shouldn't be
any need to clear them.

E.g.,

MakeBoxes[OverStar[x_], StandardForm] ^:=
  OverscriptBox[MakeBoxes[x, StandardForm], "*"];
MakeExpression[OverscriptBox[x_, "*"], StandardForm] :=
 MakeExpression[RowBox[{"OverStar", "[", x, "]"}], StandardForm]


Alternatively, you could add your own form.  Then all of your rules would be
turned on or off depending upon whether or not your form was being used.  Any
form you create can be fully integrated into Mathematica, and Mathematica will
treat it like one of its own forms.  Here's an example that does that:

MyForm /: MakeBoxes[OverStar[x_], MyForm] :=
  OverscriptBox[MakeBoxes[x, MyForm], "*"];
MyForm /: MakeExpression[OverscriptBox[x_, "*"], MyForm] :=
  MakeExpression[RowBox[{"OverStar", "[", x, "]"}], MyForm];
MyForm /: MakeBoxes[x_, MyForm] := MakeBoxes[x, StandardForm];
MyForm /: MakeExpression[x_, MyForm] :=
  MakeExpression[x, StandardForm];
$BoxForms = Union[Append[$BoxForms, MyForm]];
CurrentValue[$FrontEndSession, BoxFormFormatTypes] =
  Union[Append[CurrentValue[$FrontEndSession, BoxFormFormatTypes],
    "MyForm"]];

Note that, in this case, I've attached all of the rules to MyForm using
TagSetDelayed.  Now that it's split off into a separate form, that level of
compartmentalization wasn't really necessary, but it's what I'd consider the
natural way of doing things in Mathematica (and it follows a similar style we
used internally for building up TraditionalForm).

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Mon, 2 May 2011 06:53:18 -0400 (EDT), Peter Breitfeld wrote:
>
> I made some settings using MakeExpression and MakeBoxes. Suppose I use
>
> beautyOut[a_]:=MakExpression[...]
>
> I can find these definitions in Definition[MakeBoxes] and
> Definitions[MakeBoxes].
>
> Sometimes I want to switch off these definitions. The only way I found
> is to use Quit.
>
> My question:
> Is it possible, to remove the definitions made from the set of
> definitons of MakeExpression and Makeboxes?
>
> Thank you
> Peter



  • Prev by Date: Re: Huge file for a several-line plot
  • Next by Date: Re: Huge file for a several-line plot
  • Previous by thread: Re: Remove MakeExpression settings
  • Next by thread: Re: Remove MakeExpression settings