annotate .elisp/clojure-mode.el @ 23:e1caf3e773a8

Need an alias to do log of a named branch
author Augie Fackler <durin42@gmail.com>
date Tue, 16 Dec 2008 11:28:11 -0600
parents 9541f7e47514
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 ;;; clojure-mode.el -- Major mode for Clojure code
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 ;; Copyright (C) 2008 Jeffrey Chu
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 ;;
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 ;; Author: Jeffrey Chu <jochu0@gmail.com>
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 ;;
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 ;; Originally by: Lennart Staflin <lenst@lysator.liu.se>
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 ;; Copyright (C) 2007, 2008 Lennart Staflin
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 ;;
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 ;; This program is free software; you can redistribute it and/or
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 ;; modify it under the terms of the GNU General Public License
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 ;; as published by the Free Software Foundation; either version 3
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 ;; of the License, or (at your option) any later version.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 ;;
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 ;; This program is distributed in the hope that it will be useful,
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 ;;
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 ;; Boston, MA 02110-1301, USA.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 (require 'cl)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 (defgroup clojure-mode nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 "A mode for Clojure"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 :prefix "clojure-mode-"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 :group 'applications)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 (defcustom clojure-mode-font-lock-multiline-def t
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 "Set to non-nil in order to enable font-lock of
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 multi-line (def...) forms. Changing this will require a
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 restart (ie. M-x clojure-mode) of existing clojure mode buffers."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 :type 'boolean
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 :group 'clojure-mode)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 (defcustom clojure-mode-font-lock-comment-sexp nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 "Set to non-nil in order to enable font-lock of (comment...)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 forms. This option is experimental. Changing this will require a
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 restart (ie. M-x clojure-mode) of existing clojure mode buffers."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 :type 'boolean
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 :group 'clojure-mode)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 (defcustom clojure-mode-load-command "(clojure/load-file \"%s\")\n"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 "*Format-string for building a Clojure expression to load a file.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 This format string should use `%s' to substitute a file name
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 and should result in a Clojure expression that will command the inferior Clojure
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 to load that file."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 :type 'string
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 :group 'clojure-mode)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 (defcustom clojure-mode-use-backtracking-indent nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 "Set to non-nil to enable backtracking/context sensitive
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 indentation."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 :type 'boolean
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 :group 'clojure-mode)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 (defcustom clojure-max-backtracking 3
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 "Maximum amount to backtrack up a list to check for context."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 :type 'integer
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 :group 'clojure-mode)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 (defvar clojure-mode-map
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 (let ((map (make-sparse-keymap)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 (set-keymap-parent map lisp-mode-shared-map)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 (define-key map "\e\C-x" 'lisp-eval-defun)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 (define-key map "\C-x\C-e" 'lisp-eval-last-sexp)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 (define-key map "\C-c\C-e" 'lisp-eval-last-sexp)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 (define-key map "\C-c\C-l" 'clojure-load-file)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 (define-key map "\C-c\C-r" 'lisp-eval-region)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 (define-key map "\C-c\C-z" 'run-lisp)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75 map)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 "Keymap for ordinary Clojure mode.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 All commands in `lisp-mode-shared-map' are inherited by this map.")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 (easy-menu-define clojure-menu clojure-mode-map "Menu used in `clojure-mode'."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 '("Clojure"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 ["Eval defun" lisp-eval-defun t]
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 ["Eval defun and go" lisp-eval-defun-and-go t]
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 ["Eval last sexp" lisp-eval-last-sexp t]
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 ["Eval region" lisp-eval-region t]
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 ["Eval region and go" lisp-eval-region-and-go t]
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87 ["Load file..." clojure-load-file t]
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 ["Run Lisp" run-lisp t]))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 (defvar clojure-mode-syntax-table
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 (modify-syntax-entry ?~ "' " table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 (modify-syntax-entry ?, " " table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 (modify-syntax-entry ?\{ "(}" table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 (modify-syntax-entry ?\} "){" table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 (modify-syntax-entry ?\[ "(]" table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 (modify-syntax-entry ?\] ")[" table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 (modify-syntax-entry ?^ "'" table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100 (modify-syntax-entry ?= "'" table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 table))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 (defvar clojure-prev-l/c-dir/file nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 "Record last directory and file used in loading or compiling.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106 This holds a cons cell of the form `(DIRECTORY . FILE)'
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 describing the last `clojure-load-file' or `clojure-compile-file' command.")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110 (defun clojure-mode ()
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
111 "Major mode for editing Clojure code - similar to Lisp mode..
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112 Commands:
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 Delete converts tabs to spaces as it moves back.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 Blank lines separate paragraphs. Semicolons start comments.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115 \\{clojure-mode-map}
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 Note that `run-lisp' may be used either to start an inferior Lisp job
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 or to switch back to an existing one.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 Entry to this mode calls the value of `clojure-mode-hook'
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 if that value is non-nil."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 (interactive)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 (kill-all-local-variables)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 (use-local-map clojure-mode-map)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124 (setq major-mode 'clojure-mode)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 (setq mode-name "Clojure")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 (lisp-mode-variables nil)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 (set-syntax-table clojure-mode-syntax-table)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 (set (make-local-variable 'comment-start-skip)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
130 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 (set (make-local-variable 'lisp-indent-function)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 'clojure-indent-function)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 (set (make-local-variable 'font-lock-multiline) t)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 (if (and (not (boundp 'font-lock-extend-region-functions))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 (or clojure-mode-font-lock-multiline-def
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
137 clojure-mode-font-lock-comment-sexp))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
138 (message "Clojure mode font lock extras are unavailable, please upgrade to atleast version 22 ")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
139
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140 (when clojure-mode-font-lock-multiline-def
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 (add-to-list 'font-lock-extend-region-functions 'clojure-font-lock-extend-region-def t))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 (when clojure-mode-font-lock-comment-sexp
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144 (add-to-list 'font-lock-extend-region-functions 'clojure-font-lock-extend-region-comment t)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 (make-local-variable 'clojure-font-lock-keywords)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 (add-to-list 'clojure-font-lock-keywords 'clojure-font-lock-mark-comment t)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
149 (setq font-lock-defaults
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 '(clojure-font-lock-keywords ; keywords
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 nil nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 (("+-*/.<>=!?$%_&~^:@" . "w")) ; syntax alist
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 (font-lock-mark-block-function . mark-defun)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 (font-lock-syntactic-face-function . lisp-font-lock-syntactic-face-function)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 (run-mode-hooks 'clojure-mode-hook))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159 (defun clojure-font-lock-def-at-point (point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 "Find the position range between the top-most def* and the
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161 fourth element afterwards. Note that this means there's no
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 gaurantee of proper font locking in def* forms that are not at
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163 top-level."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 (goto-char point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 (condition-case nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166 (beginning-of-defun)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167 (error nil))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169 (let ((beg-def (point)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170 (when (and (not (= point beg-def))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 (looking-at "(def"))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172 (condition-case nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 (progn
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174 ;; move forward as much as possible until failure (or success)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 (forward-char)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
176 (dotimes (i 4)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
177 (forward-sexp)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
178 (error nil))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
179 (cons beg-def (point)))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181 (defun clojure-font-lock-extend-region-def ()
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
182 "Move fontification boundaries to always include the first four
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
183 elements of a def* forms."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
184 (let ((changed nil))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
185 (let ((def (clojure-font-lock-def-at-point font-lock-beg)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
186 (when def
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
187 (destructuring-bind (def-beg . def-end) def
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
188 (when (and (< def-beg font-lock-beg)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
189 (< font-lock-beg def-end))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
190 (setq font-lock-beg def-beg
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191 changed t)))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
193 (let ((def (clojure-font-lock-def-at-point font-lock-end)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
194 (when def
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
195 (destructuring-bind (def-beg . def-end) def
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
196 (when (and (< def-beg font-lock-end)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
197 (< font-lock-end def-end))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
198 (setq font-lock-end def-end
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
199 changed t)))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200 changed))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
201
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
202 (defun clojure-font-lock-extend-region-comment ()
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
203 "Move fontification boundaries to always contain
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
204 entire (comment ..) sexp. Does not work if you have a
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
205 white-space between ( and comment, but that is omitted to make
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
206 this run faster."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
207 (let ((changed nil))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
208 (goto-char font-lock-beg)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
209 (condition-case nil (beginning-of-defun) (error nil))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
210 (let ((pos (re-search-forward "(comment\\>" font-lock-end t)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 (when pos
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
212 (forward-char -8)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213 (when (< (point) font-lock-beg)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
214 (setq font-lock-beg (point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
215 changed t))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
216 (condition-case nil (forward-sexp) (error nil))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
217 (when (> (point) font-lock-end)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
218 (setq font-lock-end (point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
219 changed t))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
220 changed))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
221
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
222
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
223 (defun clojure-font-lock-mark-comment (limit)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
224 "Marks all (comment ..) forms with font-lock-comment-face."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
225 (let (pos)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
226 (while (and (< (point) limit)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
227 (setq pos (re-search-forward "(comment\\>" limit t)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
228 (when pos
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
229 (forward-char -8)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
230 (condition-case nil
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
231 (add-text-properties (1+ (point)) (progn (forward-sexp) (1- (point)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
232 '(face font-lock-comment-face multiline t))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
233 (error (forward-char 8))))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
234 nil)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
235
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
236 (defconst clojure-font-lock-keywords
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
237 (eval-when-compile
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
238 `( ;; Definitions.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
239 (,(concat "(\\(?:clojure/\\)?\\(def"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
240 ;; Function declarations.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
241 "\\(n-?\\|multi\\|macro\\|method\\|"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
242 ;; Variable declarations.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
243 "struct\\|once\\|"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
244 "\\)\\)\\>"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
245 ;; Any whitespace
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
246 "[ \r\n\t]*"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
247 ;; Possibly type or metadata
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
248 "\\(?:#^\\(?:{[^}]*}\\|\\sw+\\)[ \r\n\t]*\\)?"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
249
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
250 "\\(\\sw+\\)?")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
251 (1 font-lock-keyword-face)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
252 (3 font-lock-function-name-face nil t))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
253 ;; Control structures
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
254 (,(concat
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
255 "(\\(?:clojure/\\)?"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
256 (regexp-opt
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
257 '("cond" "for" "loop" "let" "recur" "do" "binding" "with-meta"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
258 "when" "when-not" "when-let" "when-first" "if" "if-let"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
259 "delay" "lazy-cons" "." ".." "->" "and" "or" "locking"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
260 "dosync" "load"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
261 "sync" "doseq" "dotimes" "import" "unimport" "ns" "in-ns" "refer"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
262 "implement" "proxy" "time" "try" "catch" "finally" "throw"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
263 "doto" "with-open" "with-local-vars" "struct-map"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
264 "gen-class" "gen-and-load-class" "gen-and-save-class") t)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
265 "\\>")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
266 . 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
267 ;; (fn name? args ...)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
268 (,(concat "(\\(?:clojure/\\)?\\(fn\\)[ \t]+"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
269 ;; Possibly type
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
270 "\\(?:#^\\sw+[ \t]*\\)?"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
271 ;; Possibly name
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
272 "\\(\\sw+\\)?" )
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
273 (1 font-lock-keyword-face)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
274 (2 font-lock-function-name-face nil t))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
275 ;; Constant values.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
276 ("\\<:\\sw+\\>" 0 font-lock-builtin-face)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
277 ;; Meta type annotation #^Type
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
278 ("#^\\sw+" 0 font-lock-type-face)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
279 ))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
280 "Default expressions to highlight in Clojure mode.")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
281
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
282
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
283 (defun clojure-load-file (file-name)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
284 "Load a Lisp file into the inferior Lisp process."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
285 (interactive (comint-get-source "Load Clojure file: " clojure-prev-l/c-dir/file
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
286 '(clojure-mode) t))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
287 (comint-check-source file-name) ; Check to see if buffer needs saved.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
288 (setq clojure-prev-l/c-dir/file (cons (file-name-directory file-name)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
289 (file-name-nondirectory file-name)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
290 (comint-send-string (inferior-lisp-proc)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
291 (format clojure-mode-load-command file-name))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
292 (switch-to-lisp t))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
293
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
294
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
295
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
296 (defun clojure-indent-function (indent-point state)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
297 "This function is the normal value of the variable `lisp-indent-function'.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
298 It is used when indenting a line within a function call, to see if the
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
299 called function says anything special about how to indent the line.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
300
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
301 INDENT-POINT is the position where the user typed TAB, or equivalent.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
302 Point is located at the point to indent under (for default indentation);
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
303 STATE is the `parse-partial-sexp' state for that position.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
304
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
305 If the current line is in a call to a Lisp function
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
306 which has a non-nil property `lisp-indent-function',
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
307 that specifies how to do the indentation. The property value can be
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
308 * `defun', meaning indent `defun'-style;
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
309 * an integer N, meaning indent the first N arguments specially
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
310 like ordinary function arguments and then indent any further
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
311 arguments like a body;
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
312 * a function to call just as this function was called.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
313 If that function returns nil, that means it doesn't specify
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
314 the indentation.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
315
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
316 This function also returns nil meaning don't specify the indentation."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
317 (let ((normal-indent (current-column)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
318 (goto-char (1+ (elt state 1)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
319 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
320 (if (and (elt state 2)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
321 (not (looking-at "\\sw\\|\\s_")))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
322 ;; car of form doesn't seem to be a symbol
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
323 (progn
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
324 (if (not (> (save-excursion (forward-line 1) (point))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
325 calculate-lisp-indent-last-sexp))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
326 (progn (goto-char calculate-lisp-indent-last-sexp)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
327 (beginning-of-line)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
328 (parse-partial-sexp (point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
329 calculate-lisp-indent-last-sexp 0 t)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
330 ;; Indent under the list or under the first sexp on the same
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
331 ;; line as calculate-lisp-indent-last-sexp. Note that first
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
332 ;; thing on that line has to be complete sexp since we are
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
333 ;; inside the innermost containing sexp.
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
334 (backward-prefix-chars)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
335 (if (and (eq (char-after (point)) ?\[)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
336 (eq (char-after (elt state 1)) ?\())
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
337 (+ (current-column) 2) ;; this is probably inside a defn
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
338 (current-column)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
339 (let ((function (buffer-substring (point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
340 (progn (forward-sexp 1) (point))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
341 (open-paren (elt state 1))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
342 method)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
343 (setq method (get (intern-soft function) 'clojure-indent-function))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
344
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
345 (cond ((member (char-after open-paren) '(?\[ ?\{))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
346 (goto-char open-paren)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
347 (1+ (current-column)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
348 ((or (eq method 'defun)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
349 (and (null method)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
350 (> (length function) 3)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
351 (string-match "\\`\\(?:clojure/\\)?def" function)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
352 (lisp-indent-defform state indent-point))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
353
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
354 ((integerp method)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
355 (lisp-indent-specform method state
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
356 indent-point normal-indent))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
357 (method
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
358 (funcall method indent-point state))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
359 (clojure-mode-use-backtracking-indent
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
360 (clojure-backtracking-indent indent-point state normal-indent)))))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
361
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
362 (defun clojure-backtracking-indent (indent-point state normal-indent)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
363 "Experimental backtracking support. Will upwards in an sexp to
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
364 check for contextual indenting."
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
365 (let (indent (path) (depth 0))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
366 (goto-char (elt state 1))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
367 (while (and (not indent)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
368 (< depth clojure-max-backtracking))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
369 (let ((containing-sexp (point)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
370 (parse-partial-sexp (1+ containing-sexp) indent-point 1 t)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
371 (when (looking-at "\\sw\\|\\s_")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
372 (let* ((start (point))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
373 (fn (buffer-substring start (progn (forward-sexp 1) (point))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
374 (meth (get (intern-soft fn) 'clojure-backtracking-indent)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
375 (let ((n 0))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
376 (when (< (point) indent-point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
377 (condition-case ()
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
378 (progn
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
379 (forward-sexp 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
380 (while (< (point) indent-point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
381 (parse-partial-sexp (point) indent-point 1 t)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
382 (incf n)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
383 (forward-sexp 1)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
384 (error nil)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
385 (push n path))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
386 (when meth
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
387 (let ((def meth))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
388 (dolist (p path)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
389 (if (and (listp def)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
390 (< p (length def)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
391 (setq def (nth p def))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
392 (if (listp def)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
393 (setq def (car (last def)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
394 (setq def nil))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
395 (goto-char (elt state 1))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
396 (when def
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
397 (setq indent (+ (current-column) def)))))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
398 (goto-char containing-sexp)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
399 (condition-case ()
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
400 (progn
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
401 (backward-up-list 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
402 (incf depth))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
403 (error (setq depth clojure-max-backtracking)))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
404 indent))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
405
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
406 ;; (defun clojure-indent-defn (indent-point state)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
407 ;; "Indent by 2 if after a [] clause that's at the beginning of a
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
408 ;; line"
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
409 ;; (if (not (eq (char-after (elt state 2)) ?\[))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
410 ;; (lisp-indent-defform state indent-point)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
411 ;; (goto-char (elt state 2))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
412 ;; (beginning-of-line)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
413 ;; (skip-syntax-forward " ")
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
414 ;; (if (= (point) (elt state 2))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
415 ;; (+ (current-column) 2)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
416 ;; (lisp-indent-defform state indent-point))))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
417
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
418 ;; (put 'defn 'clojure-indent-function 'clojure-indent-defn)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
419 ;; (put 'defmacro 'clojure-indent-function 'clojure-indent-defn)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
420
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
421 ;; clojure backtracking indent is experimental and the format for these
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
422
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
423 ;; entries are subject to change
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
424 (put 'implement 'clojure-backtracking-indent '(4 (2)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
425 (put 'proxy 'clojure-backtracking-indent '(4 4 (2)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
426
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
427
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
428 (defun put-clojure-indent (sym indent)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
429 (put sym 'clojure-indent-function indent)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
430 (put (intern (format "clojure/%s" (symbol-name sym))) 'clojure-indent-function indent))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
431
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
432 (defmacro define-clojure-indent (&rest kvs)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
433 `(progn
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
434 ,@(mapcar (lambda (x) `(put-clojure-indent (quote ,(first x)) ,(second x))) kvs)))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
435
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
436 (define-clojure-indent
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
437 (catch 2)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
438 (defmuti 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
439 (do 0)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
440 (for 1) ; FIXME (for seqs expr) and (for seqs filter expr)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
441 (if 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
442 (let 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
443 (loop 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
444 (struct-map 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
445 (assoc 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
446
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
447 (fn 'defun))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
448
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
449 ;; built-ins
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
450 (define-clojure-indent
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
451 (ns 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
452 (binding 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
453 (comment 0)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
454 (defstruct 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
455 (doseq 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
456 (dotimes 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
457 (doto 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
458 (implement 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
459 (let 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
460 (when-let 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
461 (if-let 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
462 (locking 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
463 (proxy 2)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
464 (sync 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
465 (when 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
466 (when-first 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
467 (when-let 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
468 (when-not 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
469 (with-local-vars 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
470 (with-open 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
471 (with-precision 1))
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
472
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
473 ;; macro indent (auto generated)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
474
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
475 ;; Things that just aren't right (manually removed)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
476 ; (put '-> 'clojure-indent-function 2)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
477 ; (put '.. 'clojure-indent-function 2)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
478 ; (put 'and 'clojure-indent-function 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
479 ; (put 'defmethod 'clojure-indent-function 2)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
480 ; (put 'defn- 'clojure-indent-function 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
481 ; (put 'memfn 'clojure-indent-function 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
482 ; (put 'or 'clojure-indent-function 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
483 ; (put 'lazy-cat 'clojure-indent-function 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
484 ; (put 'lazy-cons 'clojure-indent-function 1)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
485
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
486 (provide 'clojure-mode)
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
487
9541f7e47514 Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
488 ;;; clojure-mode.el ends here