I like the new feature in v2.0-beta.11.10 where targeted settings for untitled files use file patterns that match the file's directory. It does not, however, seem to pick up the fileType setting.
Would be nice to specify that new files created in various directories in the project each have a given fileType based on their location.
On 16 Jul 2016, at 17:16, Curt Sellmer wrote:
Would be nice to specify that new files created in various directories in the project each have a given fileType based on their location.
Did you see this thread: http://lists.macromates.com/textmate/2016-July/039679.html
Basically to target untitled files you must match `attr.untitled` but right now the sections in `.tm_properties` are either file patterns _or_ scope selectors, not both.
But as mentioned in that thread, it should be supported.
We should probably let `[ templates/** ]` match untitled files created under `templates/` (w/o the need for `attr.untitled`) but in practice I don’t think you want to set `fileType` for everything in a specific folder, because then even a `ReadMe.txt` would be matched.
On Sat, Jul 16, 2016 at 2:52 PM, Allan Odgaard mailinglist@textmate.org wrote:
Basically to target untitled files you must match attr.untitled but right now the sections in .tm_properties are either file patterns *or* scope selectors, not both.
But as mentioned in that thread, it should be supported.
We should probably let [ templates/** ] match untitled files created under templates/ (w/o the need for attr.untitled) but in practice I don’t think you want to set fileType for everything in a specific folder, because then even a ReadMe.txt would be matched.
OK, thanks for the clarification.
On 16 Jul 2016, at 17:16, Curt Sellmer wrote:
I like the new feature in v2.0-beta.11.10 where targeted settings for untitled files use file patterns that match the file's directory. It does not, however, seem to pick up the fileType setting.
While I thought I understood what you meant (previous reply), I seem unable to actually reproduce that (i.e. creating a `[ templates/** ]` with `fileType` and `tabSize` works when creating file via file browser, `mate`, or ⌥⌘N for then `templates` is the project folder).
Can you reformulate this issue in “steps to reproduce” with expected/actual result?
On Sun, Aug 7, 2016 at 11:24 AM, Allan Odgaard mailinglist@textmate.org wrote:
While I thought I understood what you meant (previous reply), I seem unable to actually reproduce that (i.e. creating a [ templates/** ] with fileType and tabSize works when creating file via file browser, mate, or ⌥⌘N for then templates is the project folder).
Can you reformulate this issue in “steps to reproduce” with expected/actual result?
OK, I put some time into this and here is what I have found. I set up a project directory with two subdirectories called src and templates. Then I created a .tm_properties file in the project directory that contains: [ src/** ] fileType = 'source.ruby'
[ templates/** ] fileType = 'text.html.basic'
1. When I select a directory in the file browser and the selected directory is not open (ie. the triangle is pointing to the right) and press ^⌘N the file is created not in the selected directory but as a sibling to the selected directory. Perhaps this is by design? So it does not get the assigned type because it is in a different directory. If I configure a type for the parent directory it correctly gets assigned. Good.
2. When I select a directory in the file browser and the selected directory is open (triangle points down) and press ^⌘N, the file is created in the selected directory and is assigned the correct type. Perfect.
3. When I select a directory in the file browser and press ⌥⌘N, (regardless of whether the directory is open or closed) I always get an untitled document with type 'text.plain'. When I subsequently save the file it correctly goes into the directory that was selected.
- Seems inconsistent that the open/close state of the directory affects one operation but not the other. - I'm guessing that with ⌥⌘N the file type is not being assigned because the untitled doc does not yet actually exist in the directory. But since TextMate knows where it will be saved, perhaps the logic could modified so that this works? - For now the workaround is to make sure the directory is open in the file browser and use ^⌘N.
Hope this helps.
On 8 Aug 2016, at 18:53, Curt Sellmer wrote:
- When I select a directory in the file browser and the selected
directory is not open (ie. the triangle is pointing to the right) and press ^⌘N the file is created not in the selected directory but as a sibling to the selected directory. Perhaps this is by design?
The rationale is that you can have a directory with only other directories, if we always created inside the selected item, the user would have to take extra steps to select the parent (or deselect if parent is the file browser’s root).
This is also relevant when using copy/paste in the file browser (which use the same logic).
- When I select a directory in the file browser and press ⌥⌘N,
(regardless of whether the directory is open or closed) I always get an untitled document with type 'text.plain'. When I subsequently save the file it correctly goes into the directory that was selected.
- I'm guessing that with ⌥⌘N the file type is not being assigned
because the untitled doc does not yet actually exist in the directory.
Correct, in that _New Tab_ (⌥⌘N) does not reference the file browser. But I can try to make it do it, though it would fall victim to the same logic about needing to have the selected folder expanded.
I may revise the thing about expanded folder, but it introduces some code complexity because then we ought to expand the folder when creating a new file, and folder content is loaded asynchronously…
On Wed, Aug 10, 2016 at 3:32 AM, Allan Odgaard mailinglist@textmate.org wrote:
I may revise the thing about expanded folder, but it introduces some code complexity because then we ought to expand the folder when creating a new file, and folder content is loaded asynchronously…
Thanks for looking at this. Now that I understand how things work, I have no problem with opening the folder and pressing ^⌘N. I'm sure there are more important fires to address…