diff --git a/clojure-mode.el b/clojure-mode.el index b3f2ebaa..f9479173 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -67,9 +67,259 @@ ;;; Code: -(require 'cl) +(eval-when-compile + (require 'cl) + (defvar calculate-lisp-indent-last-sexp) + (defvar font-lock-beg) + (defvar font-lock-end) + (defvar paredit-version) + (defvar paredit-mode) + (defvar slime-net-coding-system) + (defvar slime-find-buffer-package-function) + (defvar slime-from-lisp-filename-function) + (defvar slime-to-lisp-filename-function)) + (require 'tramp) (require 'inf-lisp) +(require 'imenu) + +(declare-function clojure-test-jump-to-implementation "clojure-test-mode.el") +(declare-function subseq "cl-extra.el") +(declare-function slime-connect "slime.el") +(declare-function slime-current-connection "slime.el") +(declare-function slime-disconnect "slime.el") +(declare-function slime-mode "slime.el") + +(defconst clojure-font-lock-keywords + (eval-when-compile + `( ;; Definitions. + (,(concat "(\\(?:clojure.core/\\)?\\(" + (regexp-opt '("defn" "defn-" "def" "def-" "defonce" + "defmulti" "defmethod" "defmacro" + "defstruct" "deftype" "defprotocol" + "defrecord" "deftest" + "slice" "def\\[a-z\\]" + "defalias" "defhinted" "defmacro-" + "defn-memo" "defnk" "defonce-" + "defstruct-" "defunbound" "defunbound-" + "defvar" "defvar-")) + ;; Function declarations. + "\\)\\>" + ;; Any whitespace + "[ \r\n\t]*" + ;; Possibly type or metadata + "\\(?:#?^\\(?:{[^}]*}\\|\\sw+\\)[ \r\n\t]*\\)*" + "\\(\\sw+\\)?") + (1 font-lock-keyword-face) + (2 font-lock-function-name-face nil t)) + ;; (fn name? args ...) + (,(concat "(\\(?:clojure.core/\\)?\\(fn\\)[ \t]+" + ;; Possibly type + "\\(?:#?^\\sw+[ \t]*\\)?" + ;; Possibly name + "\\(t\\sw+\\)?" ) + (1 font-lock-keyword-face) + (2 font-lock-function-name-face nil t)) + + (,(concat "(\\(\\(?:[a-z\.-]+/\\)?def\[a-z\]*-?\\)" + ;; Function declarations. + "\\>" + ;; Any whitespace + "[ \r\n\t]*" + ;; Possibly type or metadata + "\\(?:#?^\\(?:{[^}]*}\\|\\sw+\\)[ \r\n\t]*\\)*" + "\\(\\sw+\\)?") + (1 font-lock-keyword-face) + (2 font-lock-function-name-face nil t)) + ;; Deprecated functions + (,(concat + "(\\(?:clojure.core/\\)?" + (regexp-opt + '("add-watcher" "remove-watcher" "add-classpath") t) + "\\>") + 1 font-lock-warning-face) + ;; Control structures + (,(concat + "(\\(?:clojure.core/\\)?" + (regexp-opt + '("let" "letfn" "do" + "case" "cond" "condp" + "for" "loop" "recur" + "when" "when-not" "when-let" "when-first" + "if" "if-let" "if-not" + "." ".." "->" "->>" "doto" + "and" "or" + "dosync" "doseq" "dotimes" "dorun" "doall" + "load" "import" "unimport" "ns" "in-ns" "refer" + "try" "catch" "finally" "throw" + "with-open" "with-local-vars" "binding" + "gen-class" "gen-and-load-class" "gen-and-save-class" + "handler-case" "handle") t) + "\\>") + 1 font-lock-builtin-face) + ;; Built-ins + (,(concat + "(\\(?:clojure.core/\\)?" + (regexp-opt + '("*" "*1" "*2" "*3" "*agent*" + "*allow-unresolved-vars*" "*assert*" "*clojure-version*" "*command-line-args*" "*compile-files*" + "*compile-path*" "*e" "*err*" "*file*" "*flush-on-newline*" + "*in*" "*macro-meta*" "*math-context*" "*ns*" "*out*" + "*print-dup*" "*print-length*" "*print-level*" "*print-meta*" "*print-readably*" + "*read-eval*" "*source-path*" "*use-context-classloader*" "*warn-on-reflection*" "+" + "-" "/" + "<" "<=" "=" "==" ">" + ">=" "accessor" "aclone" + "agent" "agent-errors" "aget" "alength" "alias" + "all-ns" "alter" "alter-meta!" "alter-var-root" "amap" + "ancestors" "and" "apply" "areduce" "array-map" + "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" "binding" "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-array" "booleans" "bound-fn" "bound-fn*" "butlast" + "byte" "byte-array" "bytes" "case" "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" "cond" "condp" "conj" + "conj!" "cons" "constantly" "construct-proxy" "contains?" + "count" "counted?" "create-ns" "create-struct" "cycle" + "dec" "decimal?" "declare" "definline" "defmacro" + "defmethod" "defmulti" "defn" "defn-" "defonce" + "defstruct" "delay" "delay?" "deliver" "deref" + "derive" "descendants" "destructure" "disj" "disj!" + "dissoc" "dissoc!" "distinct" "distinct?" "doall" + "doc" "dorun" "doseq" "dosync" "dotimes" + "doto" "double" "double-array" "doubles" "drop" + "drop-last" "drop-while" "empty" "empty?" "ensure" + "enumeration-seq" "eval" "even?" "every?" + "extend" "extend-protocol" "extend-type" "extends?" "extenders" + "false?" "ffirst" "file-seq" "filter" "find" "find-doc" + "find-ns" "find-var" "first" "flatten" "float" "float-array" + "float?" "floats" "flush" "fn" "fn?" + "fnext" "for" "force" "format" "future" + "future-call" "future-cancel" "future-cancelled?" "future-done?" "future?" + "gen-class" "gen-interface" "gensym" "get" "get-in" + "get-method" "get-proxy-class" "get-thread-bindings" "get-validator" "group-by" + "hash" "hash-map" "hash-set" "identical?" "identity" "if-let" + "if-not" "ifn?" "import" "in-ns" "inc" + "init-proxy" "instance?" "int" "int-array" "integer?" + "interleave" "intern" "interpose" "into" "into-array" + "ints" "io!" "isa?" "iterate" "iterator-seq" + "juxt" "key" "keys" "keyword" "keyword?" + "last" "lazy-cat" "lazy-seq" "let" "letfn" + "line-seq" "list" "list*" "list?" "load" + "load-file" "load-reader" "load-string" "loaded-libs" "locking" + "long" "long-array" "longs" "loop" "macroexpand" + "macroexpand-1" "make-array" "make-hierarchy" "map" "map?" + "mapcat" "max" "max-key" "memfn" "memoize" + "merge" "merge-with" "meta" "method-sig" "methods" + "min" "min-key" "mod" "name" "namespace" + "neg?" "newline" "next" "nfirst" "nil?" + "nnext" "not" "not-any?" "not-empty" "not-every?" + "not=" "ns" "ns-aliases" "ns-imports" "ns-interns" + "ns-map" "ns-name" "ns-publics" "ns-refers" "ns-resolve" + "ns-unalias" "ns-unmap" "nth" "nthnext" "num" + "number?" "odd?" "or" "parents" "partial" + "partition" "partition-all" "partition-by" "pcalls" "peek" "persistent!" "pmap" + "pop" "pop!" "pop-thread-bindings" "pos?" "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" "quot" "rand" "rand-int" "range" + "ratio?" "rational?" "rationalize" "re-find" "re-groups" + "re-matcher" "re-matches" "re-pattern" "re-seq" "read" + "read-line" "read-string" "reify" "reduce" "ref" "ref-history-count" + "ref-max-history" "ref-min-history" "ref-set" "refer" "refer-clojure" + "release-pending-sends" "rem" "remove" "remove-method" "remove-ns" + "repeat" "repeatedly" "replace" "replicate" + "require" "reset!" "reset-meta!" "resolve" "rest" + "resultset-seq" "reverse" "reversible?" "rseq" "rsubseq" + "satisfies?" "second" "select-keys" "send" "send-off" "seq" + "seq?" "seque" "sequence" "sequential?" "set" + "set-validator!" "set?" "short" "short-array" "shorts" + "shutdown-agents" "slurp" "some" "sort" "sort-by" + "sorted-map" "sorted-map-by" "sorted-set" "sorted-set-by" "sorted?" + "special-form-anchor" "special-symbol?" "spit" "split-at" "split-with" "str" + "stream?" "string?" "struct" "struct-map" "subs" + "subseq" "subvec" "supers" "swap!" "symbol" + "symbol?" "sync" "syntax-symbol-anchor" "take" "take-last" + "take-nth" "take-while" "test" "the-ns" "time" + "to-array" "to-array-2d" "trampoline" "transient" "tree-seq" + "true?" "type" "unchecked-add" "unchecked-dec" "unchecked-divide" + "unchecked-inc" "unchecked-multiply" "unchecked-negate" "unchecked-remainder" "unchecked-subtract" + "underive" "unquote" "unquote-splicing" "update-in" "update-proxy" + "use" "val" "vals" "var-get" "var-set" + "var?" "vary-meta" "vec" "vector" "vector?" + "when" "when-first" "when-let" "when-not" "while" + "with-bindings" "with-bindings*" "with-in-str" "with-loading-context" "with-local-vars" + "with-meta" "with-open" "with-out-str" "with-precision" "xml-seq" "zipmap" + ) t) + "\\>") + 1 font-lock-variable-name-face) + ;;Other namespaces in clojure.jar + (,(concat + "(\\(?:\.*/\\)?" + (regexp-opt + '(;; clojure.inspector + "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" + ;; clojure.set + "difference" "index" "intersection" "join" "map-invert" + "project" "rename" "rename-keys" "select" "union" + ;; clojure.stacktrace + "e" "print-cause-trace" "print-stack-trace" "print-throwable" "print-trace-element" + ;; clojure.template + "do-template" "apply-template" + ;; clojure.test + "*initial-report-counters*" "*load-tests*" "*report-counters*" "*stack-trace-depth*" "*test-out*" + "*testing-contexts*" "*testing-vars*" "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" "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" + ;; clojure.xml + "*current*" "*sb*" "*stack*" "*state*" "attrs" + "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" + ) t) + "\\>") + 1 font-lock-type-face) + ;; Constant values (keywords), including as metadata e.g. ^:static + ("\\<^?:\\(\\sw\\|#\\)+\\>" 0 font-lock-constant-face) + ;; Meta type annotation #^Type or ^Type + ("#?^\\sw+" 0 font-lock-preprocessor-face) + ("\\" 0 font-lock-warning-face) + + ;;Java interop highlighting + ("\\<\\.-?[a-z][a-zA-Z0-9]*\\>" 0 font-lock-preprocessor-face) ;; .foo .barBaz .qux01 .-flibble .-flibbleWobble + ("\\<[A-Z][a-zA-Z0-9_]*[a-zA-Z0-9/$_]+\\>" 0 font-lock-preprocessor-face) ;; Foo Bar$Baz Qux_ World_OpenUDP + ("\\<[a-zA-Z]+\\.[a-zA-Z0-9._]*[A-Z]+[a-zA-Z0-9/.$]*\\>" 0 font-lock-preprocessor-face) ;; Foo/Bar foo.bar.Baz foo.Bar/baz + ("[a-z]*[A-Z]+[a-z][a-zA-Z0-9$]*\\>" 0 font-lock-preprocessor-face) ;; fooBar + ("\\<[A-Z][a-zA-Z0-9$]*\\.\\>" 0 font-lock-preprocessor-face))) ;; Foo. BarBaz. Qux$Quux. Corge9. + + + "Default expressions to highlight in Clojure mode.") (defgroup clojure-mode nil "A mode for Clojure" @@ -339,237 +589,6 @@ elements of a def* forms." (error (forward-char 8)))))) nil) -(defconst clojure-font-lock-keywords - (eval-when-compile - `( ;; Definitions. - (,(concat "(\\(?:clojure.core/\\)?\\(" - (regexp-opt '("defn" "defn-" "def" "def-" "defonce" - "defmulti" "defmethod" "defmacro" - "defstruct" "deftype" "defprotocol" - "defrecord" "deftest" - "slice" "def\\[a-z\\]" - "defalias" "defhinted" "defmacro-" - "defn-memo" "defnk" "defonce-" - "defstruct-" "defunbound" "defunbound-" - "defvar" "defvar-")) - ;; Function declarations. - "\\)\\>" - ;; Any whitespace - "[ \r\n\t]*" - ;; Possibly type or metadata - "\\(?:#?^\\(?:{[^}]*}\\|\\sw+\\)[ \r\n\t]*\\)*" - "\\(\\sw+\\)?") - (1 font-lock-keyword-face) - (2 font-lock-function-name-face nil t)) - ;; (fn name? args ...) - (,(concat "(\\(?:clojure.core/\\)?\\(fn\\)[ \t]+" - ;; Possibly type - "\\(?:#?^\\sw+[ \t]*\\)?" - ;; Possibly name - "\\(t\\sw+\\)?" ) - (1 font-lock-keyword-face) - (2 font-lock-function-name-face nil t)) - - (,(concat "(\\(\\(?:[a-z\.-]+/\\)?def\[a-z\]*-?\\)" - ;; Function declarations. - "\\>" - ;; Any whitespace - "[ \r\n\t]*" - ;; Possibly type or metadata - "\\(?:#?^\\(?:{[^}]*}\\|\\sw+\\)[ \r\n\t]*\\)*" - "\\(\\sw+\\)?") - (1 font-lock-keyword-face) - (2 font-lock-function-name-face nil t)) - ;; Deprecated functions - (,(concat - "(\\(?:clojure.core/\\)?" - (regexp-opt - '("add-watcher" "remove-watcher" "add-classpath") t) - "\\>") - 1 font-lock-warning-face) - ;; Control structures - (,(concat - "(\\(?:clojure.core/\\)?" - (regexp-opt - '("let" "letfn" "do" - "case" "cond" "condp" - "for" "loop" "recur" - "when" "when-not" "when-let" "when-first" - "if" "if-let" "if-not" - "." ".." "->" "->>" "doto" - "and" "or" - "dosync" "doseq" "dotimes" "dorun" "doall" - "load" "import" "unimport" "ns" "in-ns" "refer" - "try" "catch" "finally" "throw" - "with-open" "with-local-vars" "binding" - "gen-class" "gen-and-load-class" "gen-and-save-class" - "handler-case" "handle") t) - "\\>") - 1 font-lock-builtin-face) - ;; Built-ins - (,(concat - "(\\(?:clojure.core/\\)?" - (regexp-opt - '("*" "*1" "*2" "*3" "*agent*" - "*allow-unresolved-vars*" "*assert*" "*clojure-version*" "*command-line-args*" "*compile-files*" - "*compile-path*" "*e" "*err*" "*file*" "*flush-on-newline*" - "*in*" "*macro-meta*" "*math-context*" "*ns*" "*out*" - "*print-dup*" "*print-length*" "*print-level*" "*print-meta*" "*print-readably*" - "*read-eval*" "*source-path*" "*use-context-classloader*" "*warn-on-reflection*" "+" - "-" "/" - "<" "<=" "=" "==" ">" - ">=" "accessor" "aclone" - "agent" "agent-errors" "aget" "alength" "alias" - "all-ns" "alter" "alter-meta!" "alter-var-root" "amap" - "ancestors" "and" "apply" "areduce" "array-map" - "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" "binding" "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-array" "booleans" "bound-fn" "bound-fn*" "butlast" - "byte" "byte-array" "bytes" "case" "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" "cond" "condp" "conj" - "conj!" "cons" "constantly" "construct-proxy" "contains?" - "count" "counted?" "create-ns" "create-struct" "cycle" - "dec" "decimal?" "declare" "definline" "defmacro" - "defmethod" "defmulti" "defn" "defn-" "defonce" - "defstruct" "delay" "delay?" "deliver" "deref" - "derive" "descendants" "destructure" "disj" "disj!" - "dissoc" "dissoc!" "distinct" "distinct?" "doall" - "doc" "dorun" "doseq" "dosync" "dotimes" - "doto" "double" "double-array" "doubles" "drop" - "drop-last" "drop-while" "empty" "empty?" "ensure" - "enumeration-seq" "eval" "even?" "every?" - "extend" "extend-protocol" "extend-type" "extends?" "extenders" - "false?" "ffirst" "file-seq" "filter" "find" "find-doc" - "find-ns" "find-var" "first" "flatten" "float" "float-array" - "float?" "floats" "flush" "fn" "fn?" - "fnext" "for" "force" "format" "future" - "future-call" "future-cancel" "future-cancelled?" "future-done?" "future?" - "gen-class" "gen-interface" "gensym" "get" "get-in" - "get-method" "get-proxy-class" "get-thread-bindings" "get-validator" "group-by" - "hash" "hash-map" "hash-set" "identical?" "identity" "if-let" - "if-not" "ifn?" "import" "in-ns" "inc" - "init-proxy" "instance?" "int" "int-array" "integer?" - "interleave" "intern" "interpose" "into" "into-array" - "ints" "io!" "isa?" "iterate" "iterator-seq" - "juxt" "key" "keys" "keyword" "keyword?" - "last" "lazy-cat" "lazy-seq" "let" "letfn" - "line-seq" "list" "list*" "list?" "load" - "load-file" "load-reader" "load-string" "loaded-libs" "locking" - "long" "long-array" "longs" "loop" "macroexpand" - "macroexpand-1" "make-array" "make-hierarchy" "map" "map?" - "mapcat" "max" "max-key" "memfn" "memoize" - "merge" "merge-with" "meta" "method-sig" "methods" - "min" "min-key" "mod" "name" "namespace" - "neg?" "newline" "next" "nfirst" "nil?" - "nnext" "not" "not-any?" "not-empty" "not-every?" - "not=" "ns" "ns-aliases" "ns-imports" "ns-interns" - "ns-map" "ns-name" "ns-publics" "ns-refers" "ns-resolve" - "ns-unalias" "ns-unmap" "nth" "nthnext" "num" - "number?" "odd?" "or" "parents" "partial" - "partition" "partition-all" "partition-by" "pcalls" "peek" "persistent!" "pmap" - "pop" "pop!" "pop-thread-bindings" "pos?" "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" "quot" "rand" "rand-int" "range" - "ratio?" "rational?" "rationalize" "re-find" "re-groups" - "re-matcher" "re-matches" "re-pattern" "re-seq" "read" - "read-line" "read-string" "reify" "reduce" "ref" "ref-history-count" - "ref-max-history" "ref-min-history" "ref-set" "refer" "refer-clojure" - "release-pending-sends" "rem" "remove" "remove-method" "remove-ns" - "repeat" "repeatedly" "replace" "replicate" - "require" "reset!" "reset-meta!" "resolve" "rest" - "resultset-seq" "reverse" "reversible?" "rseq" "rsubseq" - "satisfies?" "second" "select-keys" "send" "send-off" "seq" - "seq?" "seque" "sequence" "sequential?" "set" - "set-validator!" "set?" "short" "short-array" "shorts" - "shutdown-agents" "slurp" "some" "sort" "sort-by" - "sorted-map" "sorted-map-by" "sorted-set" "sorted-set-by" "sorted?" - "special-form-anchor" "special-symbol?" "spit" "split-at" "split-with" "str" - "stream?" "string?" "struct" "struct-map" "subs" - "subseq" "subvec" "supers" "swap!" "symbol" - "symbol?" "sync" "syntax-symbol-anchor" "take" "take-last" - "take-nth" "take-while" "test" "the-ns" "time" - "to-array" "to-array-2d" "trampoline" "transient" "tree-seq" - "true?" "type" "unchecked-add" "unchecked-dec" "unchecked-divide" - "unchecked-inc" "unchecked-multiply" "unchecked-negate" "unchecked-remainder" "unchecked-subtract" - "underive" "unquote" "unquote-splicing" "update-in" "update-proxy" - "use" "val" "vals" "var-get" "var-set" - "var?" "vary-meta" "vec" "vector" "vector?" - "when" "when-first" "when-let" "when-not" "while" - "with-bindings" "with-bindings*" "with-in-str" "with-loading-context" "with-local-vars" - "with-meta" "with-open" "with-out-str" "with-precision" "xml-seq" "zipmap" - ) t) - "\\>") - 1 font-lock-variable-name-face) - ;;Other namespaces in clojure.jar - (,(concat - "(\\(?:\.*/\\)?" - (regexp-opt - '(;; clojure.inspector - "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" - ;; clojure.set - "difference" "index" "intersection" "join" "map-invert" - "project" "rename" "rename-keys" "select" "union" - ;; clojure.stacktrace - "e" "print-cause-trace" "print-stack-trace" "print-throwable" "print-trace-element" - ;; clojure.template - "do-template" "apply-template" - ;; clojure.test - "*initial-report-counters*" "*load-tests*" "*report-counters*" "*stack-trace-depth*" "*test-out*" - "*testing-contexts*" "*testing-vars*" "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" "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" - ;; clojure.xml - "*current*" "*sb*" "*stack*" "*state*" "attrs" - "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" - ) t) - "\\>") - 1 font-lock-type-face) - ;; Constant values (keywords), including as metadata e.g. ^:static - ("\\<^?:\\(\\sw\\|#\\)+\\>" 0 font-lock-constant-face) - ;; Meta type annotation #^Type or ^Type - ("#?^\\sw+" 0 font-lock-preprocessor-face) - ("\\" 0 font-lock-warning-face) - - ;;Java interop highlighting - ("\\<\\.-?[a-z][a-zA-Z0-9]*\\>" 0 font-lock-preprocessor-face) ;; .foo .barBaz .qux01 .-flibble .-flibbleWobble - ("\\<[A-Z][a-zA-Z0-9_]*[a-zA-Z0-9/$_]+\\>" 0 font-lock-preprocessor-face) ;; Foo Bar$Baz Qux_ World_OpenUDP - ("\\<[a-zA-Z]+\\.[a-zA-Z0-9._]*[A-Z]+[a-zA-Z0-9/.$]*\\>" 0 font-lock-preprocessor-face) ;; Foo/Bar foo.bar.Baz foo.Bar/baz - ("[a-z]*[A-Z]+[a-z][a-zA-Z0-9$]*\\>" 0 font-lock-preprocessor-face) ;; fooBar - ("\\<[A-Z][a-zA-Z0-9$]*\\.\\>" 0 font-lock-preprocessor-face))) ;; Foo. BarBaz. Qux$Quux. Corge9. - - - "Default expressions to highlight in Clojure mode.") - ;; Docstring positions (put 'defn 'clojure-doc-string-elt 2) (put 'defn- 'clojure-doc-string-elt 2) @@ -745,7 +764,7 @@ check for contextual indenting." (quote ,(first x)) ,(second x))) kvs))) (defun add-custom-clojure-indents (name value) - (setq clojure-defun-indents value) + (custom-set-default name value) (mapcar (lambda (x) (put-clojure-indent x 'defun)) value)) @@ -1249,4 +1268,9 @@ The arguments are dir, hostname, and port. The return value should be an `alist (add-to-list 'interpreter-mode-alist '("cake" . clojure-mode))) (provide 'clojure-mode) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions) +;; End: + ;;; clojure-mode.el ends here diff --git a/clojure-test-mode.el b/clojure-test-mode.el index 5dc895bd..8b5c2da5 100644 --- a/clojure-test-mode.el +++ b/clojure-test-mode.el @@ -120,12 +120,24 @@ ;;; Code: +(eval-when-compile + (require 'cl)) + (require 'clojure-mode) -(require 'cl) (require 'which-func) (require 'nrepl nil t) (require 'slime nil t) +(declare-function nrepl-repl-buffer "nrepl.el") +(declare-function nrepl-make-response-handler "nrepl.el") +(declare-function nrepl-send-string "nrepl.el") +(declare-function nrepl-current-ns "nrepl.el") +(declare-function slime-eval-async "slime.el") +(declare-function slime-connection-name "slime.el") +(declare-function slime-connected-p "slime.el") +(declare-function coerce "cl-extra.el") +(declare-function find-if "cl-seq.el") + ;; Faces (defface clojure-test-failure-face @@ -278,7 +290,8 @@ (defun clojure-test-highlight-problem (line event message) (save-excursion - (goto-line line) + (goto-char (point-min)) + (forward-line (1- line)) (let ((beg (point))) (end-of-line) (let ((overlay (make-overlay beg (point)))) @@ -458,4 +471,9 @@ with a \"test.\" bit on it." (add-hook 'clojure-mode-hook 'clojure-test-maybe-enable)) (provide 'clojure-test-mode) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions) +;; End: + ;;; clojure-test-mode.el ends here diff --git a/clojurescript-mode.el b/clojurescript-mode.el index b30bea20..181f4ac0 100644 --- a/clojurescript-mode.el +++ b/clojurescript-mode.el @@ -39,6 +39,12 @@ (require 'clojure-mode) +(eval-when-compile + (defvar paredit-mode) + (defvar paredit-version)) + +(declare-function slime-mode "slime.el") + (defvar clojurescript-home (getenv "CLOJURESCRIPT_HOME") "Path to ClojureScript home directory") @@ -65,7 +71,9 @@ (defun clojurescript-eval-last-expression () (interactive) - (let ((expr (slime-last-expression))) + (let ((expr (buffer-substring-no-properties + (save-excursion (backward-sexp) (point)) + (point)))) (comint-send-string (inferior-lisp-proc) (concat expr "\n")))) (defun clojurescript-compile-and-load-file ()