Command completion in mathematica : suggest rules/options

安稳与你 提交于 2019-12-30 04: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]



来源:https://stackoverflow.com/questions/8625296/command-completion-in-mathematica-suggest-rules-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!