Re: Per-language clean trailing whitespace option?

Eric Promislow <[email protected]>
Newsgroups gmane.comp.ide.komodo.general
Message-ID <[email protected]>
I got the save routine wrong...

...
var prefNames = {"cleanLineEnds":null, "ensureFinalEOL":null};
for (var prefName in prefNames) {
     if (gprefs.getBooleanPref(prefName)) {
         gprefs.setBooleanPref(prefName, false);   // not "true"!
         ko.extensions.yamlPrefsToRestore[prefName] = true; // not "false"!
     }
}

- Eric

On 2/6/2009 3:45 PM, Eric Promislow wrote:
> I would use a couple of file macro-triggers to control this.
>
> My pre-file-save macro would look like this:
>
> if (ko.views.manager.currentView.language != "YAML") return false;
> if (!('extensions' in ko)) ko.extensions = {};
> ko.extensions.yamlPrefsToRestore = {};
> var gprefs = Components.classes["@activestate.com/koPrefService;1"].getService(Components.interfaces.koIPrefService).prefs
> var prefNames = {"cleanLineEnds":null, "ensureFinalEOL":null};
> for (var prefName in prefNames) {
>       if (gprefs.getBooleanPref(prefName)) {
>           gprefs.setBooleanPref(prefName, true);
>           ko.extensions.yamlPrefsToRestore[prefName] = false;
>       }
> }
>
> The post-file-save macro would look like this:
>
> if (ko.views.manager.currentView.language != "YAML") return false;
> try {
>      var gprefs = Components.classes["@activestate.com/koPrefService;1"].getService(Components.interfaces.koIPrefService).prefs
>      for (prefName in ko.extensions.yamlPrefsToRestore) {
>         gprefs.setBooleanPref(prefName, ko.extensions.yamlPrefsToRestore[prefName]);
>      }
>      delete ko.extensions.yamlPrefsToRestore;
> } except(ex) {
> }
>
> I haven't tested it.  If you have another namespace you put your global
> data in other than ko.extensions, feel free to use that.
>
> I'm pretty sure Komodo never saves more than one file concurrently.
> Otherwise a YAML file could turn off the setting, but that would
> cause another file to be saved without whitespace cleaning.
>
> - Eric
>
> On 2/6/2009 3:20 PM, David Brewer wrote:
>> I love Komodo's 'clean trailing whitespace' option about 99% of the
>> time... the one time I don't like it is while editing yaml files.  I
>> was wondering if there was currently a way to turn this option on and
>> off for specific languages.
>>
>> The problem in yaml files is that whitspace is significant...
>> sometimes even if there is nothing on the line.  In this example, the
>> 'content' field gets set to two lines of text with an extra line break
>> between them, because there are two spaces before the line break that
>> occurs between them:
>>
>> content:>
>>     Nulla sit amet lorem. Cras velit. Suspendisse vulputate adipiscing nulla.
>>
>>     Vivamus dignissim nibh ac velit. Class aptent taciti sociosqu ad litora.
>>
>> In this example, you end up losing the line with the break because
>> there were no spaces before the break to tell yaml that the next line
>> is still part of the same block of text.
>>
>> content:>
>>     Nulla sit amet lorem. Cras velit. Suspendisse vulputate adipiscing nulla.
>>
>>     Vivamus dignissim nibh ac velit. Class aptent taciti sociosqu ad litora.
>>
>> Is there currently a way around this?  If not I may file an
>> 'enhancement' ticket.
>>
>> David
>> _______________________________________________
>> Komodo-discuss mailing list
>> [email protected]
>> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>> Other options: http://listserv.ActiveState.com/mailman/listinfo/Komodo-discuss
> _______________________________________________
> Komodo-discuss mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> Other options: http://listserv.ActiveState.com/mailman/listinfo/Komodo-discuss
_______________________________________________
Komodo-discuss mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Other options: http://listserv.ActiveState.com/mailman/listinfo/Komodo-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.