barvin has asked for the wisdom of the Perl Monks concerning the following question:

I'm using GNU Emacs 21.3.1
I've got cperl-mode.el in /usr/share/emacs/21.3/lisp/progmodes where it belongs (this represents cperl 5.22 from http://math.berkeley.edu/~ilya/software/emacs/cperl-mode.el.5.22.bz2)

Considering the code snippet below: The first '=head1 foo' pod section correctly highlights everything as comments up to and including cut. The second '=head2' pod section is syntax highlighted as if it were code. What's up with that?
=head1 foo bar =cut my $perlcode = 'code'; =head2 bar foo =cut

Replies are listed 'Best First'.
Re: Emacs, cperl mode and syntax highlighting
by FunkyMonk (Bishop) on Jul 02, 2007 at 20:26 UTC
    Your example worked fine for me; everything is coloured as I would expect.

    I'm using a newer emacs (21.4.1) and a newer cperl (5.23). Have you tried http://www.ilyaz.org/software/emacs/ to get the very latest cperl?

Re: Emacs, cperl mode and syntax highlighting
by samtregar (Abbot) on Jul 02, 2007 at 20:55 UTC
    Beware - POD is whitespace sensitive. If the line before =head2 has a single space on it then neither Emacs nor many POD tools will consider it POD.

    -sam

      I tried adding spaces around various bits of the OP's POD to see if I could replicate their problem. I couldn't get cperl to "make it look like code" no matter where I added it.

      The worst I got was the POD coloured plain white. I can't think of a case where cperl colours anything this way.

Re: Emacs, cperl mode and syntax highlighting
by educated_foo (Vicar) on Jul 03, 2007 at 02:32 UTC
    You might try running cperl-find-pods-heres. Finding POD is supposedly expensive, so cperl avoids doing so to keep editing responsive. I have this bound to C-c C-f in cperl-mode to fix things up:
    (defun my-perl-refontify () (interactive) (cperl-find-pods-heres) (font-lock-fontify-buffer))
Re: Emacs, cperl mode and syntax highlighting
by swampyankee (Parson) on Jul 03, 2007 at 00:32 UTC

    I use xemacs 21.4.1 with cperl 5.0 on Windows XP; it seems to handle POD correctly.</p.

    While I do think cperl-mode is much better than perl-mode, I do have minor gripes with it. Also, I found the outdated version that comes with the FSF emacs to be preferable to several of the later versions, but that's just me.

    Cperl-mode has a lot of settings that can be adjusted by the user, so before doing something drastic, like using ed, I'd see if twiddling cperl-mode's settings will make it behave more like you want.

    emc

    Any New York City or Connecticut area jobs? I'm currently unemployed.

    There are some enterprises in which a careful disorderliness is the true method.

    —Herman Melville