Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2065

Re: Remove MakeExpression settings

From John Fultz <jfultz@wolfram.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Remove MakeExpression settings
Date 2011-05-03 09:48 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ipoj22$g9t$1@smc.vnet.net> (permalink)

Show all headers | View raw


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@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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Remove MakeExpression settings John Fultz <jfultz@wolfram.com> - 2011-05-03 09:48 +0000

csiph-web