Skip to content

Commit e6fd958

Browse files
vspinubbatsov
authored andcommitted
[Fix #399] Fix font-locking of prefix characters inside keywords (#401)
- declare # with "_ p" syntax - no overwrite for #~@^ chars in font-lock syntax table
1 parent a5492a0 commit e6fd958

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Bugs fixed
6+
7+
* [#399](https://github.com/clojure-emacs/clojure-mode/issues/399) Fix fontification of prefix characters inside keywords.
8+
59
## 5.5.1 (2016-07-25)
610

711
### Bugs fixed

clojure-mode.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ Out-of-the box clojure-mode understands lein, boot and gradle."
258258
(modify-syntax-entry ?\} "){" table)
259259
(modify-syntax-entry ?\[ "(]" table)
260260
(modify-syntax-entry ?\] ")[" table)
261-
(modify-syntax-entry ?? "_ p" table) ; prefix outside of symbols
261+
(modify-syntax-entry ?? "_ p" table) ; ? is a prefix outside symbols
262+
(modify-syntax-entry ?# "_ p" table) ; # is allowed inside keywords (#399)
262263
(modify-syntax-entry ?~ "'" table)
263264
(modify-syntax-entry ?^ "'" table)
264265
(modify-syntax-entry ?@ "'" table)
265-
(modify-syntax-entry ?# "'" table)
266266
table)
267267
"Syntax table for Clojure mode.
268268
Inherits from `emacs-lisp-mode-syntax-table'.")
@@ -750,7 +750,7 @@ highlighted region)."
750750
(setq font-lock-defaults
751751
'(clojure-font-lock-keywords ; keywords
752752
nil nil
753-
(("+-*/.<>=!?$%_&~^:@" . "w")) ; syntax alist
753+
(("+-*/.<>=!?$%_&:" . "w")) ; syntax alist
754754
nil
755755
(font-lock-mark-block-function . mark-defun)
756756
(font-lock-syntactic-face-function

test/clojure-mode-font-lock-test.el

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,19 @@ POS."
298298
(should (eq (clojure-test-face-at 1 1) nil))
299299
(should (equal (clojure-test-face-at 2 11) '(clojure-keyword-face)))))
300300

301+
(ert-deftest clojure-mode-syntax-table/keyword-allowed-chars ()
302+
:tags '(fontification syntax-table)
303+
(should (equal (clojure-test-face-at 1 8 ":aaa#bbb") '(clojure-keyword-face))))
304+
305+
(ert-deftest clojure-mode-syntax-table/keyword-disallowed-chars ()
306+
:tags '(fontification syntax-table)
307+
(should (eq (clojure-test-face-at 1 5 ":aaa@bbb") 'various-faces))
308+
(should (equal (clojure-test-face-at 1 4 ":aaa@bbb") '(clojure-keyword-face)))
309+
(should (eq (clojure-test-face-at 1 5 ":aaa~bbb") 'various-faces))
310+
(should (equal (clojure-test-face-at 1 4 ":aaa~bbb") '(clojure-keyword-face)))
311+
(should (eq (clojure-test-face-at 1 5 ":aaa@bbb") 'various-faces))
312+
(should (equal (clojure-test-face-at 1 4 ":aaa@bbb") '(clojure-keyword-face))))
313+
301314
(ert-deftest clojure-mode-syntax-table/characters ()
302315
:tags '(fontification syntax-table)
303316
(should (eq (clojure-test-face-at 1 2 "\\a") 'clojure-character-face))

0 commit comments

Comments
 (0)