Skip to content

Properly detect underscore and apostrophe in declarations #1345

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

Merged
merged 1 commit into from
May 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions haskell-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,16 @@ like ::, class, instance, data, newtype, type."
;; "^>", otherwise a line of code starts with "^".
(line-prefix "^\\(?:> ?\\)?")

(varid "\\b[[:lower:]_][[:alnum:]'_]*\\b")
(varid "[[:lower:]_][[:alnum:]'_]*")
;; We allow ' preceding conids because of DataKinds/PolyKinds
(conid "\\b'?[[:upper:]][[:alnum:]'_]*\\b")
(conid "'?[[:upper:]][[:alnum:]'_]*")
(sym "\\s.+")

;; Top-level declarations
(topdecl-var
(concat line-prefix "\\(" varid "\\(?:\\s-*,\\s-*" varid "\\)*" "\\)\\s-*"
(concat line-prefix "\\(" varid "\\(?:\\s-*,\\s-*" varid "\\)*" "\\)"
;; optionally allow for a single newline after identifier
"\\([\n]\\s-+\\)?"
"\\(\\s-+\\|\\s-*[\n]\\s-+\\)"
;; A toplevel declaration can be followed by a definition
;; (=), a type (::) or (∷), a guard, or a pattern which can
;; either be a variable, a constructor, a parenthesized
Expand Down
11 changes: 11 additions & 0 deletions tests/haskell-font-lock-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,17 @@
'("Q +++ 12.12")
'(("+++" t haskell-definition-face))))

(ert-deftest haskell-syntactic-definition-face-4 ()
(check-properties
'("_test'")
'(("_test'" t nil))))

(ert-deftest haskell-syntactic-definition-face-5 ()
(check-properties
'("_test' _")
'(("_test'" t haskell-definition-face))))


(ert-deftest haskell-literate-bird-1 ()
(check-properties
'("Comment1"
Expand Down