From: Stefan Monnier Date: Sun, 27 Feb 2005 23:13:19 +0000 (+0000) Subject: (perl-imenu-generic-expression): Add entries for perldoc sections. X-Git-Tag: ttn-vms-21-2-B4~2078 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=35c5f5d32f7449676262abe7333b3d12dc2bcbf9;p=emacs.git (perl-imenu-generic-expression): Add entries for perldoc sections. (perl-outline-regexp, perl-outline-level): New var and function. (perl-mode): Use them. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 716f6e5a42f..fe9f2fb1930 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2005-02-27 Stefan Monnier + + * progmodes/perl-mode.el (perl-imenu-generic-expression): Add entries + for perldoc sections. + (perl-outline-regexp, perl-outline-level): New var and function. + (perl-mode): Use them. + 2005-02-27 Glenn Morris * calendar/diary-lib.el (diary-remind): Discard any mark portion diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index eb630c2ed54..ad4633e20eb 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -161,10 +161,11 @@ The expansion is entirely correct because it uses the C preprocessor." (defvar perl-imenu-generic-expression '(;; Functions - (nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)\\(\\s-\\|\n\\)*{" 1 ) + (nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)" 1) ;;Variables - ("Variables" "^\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1 ) - ("Packages" "^package\\s-+\\([-A-Za-z0-9+_:]+\\);" 1 )) + ("Variables" "^\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1) + ("Packages" "^package\\s-+\\([-A-Za-z0-9+_:]+\\);" 1) + ("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1)) "Imenu generic expression for Perl mode. See `imenu-generic-expression'.") ;; Regexps updated with help from Tom Tromey and @@ -411,6 +412,20 @@ create a new comment." (defcustom perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:[^:]" "*Lines starting with this regular expression are not auto-indented." :type 'regexp) + +;; Outline support + +(defvar perl-outline-regexp + (concat (mapconcat 'cadr perl-imenu-generic-expression "\\|") + "\\|^=cut\\>")) + +(defun perl-outline-level () + (cond + ((looking-at "package\\s-") 0) + ((looking-at "sub\\s-") 1) + ((looking-at "=head[0-9]") (- (char-before (match-end 0)) ?0)) + ((looking-at "=cut") 1) + (t 3))) ;;;###autoload (defun perl-mode () @@ -498,9 +513,12 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'." . perl-font-lock-syntactic-face-function) (parse-sexp-lookup-properties . t))) ;; Tell imenu how to handle Perl. - (make-local-variable 'imenu-generic-expression) - (setq imenu-generic-expression perl-imenu-generic-expression) + (set (make-local-variable 'imenu-generic-expression) + perl-imenu-generic-expression) (setq imenu-case-fold-search nil) + ;; Setup outline-minor-mode. + (set (make-local-variable 'outline-regexp) perl-outline-regexp) + (set (make-local-variable 'outline-level) 'perl-outline-level) (run-hooks 'perl-mode-hook)) ;; This is used by indent-for-comment