I've noticed spell checking isn't working in text.html.php strings. It is working in source.js.jquery, however. See the examples in the attached screenshots.
Here are the bundle preferences that seem relevant (Source and PHP; the HTML bundle doesn't seem to have any that effect spelling).
Where should I look to see where this could be going wrong?
Thanks, Quinn
Source.tmbundle/Preferences/Enable spell checking for strings.plist { name = "Spell Checking: Enable for Strings"; scope = "^ source string.quoted - punctuation"; settings = { spellChecking = 1; }; }
Source.tmbundle/Preferences/Disable spell checking for all.plist { name = "Spell Checking: Disable for Source"; scope = "source, constant, keyword, storage, support, variable"; settings = { spellChecking = 0; }; }
PHP.tmbundle/Preferences/Disable spellcheck in require.tmPreferences { name = "Disable spellcheck in require"; scope = "meta.include.php string.quoted"; settings = { spellChecking = 0; }; }
PHP.tmbundle/Preferences/Enable Spellchecking for Docblocks.tmPreferences { name = "Enable Spellchecking for Docblocks"; scope = "comment.block.documentation.phpdoc.php"; settings = { spellChecking = 1; }; }
On 4 Sep 2015, at 18:30, Quinn Comendant wrote:
Where should I look to see where this could be going wrong?
1. Place caret on a string in PHP code.
2. Select _Bundles → Select Bundle Item…_ (⌃⌘T)
3. Switch to _Settings_ (⌘})
4. Enter `spellchecking`
You will get a list of all settings that enable/disable spell checking (for the current scope). They should be sorted by precedence, so the top one is the culprit that you either want to edit, or to override it, create a new setting with a more specific scope.
I love TM – that's so easy.
So the top item (the culprit) is "Spell Checking: Disable for Source", which disables spellchecking (see screenshot). However, in the Source bundle, there is also a setting for "Spell Checking: Enable for Strings" (with a scope selector of `^ source string.quoted - punctuation`) but it doesn't seem to be applying here, even though I'm in a string. Also attached is a screenshot of the scope for this string (I notice "string.quoted.double.php" is not at the top of the stack of scopes, which I would expect it to be).
Can you recommend how to make "Spell Checking: Enable for Strings" work for me?
Thanks! Quinn
On 7 Sep 2015, at 4:54, Quinn Comendant wrote:
So the top item (the culprit) is "Spell Checking: Disable for Source", which disables spellchecking (see screenshot). However, in the Source bundle, there is also a setting for "Spell Checking: Enable for Strings" (with a scope selector of `^ source string.quoted - punctuation`) but it doesn't seem to be applying here, even though I'm in a string.
It’s caused by the leading `^`. This means that `source` must be the root scope.
The reason can be found here: https://github.com/textmate/source.tmbundle/commit/e3c3e64fbe43f93e24a002e6a...
We enable spell checking for strings in the source scope which allows sensible spell checking. However inside of the text scope we want to not enable these when they appear in embedded source code (eg: PHP) as it is more common to want to have spell checking enabled in text files without getting it in the source portion.
Perhaps though, this was a mistake, as you’re the second person to be confused by the lack of spell checking in source strings, when the source is embedded in a text scope.
Also attached is a screenshot of the scope for this string (I notice "string.quoted.double.php" is not at the top of the stack of scopes, which I would expect it to be).
The top of the stack is the root scope, i.e. the least specific. So it should be toward the bottom.
The attribute scopes are at the bottom, which makes them the most specific, which may seem unintuitive, but it’s because things bound to an attribute scope should generally trump everything. For example ⌘B is build when the project has a build file, even in an HTML file (when there is no selection), where ⌘B would normally insert a pair of `<strong>` tags.
Can you recommend how to make "Spell Checking: Enable for Strings" work for me?
You can make a new setting using `string.quoted.double.php` as scope selector and it will be more specific than the one that disables spelling (because the most specific part of the scope we match is longer than in the default setting).
Alternatively you can edit the _Source_ bundle and remove the leading `^`.
Though for the latter, I’ll ask Michael to make this change.
On Mon, 07 Sep 2015 21:54:45 +0200, Allan Odgaard wrote:
You can make a new setting using `string.quoted.double.php` as scope selector and it will be more specific than the one that disables spelling (because the most specific part of the scope we match is longer than in the default setting).
Awesome. Thanks, as always, for the detailed reply. 😊
Quinn