bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Indentations, PERL


From: Александр Поляков
Subject: Indentations, PERL
Date: Tue, 26 Jun 2007 22:47:20 -0700
User-agent: Thunderbird 1.5.0.12 (X11/20070604)

Hello,

I am a very basic user of Emacs, and I have never configured anything special about Emacs. So, in case what I am writing about will turn out to be just a problem with my default configuration files, I apologize.

What I think is the bug, is a problem with automatic indentations when I type PERL programs. Let me get right to the point and I'll paste first the code how it is automatically indented:

sub insert_sub {
   return unless (save_slide());
   my $after = 0;

   prompt(0, 'New Subtitle', "Would you like to " .
      "insert the new subtitle\n" .
      "before the current one or after?",
      [{GTK_ID => 'gtk-cancel',
        LABEL => 'Cancel',
        ALIGN => 'right',
        SUB => sub { $after = -1;}},
{GTK_ID => 'gtk-go-back',
LABEL => 'Before',
ALIGN => 'left',
SUB => sub {$after = 0;}},
{GTK_ID => 'gtk-go-forward',
LABEL => 'After',
ALIGN => 'right',
SUB => sub {$after = 1}},
   ]);

if ($after == 0) {
   insert_before($srt_idx);
} elsif ($after == 1) {
   insert_before($srt_idx + 1);
}
}


Next, is how I believe would be a proper way to indent the same code:

sub insert_sub {
   return unless (save_slide());
   my $after = 0;

   prompt(0, 'New Subtitle', "Would you like to " .
          "insert the new subtitle\n" .
          "before the current one or after?",
          [{GTK_ID => 'gtk-cancel',
            LABEL => 'Cancel',
            ALIGN => 'right',
            SUB => sub { $after = -1;}},
           {GTK_ID => 'gtk-go-back',
            LABEL => 'Before',
            ALIGN => 'left',
            SUB => sub {$after = 0;}},
           {GTK_ID => 'gtk-go-forward',
            LABEL => 'After',
            ALIGN => 'right',
            SUB => sub {$after = 1}},
          ]);

   if ($after == 0) {
       insert_before($srt_idx);
   } elsif ($after == 1) {
       insert_before($srt_idx + 1);
   }
}

(Somehow the exact spacing differ here, but I think you can see the difference in general.)

Basically after I enter "{... SUB => sub {}}," the indentation screws up. I hope this makes sense.

Thanks,
Alex.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]