Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

The shortest distance between cperl-mode and productivity

by mothra (Hermit)
on May 04, 2002 at 15:30 UTC ( [id://164003]=perlquestion: print w/replies, xml ) Need Help??

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

Ugh.

After searching and searching I've had no luck in finding out the tricks to being the most productive in Emacs with cperl-mode. The information laid out in C-h m for cperl-mode isn't of much use either, because it doesn't address the questions I have.

Specifically, the following (long) list of questions remain unanswered:

  1. How do I run a perl program from Emacs in Windows? How about a program for which I don't want the console window to be shown (IOW, run with wperl.exe, on Win32)?

  2. How do I turn on the feature so that when I hit RET, the cursor automatically lines up with the current indentation on the next line?

  3. How can I make backspace back up by one level of indentation?

  4. How can I make sub foo {'s be automatically closed with }'s, a newline automatically inserted after the opening {, and the cursor correctly indented?

  5. How can I run perldoc on windows? (M-x cperl-perldoc breaks by default, because it trys to run perldoc with a bash shell)

  6. How can I format calls like:
    Foo::Bar->new(-baz => 1, -moo => 2);
    into:
    Foo::Bar->new( -baz => 1, -moo => 2 );
    with a command?

  7. How can I fold/collapse all sub's matching a regex pattern?

  8. Where can I find syntax highlighting configurations that don't suck? (I find the default colors ugly :)

I know this is more an Emacs question than a Perl one, but realistically, I'm far more likely to get useful answers from Perl programmers than more general "Emacs users".

As well, I'd be more than willing to take any information about cperl-mode producitivity gained from this node (and from the bits and pieces of other nodes about Emacs on PM, that don't answer the questions above) and write a tutorial out of it (because I wanted one, but such a thing doesn't exist it would seem).

Any help, and any further tips and tricks would be much appreciated.

Replies are listed 'Best First'.
Re: The shortest distance between cperl-mode and productivity
by cjf (Parson) on May 04, 2002 at 15:36 UTC
Re: The shortest distance between cperl-mode and productivity
by samtregar (Abbot) on May 04, 2002 at 17:25 UTC
    You sound rather desperate, but I'm not sure why. I've been using cperl-mode for years and I've never used any of the features (aside from #8) that you describe! As far as #8, if you're using a recent Emacs (21.1.1 here) you can use the customize interface to change fonts and colors. Type "M-x customize-group" in the minibar and then enter "cperl-faces" to go to the screen where you can choose cperl-mode's fonts.

    As for your other questions, I suggest you go to the source. Find cperl-mode.el on your system (you may have to install the Emacs source pack to get it) and dig in. There's lots of information in the comments that isn't in the documentation. If you find the features you're looking for then you're all set. If not you can add them and contribute them back to the community.

    As a final note, I've always found the folks on comp.emacs to be exceedingly helpful and knowledgeable. Once you've done your homework you might consider posting a few questions there.

    -sam

Re: The shortest distance between cperl-mode and productivity
by samgold (Scribe) on May 04, 2002 at 19:23 UTC
    For questions 4 and 6 you could write macros to do it. Another helpful thing is to buy the oreilly emacs book. That has a ton of information in it that may be of use to you.

    Sam
Re: The shortest distance between cperl-mode and productivity
by BazB (Priest) on May 05, 2002 at 14:23 UTC

    Quite a lot of your requests with respect to formatting (points 4, 6 and 8) aren't something I've even thought about - I just hit ret and tab a lot :-)

    As far as point 8, the font-lock-mode colours - use M-x list-colors-display in combination with M-x customize-face.

    There are quite a few different variables to change...I spent plenty time hunting around for colour schemes I liked, and in the end just went through variables one by one.
    There probably is a better way, but I don't know it :-)

      Quite a lot of your requests with respect to formatting (points 4, 6 and 8) aren't something I've even thought about - I just hit ret and tab a lot :-)

      I'm just lazy; I expect more from my software than that (e.g. it shouldn't be too hard to automate away having to hit return and tab a zillion times).

      FWIW, I've found the answer to a couple of my questions (ok...I concede, I should have looked closer at cperl-mode's docs before posting...my bad). C-j is useful for getting you to the next line at the correct indent. In combination with the various "electric" settings -- like cperl-electric-keywords -- it makes editing so much easier.

      Expect more from your software. :)

Re: The shortest distance between cperl-mode and productivity
by hagus (Monk) on May 05, 2002 at 23:51 UTC
    1. I remember looking and finding nothing, so I wrote this myself. Patch as required:

    (defun run-buffer (args) (interactive "sArguments to script: ") (save-buffer) (shell-command (concat (buffer-file-name (current-buffer)) " " args) +))
    2. Have a look at my indenting setup:

    (defun hagus-perl-indent-setup () (setq cperl-extra-newline-before-brace t) (setq cperl-indent-level 4) (setq cperl-brace-offset -2) (hs-minor-mode) (cperl-set-style "linux")) (add-hook 'cperl-mode-hook 'hagus-perl-indent-setup)
    3. let emacs take care of your indentation. it is wise. check what function your backspace is bound to ... you can change that if you want.

    4. research the indentation setup. read the source. patch if required.

    5. patch the source.

    6. use 'align'. Here's something handy I keep around for indenting and aligning a selected block:

    (defun indent-and-align (beginning end) (interactive "r") (save-excursion (indent-region beginning end nil) (align beginning end) ))
    7. patch the source.

    8. patch the source.

    --
    Ash OS durbatulk, ash OS gimbatul,
    Ash OS thrakatulk, agh burzum-ishi krimpatul!
    Uzg-Microsoft-ishi amal fauthut burguuli.

      The align package is nice. It does have a way to go as far as improvement for language-sensitivity, and it would really do the job if it knew more about perl's hash arrows.
Re: The shortest distance between cperl-mode and productivity
by lachoy (Parson) on May 05, 2002 at 14:11 UTC
Re: The shortest distance between cperl-mode and productivity
by BUU (Prior) on May 04, 2002 at 20:25 UTC
    Use textpad. Sorry. Had to say it. But quite seriously, textpad does most of that, except for 6,7, you would have to write your own little code for that, and you could either do it in textpad itself or write a perl proggie and call it from textpad.
      textpad has a feature list that fits on two screens and you think it would be a good replacement for Emacs? Surely you jest.

      -sam

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-19 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found