Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Customizing Emacs for Perl Best Practices

by ait (Hermit)
on Nov 13, 2007 at 00:29 UTC ( [id://650413]=perlquestion: print w/replies, xml ) Need Help??

ait has asked for the wisdom of the Perl Monks concerning the following question:

Update 2007-11-13: Got it Working! Read more to find out how...
I was breaking my head with cperlmode until I discovered that the c-perl-mode.el bundled with Emacs 21 on Debian Etch is *VERY* outdated. I downloaded the latest c-perl-mode.el file from here and copied it to /usr/share/emacs/21.4/lisp/progmodes/

Remember to remove the .elc file and recompile the new one if you want faster load, although it is not mandatory for it to work.

After this, the recommendations in the PBP book (Chapter 2, under tabs, p. 22 in my edition (First Edition, July 2005)) work perfectly:
;; Use cperl-mode instead of the default perl-mode (defalias 'perl-mode 'cperl-mode) ;; just spaces (setq-default indent-tabs-mode nil) ;; Use 4 space indents via cperl mode (custom-set-variables '(cperl-close-paren-offset -4) '(cperl-continued-statement-offset 4) '(cperl-indent-level 4) '(cperl-indent-parens-as-block t) '(cperl-tab-always-indent t) )


Thanks to all Monks that responded!
Hello knowledgeable monks. Today I seek the wisdom of any fellow citizen of the monastery that uses Emacs and has been able to customize the indentation, in order to comply with Damian's K&R parenthesize recommendation. I have searched PM and many other places, and have truly tried my best to customize the c-style-alist variable but I don't seem to find a method in in cc-align.el to actually align the arglist anywhere except under the opening parenthesis.

I am certain that some fellow monk uses Emacs and has a working hack in their .emacs file for this and other code layout recommendations described in the book.

Furthermore, I think that by posting these Emacs hacks here, will later be found by the search engine and help other Perl enthusiasts that use Emacs to comply with and promote the use of these standards.

Replies are listed 'Best First'.
Re: Customizing Emacs for Perl Best Practices
by kyle (Abbot) on Nov 13, 2007 at 03:27 UTC
      Also, there's a list of some emacs/perl items here on emacswiki.org: PerlLanguage

      (Note: emacswiki.org seems to be completely invisible to google. You should probably just go to the site to search it.)

      Thanks!!!
      My stupidity was not using PM Super Search. I the basic search I kept getting a monk named emacs.
Re: Customizing Emacs for Perl Best Practices
by calin (Deacon) on Nov 13, 2007 at 11:19 UTC

    First, I assume that you are using CPerl instead of the obsolete perl-mode. If not, put this in your .emacs file to load it automatically:

    ;; Use cperl-mode instead of the default perl-mode (add-to-list 'auto-mode-alist '("\\.\\([pP]\\([Llm]\\|[oO][dD]\\)\\|al +\\)\\'" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))

    Then you can do

    M-x customize-group RET cperl-indentation-details RET
    I don't seem to find a method in in cc-align.el to actually align the arglist anywhere except under the opening parenthesis.

    I'm not familiar with Damian's recommendations but I suggest you check cperl-indent-parens-as-block, it might work at least as a compromise.

      Thank you for your reply.

      I was breaking my head with cperl-indent-parens-as-block until I discovered that the cperl-mode.el distributed with Emacs 21 on Debian Etch is *VERY* out dated.
      I downloaded the latest 5.x version from here and it's all working perfectly now. BTW, I have update my original node for a little how-to on the subject.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-03-19 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found