Skip to content

Conversation

@danielmartin
Copy link
Contributor

Emacs can show negation characters using a specific face in font-lock.
This commit adds support for it in swift-mode.

Screen Shot 2020-11-21 at 10 08 07 PM

Emacs can show negation characters using a specific face in font-lock. This commit adds support for it in swift-mode.
@taku0
Copy link
Member

taku0 commented Nov 22, 2020

It's very attractive. I see some minor cases are missing:

// should be highlighted; OK if !foo {} if !!!!!foo {} if !!!!!(foo) {} if (!foo) {} let x = [!a,!b] let x = [a:!b] // should not be highlighted; Some cases are missing try! foo foo as! Foo foo != bar foo !== bar a.b.c! a.b.c_! a.b.aあ! init! {} let foo: Foo! = bar let x = foo()! // NG let x = foo[0]! // NG // identifiers can be quoted a.b.`c`! // NG // custom operator foo +!+!+!+!+ bbb // NG

How about "\\(?:^\\|\\s-\\|\\s(\\|\\s>\\|[,:;]\\)\\(!+\\)[^=]"? That is:

  • any of:
    • beginning of a line
    • whitespaces
    • open brackets
    • comments
    • ,, ;, or :, and
  • one or more !s
  • any character other than =.
For now, they are only focused on swift-mode:negation-char-face.
@danielmartin
Copy link
Contributor Author

@taku0 Thanks for the feedback, I've applied your suggestion. I've also added some font-lock tests to avoid regressions.

@taku0
Copy link
Member

taku0 commented Nov 23, 2020

Tests for font-locking is a long-awaited feature. It works perfectly on all versions non-interactively and interactively. Thank you.

@taku0 taku0 merged commit 02a1726 into swift-emacs:master Nov 23, 2020
@danielmartin danielmartin deleted the negation-char-face branch November 23, 2020 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants