Commit 35c5f5d3 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(perl-imenu-generic-expression): Add entries for perldoc sections.

(perl-outline-regexp, perl-outline-level): New var and function.
(perl-mode): Use them.
parent f43ae016
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> 2005-02-27 Glenn Morris <gmorris@ast.cam.ac.uk>
   
* calendar/diary-lib.el (diary-remind): Discard any mark portion * calendar/diary-lib.el (diary-remind): Discard any mark portion
......
...@@ -161,10 +161,11 @@ The expansion is entirely correct because it uses the C preprocessor." ...@@ -161,10 +161,11 @@ The expansion is entirely correct because it uses the C preprocessor."
(defvar perl-imenu-generic-expression (defvar perl-imenu-generic-expression
'(;; Functions '(;; Functions
(nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)\\(\\s-\\|\n\\)*{" 1 ) (nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)" 1)
;;Variables ;;Variables
("Variables" "^\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1 ) ("Variables" "^\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1)
("Packages" "^package\\s-+\\([-A-Za-z0-9+_:]+\\);" 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'.") "Imenu generic expression for Perl mode. See `imenu-generic-expression'.")
;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and ;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and
...@@ -411,6 +412,20 @@ create a new comment." ...@@ -411,6 +412,20 @@ create a new comment."
(defcustom perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:[^:]" (defcustom perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:[^:]"
"*Lines starting with this regular expression are not auto-indented." "*Lines starting with this regular expression are not auto-indented."
:type 'regexp) :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 ;;;###autoload
(defun perl-mode () (defun perl-mode ()
...@@ -498,9 +513,12 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'." ...@@ -498,9 +513,12 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'."
. perl-font-lock-syntactic-face-function) . perl-font-lock-syntactic-face-function)
(parse-sexp-lookup-properties . t))) (parse-sexp-lookup-properties . t)))
;; Tell imenu how to handle Perl. ;; Tell imenu how to handle Perl.
(make-local-variable 'imenu-generic-expression) (set (make-local-variable 'imenu-generic-expression)
(setq imenu-generic-expression perl-imenu-generic-expression) perl-imenu-generic-expression)
(setq imenu-case-fold-search nil) (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)) (run-hooks 'perl-mode-hook))
;; This is used by indent-for-comment ;; This is used by indent-for-comment
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment