Skip to content

Commit 12a34c4

Browse files
committed
Restrict character literals to one character, allow names to start with 0-2 quotes in haskell-indentation
1 parent 9aee098 commit 12a34c4

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

haskell-indentation.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,15 +1180,15 @@ the current buffer."
11801180
"Skip to the next token."
11811181
(let ((case-fold-search nil))
11821182

1183-
(if (or (looking-at "\"\\([^\\\"]\\|\\\\.\\)*\"")
1183+
(if (or (looking-at "'\\([^\\']\\|\\\\.\\)'")
1184+
(looking-at "\"\\([^\\\"]\\|\\\\.\\)*\"")
11841185
(looking-at ; Hierarchical names always start with uppercase
1185-
"[[:upper:]]\\(\\s_\\|\\sw\\|'\\)*\\(\\.\\(\\s_\\|\\sw\\|'\\)+\\)*")
1186-
(looking-at "\\(\\s_\\|\\sw\\)\\(\\s_\\|\\sw\\|'\\)*") ; Only unqualified vars can start with lowercase
1186+
"'?'?[[:upper:]]\\(\\s_\\|\\sw\\|'\\)*\\(\\.\\(\\s_\\|\\sw\\|'\\)+\\)*")
1187+
(looking-at "'?'?\\(\\s_\\|\\sw\\)\\(\\s_\\|\\sw\\|'\\)*") ; Only unqualified vars can start with lowercase
11871188
(looking-at "[0-9][0-9oOxXeE+-]*")
11881189
(looking-at "[-:!#$%&*+./<=>?@\\\\^|~]+")
11891190
(looking-at "[](){}[,;]")
1190-
(looking-at "`[[:alnum:]']*`")
1191-
(looking-at "'\\([^\\']\\|\\\\.\\)*'"))
1191+
(looking-at "`[[:alnum:]']*`"))
11921192
(goto-char (match-end 0))
11931193
;; otherwise skip until space found
11941194
(skip-syntax-forward "^-"))

tests/haskell-indentation-tests.el

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,16 @@ Example of lines:
423423
" , baz = 0"
424424
" ^"))
425425

426-
(ert-deftest haskell-indentation-check-22 ()
427-
"layout versus comma in braces (unicode)"
426+
(ert-deftest haskell-indentation-check-22a ()
427+
"names starting with quotes"
428428
(haskell-indentation-check
429429
"f = a (a 'A)"
430430
" (a 'A)"
431431
"^ ^"))
432+
433+
(ert-deftest haskell-indentation-check-22b ()
434+
"character literal (escape sequence)"
435+
(haskell-indentation-check
436+
"f = '\\\\"
437+
""
438+
"^ ^"))

0 commit comments

Comments
 (0)