Skip to content

Commit af8fcfb

Browse files
committed
Merge imenu support.
2 parents 210014f + 60d975b commit af8fcfb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clojure-mode.el

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
;; (defun lisp-enable-paredit-hook () (paredit-mode 1))
3636
;; (add-hook 'clojure-mode-hook 'lisp-enable-paredit-hook)
3737

38+
;;; Todo:
39+
40+
;; * hashbang is also a valid comment character
41+
3842
;;; License:
3943

4044
;; This program is free software; you can redistribute it and/or
@@ -137,6 +141,9 @@ All commands in `lisp-mode-shared-map' are inherited by this map.")
137141
This holds a cons cell of the form `(DIRECTORY . FILE)'
138142
describing the last `clojure-load-file' or `clojure-compile-file' command.")
139143

144+
(defvar clojure-def-regexp "^\\s *\\((def\\S *\\s +\\(\\S +\\)\\)"
145+
"A regular expression to match any top-level definitions.")
146+
140147
;;;###autoload
141148
(defun clojure-mode ()
142149
"Major mode for editing Clojure code - similar to Lisp mode..
@@ -163,6 +170,12 @@ if that value is non-nil."
163170
'clojure-indent-function)
164171
(set (make-local-variable 'font-lock-multiline) t)
165172

173+
(setq lisp-imenu-generic-expression
174+
`((nil ,clojure-def-regexp 2)))
175+
(setq imenu-create-index-function
176+
(lambda ()
177+
(imenu--generic-function lisp-imenu-generic-expression)))
178+
166179
(if (and (not (boundp 'font-lock-extend-region-functions))
167180
(or clojure-mode-font-lock-multiline-def
168181
clojure-mode-font-lock-comment-sexp))

0 commit comments

Comments
 (0)