how do I indent perl code? Is there any key?
Thanks
Jagadeesh
M-x cperl-mode
Thanks for the reply.
Its not indenting it. when I do M-x cperl-mode, there is no effect.
Thanks
J> On Dec 2, 12:11 am, aartist <aart...@gmail.com> wrote:
>> On Dec 1, 11:13 am, Jagadeesh <mnjagade...@gmail.com> wrote:
>>
>> > Hi,
>> > Again this is a newbie question.
>>
>> > how do I indent perl code? Is there any key?
>>
>> > Thanks
>> > Jagadeesh
>>
>> M-x cperl-mode
J> Thanks for the reply.
J> Its not indenting it. when I do M-x cperl-mode, there is no effect.
Start Emacs without any init files:
emacs -q test.pl
Then do
M-x cperl-mode
Type in a short program, e.g.
#!/usr/bin/perl
if (scalar @ARGV)
{
print "indentation test here\n";
}
Does line 5 not indent when you hit TAB? It does for me.
Ted
It's not designed to automatically re-indent the current file.
Any new code you enter will be indented according to style,
as well any line you press 'TAB' on. To set the particular
style, use cperl-set-style - my personal favourite is 'C++',
even though it has problems with multi-line lists.
There's also 'perl-mode', which again will not automatically
re-intent any of your buffer. It's a bit less colourful, but
just as functional as 'cperl-mode'.
Phil
--
I tried the Vista speech recognition by running the tutorial. I was
amazed, it was awesome, recognised every word I said. Then I said the
wrong word ... and it typed the right one. It was actually just
detecting a sound and printing the expected word! -- pbhj on /.
Thanks
Jagadeesh
For any region you can use C-M-\ (indent-region) or you can also use C-j
(newline-and-indent) instead of Enter (newline) when writing the code.
I have inserted the following code in my .emacs, then C-c t will do the job on any marked region.
If you use activeperl, perltidy will be located in "Perl_Directory"/site/bin/perltidy
Regards
Bour9
;; PerlTidy
(defmacro mark-active ()
"Xemacs/emacs compatibility macro"
(if (boundp 'mark-active)
'mark-active
'(mark)))
(defun perltidy ( )
"Run perltidy on the current region or buffer."
(interactive)
(let ((orig-point (point)))
(unless (mark-active) (mark-defun))
(shell-command-on-region (point) (mark) "perltidy -q -ci=2 -bli -l=0 -lp -vt=1 -vtc=1 -nsfs -ndln" nil t)
(goto-char orig-point)))
(global-set-key "\C-ct" 'perltidy)
> -----Message d'origine-----
> De :
> help-gnu-emacs-bounces+francois.bourgneuf=groupe...@gnu.or
> g
> [mailto:help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.f
> r...@gnu.org] De la part de Teemu Likonen
> Envoyé : samedi 6 décembre 2008 08:14
> À : help-gn...@gnu.org
> Objet : Re: perl indentation