Major mode for editing Perl code.
Expression and list commands understand all C brackets.
Tab indents for Perl code.
Paragraphs are separated by blank lines only.
Delete converts tabs to spaces as it moves back.
Various characters in Perl almost always come in pairs: {}, (), [],
sometimes <>. When the user types the first, she gets the second as
well, with optional special formatting done on {}. (Disabled by
default.) You can always quote (with C-q) the left
"paren" to avoid the expansion. The processing of < is special,
since most the time you mean "less". CPerl mode tries to guess
whether you want to type pair <>, and inserts is if it
appropriate. You can set `cperl-electric-parens-string' to the string that
contains the parens from the above list you want to be electrical.
Electricity of parens is controlled by `cperl-electric-parens'.
You may also set `cperl-electric-parens-mark' to have electric parens
look for active mark and "embrace" a region if possible.'
CPerl mode provides expansion of the Perl control constructs:
if, else, elsif, unless, while, until, continue, do,
for, foreach, formy and foreachmy.
and POD directives (Disabled by default, see `cperl-electric-keywords'.)
The user types the keyword immediately followed by a space, which
causes the construct to be expanded, and the point is positioned where
she is most likely to want to be. E.g., when the user types a space
following "if" the following appears in the buffer: if () { or if ()
} { } and the cursor is between the parentheses. The user can then
type some boolean expression within the parens. Having done that,
typing M-x cperl-linefeed places you - appropriately indented - on a
new line between the braces (if you typed M-x cperl-linefeed in a POD
directive line, then appropriate number of new lines is inserted).
If CPerl decides that you want to insert "English" style construct like
bite if angry;
it will not do any expansion. See also help on variable
`cperl-extra-newline-before-brace'. (Note that one can switch the
help message on expansion by setting `cperl-message-electric-keyword'
to nil.)
M-x cperl-linefeed is a convenience replacement for typing carriage
return. It places you in the next line with proper indentation, or if
you type it inside the inline block of control construct, like
foreach (@lines) {print; print}
and you are on a boundary of a statement inside braces, it will
transform the construct into a multiline and will place you into an
appropriately indented blank line. If you need a usual
`newline-and-indent' behavior, it is on C-j,
see documentation on `cperl-electric-linefeed'.
Use M-x cperl-invert-if-unless to change a construction of the form
if (A) { B }
into
B if A;
Uses keymap `cperl-mode-map', which is not currently defined.
Setting the variable `cperl-font-lock' to t switches on font-lock-mode
(even with older Emacsen), `cperl-electric-lbrace-space' to t switches
on electric space between $ and {, `cperl-electric-parens-string' is
the string that contains parentheses that should be electric in CPerl
(see also `cperl-electric-parens-mark' and `cperl-electric-parens'),
setting `cperl-electric-keywords' enables electric expansion of
control structures in CPerl. `cperl-electric-linefeed' governs which
one of two linefeed behavior is preferable. You can enable all these
options simultaneously (recommended mode of use) by setting
`cperl-hairy' to t. In this case you can switch separate options off
by setting them to `null'. Note that one may undo the extra
whitespace inserted by semis and braces in `auto-newline'-mode by
consequent M-x cperl-electric-backspace.
If your site has perl5 documentation in info format, you can use commands
M-x cperl-info-on-current-command and M-x cperl-info-on-command to access it.
These keys run commands `cperl-info-on-current-command' and
`cperl-info-on-command', which one is which is controlled by variable
`cperl-info-on-command-no-prompt' and `cperl-clobber-lisp-bindings'
(in turn affected by `cperl-hairy').
Even if you have no info-format documentation, short one-liner-style
help is available on M-x cperl-get-help, and one can run perldoc or
man via menu.
It is possible to show this help automatically after some idle time.
This is regulated by variable `cperl-lazy-help-time'. Default with
`cperl-hairy' (if the value of `cperl-lazy-help-time' is nil) is 5
secs idle time . It is also possible to switch this on/off from the
menu, or via M-x cperl-toggle-autohelp. Requires `run-with-idle-timer'.
Use M-x cperl-lineup to vertically lineup some construction - put the
beginning of the region at the start of construction, and make region
span the needed amount of lines.
Variables `cperl-pod-here-scan', `cperl-pod-here-fontify',
`cperl-pod-face', `cperl-pod-head-face' control processing of POD and
here-docs sections. With capable Emaxen results of scan are used
for indentation too, otherwise they are used for highlighting only.
Variables controlling indentation style:
`cperl-tab-always-indent'
Non-nil means TAB in CPerl mode should always reindent the current line,
regardless of where in the line point is when the TAB command is used.
`cperl-indent-left-aligned-comments'
Non-nil means that the comment starting in leftmost column should indent.
`cperl-auto-newline'
Non-nil means automatically newline before and after braces,
and after colons and semicolons, inserted in Perl code. The following
M-x cperl-electric-backspace will remove the inserted whitespace.
Insertion after colons requires both this variable and
`cperl-auto-newline-after-colon' set.
`cperl-auto-newline-after-colon'
Non-nil means automatically newline even after colons.
Subject to `cperl-auto-newline' setting.
`cperl-indent-level'
Indentation of Perl statements within surrounding block.
The surrounding block's indentation is the indentation
of the line on which the open-brace appears.
`cperl-continued-statement-offset'
Extra indentation given to a substatement, such as the
then-clause of an if, or body of a while, or just a statement continuation.
`cperl-continued-brace-offset'
Extra indentation given to a brace that starts a substatement.
This is in addition to `cperl-continued-statement-offset'.
`cperl-brace-offset'
Extra indentation for line if it starts with an open brace.
`cperl-brace-imaginary-offset'
An open brace following other text is treated as if it the line started
this far to the right of the actual line indentation.
`cperl-label-offset'
Extra indentation for line that is a label.
`cperl-min-label-indent'
Minimal indentation for line that is a label.
Settings for classic indent-styles: K&R BSD=C++ GNU PerlStyle=Whitesmith
`cperl-indent-level' 5 4 2 4
`cperl-brace-offset' 0 0 0 0
`cperl-continued-brace-offset' -5 -4 0 0
`cperl-label-offset' -5 -4 -2 -4
`cperl-continued-statement-offset' 5 4 2 4
CPerl knows several indentation styles, and may bulk set the
corresponding variables. Use M-x cperl-set-style to do this. Use
M-x cperl-set-style-back to restore the memorized preexisting values
(both available from menu). See examples in `cperl-style-examples'.
Part of the indentation style is how different parts of if/elsif/else
statements are broken into lines; in CPerl, this is reflected on how
templates for these constructs are created (controlled by
`cperl-extra-newline-before-brace'), and how reflow-logic should treat
"continuation" blocks of else/elsif/continue, controlled by the same
variable, and by `cperl-extra-newline-before-brace-multiline',
`cperl-merge-trailing-else', `cperl-indent-region-fix-constructs'.
If `cperl-indent-level' is 0, the statement after opening brace in
column 0 is indented on
`cperl-brace-offset'+`cperl-continued-statement-offset'.
Turning on CPerl mode calls the hooks in the variable `cperl-mode-hook'
with no args.
DO NOT FORGET to read micro-docs (available from `Perl' menu)
or as help on variables `cperl-tips', `cperl-problems',
`cperl-praise', `cperl-speed'.
(fn)