Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

[OT] Folding Perl code with Emacs 25

by loris (Hermit)
on Sep 24, 2018 at 08:45 UTC ( #1222906=perlquestion: print w/replies, xml ) Need Help??
loris has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

To get folding in Emacs 25 for Perl programs I have cargo-cult-copied the outline-based set-up https://github.com/villadora/emacs-config/blob/master/modes.el.

In particular I have:

;; CPerl mode hook (setq cperl-mode-hook 'my-cperl-customizations) (defun my-cperl-customizations () "cperl-mode customizations that must be done after cperl-mode load +s" (outline-minor-mode) (abbrev-mode) (defun cperl-outline-level () (looking-at outline-regexp) (let ((match (match-string 1))) (cond ((eq match "=head1" ) 1) ((eq match "package") 2) ((eq match "=head2" ) 3) ((eq match "=item" ) 4) ((eq match "sub" ) 5) (t 7) ))) (setq cperl-outline-regexp my-cperl-outline-regexp) (setq outline-regexp cperl-outline-regexp) (setq outline-level 'cperl-outline-level) )

My expectation was that if I have

=head2 STUFF =over =item foo Do foo =cut sub foo { return 'foo'; }

I should be able to fold to

=head2 STUFF...

but instead I just can only fold to, say

=head2 STUFF... =item foo Do foo =cut sub foo { return 'foo'; }

i.e. the hierarchy, which I thought gets defined by 'outline-level' doesn't seem to work.

I do have

(add-hook 'outline-minor-mode-hook 'outshine-hook-function)

to get tab-cycling, but maybe this is screwing things up.

Any thoughts or other approaches?

Thanks,

loris

Note: This is something I originally posted, somewhat spuriously, to the Orgmode mailing list several weeks ago. Not that surprisingly, I got no reply.

Replies are listed 'Best First'.
Re: [OT] Folding Perl code with Emacs 25
by LanX (Bishop) on Sep 24, 2018 at 11:17 UTC
    Hi

    I'm not using any folding and skeptical about such approaches with regexes.

    But your example could have another problem:

    Perl defines that =POD commands are surrounded by empty lines. Many IDEs (and even Perl) are not enforcing this, but cperl-mode does!

    So do you still have your problem with...?

    =head2 STUFF =over =item foo Do foo =cut sub foo { return 'foo'; }

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: [OT] Folding Perl code with Emacs 25
by LanX (Bishop) on Sep 24, 2018 at 11:23 UTC
    On another note:

    my-cperl-outline-regexp

    is undefined in your post but available in the source you linked to.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1222906]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2018-09-24 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (191 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!