Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

perl indentation

0 views
Skip to first unread message

Jagadeesh

unread,
Dec 1, 2008, 11:13:03 AM12/1/08
to
Hi,
Again this is a newbie question.

how do I indent perl code? Is there any key?

Thanks
Jagadeesh

aartist

unread,
Dec 1, 2008, 2:11:35 PM12/1/08
to

M-x cperl-mode

Jagadeesh

unread,
Dec 1, 2008, 11:53:45 PM12/1/08
to

Thanks for the reply.
Its not indenting it. when I do M-x cperl-mode, there is no effect.

Thanks

Ted Zlatanov

unread,
Dec 2, 2008, 9:44:29 AM12/2/08
to
On Mon, 1 Dec 2008 20:53:45 -0800 (PST) Jagadeesh <mnjag...@gmail.com> wrote:

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

Phil Carmody

unread,
Dec 2, 2008, 10:32:13 AM12/2/08
to

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 /.

Jagadeesh

unread,
Dec 5, 2008, 11:45:31 PM12/5/08
to
Yes. TAB Does the magic. But when you are writing tons of line, you
can not press tons of TABs.
So is there any block indentation technique? VIM has this feature.

Thanks
Jagadeesh

Teemu Likonen

unread,
Dec 6, 2008, 2:14:23 AM12/6/08
to

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.

Bourgneuf Francois

unread,
Dec 8, 2008, 4:35:10 AM12/8/08
to help-gn...@gnu.org
You may use perltidy.

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

0 new messages