Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Specific Indentation request for perl in Emacs

by pdcawley (Hermit)
on Aug 17, 2004 at 21:01 UTC ( [id://383795]=note: print w/replies, xml ) Need Help??


in reply to Specific Indentation request for perl in Emacs

If you really want to do that, and I strongly recommend that you don't, then add the following to your .emacs
(setq cperl-indent-parens-as-block t)
You can also customize the cperl-indent-parens-as-block variable so as not to confuse customize later. Why do I recommend you don't do that? Because indenting parenthesized expressions the same way as a block can create confusion in the reader. If you've got a problem with the right margin encroaching, you can always reindent as follows:
my $var = $new->function( arg1 => 1, );
And what do you know? You claw back some vertical space, which is never a bad thing.

Replies are listed 'Best First'.
Re^2: Specific Indentation request for perl in Emacs
by aufflick (Deacon) on Jan 13, 2005 at 03:04 UTC
    Darn i've been looking for this for a while.

    My Coworkers have been moaning about my emacs-indentation for months!

    I had to download the latest cperl-mode.el from the cpan module, and then it worked fine.

    The perltidy macro above is really nice too.

    I love emacs!

Re^2: Specific Indentation request for perl in Emacs
by Yoyoson (Novice) on Aug 18, 2004 at 15:09 UTC
    pdcawley,

    I truly appreciate your reply, this is the closest I've been to solving this issue so far. Unfortunately, I'm having trouble getting it to work.
    By default, my emacs uses perl-mode when I open a perl file or module. So I know how to switch into cperl-mode after I've started the buffer (M-x cperl-mode) and I know how to put the (setq ... ) line in my .emacs, except I'm wondering if I also need to start up cperl-mode automatically from within my .emacs to get this to work.

    As for your advice against using this, I can definitely see the logic in your argument, the only thing is that this particular indentation nuance is a part of my workplace's official coding standard.

    I guess my question then, is, how can I get cperl-mode to start up automatically in my .emacs, or how can I set that toggle-setting after I've started the buffer?

    Thanks!!
      Okay, I managed to get cperl-mode starting up automatically on my own - but the dang thing still doesn't work. I also found the variable cperl-indent-parens-as-block inside of my cperl-mode.el (it's version 4.32) so I don't think that's the issue here. I'm not sure what it could be.
        pdcawley's solution worked for me under xemacs... you do know that GNU emacs has both cperl-mode and perl-mode?

        What is the value of auto-mode-alist? You may be going into perl-mode instead of cperl-mode. Here's sample line that puts me in cperl-mode when opening a test file:

        (add-to-list 'auto-mode-alist '("\\.t$" . cperl-mode)) (setq cperl-indent-parens-as-block t)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://383795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-26 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found