Function this.registry.startIdForScope is not a function


There is an issue with my atom-tasks package not loading in 1.24 in regards to custom grammars being set. However, just from the stack traces (and testing the package itself) I can’t really tell what’s going on.

There are two other packages with the same issue:

Any thoughts? Anybody know what’s going on? Thanks!


According to the stack trace, is the last line of your package that executes before the error. Given that, I would first look to see if something about atom.grammars.addGrammar() has changed. However, I also noticed that the Grammar documentation specifically instructs, “This class should not be instantiated directly but instead obtained from a GrammarRegistry by calling GrammarRegistry::loadGrammar.” Based on a cursory examination of Atom’s file, my conjecture is that Atom’s grammar registry logic calls functions outside of the Grammar class when building a new instance of the class. You could try to emulate this, or you could use atom.grammars.loadGrammar() to tell Atom to generate a new Grammar from your file. This will automatically add it to the registry, and I can confirm that it works as I use the following code to rapidly prototype new grammars:

atom.commands.add 'atom-text-editor', 'custom:load-active-editor-as-grammar', ->
    editor = atom.workspace.getActiveTextEditor()



I’ve just replaced the line:
newG = new Grammar atom.grammars, g
newG = atom.grammars.readGrammarSync(__dirname + ‘/tasks.cson’)

… and, apparently, based on your excelent overview, it works nicely.

@irrationalistic, can you commit this change (after testing, and seeing that this makes some sense), please?

P.S.: never worked with the Atom “guts” before, that’s a first =)
P.S. #2: never worked with coffescript, also a first =) =)



Sorry, i forgot to mention the file that was changed: it was the file “”.


Thanks for giving this a shot! Unfortunately, the main reason I’m doing this creation of a new grammar is that the grammar itself is dynamic based on the settings the user has set, so I can’t just load and apply the grammar directly without processing :frowning:


I’ll take a look at the grammar registry internals to see if there’s anything relevant. I can’t do loading grammars directly from file unless i’m also dynamically writing to a file based on the user settings, which feels fragile. It’s possible i’m just missing some custom values or additional information along the way :slight_smile: I’ll update as I dig in!


No problem! I’m in that classic cornercase: “works for me” (at least,
I’m able to use my .TODO files as I always did) =)

Great package, by the way!




I haven’t looked much into your package, but how is that much different from how Atom stores all of its settings? The .atom/ folder is a great storage place for files like that.


:open_mouth: that’s a really interesting idea! Is there an API for writing files to that directory? Whenever you change settings I could re-write a grammar to that location and then just simply load it back up…


There’s an API for writing files to anywhere, and an environment variable ATOM_HOME which contains the location of the .atom/ folder.


I’m also in favor of writing to a permanent-but-expendable file because it can be a huge help when debugging by allowing a user to take a look at the last state of the package without interacting with it.


Definitely! I’m writing to a TaskGrammar.cson file in the home directory, which i’ll initialize from settings on activation and then update whenever the settings change.


Just posted an updated version of the plugin that reads from and writes to a custom grammar file. Thanks for the great suggestions @DamnedScholar! Super helpful :smiley:


No problem. I’m happy that my oddly specific knowledge of Atom’s grammar system can make someone else’s life easier. :slight_smile: