diff --git a/CHANGELOG.md b/CHANGELOG.md index 842d75a1..ebcf9bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Changes +* [#622](https://github.com/clojure-emacs/clojure-mode/issues/622): Add font locking for missing clojure.core macros * [#615](https://github.com/clojure-emacs/clojure-mode/issues/615): Support clojure-dart files. ## 5.14.0 (2022-03-07) diff --git a/clojure-mode-extra-font-locking.el b/clojure-mode-extra-font-locking.el index 5471b029..6e7cfd7b 100644 --- a/clojure-mode-extra-font-locking.el +++ b/clojure-mode-extra-font-locking.el @@ -41,149 +41,620 @@ (require 'clojure-mode) (defvar clojure-built-in-vars - '(;; clojure.core - "accessor" "aclone" - "agent" "agent-errors" "aget" "alength" "alias" - "all-ns" "alter" "alter-meta!" "alter-var-root" "amap" - "ancestors" "any?" "apply" "areduce" "array-map" "as->" - "aset" "aset-boolean" "aset-byte" "aset-char" "aset-double" - "aset-float" "aset-int" "aset-long" "aset-short" "assert" - "assoc" "assoc!" "assoc-in" "associative?" "atom" - "await" "await-for" "await1" "bases" "bean" - "bigdec" "bigint" "bit-and" "bit-and-not" - "bit-clear" "bit-flip" "bit-not" "bit-or" "bit-set" - "bit-shift-left" "bit-shift-right" "bit-test" "bit-xor" "boolean" "boolean?" - "boolean-array" "booleans" "bounded-count" "bound-fn" "bound-fn*" - "bound?" "butlast" "byte" "byte-array" "bytes" "bytes?" "cast" "char" - "char-array" "char-escape-string" "char-name-string" "char?" "chars" - "chunk" "chunk-append" "chunk-buffer" "chunk-cons" "chunk-first" - "chunk-next" "chunk-rest" "chunked-seq?" "class" "class?" - "clear-agent-errors" "clojure-version" "coll?" "comment" "commute" - "comp" "comparator" "compare" "compare-and-set!" "compile" - "complement" "concat" "conj" - "conj!" "cons" "constantly" "construct-proxy" "contains?" - "count" "counted?" "create-ns" "create-struct" "cycle" - "dec" "decimal?" "delay" "delay?" "deliver" "denominator" "deref" - "derive" "descendants" "destructure" "disj" "disj!" - "dissoc" "dissoc!" "distinct" "distinct?" + '( + ;; clojure.core + "accessor" + "aclone" + "agent" + "agent-errors" + "aget" + "alength" + "alias" + "all-ns" + "alter" + "alter-meta!" + "alter-var-root" + "ancestors" + "any?" + "apply" + "array-map" + "aset" + "aset-boolean" + "aset-byte" + "aset-char" + "aset-double" + "aset-float" + "aset-int" + "aset-long" + "aset-short" + "assoc" + "assoc!" + "assoc-in" + "associative?" + "atom" + "await" + "await-for" + "await1" + "bases" + "bean" + "bigdec" + "bigint" + "bit-and" + "bit-and-not" + "bit-clear" + "bit-flip" + "bit-not" + "bit-or" + "bit-set" + "bit-shift-left" + "bit-shift-right" + "bit-test" + "bit-xor" + "boolean" + "boolean?" + "boolean-array" + "booleans" + "bounded-count" + "bound-fn*" + "bound?" + "butlast" + "byte" + "byte-array" + "bytes" + "bytes?" + "cast" + "char" + "char-array" + "char-escape-string" + "char-name-string" + "char?" + "chars" + "chunk" + "chunk-append" + "chunk-buffer" + "chunk-cons" + "chunk-first" + "chunk-next" + "chunk-rest" + "chunked-seq?" + "class" + "class?" + "clear-agent-errors" + "clojure-version" + "coll?" + "commute" + "comp" + "comparator" + "compare" + "compare-and-set!" + "compile" + "complement" + "concat" + "conj" + "conj!" + "cons" + "constantly" + "construct-proxy" + "contains?" + "count" + "counted?" + "create-ns" + "create-struct" + "cycle" + "dec" + "decimal?" + "delay?" + "deliver" + "denominator" + "deref" + "derive" + "descendants" + "destructure" + "disj" + "disj!" + "dissoc" + "dissoc!" + "distinct" + "distinct?" "doc" - "double" "double?" "double-array" "doubles" "drop" - "drop-last" "drop-while" "empty" "empty?" "ensure" - "enumeration-seq" "error-handler" "error-mode" "eval" "even?" "every?" - "every-pred" "extend" "extend-protocol" "extend-type" "extends?" - "extenders" "ex-info" "ex-data" - "false?" "ffirst" "file-seq" "filter" "filterv" "find" "find-doc" - "find-ns" "find-keyword" "find-var" "first" "flatten" "float" "float-array" - "float?" "floats" "flush" "fn?" - "fnext" "force" "format" "frequencies" "future" - "future-call" "future-cancel" "future-cancelled?" "future-done?" "future?" - "gen-interface" "gensym" "get" "get-in" - "get-method" "get-proxy-class" "get-thread-bindings" "get-validator" - "group-by" "halt-when?" "hash" "hash-map" "hash-ordered-coll" "hash-set" - "hash-unordered-coll" "ident?" "identical?" "identity" "indexed?" "ifn?" "inc" - "init-proxy" "instance?" "inst-ms" "inst?" "int" "int?" "int-array" "integer?" - "interleave" "intern" "interpose" "into" "into-array" - "ints" "io!" "isa?" "iterate" "iterator-seq" - "juxt" "keep" "keep-indexed" "key" "keys" "keyword" "keyword?" - "last" "lazy-cat" "lazy-seq" - "line-seq" "list" "list*" "list?" - "load-file" "load-reader" "load-string" "loaded-libs" "locking" - "long" "long-array" "longs" "macroexpand" - "macroexpand-1" "make-array" "make-hierarchy" "map" "mapv" "map?" - "map-indexed" "mapcat" "max" "max-key" "memfn" "memoize" - "merge" "merge-with" "meta" "method-sig" "methods" - "min" "min-key" "mix-collection-hash" "mod" "name" "namespace" - "nat-int?" "neg-int?" - "neg?" "newline" "next" "nfirst" "nil?" - "nnext" "not" "not-any?" "not-empty" "not-every?" - "not=" "ns-aliases" "ns-imports" "ns-interns" - "ns-map" "ns-name" "ns-publics" "ns-refers" "ns-resolve" - "ns-unalias" "ns-unmap" "nth" "nthnext" "nthrest" "num" - "number?" "numerator" "object-array" "odd?" "parents" "partial" - "partition" "partition-all" "partition-by" "pcalls" "peek" "persistent!" - "pmap" "pop" "pop!" "pop-thread-bindings" "pos?" "pos-int?" "pr" - "pr-str" "prefer-method" "prefers" "primitives-classnames" "print" - "print-ctor" "print-doc" "print-dup" "print-method" "print-namespace-doc" - "print-simple" "print-special-doc" "print-str" "printf" "println" - "println-str" "prn" "prn-str" "promise" "proxy" - "proxy-call-with-super" "proxy-mappings" "proxy-name" "proxy-super" - "push-thread-bindings" "pvalues" "qualified-ident?" "qualified-keyword?" - "qualified-symbol?" "quot" "rand" "rand-int" "rand-nth" "range" - "ratio?" "rational?" "rationalize" "re-find" "re-groups" - "re-matcher" "re-matches" "re-pattern" "re-seq" "read" - "read-line" "read-string" "realized?" "record?" "reduce" "reduce-kv" - "reduced" "reduced?" "reductions" "reify" "ref" "ref-history-count" - "ref-max-history" "ref-min-history" "ref-set" "refer-clojure" - "release-pending-sends" "rem" "remove" "remove-all-methods" - "remove-method" "remove-ns" "remove-watch" - "repeat" "repeatedly" "replace" "replicate" - "require" "restart-agent" "reset!" "reset-meta!" "reset-vals!" "resolve" "rest" - "resultset-seq" "reverse" "reversible?" "rseq" "rsubseq" - "satisfies?" "second" "select-keys" "send" "send-off" "send-via" "seq" - "seq?" "seqable?" "seque" "sequence" "sequential?" "set" - "set-agent-send-executor!" "set-agent-send-off-executor!" - "set-error-handler!" "set-error-mode!" "set-validator!" "set?" "short" - "short-array" "shorts" "shuffle" - "shutdown-agents" "simple-indent?" "simple-keyword?" "simple-symbol?" - "slurp" "some" "some->" "some->>" "some-fn" "some?" - "sort" "sort-by" "sorted-map" "sorted-map-by" "sorted-set" "sorted-set-by" - "sorted?" "special-form-anchor" "special-symbol?" "specify" "specify!" - "spit" "split-at" "split-with" "str" - "stream?" "string?" "struct" "struct-map" "subs" - "subseq" "subvec" "supers" "swap!" "swap-vals!" "symbol" - "symbol?" "sync" "syntax-symbol-anchor" "take" "take-last" - "take-nth" "take-while" "test" "the-ns" "thread-bound?" "time" - "to-array" "to-array-2d" "trampoline" "transient" "tree-seq" - "true?" "type" "unchecked-add" "unchecked-add-int" "unchecked-byte" - "unchecked-char" "unchecked-dec" "unchecked-dec-int" "unchecked-divide" - "unchecked-divide-int" "unchecked-double" "unchecked-float" - "unchecked-inc" "unchecked-inc-int" "unchecked-long" "unchecked-multiply" - "unchecked-multiply-int" "unchecked-negate" "unchecked-negate-int" - "unchecked-remainder" "unchecked-remainder-int" "unchecked-short" - "unchecked-subtract-int" "unchecked-subtract" - "underive" "unsigned-bit-shift-right" "unquote" "unquote-splicing" - "update" "update-in" "update-proxy" "uri?" "use" "uuid?" "val" "vals" - "var-get" "var-set" - "var?" "vary-meta" "vec" "vector" "vector?" "vector-of" "while" - "with-bindings" "with-bindings*" "with-in-str" "with-loading-context" - "with-meta" "with-out-str" "with-precision" - "xml-seq" "zero?" "zipmap" + "double" + "double?" + "double-array" + "doubles" + "drop" + "drop-last" + "drop-while" + "empty" + "empty?" + "ensure" + "enumeration-seq" + "error-handler" + "error-mode" + "eval" + "even?" + "every?" + "every-pred" + "extend" + "extends?" + "extenders" + "ex-info" + "ex-data" + "false?" + "ffirst" + "file-seq" + "filter" + "filterv" + "find" + "find-doc" + "find-ns" + "find-keyword" + "find-var" + "first" + "flatten" + "float" + "float-array" + "float?" + "floats" + "flush" + "fn?" + "fnext" + "force" + "format" + "frequencies" + "future-call" + "future-cancel" + "future-cancelled?" + "future-done?" + "future?" + "gensym" + "get" + "get-in" + "get-method" + "get-proxy-class" + "get-thread-bindings" + "get-validator" + "group-by" + "halt-when?" + "hash" + "hash-map" + "hash-ordered-coll" + "hash-set" + "hash-unordered-coll" + "ident?" + "identical?" + "identity" + "indexed?" + "ifn?" + "inc" + "init-proxy" + "instance?" + "inst-ms" + "inst?" + "int" + "int?" + "int-array" + "integer?" + "interleave" + "intern" + "interpose" + "into" + "into-array" + "ints" + "isa?" + "iterate" + "iterator-seq" + "juxt" + "keep" + "keep-indexed" + "key" + "keys" + "keyword" + "keyword?" + "last" + "line-seq" + "list" + "list*" + "list?" + "load-file" + "load-reader" + "load-string" + "loaded-libs" + "long" + "long-array" + "longs" + "macroexpand" + "macroexpand-1" + "make-array" + "make-hierarchy" + "map" + "mapv" + "map?" + "map-indexed" + "mapcat" + "max" + "max-key" + "memoize" + "merge" + "merge-with" + "meta" + "method-sig" + "methods" + "min" + "min-key" + "mix-collection-hash" + "mod" + "name" + "namespace" + "nat-int?" + "neg-int?" + "neg?" + "newline" + "next" + "nfirst" + "nil?" + "nnext" + "not" + "not-any?" + "not-empty" + "not-every?" + "not=" + "ns-aliases" + "ns-imports" + "ns-interns" + "ns-map" + "ns-name" + "ns-publics" + "ns-refers" + "ns-resolve" + "ns-unalias" + "ns-unmap" + "nth" + "nthnext" + "nthrest" + "num" + "number?" + "numerator" + "object-array" + "odd?" + "parents" + "partial" + "partition" + "partition-all" + "partition-by" + "pcalls" + "peek" + "persistent!" + "pmap" + "pop" + "pop!" + "pop-thread-bindings" + "pos?" + "pos-int?" + "pr" + "pr-str" + "prefer-method" + "prefers" + "primitives-classnames" + "print" + "print-ctor" + "print-doc" + "print-dup" + "print-method" + "print-namespace-doc" + "print-simple" + "print-special-doc" + "print-str" + "printf" + "println" + "println-str" + "prn" + "prn-str" + "promise" + "proxy-call-with-super" + "proxy-mappings" + "proxy-name" + "push-thread-bindings" + "qualified-ident?" + "qualified-keyword?" + "qualified-symbol?" + "quot" + "rand" + "rand-int" + "rand-nth" + "range" + "ratio?" + "rational?" + "rationalize" + "re-find" + "re-groups" + "re-matcher" + "re-matches" + "re-pattern" + "re-seq" + "read" + "read-line" + "read-string" + "realized?" + "record?" + "reduce" + "reduce-kv" + "reduced" + "reduced?" + "reductions" + "ref" + "ref-history-count" + "ref-max-history" + "ref-min-history" + "ref-set" + "release-pending-sends" + "rem" + "remove" + "remove-all-methods" + "remove-method" + "remove-ns" + "remove-watch" + "repeat" + "repeatedly" + "replace" + "replicate" + "require" + "restart-agent" + "reset!" + "reset-meta!" + "reset-vals!" + "resolve" + "rest" + "resultset-seq" + "reverse" + "reversible?" + "rseq" + "rsubseq" + "satisfies?" + "second" + "select-keys" + "send" + "send-off" + "send-via" + "seq" + "seq?" + "seqable?" + "seque" + "sequence" + "sequential?" + "set" + "set-agent-send-executor!" + "set-agent-send-off-executor!" + "set-error-handler!" + "set-error-mode!" + "set-validator!" + "set?" + "short" + "short-array" + "shorts" + "shuffle" + "shutdown-agents" + "simple-indent?" + "simple-keyword?" + "simple-symbol?" + "slurp" + "some" + "some-fn" + "some?" + "sort" + "sort-by" + "sorted-map" + "sorted-map-by" + "sorted-set" + "sorted-set-by" + "sorted?" + "special-form-anchor" + "special-symbol?" + "specify" + "specify!" + "spit" + "split-at" + "split-with" + "str" + "stream?" + "string?" + "struct" + "struct-map" + "subs" + "subseq" + "subvec" + "supers" + "swap!" + "swap-vals!" + "symbol" + "symbol?" + "syntax-symbol-anchor" + "take" + "take-last" + "take-nth" + "take-while" + "test" + "the-ns" + "thread-bound?" + "to-array" + "to-array-2d" + "trampoline" + "transient" + "tree-seq" + "true?" + "type" + "unchecked-add" + "unchecked-add-int" + "unchecked-byte" + "unchecked-char" + "unchecked-dec" + "unchecked-dec-int" + "unchecked-divide" + "unchecked-divide-int" + "unchecked-double" + "unchecked-float" + "unchecked-inc" + "unchecked-inc-int" + "unchecked-long" + "unchecked-multiply" + "unchecked-multiply-int" + "unchecked-negate" + "unchecked-negate-int" + "unchecked-remainder" + "unchecked-remainder-int" + "unchecked-short" + "unchecked-subtract-int" + "unchecked-subtract" + "underive" + "unsigned-bit-shift-right" + "unquote" + "unquote-splicing" + "update" + "update-in" + "update-proxy" + "uri?" + "use" + "uuid?" + "val" + "vals" + "var-get" + "var-set" + "var?" + "vary-meta" + "vec" + "vector" + "vector?" + "vector-of" + "with-bindings*" + "with-meta" + "xml-seq" + "zero?" + "zipmap" + ;; clojure.inspector - "atom?" "collection-tag" "get-child" "get-child-count" "inspect" - "inspect-table" "inspect-tree" "is-leaf" "list-model" "list-provider" + "atom?" + "collection-tag" + "get-child" + "get-child-count" + "inspect" + "inspect-table" + "inspect-tree" + "is-leaf" + "list-model" + "list-provider" + ;; clojure.main - "load-script" "main" "repl" "repl-caught" "repl-exception" - "repl-prompt" "repl-read" "skip-if-eol" "skip-whitespace" "with-bindings" + "load-script" + "main" + "repl" + "repl-caught" + "repl-exception" + "repl-prompt" + "repl-read" + "skip-if-eol" + "skip-whitespace" + ;; clojure.set - "difference" "index" "intersection" "join" "map-invert" - "project" "rename" "rename-keys" "select" "union" + "difference" + "index" + "intersection" + "join" + "map-invert" + "project" + "rename" + "rename-keys" + "select" + "union" + ;; clojure.stacktrace - "e" "print-cause-trace" "print-stack-trace" "print-throwable" + "e" + "print-cause-trace" + "print-stack-trace" + "print-throwable" "print-trace-element" + ;; clojure.template - "do-template" "apply-template" + "do-template" + "apply-template" + ;; clojure.test - "are" "assert-any" "assert-expr" - "assert-predicate" "compose-fixtures" "deftest" "deftest-" "file-position" - "function?" "get-possibly-unbound-var" "inc-report-counter" "is" - "join-fixtures" "report" "run-all-tests" "run-tests" "set-test" - "successful?" "test-all-vars" "test-ns" "test-var" "test-vars" "testing" - "testing-contexts-str" "testing-vars-str" "try-expr" "use-fixtures" - "with-test" "with-test-out" + "are" + "assert-any" + "assert-expr" + "assert-predicate" + "compose-fixtures" + "deftest" + "deftest-" + "file-position" + "function?" + "get-possibly-unbound-var" + "inc-report-counter" + "is" + "join-fixtures" + "report" + "run-all-tests" + "run-tests" + "set-test" + "successful?" + "test-all-vars" + "test-ns" + "test-var" + "test-vars" + "testing" + "testing-contexts-str" + "testing-vars-str" + "try-expr" + "use-fixtures" + "with-test" + "with-test-out" + ;; clojure.walk - "keywordize-keys" "macroexpand-all" "postwalk" "postwalk-demo" - "postwalk-replace" "prewalk" "prewalk-demo" "prewalk-replace" - "stringify-keys" "walk" + "keywordize-keys" + "macroexpand-all" + "postwalk" + "postwalk-demo" + "postwalk-replace" + "prewalk" + "prewalk-demo" + "prewalk-replace" + "stringify-keys" + "walk" + ;; clojure.xml "attrs" - "content" "content-handler" "element" "emit" "emit-element" + "content" + "content-handler" + "element" + "emit" + "emit-element" + ;; clojure.zip - "append-child" "branch?" "children" "down" "edit" - "end?" "insert-child" "insert-left" "insert-right" "left" - "leftmost" "lefts" "make-node" "next" "node" - "path" "prev" "remove" "replace" "right" - "rightmost" "rights" "root" "seq-zip" "up" - )) + "append-child" + "branch?" + "children" + "down" + "edit" + "end?" + "insert-child" + "insert-left" + "insert-right" + "left" + "leftmost" + "lefts" + "make-node" + "next" + "node" + "path" + "prev" + "remove" + "replace" + "right" + "rightmost" + "rights" + "root" + "seq-zip" + "up" + ) + ) (defvar clojure-built-in-dynamic-vars '(;; clojure.test diff --git a/clojure-mode.el b/clojure-mode.el index 90fc6bdf..92948926 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -831,7 +831,7 @@ any number of matches of `clojure--sym-forbidden-rest-chars'.")) (,(concat "(" (regexp-opt - '("def" "do" "if" "let" "let*" "var" "fn" "fn*" "loop" "loop*" + '("def" "do" "if" "let*" "var" "fn" "fn*" "loop*" "recur" "throw" "try" "catch" "finally" "set!" "new" "." "monitor-enter" "monitor-exit" "quote") t) @@ -841,15 +841,79 @@ any number of matches of `clojure--sym-forbidden-rest-chars'.")) (,(concat "(\\(?:clojure.core/\\)?" (regexp-opt - '("letfn" "case" "cond" "cond->" "cond->>" "condp" - "for" "when" "when-not" "when-let" "when-first" "when-some" - "if-let" "if-not" "if-some" - ".." "->" "->>" "as->" "doto" "and" "or" - "dosync" "doseq" "dotimes" "dorun" "doall" - "ns" "in-ns" - "with-open" "with-local-vars" "binding" - "with-redefs" "with-redefs-fn" - "declare") t) + '( + "->" + "->>" + ".." + "amap" + "and" + "areduce" + "as->" + "assert" + "binding" + "bound-fn" + "case" + "comment" + "cond" + "cond->" + "cond->>" + "condp" + "declare" + "delay" + "doall" + "dorun" + "doseq" + "dosync" + "dotimes" + "doto" + "extend-protocol" + "extend-type" + "for" + "future" + "gen-class" + "gen-interface" + "if-let" + "if-not" + "if-some" + "import" + "in-ns" + "io!" + "lazy-cat" + "lazy-seq" + "let" + "letfn" + "locking" + "loop" + "memfn" + "ns" + "or" + "proxy" + "proxy-super" + "pvalues" + "refer-clojure" + "reify" + "some->" + "some->>" + "sync" + "time" + "vswap!" + "when" + "when-first" + "when-let" + "when-not" + "when-some" + "while" + "with-bindings" + "with-in-str" + "with-loading-context" + "with-local-vars" + "with-open" + "with-out-str" + "with-precision" + "with-redefs" + "with-redefs-fn" + ) + t) "\\>") 1 font-lock-keyword-face) ;; Macros similar to let, when, and while