In the archive I found this conversion:
Looking for help with language grammar. Coding in perl, and adding pod (documentation) within a codeblock, pod code gets automatically indented. Is there a way to have lines that begin with a = symbol auto- 'out-dent'? And then any subsequent lines, before a '=cut' line to be indented to match the previous line?
I assume decrease indent only by a single unit? If so, you can make the line be matched by both the increase and decrease indent pattern, e.g.:
increaseIndentPattern = '^\s*=\w+'; decreaseIndentPattern = '^\s*=\w+';
This should give the behavior. Note though that if the indent is zero when the cut line is used, the current build will not cause the indent to be increased for the following lines, but this will be fixed in next build.
Also, we disable indent-as-you-type for source.comment, so if you setup useful indent patterns for the documentation blocks (which I assume are scoped as block comments) then it might be useful to re-enable indent-as-you-type:
disableIndentCorrections = :false;
I am not sure, where to change these settings. In the Perl Bundle -> Settings -> Indention? Or should I better make my own Bundle, so that these Settings stick in case of an update?
Thanks in advance!
On 5 Dec 2013, at 15:24, Ingo Lantschner wrote:
In the archive I found this conversion:
[…] increaseIndentPattern = '^\s*=\w+'; decreaseIndentPattern = '^\s*=\w+';
I am not sure, where to change these settings. In the Perl Bundle -> Settings -> Indention? Or should I better make my own Bundle, so that these Settings stick in case of an update?
You can change them directly in the Perl bundle. A delta of your changes will be saved in ~/Library/Application Support/Avian/Bundles/Perl.tmbundle that ensures they survive an update.
Since you wish to alter the existing values, adding new items would not work, since TM would not know which settings have the highest priority.
On 8 Dec 2013, at 2:49, Allan Odgaard wrote:
On 5 Dec 2013, at 15:24, Ingo Lantschner wrote:
In the archive I found this conversion:
[…] increaseIndentPattern = '^\s*=\w+'; decreaseIndentPattern = '^\s*=\w+';
I am not sure, where to change these settings. In the Perl Bundle -> Settings -> Indention? Or should I better make my own Bundle, so that these Settings stick in case of an update?
You can change them directly in the Perl bundle. […]
Thanks for your answer! Now I know at least in which Bundle I have to write the changes. Since changing the "global" indention rules for Perl (`Bundle->Settings->Indention`) is probably not what we want, I tried to change it just for the POD-text, by editing the Language Grammar of Perl, and there the scope `comment.block.documentation.perl`:
patterns = ( { include = '#line_comment'; }, { name = 'comment.block.documentation.perl'; begin = '^='; end = '^=cut'; captures = { 0 = { name = 'punctuation.definition.comment.perl'; }; }; increaseIndentPattern = '^\s*=\w+'; decreaseIndentPattern = '^\s*=\w+'; },
Unfortunately this did not change anything. So is this the right place? Or did I misspell something?
Kind regards, Ingo
On 9 Dec 2013, at 1:42, Ingo Lantschner wrote:
[…] Since changing the "global" indention rules for Perl (`Bundle->Settings->Indention`) is probably not what we want, I tried to change it just for the POD-text, by editing the Language Grammar of Perl, and there the scope `comment.block.documentation.perl`: […] Unfortunately this did not change anything. So is this the right place? Or did I misspell something?
You want to create a new settings item in the bundle editor (⌘N) and then set the increase/decrease indent patterns in this settings item, and adjust the scope selector for the item to where it should be active, in your case ‘comment.block.documentation.perl’.
For more about scope selectors see http://manual.macromates.com/en/scope_selectors (and the extended 2.0 grammar is at http://manual.textmate.org/references.html#scope-selector)
On 9 Dec 2013, at 5:16, Allan Odgaard wrote:
You want to create a new settings item in the bundle editor (⌘N) and then set the increase/decrease indent patterns in this settings item, and adjust the scope selector for the item to where it should be active, in your case ‘comment.block.documentation.perl’.
Thanks! This was the "missing link". Just for the records: The correct settings for Perls POD sections is
{ increaseIndentPattern = ''; decreaseIndentPattern = ''; }
The above disables any automatic indention, which in my opinion is the best setting for PODs.
What would be the best way to contribute such changes and settings to the built in Perl bundle?
Thanks again, Ingo
On 10 Dec 2013, at 14:23, Ingo Lantschner wrote:
[…] This was the "missing link". Just for the records: The correct settings for Perls POD sections is
{ increaseIndentPattern = ''; decreaseIndentPattern = ''; }
The above disables any automatic indention, which in my opinion is the best setting for PODs.
I thought that was already the case due to https://github.com/textmate/source.tmbundle/blob/master/Preferences/Comments...
The (badly named) unIndentedLinePattern is effectively an “ignore”, so the indenter should ignore all lines in block comments.
What would be the best way to contribute such changes and settings to the built in Perl bundle?
The preferred way is to click the arrow to the right of Perl in Preferences → Bundles, this will take you to the bundle’s GitHub page.
Then fork the bundle, clone it to ~/Library/Application Support/TextMate/Bundles, make the change(s), git commit and push to your fork on GitHub.
Then submit a pull request (via GitHub).
Though in this case, I think we should instead figure out why the Source bundle’s indent settings are not working for you. Given your other email it might sound like you have disabled the Source bundle.
To be sure everything is as default see https://github.com/textmate/textmate/wiki/Reverting-To-Defaults
On 12 Dec 2013, at 6:46, Allan Odgaard wrote:
[…] This was the "missing link". Just for the records: The correct settings for Perls POD sections is
{ increaseIndentPattern = ''; decreaseIndentPattern = ''; }
The above disables any automatic indention, which in my opinion is the best setting for PODs.
I thought that was already the case due to https://github.com/textmate/source.tmbundle/blob/master/Preferences/Comments... (...) Though in this case, I think we should instead figure out why the Source bundle’s indent settings are not working for you. Given your other email it might sound like you have disabled the Source bundle.
To be sure everything is as default see https://github.com/textmate/textmate/wiki/Reverting-To-Defaults
Just removed TM2 from my system and reverted anything as described in the link. After installing a fresh new TM2 I still have this behavior in Perl POD text. So I am quite sure this is missing in the original Perl Bundle. Fortunately it can be fixed as described in this thread.
Kind regards, Ingo
On Jan 2, 2014, at 7:30 AM, Ingo Lantschner lists14@lantschner.name wrote:
Just removed TM2 from my system and reverted anything as described in the link. After installing a fresh new TM2 I still have this behavior in Perl POD text. So I am quite sure this is missing in the original Perl Bundle. Fortunately it can be fixed as described in this thread.
Can you confirm that you have the Source bundle active? It should appear under the Bundles menu. The settings item "Comments: Disable Indent” should be disabling indention in any block comments.
If the Source bundle is enabled can you provide a step-by-step guide of how to reproduce so I can make sure we are referring to the same issue?
On 3 Jan 2014, at 9:55, Michael Sheets wrote:
Can you confirm that you have the Source bundle active? It should appear under the Bundles menu.
definitely yes. Also in Preferences→Bundles the checkbox is checked (see attachment).
Something strange - may be related: After restarting my computer today and starting TM2 the themes were gone. No syntax-highlighting, no themes available in View→Theme. After restarting TM2, de-selecting the Theme-Bundle and reselecting it again, the theme reappeared again.
If the Source bundle is enabled can you provide a step-by-step guide of how to reproduce so I can make sure we are referring to the same issue?
1. New TM document 2. Select Perl as language (taskbar) 3. Write some code 4. Write a sub 5. Write some POD in the sub, starting with `=head2` 6. Press enter 7. Cursor will jump to col4 in the next line (should be in col 1) see attachment
This does not happen if I activate an additional setting as already described in this thread.
Kind regards, Ingo
On 7 Jan 2014, at 13:34, Ingo Lantschner wrote:
- New TM document
- Select Perl as language (taskbar)
- Write some code
- Write a sub
- Write some POD in the sub, starting with `=head2`
- Press enter
- Cursor will jump to col4 in the next line (should be in col 1) see
attachment
The issue here is that the context above the POD has higher indent than desired in the POD context.
So while we disable indent (by default) in the POD context (being a block comment), new lines still get too much indent, as TextMate scans from current line and up, to find a line it can use to do the indent calculations, and here it will ignore anything in the POD, as we have setup the patterns to ignore those lines.
The thinking here was that anything typed in a block comment should have (initial) indent like what’s above the comment. But that assertion fails for zero-indented block comments (with indented code above them).
Your workaround, I think, makes it so that TM will just use the indent from the line above, rather than the first line above the POD context. This might also work in the general case.