Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight comments properly #156

Closed
wants to merge 1 commit into from
Closed

Highlight comments properly #156

wants to merge 1 commit into from

Conversation

Mango0x45
Copy link

I am really not sure what is up with that weird regex that you guys use to
syntax-highlight comments, but to quote the git docs on the .gitignore file:

“A line starting with # serves as a comment. Put a backslash (‘\’) in front of
the first hash for patterns that begin with a hash.”

There shouldn’t be any valid comment in a .gitignore besides a ‘#’ at the start
of a line.

@tarsius
Copy link
Member

tarsius commented Aug 1, 2023

Have you encountered any false positives or false negatives, or have you just stumbled into this and thought it looked odd? If it is the former, then please provide examples.

"^\\s<.*$"

I am really not sure what is up with that weird regex that you guys use to syntax-highlight comments

https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Backslash.html

‘\sCODE’
     matches any character whose syntax is CODE.  Here CODE is a
     character that represents a syntax code: thus, ‘w’ for word
     constituent, ‘-’ for whitespace, ‘(’ for open parenthesis, etc.  To
     represent whitespace syntax, use either ‘-’ or a space character.
     *Note Syntax Class Table::, for a list of syntax codes and the
     characters that stand for them.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html

Comment starters: ‘<’
Comment enders: ‘>’
     Characters used in various languages to delimit comments.  Human
     text has no comment characters.  In Lisp, the semicolon (‘;’)
     starts a comment and a newline or formfeed ends one.

However this entry of gitignore-mode-font-lock-keywords seems redundant; the call to conf-mode-initialize appears to fully take care of comments. But I'll need to double check.

@Mango0x45
Copy link
Author

Mango0x45 commented Aug 1, 2023

Ah apologies. My comments were not being syntax highlighted so I took a look at the package, and then the Emacs docs when I saw ‘\s<’. It seems I confused the syntax class of ‘<’ with the regex ‘\<’ leading me to believe this was wrong.

No idea why my comments weren't working though, I'll check during work today to see if that behavior is still happening

@Mango0x45 Mango0x45 closed this by deleting the head repository Aug 1, 2023
@tarsius
Copy link
Member

tarsius commented Aug 7, 2023

However this entry of gitignore-mode-font-lock-keywords seems redundant; the call to conf-mode-initialize appears to fully take care of comments. But I'll need to double check.

It's not redundant, because we have to disable syntactic font-lock. See comment in gitignore-mode.

@tarsius tarsius added the invalid label Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants