|
31 | 31 | (defconst rust-re-ident "[[:word:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*")
|
32 | 32 | (defconst rust-re-lc-ident "[[:lower:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*")
|
33 | 33 | (defconst rust-re-uc-ident "[[:upper:]][[:word:][:multibyte:]_[:digit:]]*")
|
| 34 | +(defconst rust-re-vis "pub") |
34 | 35 |
|
35 | 36 | (defconst rust-re-non-standard-string
|
36 | 37 | (rx
|
@@ -543,8 +544,13 @@ buffer."
|
543 | 544 | (defconst rust-re-pre-expression-operators "[-=!%&*/:<>[{(|.^;}]")
|
544 | 545 | (defun rust-re-word (inner) (concat "\\<" inner "\\>"))
|
545 | 546 | (defun rust-re-grab (inner) (concat "\\(" inner "\\)"))
|
| 547 | +(defun rust-re-shy (inner) (concat "\\(?:" inner "\\)")) |
546 | 548 | (defun rust-re-item-def (itype)
|
547 | 549 | (concat (rust-re-word itype) "[[:space:]]+" (rust-re-grab rust-re-ident)))
|
| 550 | +(defun rust-re-item-def-imenu (itype) |
| 551 | + (concat "^[[:space:]]*" |
| 552 | + (rust-re-shy (concat (rust-re-word rust-re-vis) "[[:space:]]+")) "?" |
| 553 | + (rust-re-item-def itype))) |
548 | 554 |
|
549 | 555 | (defconst rust-re-special-types (regexp-opt rust-special-types 'symbols))
|
550 | 556 |
|
@@ -1189,9 +1195,9 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
|
1189 | 1195 | ;;; Imenu support
|
1190 | 1196 | (defvar rust-imenu-generic-expression
|
1191 | 1197 | (append (mapcar #'(lambda (x)
|
1192 |
| - (list nil (rust-re-item-def x) 1)) |
| 1198 | + (list nil (rust-re-item-def-imenu x) 1)) |
1193 | 1199 | '("enum" "struct" "type" "mod" "fn" "trait"))
|
1194 |
| - `(("Impl" ,(rust-re-item-def "impl") 1))) |
| 1200 | + `(("Impl" ,(rust-re-item-def-imenu "impl") 1))) |
1195 | 1201 | "Value for `imenu-generic-expression' in Rust mode.
|
1196 | 1202 |
|
1197 | 1203 | Create a flat index of the item definitions in a Rust file.
|
|
0 commit comments