Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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"
  (interactive)
  (setq outline-regexp "sub")
  (outline-minor-mode))

Update: This works even better:

(defun perl-outline-mode ()
  "set customized outline minor mode for Perl"
  (interactive)
  (setq outline-regexp 
    "#!.\\|\\(pac\\)kage\\|sub\\|\\(=he\\)ad\\|\\(=po\\)d")
  (outline-minor-mode))

Comment on Emacs outline mode for Perl
Select or Download Code
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 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
      http://www.brainbench.com

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 +))))
    also,
    (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.

    p
Reaped: Re: Emacs outline mode for Perl
by NodeReaper (Curate) on Apr 16, 2010 at 14:03 UTC
Re: Emacs outline mode for Perl
by metaperl (Curate) on Apr 16, 2010 at 14:06 UTC

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://59405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (21)
As of 2014-07-30 13:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (233 votes), past polls