Skip to content

Commit e6eceea

Browse files
committed
Add macro_rules names to imenu
imenu did not register macros previously. We must add `!` to the `word` syntax category for imenu since we reuse the `rust-re-item-def-imenu` regexp which use word boundaries.
1 parent e3c545e commit e6eceea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rust-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
11961196
(defvar rust-imenu-generic-expression
11971197
(append (mapcar #'(lambda (x)
11981198
(list nil (rust-re-item-def-imenu x) 1))
1199-
'("enum" "struct" "type" "mod" "fn" "trait"))
1199+
'("enum" "struct" "type" "mod" "fn" "trait" "macro_rules!"))
12001200
`(("Impl" ,(rust-re-item-def-imenu "impl") 1)))
12011201
"Value for `imenu-generic-expression' in Rust mode.
12021202
@@ -1340,6 +1340,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
13401340
(setq-local comment-multi-line t)
13411341
(setq-local comment-line-break-function 'rust-comment-indent-new-line)
13421342
(setq-local imenu-generic-expression rust-imenu-generic-expression)
1343+
(setq-local imenu-syntax-alist '((?! . "w"))) ; For macro_rules!
13431344
(setq-local beginning-of-defun-function 'rust-beginning-of-defun)
13441345
(setq-local end-of-defun-function 'rust-end-of-defun)
13451346
(setq-local parse-sexp-lookup-properties t)

0 commit comments

Comments
 (0)