Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

init.m #1

Closed
jensbob opened this Issue · 2 comments

2 participants

@jensbob

Great extension, thanks! I played with it a little and here is my issue:

I added Needs["MathematicaAutocompletionTweaker`"] to the Kernel/init.m. The auto complete works fine, but whenever a Kernel is started the Messages dialog pops up with the error:

Throw::nocatch: Uncaught Throw[False] returned to top level.

Also it is better practice to use Needs to load packages, then Mathematica first checks, whether the package was already loaded. If not, it will be loaded. If so, Mathematica will do nothing. This package does not establish a new context, meaning that you get the warning

Needs::nocont: "Context .... was not created when Needs was evaluated."

when loading the package using Needs.
Adding BeginPackage["MathematicaAutocompletionTweaker`"] at the beginning and EndPackage[] at the end would be an option to remove this warning.

@halirutan halirutan was assigned
@halirutan
Owner

Thanks for reporting this. Since I was working on it, I never put it into init.m myself. The same happens here on Linux-x86-64 and I could track the issue down, although I don't understand it. I used a simple StringMatchQ with $SystemID to decide which OS the user is running. Windows and Mac are handled in the same way, therefore they get one section which is tested by

StringMatchQ[$SystemID, "MacOSX*" | "Windows*" ]

The Alternative in combination with StringMatchQ seems to throw this error. If you only put this line (with a semicolon at the end) into your init.m you get the same message. I tried to express it differently with ("Linux" | "Windows") ~~ ___ but still the same.

Circumventing this by using a logical alternative fixes the problem.

StringMatchQ[$SystemID, "MacOSX*"] || StringMatchQ[$SystemID, "Windows*"]

I'll put this into the code.

Regarding your second suggestion: I didn't introduce a package-context on purpose. There are two reasons for that

  1. Autocompletion is very different from other packages, that provide you with additional functions to calculate something. Autocompletion is either used all the time or never (in case you don't like it). Therefore, we always want to turn the autocompletion on during starting of the kernel.

  2. Although namespaces are a good thing, I only introduce 3 functions which don't clash with defined FE functions.
    When I would introduce a package, what would this package provide? It consists only of the helper-functions, which are not really useful when called directly and the redefinition of the FE functions.

Given the case, that this code is really used by at least some users, I'll maybe prepare small, system-specific code-snips which don't clutter the init.m that much.

@halirutan halirutan closed this
@jensbob

Thanks. Works great now. I guess you are right, this should be loaded by default and it shouldn't require user interaction (other than the one it is intended for).

To avoid clutter in the Kernel/init.m file you can also auto load the content of a separate file in, for example, $UserBaseDirectory/Autoload/Autocompletion/init.m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.