Command completion in mathematica : suggest rules/

2019-02-08 20:08发布

问题:

In current version of Mathematica these keyboard shortcuts are quite handy

Ctrl+K completes current command

GraphPl -> press Ctrl+K  -> GraphPlot

Ctrl+Shift+K completes current command and adds argument placeholders which could be replaced with actual values with tab key

GraphPl -> press Ctrl+Shift+K  ->  GraphPlot[{vi1->vj1,vi2->vj2,...}]

However I couldn't find any keyboard option to show associated settings/options

For instance Say If I need to plot a graph with different layouts, I know I need to set Method with one of these Possible settings

  • "CircularEmbedding"
  • "RandomEmbedding"
  • "HighDimensionalEmbedding"
  • "RadialDrawing"
  • "SpringEmbedding"
  • "SpringElectricalEmbedding"

Two things

First How to autocomplete these options , is there any shortcut key ?

GraphPlot[sg, Method -> <what keyboard shortcut to display all possible options>]

Second how to generate following PopupMenu list programmatically

  list={
   "CircularEmbedding"
   , "RandomEmbedding"
   , "HighDimensionalEmbedding"
   , "RadialDrawing"
   , "SpringEmbedding"
   , "SpringElectricalEmbedding"
   }
Manipulate[GraphPlot[sg, Method -> m], {m, list}, ControlType -> PopupMenu]

Is there any way to introspect Mathematica functions and access method Metadata similar to the way it could be done in other programming languages, Like using reflection in Java ?

回答1:

I don't believe there is any included function to auto-complete a string. I also cannot recall a way to view all valid settings for a particular option, other than searching the help files.

You can expedite input with the Options Inspector settings InputAliases and InputAutoReplacements, allowing entry by EsctxtEsc or txtSpace.



回答2:

Draft : work in progress ...

This is the nearest I could reach so far, though It needs loads of enhancement, Adding it as it is hoping to get some Ideas from community. If anyone could help enhance it further, Or suggest any Idea, It would really be appreciated.

ruleOfRule[list_] := Map[Rule[#, #] &, list];
Manipulate[
 GraphPlot @@ {{"A" -> "B", "B" -> "C", "C" -> "A"}, 
   options}, {{options, {}}, ruleOfRule[Options[GraphPlot]]}, 
 ControlType -> CheckboxBar]