Skip to content

Commit b53ba49

Browse files
committed
Put Haskell symbol chars in punctuation char class.
Emacs defines 'w' class as word chars and '_' as set that together with 'w' can form identifiers. Note that by this operators in programming languages fall under punctuation '.' class and are treated as such by for example c-mode, java-mode, etc. It is confusing that characters defined in Haskell Report as 'symbol' are NOT the same as 'symbol' character class defined in Emacs.
1 parent e14ca8b commit b53ba49

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

haskell-mode.el

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -459,44 +459,28 @@ Run M-x describe-variable haskell-mode-hook for a list of such modes."))
459459
(modify-syntax-entry ?\t " " table)
460460
(modify-syntax-entry ?\" "\"" table)
461461
(modify-syntax-entry ?\' "_" table)
462-
(modify-syntax-entry ?_ "w" table)
462+
(modify-syntax-entry ?_ "_" table)
463463
(modify-syntax-entry ?\( "()" table)
464464
(modify-syntax-entry ?\) ")(" table)
465465
(modify-syntax-entry ?\[ "(]" table)
466466
(modify-syntax-entry ?\] ")[" table)
467467

468468
(modify-syntax-entry ?\{ "(}1nb" table)
469469
(modify-syntax-entry ?\} "){4nb" table)
470-
(modify-syntax-entry ?- "_ 123" table)
470+
(modify-syntax-entry ?- ". 123" table)
471471
(modify-syntax-entry ?\n ">" table)
472472

473-
(let (i lim)
474-
(map-char-table
475-
(lambda (k v)
476-
(when (equal v '(1))
477-
;; The current Emacs 22 codebase can pass either a char
478-
;; or a char range.
479-
(if (consp k)
480-
(setq i (car k)
481-
lim (cdr k))
482-
(setq i k
483-
lim k))
484-
(while (<= i lim)
485-
(when (> i 127)
486-
(modify-syntax-entry i "_" table))
487-
(setq i (1+ i)))))
488-
(standard-syntax-table)))
489-
490473
(modify-syntax-entry ?\` "$`" table)
491474
(modify-syntax-entry ?\\ "\\" table)
492475
(mapc (lambda (x)
493-
(modify-syntax-entry x "_" table))
494-
;; Some of these are actually OK by default.
476+
(modify-syntax-entry x "." table))
495477
"!#$%&*+./:<=>?@^|~")
496478

497-
;; Precise syntax table entries for symbol characters
479+
;; Haskell symbol characters are treated as punctuation because
480+
;; they are not able to form identifiers with word constituent 'w'
481+
;; class characters.
498482
(dolist (charcodes haskell--char-syntax-symbols)
499-
(modify-syntax-entry charcodes "_" table))
483+
(modify-syntax-entry charcodes "." table))
500484
;; ... and for identifier characters
501485
(dolist (charcodes haskell--char-syntax-identifiers)
502486
(modify-syntax-entry charcodes "w" table))

0 commit comments

Comments
 (0)