waveclaw / language-rpm-spec

Atom support for basic RPM specfiles
MIT License
3 stars 3 forks source link

Commenting out lines produces weird output #14

Closed xenithorb closed 7 years ago

xenithorb commented 7 years ago

I'm not entirely sure if this is the fault of your plugin or not, if not then it must be Atom itself because it's the only SPEC related plugin I have installed.

When I comment lines in a SPEC file I get output like:

# Uncommented:
%autosetup -n %{srcname}-%{version}
# Commented with CTRL+/
#(?<!C#|F#|M#)%autosetup -n %{srcname}-%{version}

What should actually happen here is this:

#%%autosetup -n %%{srcname}-%%{version}

Because it's very likely that commenting out a line with a macro, you will also want to comment out the macro too, since they need to be escaped with an additional % to not be expanded.

waveclaw commented 7 years ago

Yes, this is caused by language-rpm-spec. See a discussion (here)[https://discuss.atom.io/t/add-comment-toggle-to-the-custom-grammar/19733] for what is going on.

Sadly, Atom's commenting macro for Ctrl+/ is not going to be able to do the doubling of %% characters. Commenting a line as shown will cause warning on Open Build Service jobs for making RPMs because the SUSE brp-checks will flag any macros that are in a comment.

The Ctrl+/ is controlled by the settings file. This line in particular:

'commentStart': '#(?<!C#|F#|M#)'

When detecting a comment in the grammar, because of the Microsoft Sharp languages, I have a very complicated pattern (line 508 in the grammer file rpm-spec.cson) called a negative-width lookbehind assertion. This figures out that you wanted to write F# or C# instead of starting a comment.

It turns out you don't want to use that in the settings file for your language parser.

I can kill the direct bug to remove the (?<...) garbage, but I know of no way to tell atom that it needs to translate that line further.