Skip to content

Commit f9dbbe5

Browse files
committed
Merge pull request #1345 from gracjan/pr-apos
Properly detect underscore and apostrophe in declarations
2 parents dc775d5 + 631f9c1 commit f9dbbe5

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

haskell-font-lock.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,16 @@ like ::, class, instance, data, newtype, type."
335335
;; "^>", otherwise a line of code starts with "^".
336336
(line-prefix "^\\(?:> ?\\)?")
337337

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

343343
;; Top-level declarations
344344
(topdecl-var
345-
(concat line-prefix "\\(" varid "\\(?:\\s-*,\\s-*" varid "\\)*" "\\)\\s-*"
345+
(concat line-prefix "\\(" varid "\\(?:\\s-*,\\s-*" varid "\\)*" "\\)"
346346
;; optionally allow for a single newline after identifier
347-
"\\([\n]\\s-+\\)?"
347+
"\\(\\s-+\\|\\s-*[\n]\\s-+\\)"
348348
;; A toplevel declaration can be followed by a definition
349349
;; (=), a type (::) or (∷), a guard, or a pattern which can
350350
;; either be a variable, a constructor, a parenthesized

tests/haskell-font-lock-tests.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,17 @@
443443
'("Q +++ 12.12")
444444
'(("+++" t haskell-definition-face))))
445445

446+
(ert-deftest haskell-syntactic-definition-face-4 ()
447+
(check-properties
448+
'("_test'")
449+
'(("_test'" t nil))))
450+
451+
(ert-deftest haskell-syntactic-definition-face-5 ()
452+
(check-properties
453+
'("_test' _")
454+
'(("_test'" t haskell-definition-face))))
455+
456+
446457
(ert-deftest haskell-literate-bird-1 ()
447458
(check-properties
448459
'("Comment1"

0 commit comments

Comments
 (0)