I've (once again) got fed up with saving things only to find that git is rejecting the commit due to trailing whitespace, and have had another look at automatically stripping it.
I've tried the bundle at https://github.com/bomberstudios/Strip-Whitespace-On-Save.tmbundle, which hasn't been working for me for ages, and the solution at http://reinteractive.net/posts/4-stripping-whitespace-out-of-textmate-2, which saves the file with the whitespace unstripped and *then* strips the whitespace (and unhelpfully moves the cursor to the end of the document, too). None of them results in me achieving my goal of a file on disk which doesn't have trailing whitespace, and a buffer in TextMate which shows as saved.
Is there some solution I'm missing?
(The ideal would be for whitespace stripping to be built in, not just as a manually-executed command in the Source bundle, but something in the app preferences that could also be turned on/off in .tm_properties — that would mean every TM2 user cloning a no-trailing-whitespace-allowed repo would get a .tm_properties file that causes it to do the Right Thing for that project, regardless of how the user has their preferences set up. Allan, is there any chance of this in a future build?)
Thanks
I have at least a fix for the cursor going to the end of the document:
If you change Caret Placement from whatever you have to Heuristic, your cursor should stay in place. That said, I would also love this option so I don't have to remember to check for this, save extra documents, etc. Next up, I'm going to look into git pre-commit hooks.
Edward
On Sunday, July 8, 2012 at 5:12 PM, John Yeates wrote:
I've (once again) got fed up with saving things only to find that git is rejecting the commit due to trailing whitespace, and have had another look at automatically stripping it. I've tried the bundle at https://github.com/bomberstudios/Strip-Whitespace-On-Save.tmbundle, which hasn't been working for me for ages, and the solution at http://reinteractive.net/posts/4-stripping-whitespace-out-of-textmate-2, which saves the file with the whitespace unstripped and *then* strips the whitespace (and unhelpfully moves the cursor to the end of the document, too). None of them results in me achieving my goal of a file on disk which doesn't have trailing whitespace, and a buffer in TextMate which shows as saved. Is there some solution I'm missing? (The ideal would be for whitespace stripping to be built in, not just as a manually-executed command in the Source bundle, but something in the app preferences that could also be turned on/off in .tm_properties — that would mean every TM2 user cloning a no-trailing-whitespace-allowed repo would get a .tm_properties file that causes it to do the Right Thing for that project, regardless of how the user has their preferences set up. Allan, is there any chance of this in a future build?) Thanks -- John Yeates _______________________________________________ textmate mailing list textmate@lists.macromates.com (mailto:textmate@lists.macromates.com) http://lists.macromates.com/listinfo/textmate
On 8 Jul 2012, at 23:12, John Yeates wrote:
[ …built-in strip whitespace… ] Allan, is there any chance of this in a future build?
I think it should be done as a bundle command because there are many related things that benefit from the same infrastructure, and even how to strip whitespace is a topic for debate.
It does however seem that the current number of semantic classes can be expanded to better suit some user’s desires. For now, the best option is probably to either do a command that runs as an export command (that strips the whitespace) or alternatively, the did-save, but then it only affects the buffer in memory, so a will-save action should probably be introduced.
As for ease of enabling it, this again is more a matter of improving existing bundle item infrastructure – we have a per-item enable/disable and we have bundle installing done via Preferences, but again, room for much improvement to make it easy to simply enable the proper “strip whitespace on save”-item in the list of items that is available to “install”.
On 16 Jul 2012, at 19:27, Allan Odgaard wrote:
we have a per-item enable/disable
Make that a per-item disable :) once it's disabled you can't then reselect (in the bundle editor anyway)