From f42484a2cd1826f60f946bba6f1ec222d8d19c3b Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Wed, 26 Jul 1995 18:01:10 +0000 Subject: [PATCH] (perl-imenu-generic-expression) New variable. (perl-mode): Set imenu-generic-expression. --- lisp/progmodes/perl-mode.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index d6c9d5802f9..4157554fdef 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -147,6 +147,15 @@ The expansion is entirely correct because it uses the C preprocessor." (modify-syntax-entry ?| "." perl-mode-syntax-table) ) +(defvar perl-imenu-generic-expression + '( + ;; Functions + (nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)\\(\\s-\\|\n\\)*{" 1 ) + ;;Variables + ("Variables" "^\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1 ) + ) + "Imenu generic expression for Perl mode. See `imenu-generic-expression'.") + (defvar perl-font-lock-keywords (list ; ("if" "until" "while" "elsif" "else" "unless" "for" "foreach" "continue" @@ -273,6 +282,9 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'." (setq parse-sexp-ignore-comments t) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(perl-font-lock-keywords)) + ;; Tell imenu how to handle Perl. + (make-local-variable 'imenu-generic-expression) + (setq imenu-generic-expression perl-imenu-generic-expression) (run-hooks 'perl-mode-hook)) ;; This is used by indent-for-comment -- 2.39.2