13

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 ?

Prashant Bhate
  • 10,907
  • 7
  • 47
  • 82
  • 1
    Thomas Munsch in MathGroup had posted the code for a palette `ClickableOptions` that you might find useful: [http://forums.wolfram.com/mathgroup/archive/2009/May/msg00351.html] – kglr Dec 24 '11 at 16:21
  • 1
    You might find the `Options` function useful, but it only gives option names with default values. I know it's much more narrow than what you're asking for and it's not a keyboard shortcut. Just mentioning it in case you might find it useful. – Szabolcs Dec 24 '11 at 17:37
  • @Szabolcs I indeed tried `Options` As you rightly pointed, It just gives default options and not all possible options for a setting :( I will add what I could do so far – Prashant Bhate Dec 24 '11 at 23:06
  • 1
    @Prashant I believe there's no way to retrieve option *values*. Why this is so will become clear if you think about how you implement options for your own functions. Unfortunately values are often not even documented (think `Method` ...) – Szabolcs Dec 25 '11 at 10:23

2 Answers2

3

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.

Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125
  • 1
    Not only isn't there an autocomplete function but there isn't any spell-checking done for string-based options (either option names or values) either. It's a rather annoying situation. – Sjoerd C. de Vries Dec 25 '11 at 09:55
  • @Sjoerd despite being a poor speller, I found the old `General:spell1` quite annoying, and while I could see that being a nice *option* I don't know that I would turn it on. – Mr.Wizard Dec 26 '11 at 05:38
  • I'm talking about spell-checking during command entrance as part of syntax coloring. If I miswrite an option name the color signals this. Not so for option names that are strings. – Sjoerd C. de Vries Dec 27 '11 at 12:37
  • @Sjoerd possibly because it would slow things down? As is stands the syntax styling slows down your typing in the front end quite a bit once your code is long. – Mike Honeychurch Dec 27 '11 at 20:43
  • 1
    @MikeHoneychurch My hypothesis would be that names as strings instead of symbols are used to reduce the namespace footprint (I haven't nocited slowdowns). But I really hate it, especially since some names occur both as a string and as a symbol (Method being an example). And it breaks my mental image of an option rule. Name -> Value to me reads as "Variable takes Value", but "name" -> "value" just doesn't feel right, it feels like "value takes value" or 1=2. I know that it's OK in pattern matching/replacement terms, but I feel my brain gnash when I read it in an option statement. – Sjoerd C. de Vries Dec 27 '11 at 21:31
  • @Sjoerd on a Mac the slowness is noticeable once code length runs to, say 2-3 pages or more -- cannot comment about other platforms. Switch off syntax styling and everything is fine. This has been discussed on Mathgroup but can't remember when. – Mike Honeychurch Dec 27 '11 at 22:08
  • @MikeHoneychurch Is that notebook length or Cell/Module length? I have had notebooks of about 150 pages with no problems at all, but I never had a single cell that long (but then, I think that wouldn't be good). – Sjoerd C. de Vries Dec 27 '11 at 23:02
  • @Sjoerd this is not a scientific test but a cell that runs 2-3 pages of code is very slow to type things in. Switch off syntax styling and it is fine. I'll try to find the mathgroup thread where this was discussed. – Mike Honeychurch Dec 28 '11 at 08:55
1

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]

options

Prashant Bhate
  • 10,907
  • 7
  • 47
  • 82
  • This only gives you the default options, which doesn't make much sense. As far as I know, Mathematica doesn't provide a standard mechanism to retrieve all possible option values, so I don't think this effort will bring you anywhere. Alas. – Sjoerd C. de Vries Dec 25 '11 at 09:52
  • 2
    @Sjoerd perhaps that is where this community comes in? Could we not work together to detail option values for the majority of functions, and implement something like this in practice? If the mathematica.SE site becomes a reality, I hope that a "cooperative projects" section is made part of it. – Mr.Wizard Dec 26 '11 at 05:40
  • 6
    @Mr.Wizard I feel that is a task for which WRi is better positioned than the community. I suppose they already have a database of options. I'm all for cooperative projects, but this seems like an enormous amount of effort wasted to achieve something that WRI could do rather easily. – Sjoerd C. de Vries Dec 27 '11 at 12:32