Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

universal shortcut

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131830] universal shortcut
  • From: Arturas Acus <arturas.acus at tfai.vu.lt>
  • Date: Fri, 11 Oct 2013 05:00:40 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Dear Group, 

despite my rather long experience with Mathematica I was never satisfied with
palettes or shortcuts ideas to input nice formated symbols in Mathematica. The
first is too slow, the second requires to remember a lot of
abbreviations.  From the other side Shift + K idea (universal completion
template) I found rather useful. So I would like to implement something
like universal "shortcut" (well, say for simple heads with fixed number
of arguments at least). Consider for example the following particular
shortcut:

SetOptions[System`$FrontEndSession, 
 InputAliases -> 
  Fold[DeleteCases, 
   CurrentValue[System`$FrontEndSession, InputAliases],
   Thread[Rule[{"mvb"}, Blank[]]]]]

$GAPackageInputAliases = {};

$GAPackageInputAliases = 
  Join[$GAPackageInputAliases, {"mvb" -> 
     RowBox[{TemplateBox[{TemplateBox[{TagBox[FrameBox["index"], 
            "Placeholder"]}, "GADown", 
          DisplayFunction -> (SubscriptBox["\[InvisibleSpace]", 
              RowBox[{##, "\[InvisibleSpace]"}]] &)], 
         "RunningAlgebra"}, "\[DoubleStruckE]", 
        DisplayFunction -> (RowBox[{StyleBox["\[DoubleStruckE]", 
              RGBColor[0, 0, 0]], "\[InvisibleSpace]", #}] &)]}] }];

SetOptions[System`$FrontEndSession, 
  InputAliases -> 
   Join[CurrentValue[System`$FrontEndSession, 
     InputAliases], $GAPackageInputAliases]];



with the following definitions



MakeBoxes[GADown[in__], StandardForm] := 
 With[{pf = 
    Function @@ {SubscriptBox["\[InvisibleSpace]", 
       RowBox[Riffle[Slot /@ Range[Length[{in}]], 
         "\[InvisibleSpace]"]]]}}, 
  TemplateBox[MakeBoxes /@ {in}, "GADown", DisplayFunction -> pf, 
   SyntaxForm -> SubscriptBox, Tooltip -> ToString[GADown[in]]]]
MakeBoxes[\[DoubleStruckE][in__, ra_Cl], StandardForm] := 
 With[{pf = 
     Function @@ {RowBox[
        Join[{StyleBox["\[DoubleStruckE]", GAStyle[ra]], 
          "\[InvisibleSpace]"}, 
         Riffle[Slot /@ Range[Length[{in}]], "\[InvisibleSpace]"]]]}},
    TemplateBox[MakeBoxes /@ {in, ra}, "\[DoubleStruckE]", 
    DisplayFunction -> pf, SyntaxForm -> RowBox, Tooltip -> None]] /; 
  MemberQ[GAStyle[ra], _Rule]

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})]]]

Options[DefineGeometricAlgebra] = {FontColor -> Automatic};
DefineGeometricAlgebra[{p_Integer, q_Integer, r_Integer: 0}, 
  opts___?OptionQ] := (
  RunningAlgebra = Cl[p, q, r];
  GAStyle[
    Cl[p, q, r]] = {FontColor -> 
     Module[{value}, 
      Switch[value = ((FontColor /. 
            FilterRules[{opts}, Options[StyleBox]]) /. 
          Options[DefineGeometricAlgebra]), _RGBColor, value, 
       Automatic, RGBColor[p, r, q], _, Black]]};
  
  upgradeInputAlias["mvb", 
   RGBColor[__] -> (FontColor /. GAStyle[Cl[p, q, r]])];
  upgradeInputAlias["mvb", "RunningAlgebra" -> MakeBoxes[Cl[p, q, r]]];
  )



Now if we define 

DefineGeometricAlgebra[{5, 3, 0}]

then input shortcut <esc>mvb<esc> seems work nice.

Suppose now that I don't want to remember what "mvb" means. Instead I
would like to start typing  container name i.e. \[DoubleStruckE] and
then pres some universal combination like Shift + ctrl + W or any other
not reserved, and this will look in defined input aliases (or You can
think any other idea) and insert Template box matching
\[DoubleStruckE] .

Can the idea of "universal shortcut" or "supershorcut" be implemented? 
The Mathematica expression completion description is rather sketchy.

Sincerely, Arturas Acus 












  • Prev by Date: Re: bug in Print
  • Next by Date: Re: Decision whether point lies within closed contour
  • Previous by thread: Re: Image color ratio
  • Next by thread: Maple procedures to Mathematica