Mercurial > emacs
changeset 60300:8da4bb4a512f
(perl-imenu-generic-expression): Add entries for perldoc sections.
(perl-outline-regexp, perl-outline-level): New var and function.
(perl-mode): Use them.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 27 Feb 2005 23:13:19 +0000 |
parents | 70e25b87a334 |
children | f3c5c717aa02 |
files | lisp/ChangeLog lisp/progmodes/perl-mode.el |
diffstat | 2 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sun Feb 27 22:54:12 2005 +0000 +++ b/lisp/ChangeLog Sun Feb 27 23:13:19 2005 +0000 @@ -1,3 +1,10 @@ +2005-02-27 Stefan Monnier <monnier@iro.umontreal.ca> + + * 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 <gmorris@ast.cam.ac.uk> * calendar/diary-lib.el (diary-remind): Discard any mark portion
--- a/lisp/progmodes/perl-mode.el Sun Feb 27 22:54:12 2005 +0000 +++ b/lisp/progmodes/perl-mode.el Sun Feb 27 23:13:19 2005 +0000 @@ -161,10 +161,11 @@ (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 <tromey@cambric.colorado.edu> and @@ -411,6 +412,20 @@ (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 @@ . 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