MathGroup Archive 2012

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

Search the Archive

Re: dynamic input alias

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126435] Re: dynamic input alias
  • From: Arturas Acus <arturas.acus at tfai.vu.lt>
  • Date: Thu, 10 May 2012 04:58:48 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

In order not to left unanswered question I post solution I have found on
how dynamic aliases can be emulated. 

Suppose initially I have an alias "mv"

SetOptions[System`$FrontEndSession,InputAliases ->
Union[Join[CurrentValue[System`$FrontEndSession,InputAliases], {"mv" ->
SubscriptBox[RowBox[{StyleBox["\[LeftAngleBracket]",RGBColor[0,0,0]],"\[SelectionPlaceholder]",StyleBox["\[RightAngleBracket]",RGBColor[0,0,0]]}],
TagBox[RowBox[{"{","\[Placeholder]","}"}],{#,RunningAlgebra}&]]}]]];

I want it to change when value of RunningAlgebra is changed.
To do so I define upgradeInputAlias[ ] function below.


SetAttributes[upgradeInputAlias,HoldRest];
upgradeInputAlias[aliasName_String,aliasReplacementRul_Rule]:=Module[{inpOpt,alposition},SetOptions[System`$FrontEndSession,ReplacePart[inpOpt=Options[System`$FrontEndSession,InputAliases],(alposition=Position[inpOpt,aliasName->_][[1]])->(Extract[inpOpt,alposition]/.aliasReplacementRul)]]]

Then along with changing RunningAlgebra value issue

upgradeInputAlias["mv",RGBColor[__]->RGBColor[1,0,0]];

and alias will change. 


Second solution would be instead of RGBColor[0,0,0] to use
Dynamic[mystyle]. And set mystyle to preffered color. Unfortunatelly
this makes FrontEnd unstable (at least on my system) and Mathematica warns when
openning any notebook about "potentially unsafe dynamic", because front
end initialization init.m file now contains Dynamic[ ], which was not
intended by design.


Sincerely, Arturas Acus


-------------------------------

Dear group,

I wonder can "dynamic" input aliases be defined in Mathematica?

For example, suppose I define input alias

SetOptions[System`
$FrontEndSession,InputAliases->Union[Join[CurrentValue[System`
$FrontEndSession,InputAliases],
{"mv"->SubscriptBox[RowBox[{"\[LeftAngleBracket]","\[SelectionPlaceholder]","\[RightAngleBracket]"}],
StyleBox[TagBox[RowBox[{"{","\[Placeholder]","}"}],{#,RunningMark}&],FontColor->RunningColor]]}]]];

And then evaluate in the notebook 

RunningMark="MyMark"; 
RunningColor=RGBColor[1,0,0];

Now 
I would like that when using input alias in the notebook it would
evaluate with above set values, i.e. RunningMark being replaced by
"MyMark", and RunningColor with provided color.  

Is it possible to realize this "dynamic" input alias?

Sincerely, Arturas Acus






  • Prev by Date: Speed of Mathematica on AMD machines
  • Next by Date: ticks but no numbers on the axes
  • Previous by thread: Re: Speed of Mathematica on AMD machines
  • Next by thread: ticks but no numbers on the axes