Skip to content

Commit 222fdaf

Browse files
authored
[Fix #671] Font-lock properly multi-digit lambda args (#672)
1 parent 25d713a commit 222fdaf

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Bugs fixed
6+
7+
* [#671](https://github.com/clojure-emacs/clojure-mode/issues/671): Syntax highlighting for digits after the first in % args
8+
59
## 5.18.1 (2023-11-24)
610

711
### Bugs fixed

clojure-mode.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ any number of matches of `clojure--sym-forbidden-rest-chars'."))
10581058
1 'clojure-character-face)
10591059
;; lambda arguments - %, %&, %1, %2, etc
10601060
;; must come after character literals for \% to be handled properly
1061-
("\\<%[&1-9]?" (0 font-lock-variable-name-face))
1061+
("\\<%[&1-9]*" (0 font-lock-variable-name-face))
10621062
;; namespace definitions: (ns foo.bar)
10631063
(,(concat "(\\<ns\\>[ \r\n\t]*"
10641064
;; Possibly metadata, shorthand and/or longhand

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,24 @@ DESCRIPTION is the description of the spec."
901901
(2 3 font-lock-keyword-face)
902902
( 5 7 font-lock-function-name-face)))
903903

904-
(when-fontifying-it "should handle lambda-params"
904+
(when-fontifying-it "should handle lambda-params %, %1, %n..."
905905
("#(+ % %2 %3 %&)"
906906
(5 5 font-lock-variable-name-face)
907907
(7 8 font-lock-variable-name-face)
908908
(10 11 font-lock-variable-name-face)
909909
(13 14 font-lock-variable-name-face)))
910910

911+
(when-fontifying-it "should handle multi-digit lambda-params"
912+
;; % args with >1 digit are rare and unidiomatic but legal up to
913+
;; `MAX_POSITIONAL_ARITY` in Clojure's compiler, which as of today is 20
914+
("#(* %10 %15 %19 %20)"
915+
;; it would be better if this were just `font-lock-variable-name-face` but
916+
;; it seems to work as-is
917+
(5 7 various-faces)
918+
(9 11 font-lock-variable-name-face)
919+
(13 15 font-lock-variable-name-face)
920+
(17 19 various-faces)))
921+
911922
(when-fontifying-it "should handle nils"
912923
("(= nil x)"
913924
(4 6 font-lock-constant-face))

0 commit comments

Comments
 (0)