Opened 12 years ago

Closed 12 years ago

#7915 closed defect (fixed)

Improve TAB-completion in Macaulay2

Reported by: novoselt Owned by: was
Priority: major Milestone: sage-4.5.2
Component: interfaces Keywords: Macaulay2, interface, TAB-completion
Cc: Merged in: sage-4.5.2.alpha0
Authors: Andrey Novoseltsev Reviewers: Mike Hansen
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by novoselt)

There are the following problems with the current TAB-completion in Macaulay2:

  • it is slow and there is a special function which creates the list of commands and stores it in file for future use;
  • this function prints a message which is not visible in the notebook and it looks like the notebook stopped responding;
  • new objects defined by user or introduced by loaded packages do not appear in this static list;
  • TAB-completion for Macaulay2 objects shows the same list of more than 1000 names as for Macaulay2 sessions, most of the stuff in this list cannot be applied to the given object.

The attached patch changes trait_names functions so that

  • functions for building command lists execute reasonably fast for interaction (0.2-0.6 second on my machine);
  • both lists for an interpreter session and for objects in it are computed dynamically on each call and take into account loaded and created names;
  • only methods which can take an object as the first argument are shown for objects;
  • execution time for "sage -t --optional macaulay2.py" dropped from 3 minutes (which was really annoying me for the last 5 days) to 30 seconds.

New problem (doesn't need much attention, I think):

  • shortcuts like "gens" for "generators" are not displayed in both lists because of the way they are defined in Macaulay2, this is likely to be fixed in the next release (of Macaulay2).

Remaining problem (to be addressed later):

  • Macaulay2 convention is to put "the important argument" last, so a useful function "f" will not be displayed in TAB-completion for "x" if it should be called like "f(7, x)" in Macaulay2. Since the default call corresponding to Sage command "x.f(7)" is "f(x, 7)", this is actually correct and "f" should not be listed. However, it may be useful to have an option to translate all calls of the form "x.f(...)" in Sage to "f(..., x)" in Macaulay2.

Patches from #7897 are a prerequisite for this one. Patch from #5467 is independent, but relevant and trivial, so please try to review it too if you are interested in this one.

Attachments (2)

macaulay2_improved_tab.patch (6.9 KB) - added by novoselt 12 years ago.
trac_7915_macaulay2_tab_completion.patch (6.9 KB) - added by novoselt 12 years ago.

Download all attachments as: .zip

Change History (8)

Changed 12 years ago by novoselt

comment:1 Changed 12 years ago by novoselt

  • Status changed from new to needs_review

Changed 12 years ago by novoselt

comment:2 Changed 12 years ago by novoselt

Changed the patch name and the commit message to contain the ticket number.

comment:3 Changed 12 years ago by novoselt

  • Description modified (diff)

comment:4 Changed 12 years ago by novoselt

  • Milestone set to sage-4.4

comment:5 Changed 12 years ago by mhansen

  • Reviewers set to Mike Hansen
  • Status changed from needs_review to positive_review

Looks good to me.

comment:6 Changed 12 years ago by mpatel

  • Merged in set to sage-4.5.2.alpha0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.