diff --git a/CHANGELOG.md b/CHANGELOG.md index 416a855a..80b0c00b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master (unreleased) +### Bugs fixed + +* [#671](https://github.com/clojure-emacs/clojure-mode/issues/671): Syntax highlighting for digits after the first in % args + ## 5.18.1 (2023-11-24) ### Bugs fixed diff --git a/clojure-mode.el b/clojure-mode.el index fba42115..40fb0924 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -1058,7 +1058,7 @@ any number of matches of `clojure--sym-forbidden-rest-chars'.")) 1 'clojure-character-face) ;; lambda arguments - %, %&, %1, %2, etc ;; must come after character literals for \% to be handled properly - ("\\<%[&1-9]?" (0 font-lock-variable-name-face)) + ("\\<%[&1-9]*" (0 font-lock-variable-name-face)) ;; namespace definitions: (ns foo.bar) (,(concat "(\\[ \r\n\t]*" ;; Possibly metadata, shorthand and/or longhand diff --git a/test/clojure-mode-font-lock-test.el b/test/clojure-mode-font-lock-test.el index 5e578ba1..e25fb571 100644 --- a/test/clojure-mode-font-lock-test.el +++ b/test/clojure-mode-font-lock-test.el @@ -901,13 +901,24 @@ DESCRIPTION is the description of the spec." (2 3 font-lock-keyword-face) ( 5 7 font-lock-function-name-face))) - (when-fontifying-it "should handle lambda-params" + (when-fontifying-it "should handle lambda-params %, %1, %n..." ("#(+ % %2 %3 %&)" (5 5 font-lock-variable-name-face) (7 8 font-lock-variable-name-face) (10 11 font-lock-variable-name-face) (13 14 font-lock-variable-name-face))) + (when-fontifying-it "should handle multi-digit lambda-params" + ;; % args with >1 digit are rare and unidiomatic but legal up to + ;; `MAX_POSITIONAL_ARITY` in Clojure's compiler, which as of today is 20 + ("#(* %10 %15 %19 %20)" + ;; it would be better if this were just `font-lock-variable-name-face` but + ;; it seems to work as-is + (5 7 various-faces) + (9 11 font-lock-variable-name-face) + (13 15 font-lock-variable-name-face) + (17 19 various-faces))) + (when-fontifying-it "should handle nils" ("(= nil x)" (4 6 font-lock-constant-face))