Skip to content
Browse files

upgrade clojure-mode, inf-ruby, and rainbow-mode

  • Loading branch information...
1 parent 526c984 commit 571a8f847ebbf474da8b16d40eeec2576ac3da5b @bleything committed Jan 2, 2013
View
1 elpa/clojure-mode-1.11.5/clojure-mode-pkg.el
@@ -1 +0,0 @@
-(define-package "clojure-mode" "1.11.5" "Major mode for Clojure code" (quote nil))
View
21 ...ure-mode-1.11.5/clojure-mode-autoloads.el → ...jure-mode-2.0.0/clojure-mode-autoloads.el
@@ -3,8 +3,8 @@
;;; Code:
-;;;### (autoloads (clojure-enable-slime-on-existing-buffers clojure-jack-in
-;;;;;; clojure-mode) "clojure-mode" "clojure-mode.el" (20322 55315))
+;;;### (autoloads (clojure-mode) "clojure-mode" "clojure-mode.el"
+;;;;;; (20708 51037 0 0))
;;; Generated autoloads from clojure-mode.el
(autoload 'clojure-mode "clojure-mode" "\
@@ -21,23 +21,20 @@ if that value is non-nil.
\(fn)" t nil)
-(autoload 'clojure-jack-in "clojure-mode" "\
+(put 'clojure-test-ns-segment-position 'safe-local-variable 'integerp)
+(put 'clojure-mode-load-command 'safe-local-variable 'stringp)
-\(fn)" t nil)
-
-(autoload 'clojure-enable-slime-on-existing-buffers "clojure-mode" "\
-
-
-\(fn)" t nil)
+(add-to-list 'auto-mode-alist '("\\.clj\\'" . clojure-mode))
-(add-hook 'slime-connected-hook 'clojure-enable-slime-on-existing-buffers)
+(add-to-list 'interpreter-mode-alist '("jark" . clojure-mode))
-(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
+(add-to-list 'interpreter-mode-alist '("cake" . clojure-mode))
;;;***
-;;;### (autoloads nil nil ("clojure-mode-pkg.el") (20322 55315 118883))
+;;;### (autoloads nil nil ("clojure-mode-pkg.el") (20708 51037 371955
+;;;;;; 0))
;;;***
View
1 elpa/clojure-mode-2.0.0/clojure-mode-pkg.el
@@ -0,0 +1 @@
+(define-package "clojure-mode" "2.0.0" "Major mode for Clojure code" (quote nil))
View
812 elpa/clojure-mode-1.11.5/clojure-mode.el → elpa/clojure-mode-2.0.0/clojure-mode.el
@@ -1,12 +1,12 @@
;;; clojure-mode.el --- Major mode for Clojure code
-;; Copyright (C) 2007-2011 Jeffrey Chu, Lennart Staflin, Phil Hagelberg
+;; Copyright © 2007-2013 Jeffrey Chu, Lennart Staflin, Phil Hagelberg
;;
;; Authors: Jeffrey Chu <jochu0@gmail.com>
;; Lennart Staflin <lenst@lysator.liu.se>
;; Phil Hagelberg <technomancy@gmail.com>
;; URL: http://github.com/technomancy/clojure-mode
-;; Version: 1.11.5
+;; Version: 2.0.0
;; Keywords: languages, lisp
;; This file is not part of GNU Emacs.
@@ -19,34 +19,16 @@
;; Users of older Emacs (pre-22) should get version 1.4:
;; http://github.com/technomancy/clojure-mode/tree/1.4
-;;; Installation:
+;; Slime integration has been removed; see the 1.x releases if you need it.
-;; Use package.el. You'll need to add Marmalade to your archives:
-
-;; (require 'package)
-;; (add-to-list 'package-archives
-;; '("marmalade" . "http://marmalade-repo.org/packages/"))
-
-;; If you use a version of Emacs prior to 24 that doesn't include
-;; package.el, you can get it from http://bit.ly/pkg-el23. If you have
-;; an older package.el installed from tromey.com, you should upgrade
-;; in order to support installation from multiple sources.
-
-;; Of course, it's possible to just place it on your load-path and
-;; require it as well if you don't mind missing out on
-;; byte-compilation and autoloads.
-
-;; Using clojure-mode with paredit is highly recommended. It is also
-;; available using package.el from the above archive.
-
-;; Use paredit as you normally would with any other mode; for instance:
+;; Using clojure-mode with paredit is highly recommended. Use paredit
+;; as you would with any other minor mode; for instance:
;;
;; ;; require or autoload paredit-mode
-;; (defun turn-on-paredit () (paredit-mode 1))
-;; (add-hook 'clojure-mode-hook 'turn-on-paredit)
+;; (add-hook 'clojure-mode-hook 'paredit-mode)
-;; See Swank Clojure (http://github.com/technomancy/swank-clojure) for
-;; better interaction with subprocesses via SLIME.
+;; See nREPL.el (http://github.com/kingtim/nrepl.el) for
+;; better interaction with subprocesses via nREPL.
;;; License:
@@ -67,7 +49,245 @@
;;; Code:
+(eval-when-compile
+ (defvar calculate-lisp-indent-last-sexp)
+ (defvar font-lock-beg)
+ (defvar font-lock-end)
+ (defvar paredit-version)
+ (defvar paredit-mode))
+
(require 'cl)
+(require 'tramp)
+(require 'inf-lisp)
+(require 'imenu)
+
+(declare-function clojure-test-jump-to-implementation "clojure-test-mode.el")
+
+(defconst clojure-font-lock-keywords
+ (eval-when-compile
+ `( ;; Definitions.
+ (,(concat "(\\(?:clojure.core/\\)?\\("
+ (regexp-opt '("defn" "defn-" "def" "defonce"
+ "defmulti" "defmethod" "defmacro"
+ "defstruct" "deftype" "defprotocol"
+ "defrecord" "deftest" "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))
+ ;; (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-keyword-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-builtin-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)
+ ("\\<io\\!\\>" 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"
@@ -107,9 +327,9 @@ Clojure to load that file."
(define-key map "\C-c\C-e" 'lisp-eval-last-sexp)
(define-key map "\C-c\C-l" 'clojure-load-file)
(define-key map "\C-c\C-r" 'lisp-eval-region)
- (define-key map "\C-c\C-z" 'run-lisp)
- (define-key map (kbd "RET") 'reindent-then-newline-and-indent)
- (define-key map (kbd "C-c t") 'clojure-jump-to-test)
+ (define-key map (kbd "C-c C-t") 'clojure-jump-between-tests-and-code)
+ (define-key map "\C-c\C-z" 'clojure-display-inferior-lisp-buffer)
+ (define-key map (kbd "C-c M-q") 'clojure-fill-docstring)
map)
"Keymap for Clojure mode. Inherits from `lisp-mode-shared-map'.")
@@ -147,7 +367,7 @@ numbers count from the end:
(defun clojure-mode-version ()
"Currently package.el doesn't support prerelease version numbers."
- "1.11.5")
+ "2.0.0")
;;;###autoload
(defun clojure-mode ()
@@ -187,13 +407,21 @@ if that value is non-nil."
(clojure-mode-font-lock-setup)
+ (add-hook 'paredit-mode-hook
+ (lambda ()
+ (when (>= paredit-version 21)
+ (define-key clojure-mode-map "{" 'paredit-open-curly)
+ (define-key clojure-mode-map "}" 'paredit-close-curly))))
+
(run-mode-hooks 'clojure-mode-hook)
- (run-hooks 'prog-mode-hook)
+ (run-hooks 'prog-mode-hook))
- ;; Enable curly braces when paredit is enabled in clojure-mode-hook
- (when (and (featurep 'paredit) paredit-mode (>= paredit-version 21))
- (define-key clojure-mode-map "{" 'paredit-open-curly)
- (define-key clojure-mode-map "}" 'paredit-close-curly)))
+(defun clojure-display-inferior-lisp-buffer ()
+ "Display a buffer bound to `inferior-lisp-buffer'."
+ (interactive)
+ (if (and inferior-lisp-buffer (get-buffer inferior-lisp-buffer))
+ (pop-to-buffer inferior-lisp-buffer t)
+ (run-lisp inferior-lisp-program)))
(defun clojure-load-file (file-name)
"Load a Lisp file into the inferior Lisp process."
@@ -287,17 +515,24 @@ elements of a def* forms."
changed t)))))
changed))
+(defun clojure-find-block-comment-start (limit)
+ "Search for (comment...) or #_ style block comments and put
+ point at the beginning of the expression."
+ (let ((pos (re-search-forward "\\((comment\\>\\|#_\\)" limit t)))
+ (when pos
+ (forward-char (- (length (match-string 1))))
+ pos)))
+
(defun clojure-font-lock-extend-region-comment ()
"Move fontification boundaries to always contain
- entire (comment ..) sexp. Does not work if you have a
+ entire (comment ..) and #_ sexp. Does not work if you have a
white-space between ( and comment, but that is omitted to make
this run faster."
(let ((changed nil))
(goto-char font-lock-beg)
(condition-case nil (beginning-of-defun) (error nil))
- (let ((pos (re-search-forward "(comment\\>" font-lock-end t)))
+ (let ((pos (clojure-find-block-comment-start font-lock-end)))
(when pos
- (forward-char -8)
(when (< (point) font-lock-beg)
(setq font-lock-beg (point)
changed t))
@@ -308,258 +543,29 @@ elements of a def* forms."
changed))
(defun clojure-font-lock-mark-comment (limit)
- "Marks all (comment ..) forms with font-lock-comment-face."
+ "Marks all (comment ..) and #_ forms with font-lock-comment-face."
(let (pos)
(while (and (< (point) limit)
- (setq pos (re-search-forward "(comment\\>" limit t)))
+ (setq pos (clojure-find-block-comment-start limit)))
(when pos
- (forward-char -8)
(condition-case nil
- (add-text-properties (1+ (point)) (progn
- (forward-sexp) (1- (point)))
+ (add-text-properties (point)
+ (progn
+ (forward-sexp)
+ (point))
'(face font-lock-comment-face multiline t))
(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))
- ;; 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" "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" "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?" "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)
- ;; (fn name? args ...)
- (,(concat "(\\(?:clojure.core/\\)?\\(fn\\)[ \t]+"
- ;; Possibly type
- "\\(?:#?^\\sw+[ \t]*\\)?"
- ;; Possibly name
- "\\(\\sw+\\)?" )
- (1 font-lock-keyword-face)
- (2 font-lock-function-name-face nil t))
- ;;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-type-face)
- ("\\<io\\!\\>" 0 font-lock-warning-face)
-
- ;;Java interop highlighting
- ("\\<\\.[a-z][a-zA-Z0-9]*\\>" 0 font-lock-preprocessor-face) ;; .foo .barBaz .qux01
- ("\\<[A-Z][a-zA-Z0-9]*/[a-zA-Z0-9/$_]+\\>" 0 font-lock-preprocessor-face) ;; Foo Bar$Baz Qux_
- ("\\<[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 'ns 'clojure-doc-string-elt 2)
(put 'defn 'clojure-doc-string-elt 2)
(put 'defn- 'clojure-doc-string-elt 2)
(put 'defmulti 'clojure-doc-string-elt 2)
(put 'defmacro 'clojure-doc-string-elt 2)
(put 'definline 'clojure-doc-string-elt 2)
(put 'defprotocol 'clojure-doc-string-elt 2)
-;; Docstring positions - contrib
-(put 'defalias 'clojure-doc-string-elt 3)
-(put 'defmacro- 'clojure-doc-string-elt 2)
-(put 'defn-memo 'clojure-doc-string-elt 2)
-(put 'defnk 'clojure-doc-string-elt 2)
-(put 'defonce- 'clojure-doc-string-elt 3)
-(put 'defunbound 'clojure-doc-string-elt 2)
-(put 'defunbound- 'clojure-doc-string-elt 2)
-(put 'defvar 'clojure-doc-string-elt 3)
-(put 'defvar- 'clojure-doc-string-elt 3)
-
(defun clojure-forward-sexp (n)
@@ -623,11 +629,14 @@ This function also returns nil meaning don't specify the indentation."
(eq (char-after (elt state 1)) ?\())
(+ (current-column) 2) ;; this is probably inside a defn
(current-column)))
- (let ((function (buffer-substring (point)
- (progn (forward-sexp 1) (point))))
- (open-paren (elt state 1))
- method)
- (setq method (get (intern-soft function) 'clojure-indent-function))
+ (let* ((function (buffer-substring (point)
+ (progn (forward-sexp 1) (point))))
+ (open-paren (elt state 1))
+ (method nil)
+ (function-tail (first
+ (last
+ (split-string (substring-no-properties function) "/")))))
+ (setq method (get (intern-soft function-tail) 'clojure-indent-function))
(cond ((member (char-after open-paren) '(?\[ ?\{))
(goto-char open-paren)
@@ -713,7 +722,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))
@@ -763,6 +772,7 @@ use (put-clojure-indent 'some-symbol 'defun)."
(try 0)
(catch 2)
+ (finally 0)
;; binding forms
(let 1)
@@ -785,12 +795,100 @@ use (put-clojure-indent 'some-symbol 'defun)."
;; clojure.test
(testing 1)
(deftest 'defun)
+ (use-fixtures 'defun))
- ;; contrib
- (handler-case 1)
- (handle 1)
- (dotrace 1)
- (deftrace 'defun))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Better docstring filling for clojure-mode
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun clojure-string-start ()
+ "Return the position of the \" that begins the string at point."
+ (save-excursion
+ (save-match-data
+ ;; Find a quote that appears immediately after whitespace,
+ ;; beginning of line, or an open paren, brace, or bracket
+ (re-search-backward "\\(\\s-\\|^\\|(\\|\\[\\|{\\)\\(\"\\)")
+ (match-beginning 2))))
+
+(defun clojure-char-at-point ()
+ "Return the char at point or nil if at buffer end."
+ (when (not (= (point) (point-max)))
+ (buffer-substring-no-properties (point) (1+ (point)))))
+
+(defun clojure-char-before-point ()
+ "Return the char before point or nil if at buffer beginning."
+ (when (not (= (point) (point-min)))
+ (buffer-substring-no-properties (point) (1- (point)))))
+
+;; TODO: Deal with the fact that when point is exactly at the
+;; beginning of a string, it thinks that is the end.
+(defun clojure-string-end ()
+ "Return the position of the \" that ends the string at point.
+
+Note that point must be inside the string - if point is
+positioned at the opening quote, incorrect results will be
+returned."
+ (save-excursion
+ (save-match-data
+ ;; If we're at the end of the string, just return point.
+ (if (and (string= (clojure-char-at-point) "\"")
+ (not (string= (clojure-char-before-point) "\\")))
+ (point)
+ ;; We don't want to get screwed by starting out at the
+ ;; backslash in an escaped quote.
+ (when (string= (clojure-char-at-point) "\\")
+ (backward-char))
+ ;; Look for a quote not preceeded by a backslash
+ (re-search-forward "[^\\]\\\(\\\"\\)")
+ (match-beginning 1)))))
+
+(defun clojure-docstring-start+end-points ()
+ "Return the start and end points of the string at point as a cons."
+ (if (and (fboundp 'paredit-string-start+end-points) paredit-mode)
+ (paredit-string-start+end-points)
+ (cons (clojure-string-start) (clojure-string-end))))
+
+(defun clojure-mark-string ()
+ "Mark the string at point."
+ (interactive)
+ (goto-char (clojure-string-start))
+ (forward-char)
+ (set-mark (clojure-string-end)))
+
+(defun clojure-fill-docstring (&optional argument)
+ "Fill the definition that the point is on appropriate for Clojure.
+
+ Fills so that every paragraph has a minimum of two initial spaces,
+ with the exception of the first line. Fill margins are taken from
+ paragraph start, so a paragraph that begins with four spaces will
+ remain indented by four spaces after refilling."
+ (interactive "P")
+ (if (and (fboundp 'paredit-in-string-p) paredit-mode)
+ (unless (paredit-in-string-p)
+ (error "Must be inside a string")))
+ ;; Oddly, save-excursion doesn't do a good job of preserving point.
+ ;; It's probably because we delete the string and then re-insert it.
+ (let ((old-point (point)))
+ (save-restriction
+ (save-excursion
+ (let* ((string-region (clojure-docstring-start+end-points))
+ (string-start (1+ (car string-region)))
+ (string-end (cdr string-region))
+ (string (buffer-substring-no-properties (1+ (car string-region))
+ (cdr string-region))))
+ (delete-region string-start string-end)
+ (insert
+ (with-temp-buffer
+ (insert string)
+ (let ((left-margin 2))
+ (delete-trailing-whitespace)
+ (fill-region (point-min) (point-max))
+ (buffer-substring-no-properties (+ 2 (point-min)) (point-max))))))))
+ (goto-char old-point)))
@@ -838,126 +936,82 @@ use (put-clojure-indent 'some-symbol 'defun)."
+(defun clojure-expected-ns ()
+ "Returns the namespace name that the file should have."
+ (let* ((project-dir (file-truename
+ (locate-dominating-file default-directory
+ "project.clj")))
+ (relative (substring (buffer-file-name) (length project-dir) -4)))
+ (replace-regexp-in-string
+ "_" "-" (mapconcat 'identity (cdr (split-string relative "/")) "."))))
+
(defun clojure-insert-ns-form ()
(interactive)
(goto-char (point-min))
- (let* ((rel (car (last (split-string buffer-file-name "src/\\|test/"))))
- (relative (car (split-string rel "\\.clj")))
- (segments (split-string relative "/")))
- (insert (format "(ns %s)" (mapconcat #'identity segments ".")))))
-
-
-;;; Slime help
-
-(defvar clojure-project-root-file "project.clj")
-
-;; Pipe to $SHELL to work around mackosecks GUI Emacs $PATH issues.
-(defcustom clojure-swank-command
- (if (or (locate-file "lein" exec-path) (locate-file "lein.bat" exec-path))
- "lein jack-in %s"
- "echo \"lein jack-in %s\" | $SHELL -l")
- "The command used to start swank via clojure-jack-in."
- :type 'string
- :group 'clojure-mode)
-
-(defun clojure-jack-in-sentinel (process event)
- (let ((debug-on-error t))
- (error "Could not start swank server: %s"
- (with-current-buffer (process-buffer process)
- (buffer-substring (point-min) (point-max))))))
-
-(defun clojure-eval-bootstrap-region (process)
- "Eval only the elisp in between the markers."
- (with-current-buffer (process-buffer process)
- (save-excursion
- (goto-char 0)
- (search-forward ";;; Bootstrapping bundled version of SLIME")
- (let ((begin (point)))
- (when (not (search-forward ";;; Done bootstrapping." nil t))
- ;; fall back to possibly-ambiguous string if above isn't found
- (search-forward "(run-hooks 'slime-load-hook)"))
- (eval-region begin (point))))))
+ (insert (format "(ns %s)" (clojure-expected-ns))))
-;;;###autoload
-(defun clojure-jack-in ()
+(defun clojure-update-ns ()
+ "Updates the namespace of the current buffer. Useful if a file has been renamed."
(interactive)
- (setq slime-net-coding-system 'utf-8-unix)
- (lexical-let ((port (- 65535 (mod (caddr (current-time)) 4096)))
- (dir default-directory))
- (when (and (functionp 'slime-disconnect) (slime-current-connection))
- (slime-disconnect))
- (when (get-buffer "*swank*")
- (kill-buffer "*swank*"))
- (let* ((swank-cmd (format clojure-swank-command port))
- (proc (start-process-shell-command "swank" "*swank*" swank-cmd)))
- (set-process-sentinel (get-buffer-process "*swank*")
- 'clojure-jack-in-sentinel)
- (set-process-filter (get-buffer-process "*swank*")
- (lambda (process output)
- (with-current-buffer (process-buffer process)
- (insert output))
- (when (string-match "proceed to jack in" output)
- (clojure-eval-bootstrap-region process)
- (slime-connect "localhost" port)
- (with-current-buffer (slime-output-buffer t)
- (setq default-directory dir))
- (set-process-sentinel process nil)
- (set-process-filter process nil))))))
- (message "Starting swank server..."))
+ (let ((nsname (clojure-expected-ns)))
+ (when nsname
+ (save-restriction
+ (save-excursion
+ (save-match-data
+ (if (clojure-find-ns)
+ (replace-match nsname nil nil nil 4)
+ (error "Namespace not found"))))))))
(defun clojure-find-ns ()
(let ((regexp clojure-namespace-name-regex))
- (save-excursion
- (when (or (re-search-backward regexp nil t)
- (re-search-forward regexp nil t))
- (match-string-no-properties 4)))))
+ (save-restriction
+ (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward regexp nil t)
+ (match-string-no-properties 4))))))
(defalias 'clojure-find-package 'clojure-find-ns)
-(defun clojure-enable-slime ()
- (slime-mode t)
- (set (make-local-variable 'slime-find-buffer-package-function)
- 'clojure-find-ns))
-
-;;;###autoload
-(defun clojure-enable-slime-on-existing-buffers ()
- (interactive)
- (add-hook 'clojure-mode-hook 'clojure-enable-slime)
- (save-window-excursion
- (dolist (buffer (buffer-list))
- (with-current-buffer buffer
- (when (eq major-mode 'clojure-mode)
- (clojure-enable-slime))))))
-
;; Test navigation:
+(defun clojure-in-tests-p ()
+ (or (string-match-p "test\." (clojure-find-ns))
+ (string-match-p "/test" (buffer-file-name))))
(defun clojure-underscores-for-hyphens (namespace)
(replace-regexp-in-string "-" "_" namespace))
(defun clojure-test-for (namespace)
(let* ((namespace (clojure-underscores-for-hyphens namespace))
- (segments (split-string namespace "\\."))
- (before (subseq segments 0 clojure-test-ns-segment-position))
- (after (subseq segments clojure-test-ns-segment-position))
- (test-segments (append before (list "test") after)))
- (mapconcat 'identity test-segments "/")))
+ (segments (split-string namespace "\\.")))
+ (mapconcat 'identity segments "/")))
(defun clojure-jump-to-test ()
"Jump from implementation file to test."
(interactive)
- (find-file (format "%s/test/%s.clj"
- (locate-dominating-file buffer-file-name "src/")
+ (find-file (format "%stest/%s_test.clj"
+ (file-name-as-directory
+ (locate-dominating-file buffer-file-name "src/"))
(clojure-test-for (clojure-find-ns)))))
-;;;###autoload
-(add-hook 'slime-connected-hook 'clojure-enable-slime-on-existing-buffers)
-
-
+(defun clojure-jump-between-tests-and-code ()
+ (interactive)
+ (if (clojure-in-tests-p)
+ (clojure-test-jump-to-implementation)
+ (clojure-jump-to-test)))
;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
-(add-to-list 'interpreter-mode-alist '("jark" . clojure-mode))
-(add-to-list 'interpreter-mode-alist '("cake" . clojure-mode))
+(progn
+ (put 'clojure-test-ns-segment-position 'safe-local-variable 'integerp)
+ (put 'clojure-mode-load-command 'safe-local-variable 'stringp)
+
+ (add-to-list 'auto-mode-alist '("\\.clj\\'" . clojure-mode))
+ (add-to-list 'interpreter-mode-alist '("jark" . clojure-mode))
+ (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
View
1 elpa/inf-ruby-2.2.3/inf-ruby-pkg.el
@@ -1 +0,0 @@
-(define-package "inf-ruby" "2.2.3" "Run a ruby process in a buffer" (quote nil))
View
11 elpa/inf-ruby-2.2.3/inf-ruby-autoloads.el → elpa/inf-ruby-2.2.4/inf-ruby-autoloads.el
@@ -3,11 +3,11 @@
;;; Code:
-;;;### (autoloads (run-ruby inf-ruby inf-ruby-keys) "inf-ruby" "inf-ruby.el"
-;;;;;; (20293 31706))
+;;;### (autoloads (run-ruby inf-ruby inf-ruby-setup-keybindings)
+;;;;;; "inf-ruby" "inf-ruby.el" (20708 51036 0 0))
;;; Generated autoloads from inf-ruby.el
-(autoload 'inf-ruby-keys "inf-ruby" "\
+(autoload 'inf-ruby-setup-keybindings "inf-ruby" "\
Set local key defs to invoke inf-ruby from ruby-mode.
\(fn)" nil nil)
@@ -31,11 +31,12 @@ of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
\(fn &optional COMMAND NAME)" t nil)
-(eval-after-load 'ruby-mode '(add-hook 'ruby-mode-hook 'inf-ruby-keys))
+(eval-after-load 'ruby-mode '(inf-ruby-setup-keybindings))
;;;***
-;;;### (autoloads nil nil ("inf-ruby-pkg.el") (20293 31706 998780))
+;;;### (autoloads nil nil ("inf-ruby-pkg.el") (20708 51036 442621
+;;;;;; 0))
;;;***
View
1 elpa/inf-ruby-2.2.4/inf-ruby-pkg.el
@@ -0,0 +1 @@
+(define-package "inf-ruby" "2.2.4" "Run a ruby process in a buffer" (quote nil))
View
24 elpa/inf-ruby-2.2.3/inf-ruby.el → elpa/inf-ruby-2.2.4/inf-ruby.el
@@ -6,7 +6,7 @@
;; URL: http://github.com/nonsequitur/inf-ruby
;; Created: 8 April 1998
;; Keywords: languages ruby
-;; Version: 2.2.3
+;; Version: 2.2.4
;;; Commentary:
;;
@@ -16,9 +16,9 @@
;; * drop the file somewhere on your load path (perhaps ~/.emacs.d)
;; * Add the following lines to your .emacs file:
;; (autoload 'inf-ruby "inf-ruby" "Run an inferior Ruby process" t)
-;; (autoload 'inf-ruby-keys "inf-ruby" "" t)
+;; (autoload 'inf-ruby-setup-keybindings "inf-ruby" "" t)
;; (eval-after-load 'ruby-mode
-;; '(add-hook 'ruby-mode-hook 'inf-ruby-keys))
+;; '(add-hook 'ruby-mode-hook 'inf-ruby-setup-keybindings))
;;; TODO:
;;
@@ -80,7 +80,7 @@ next one.")
("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
;;;###autoload
-(defun inf-ruby-keys ()
+(defun inf-ruby-setup-keybindings ()
"Set local key defs to invoke inf-ruby from ruby-mode."
(define-key ruby-mode-map "\M-\C-x" 'ruby-send-definition)
(define-key ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
@@ -208,7 +208,7 @@ of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
(setq name (or name "ruby"))
(if (not (comint-check-proc inf-ruby-buffer))
- (let ((commandlist (split-string command)))
+ (let ((commandlist (split-string-and-unquote command)))
(set-buffer (apply 'make-comint name (car commandlist)
nil (cdr commandlist)))
(inf-ruby-mode)))
@@ -326,9 +326,16 @@ Then switch to the process buffer."
(defun ruby-escape-single-quoted (str)
(replace-regexp-in-string "'" "\\\\'"
- (replace-regexp-in-string "\n" "\\\\n"
+ (replace-regexp-in-string "\n" "\\\\n"
(replace-regexp-in-string "\\\\" "\\\\\\\\" str))))
+(defun inf-ruby-fix-completions-on-windows ()
+ "On Windows, the string received by `accept-process-output'
+starts with the last line that was sent to the Ruby process.
+The reason for this is unknown. Remove this line from `completions'."
+ (if (eq system-type 'windows-nt)
+ (setq completions (cdr completions))))
+
(defun inf-ruby-completions (seed)
"Return a list of completions for the line of ruby code starting with SEED."
(let* ((proc (get-buffer-process inf-ruby-buffer))
@@ -339,7 +346,8 @@ Then switch to the process buffer."
(ruby-escape-single-quoted seed)))
(while (and (not (string-match inf-ruby-prompt-pattern kept))
(accept-process-output proc 2)))
- (setq completions (cdr (butlast (split-string kept "\r?\n") 2)))
+ (setq completions (butlast (split-string kept "\r?\n") 2))
+ (inf-ruby-fix-completions-on-windows)
(set-process-filter proc comint-filt)
completions))
@@ -373,7 +381,7 @@ Module used by readline when running irb through a terminal"
;;;###autoload
(eval-after-load 'ruby-mode
- '(add-hook 'ruby-mode-hook 'inf-ruby-keys))
+ '(inf-ruby-setup-keybindings))
(provide 'inf-ruby)
;;; inf-ruby.el ends here
View
1 elpa/rainbow-mode-0.2/rainbow-mode-pkg.el
@@ -1 +0,0 @@
-(define-package "rainbow-mode" "0.2" "Colorize color names in buffers" (quote nil))
View
5 ...ainbow-mode-0.2/rainbow-mode-autoloads.el → ...ainbow-mode-0.6/rainbow-mode-autoloads.el
@@ -4,7 +4,7 @@
;;;### (autoloads (rainbow-mode) "rainbow-mode" "rainbow-mode.el"
-;;;;;; (20297 27418))
+;;;;;; (20708 51035 0 0))
;;; Generated autoloads from rainbow-mode.el
(autoload 'rainbow-mode "rainbow-mode" "\
@@ -15,7 +15,8 @@ This will fontify with colors the string like \"#aabbcc\" or \"blue\".
;;;***
-;;;### (autoloads nil nil ("rainbow-mode-pkg.el") (20297 27418 671357))
+;;;### (autoloads nil nil ("rainbow-mode-pkg.el") (20708 51035 781696
+;;;;;; 0))
;;;***
View
1 elpa/rainbow-mode-0.6/rainbow-mode-pkg.el
@@ -0,0 +1 @@
+(define-package "rainbow-mode" "0.6" "Colorize color names in buffers" (quote nil))
View
161 elpa/rainbow-mode-0.2/rainbow-mode.el → elpa/rainbow-mode-0.6/rainbow-mode.el
@@ -1,10 +1,10 @@
;;; rainbow-mode.el --- Colorize color names in buffers
-;; Copyright (C) 2010-2011 Free Software Foundation, Inc
+;; Copyright (C) 2010-2012 Free Software Foundation, Inc
;; Author: Julien Danjou <julien@danjou.info>
;; Keywords: faces
-;; Version: 0.2
+;; Version: 0.6
;; This file is part of GNU Emacs.
@@ -34,6 +34,10 @@
(require 'regexp-opt)
(require 'faces)
+(require 'color)
+
+(unless (require 'xterm-color nil t)
+ (require 'ansi-color))
(defgroup rainbow nil
"Show color strings with a background color."
@@ -42,7 +46,9 @@
;; Hexadecimal colors
(defvar rainbow-hexadecimal-colors-font-lock-keywords
- '(("#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}"
+ '(("[^&]\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)"
+ (1 (rainbow-colorize-itself 1)))
+ ("^\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)"
(0 (rainbow-colorize-itself)))
("[Rr][Gg][Bb]:[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}"
(0 (rainbow-colorize-itself)))
@@ -263,36 +269,57 @@ will be enabled if a major mode has been detected from the
(0 (rainbow-colorize-rgb)))
("{HTML}{\\([0-9A-Fa-f]\\{6\\}\\)}"
(0 (rainbow-colorize-hexadecimal-without-sharp))))
- "Font-lock keywords to add for X colors.")
+ "Font-lock keywords to add for LaTeX colors.")
(defcustom rainbow-latex-colors-major-mode-list
'(latex-mode)
- "List of major mode where X colors are enabled when
+ "List of major mode where LaTeX colors are enabled when
`rainbow-x-colors' is set to auto."
:group 'rainbow)
(defcustom rainbow-latex-colors 'auto
"When to enable LaTeX colors.
If set to t, the LaTeX colors will be enabled. If set to nil, the
-X colors will not be enabled. If set to auto, the LaTeX colors
+LaTeX colors will not be enabled. If set to auto, the LaTeX colors
will be enabled if a major mode has been detected from the
`rainbow-latex-colors-major-mode-list'."
:group 'rainbow)
+;; Shell colors
+(defvar rainbow-ansi-colors-font-lock-keywords
+ '(("\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\|\033\\)\\[\\([0-9;]*m\\)"
+ (0 (rainbow-colorize-ansi))))
+ "Font-lock keywords to add for ANSI colors.")
+
+(defcustom rainbow-ansi-colors-major-mode-list
+ '(sh-mode c-mode c++-mode)
+ "List of major mode where ANSI colors are enabled when
+`rainbow-ansi-colors' is set to auto."
+ :group 'rainbow)
+
+(defcustom rainbow-ansi-colors 'auto
+ "When to enable ANSI colors.
+If set to t, the ANSI colors will be enabled. If set to nil, the
+ANSI colors will not be enabled. If set to auto, the ANSI colors
+will be enabled if a major mode has been detected from the
+`rainbow-ansi-colors-major-mode-list'."
+ :group 'rainbow)
+
;; Functions
-(defun rainbow-colorize-match (color)
+(defun rainbow-colorize-match (color &optional match)
"Return a matched string propertized with a face whose
background is COLOR. The foreground is computed using
`rainbow-color-luminance', and is either white or black."
- (put-text-property
- (match-beginning 0) (match-end 0)
- 'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
- "white" "black"))
- (:background ,color))))
-
-(defun rainbow-colorize-itself ()
+ (let ((match (or match 0)))
+ (put-text-property
+ (match-beginning match) (match-end match)
+ 'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
+ "white" "black"))
+ (:background ,color)))))
+
+(defun rainbow-colorize-itself (&optional match)
"Colorize a match with itself."
- (rainbow-colorize-match (match-string-no-properties 0)))
+ (rainbow-colorize-match (match-string-no-properties (or match 0)) match))
(defun rainbow-colorize-hexadecimal-without-sharp ()
"Colorize an hexadecimal colors and prepend # to it."
@@ -312,34 +339,14 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
(/ (* (string-to-number (substring number 0 string-length)) 255) 100)
(string-to-number number))))
-(defun rainbow-hue-to-rgb (x y h)
- "Convert X Y H to RGB value."
- (when (< h 0) (incf h))
- (when (> h 1) (decf h))
- (cond ((< h (/ 1 6.0)) (+ x (* (- y x) h 6)))
- ((< h 0.5) y)
- ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6)))
- (t x)))
-
-(defun rainbow-hsl-to-rgb-fractions (h s l)
- "Convert H S L to fractional RGB values."
- (let (m1 m2)
- (if (<= l 0.5)
- (setq m2 (* l (+ s 1)))
- (setq m2 (- (+ l s) (* l s))))
- (setq m1 (- (* l 2) m2))
- (list (rainbow-hue-to-rgb m1 m2 (+ h (/ 1 3.0)))
- (rainbow-hue-to-rgb m1 m2 h)
- (rainbow-hue-to-rgb m1 m2 (- h (/ 1 3.0))))))
-
(defun rainbow-colorize-hsl ()
"Colorize a match with itself."
(let ((h (/ (string-to-number (match-string-no-properties 1)) 360.0))
(s (/ (string-to-number (match-string-no-properties 2)) 100.0))
(l (/ (string-to-number (match-string-no-properties 3)) 100.0)))
(rainbow-colorize-match
(multiple-value-bind (r g b)
- (rainbow-hsl-to-rgb-fractions h s l)
+ (color-hsl-to-rgb h s l)
(format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255))))))
(defun rainbow-colorize-rgb ()
@@ -356,6 +363,40 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
(b (* (string-to-number (match-string-no-properties 3)) 255.0)))
(rainbow-colorize-match (format "#%02X%02X%02X" r g b))))
+(defun rainbow-colorize-ansi ()
+ "Return a matched string propertized with ansi color face."
+ (let ((xterm-color? (featurep 'xterm-color))
+ (string (match-string-no-properties 0))
+ color)
+ (save-match-data
+ (let* ((replaced (concat
+ (replace-regexp-in-string
+ "^\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\)"
+ "\033" string) "x"))
+ xterm-color-current
+ ansi-color-context
+ (applied (funcall (if xterm-color?
+ 'xterm-color-filter
+ 'ansi-color-apply)
+ replaced))
+ (face-property (get-text-property
+ 0
+ (if xterm-color? 'face 'font-lock-face)
+ applied)))
+ (unless (listp (car face-property))
+ (setq face-property (list face-property)))
+ (setq color (funcall (if xterm-color? 'cadr 'cdr)
+ (or (assq (if xterm-color?
+ :foreground
+ 'foreground-color)
+ face-property)
+ (assq (if xterm-color?
+ :background
+ 'background-color)
+ face-property))))))
+ (when color
+ (rainbow-colorize-match color))))
+
(defun rainbow-color-luminance (red green blue)
"Calculate the luminance of color composed of RED, BLUE and GREEN.
Return a value between 0 and 1."
@@ -386,6 +427,12 @@ Return a value between 0 and 1."
(memq major-mode rainbow-latex-colors-major-mode-list)))
(font-lock-add-keywords nil
rainbow-latex-rgb-colors-font-lock-keywords))
+ ;; Activate ANSI colors?
+ (when (or (eq rainbow-ansi-colors t)
+ (and (eq rainbow-ansi-colors 'auto)
+ (memq major-mode rainbow-ansi-colors-major-mode-list)))
+ (font-lock-add-keywords nil
+ rainbow-ansi-colors-font-lock-keywords))
;; Activate HTML colors?
(when (or (eq rainbow-html-colors t)
(and (eq rainbow-html-colors 'auto)
@@ -419,6 +466,48 @@ This will fontify with colors the string like \"#aabbcc\" or \"blue\"."
;; Turn on font lock
(font-lock-mode 1)))
+;;;; ChangeLog:
+
+;; 2012-11-26 Julien Danjou <julien@danjou.info>
+;;
+;; rainbow-mode: fix some LaTex docstrings
+;;
+;; 2012-11-14 Julien Danjou <julien@danjou.info>
+;;
+;; rainbow-mode: version 0.5
+;;
+;; * rainbow-mode.el: fix syntax error on
+;; `rainbow-hexadecimal-colors-font-lock-keywords'.
+;;
+;; 2012-11-09 Julien Danjou <julien@danjou.info>
+;;
+;; rainbow-mode: version 0.4
+;;
+;; * rainbow-mode.el: Use functions from color package to colorize HSL rather
+;; than our own copy.
+;;
+;; 2012-11-09 Julien Danjou <julien@danjou.info>
+;;
+;; rainbow-mode 0.3
+;;
+;; * rainbow-mode.el: avoid colorizing HTML entities
+;;
+;; 2011-09-23 Julien Danjou <julien@danjou.info>
+;;
+;; Update rainbow-mode to version 0.2
+;;
+;; 2011-07-01 Chong Yidong <cyd@stupidchicken.com>
+;;
+;; Reorganize repository layout, allowing site installation.
+;;
+;; A Makefile with "site", "archive" and "archive-full" rules can now be
+;; used for site-installation, partial archive deployment, and full
+;; archive deployment respectively.
+;;
+;; Rewrite the admin/archive-contents.el script to handle these changes.
+;;
+
+
(provide 'rainbow-mode)
;;; rainbow-mode.el ends here

0 comments on commit 571a8f8

Please sign in to comment.
Something went wrong with that request. Please try again.