Skip to content

Commit f46cc5d

Browse files
vspinubbatsov
authored andcommitted
Add imenu support for multimethods
1 parent 2d67af4 commit f46cc5d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
### New features
1111

12+
* Add imenu support for multimethods
1213
* New interactive command `clojure-cycle-when`.
1314
* New interactive command `clojure-cycle-not`.
1415

clojure-mode.el

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,23 +657,28 @@ and `(match-end 1)'."
657657
Called by `imenu--generic-function'."
658658
;; we have to take into account namespace-definition forms
659659
;; e.g. s/defn
660-
(when (re-search-backward "^(\\([a-z0-9.-]+/\\)?def\\sw*" nil t)
660+
(when (re-search-backward "^(\\([a-z0-9.-]+/\\)?\\(def\\sw*\\)" nil t)
661661
(save-excursion
662662
(let (found?
663+
(deftype (match-string 2))
663664
(start (point)))
664665
(down-list)
665666
(forward-sexp)
666667
(while (not found?)
667668
(ignore-errors
668669
(forward-sexp))
669-
(or (if (char-equal ?[ (char-after (point)))
670-
(backward-sexp))
671-
(if (char-equal ?) (char-after (point)))
670+
(or (when (char-equal ?[ (char-after (point)))
671+
(backward-sexp))
672+
(when (char-equal ?) (char-after (point)))
672673
(backward-sexp)))
673674
(cl-destructuring-bind (def-beg . def-end) (bounds-of-thing-at-point 'sexp)
674675
(if (char-equal ?^ (char-after def-beg))
675676
(progn (forward-sexp) (backward-sexp))
676677
(setq found? t)
678+
(when (string= deftype "defmethod")
679+
(setq def-end (progn (goto-char def-end)
680+
(forward-sexp)
681+
(point))))
677682
(set-match-data (list def-beg def-end)))))
678683
(goto-char start)))))
679684

0 commit comments

Comments
 (0)