Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Emacs outline mode for Perl

by clemburg (Curate)
on Feb 19, 2001 at 21:19 UTC ( #59405=sourcecode: print w/replies, xml ) Need Help??
Category: Miscellaneous
Author/Contact Info clemburg
Description: Ever tried outline-mode in an emacs? It works with Perl, too. Just put this code into your .emacs, or execute it from buffer *scratch*. Then do M-x perl-outline-mode after you opened the Perl code file. You can then expand and contract subroutines (with C-c @ C-t to contract all, C-c @ C-a to expand all, C-c @ C-d to contract a function, C-c @ C-s to expand it).
(defun perl-outline-mode ()
  "set customized outline minor mode for Perl"
  (setq outline-regexp "sub")

Update: This works even better:

(defun perl-outline-mode ()
  "set customized outline minor mode for Perl"
  (setq outline-regexp 
Replies are listed 'Best First'.
Re: Emacs outline mode for Perl
by stefan k (Curate) on Feb 19, 2001 at 21:47 UTC
    Another way is to put

    ;; Local variables: ;; folded-file: t ;; end:

    At the end of your file. Then you can use the string # {{{ (note the space at the end: Hash-Space-Brace-Brace-Brace-Space) to begin a fold block and # }}} (space!) to end that block. When XEmacs loads that file all blocks will be folded and you can usually open them with a rightclick on the fold mark. ISearch works over the folded parts, too.

    Of course this works in many more languages (examine the value of fold-top-regexp or fold-top-mark to find the right string

    Regards Stefan K

Re: Emacs outline mode for Perl
by petral (Curate) on Feb 21, 2001 at 01:22 UTC
    or for all perl files:
    (add-hook 'cperl-mode-hook '(lambda () (and (setq outline-regexp "sub") (outline-minor-mode +))))
    (setq outline-regexp "sub\\|^\\S-")
    leaves all unindented text visible (eg, 'use', etc. outside of subs).

    Wrong:   Newline isn't a space character (at least in my tables) it's an '>' -- "end of comment" character (sigh). the only regexp I could actually make work is "sub\\|^[^ <tab><c-J>]"where I actually ctl-q inserted the tab and newline.

Re: Emacs outline mode for Perl
by TheoPetersen (Priest) on Feb 19, 2001 at 21:52 UTC
    Works great as advertised, but the key interface is horrid. The menus work, but I was hunting around for some control-click combo that would accomplish the same thing.

    Is there a point and click interface for the outline functions?

      Hm. In my GNU Emacs, I get new menu items - "Headings", "Show", "Hide" (you can get at menu items in text mode by using M-x tmm-menu).

      Christian Lemburg
      Brainbench MVP for Perl

Re: Emacs outline mode for Perl
by metaperl (Curate) on Apr 16, 2010 at 14:06 UTC
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://59405]
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-10-20 15:28 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (263 votes). Check out past polls.