Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Favorite Hacks in Emacs

by jaschwartz (Novice)
on May 12, 2009 at 20:01 UTC ( #763582=perlquestion: print w/replies, xml ) Need Help??
jaschwartz has asked for the wisdom of the Perl Monks concerning the following question:

While I have come across a few very cool hacks in emacs, I'm always in the mood to learn a few more. What tricks do you commonly use or hacks that have helped you?

Replies are listed 'Best First'.
Re: Favorite Hacks in Emacs
by Joost (Canon) on May 12, 2009 at 20:22 UTC
Re: Favorite Hacks in Emacs
by artist (Parson) on May 13, 2009 at 02:23 UTC
    M-x org-mode
    I export the lists to HTML or Freemind.

    Here is a good survey of such features. Also see the most useful ones.

Re: Favorite Hacks in Emacs
by Porculus (Hermit) on May 13, 2009 at 07:09 UTC

    shell-command-on-region. With a prefix argument it replaces the region with the shell command's output. Great way to run Perl one-liners on whatever you're editing!

    Also, align-regexp. Ideal for picky types who want a bunch of assignments to line up on the =. ;)

      that reminds me! I forgot cperl-mode's C-M-| for lining up stuff. I use that alot.

      Just don't miss and hit backspace in X windows...

Re: Favorite Hacks in Emacs
by Your Mother (Chancellor) on May 13, 2009 at 05:39 UTC

    I hope these are pasted right.

    (global-set-key "\M-3" 'script-blank) (global-set-key "\M-4" 'subroutine-blank) (define-skeleton script-blank "Insert a blank script." nil "#!/usr/bin/perl \n use strict; use warnings; # et cetera... Looooooong list of modules which # are easier to cut when unused than type otherwise. \n _ \n \n "exit 0; __DATA__ " ) ;;-------------------------------------------------------------------- (define-skeleton subroutine-blank "Insert a blank sub." nil "sub " _ " {" \n \n \n \n "}" )

Re: Favorite Hacks in Emacs
by shem (Initiate) on May 13, 2009 at 11:37 UTC
    (defun cw_save_check () "Run the Perl syntax checker on this buffer after saving." (cond ((equal mode-name "CPerl") (progn (save-current-buffer (set-buffer (get-buffer-create "*Perl cw output*")) (erase-buffer)) (call-process-region (point-min) (point-max) "/usr/bin/perl" nil + "*Perl cw output*" n il "-c -I.") (save-current-buffer (set-buffer "*Perl cw output*") (cond ((equal (buffer-string) "- syntax OK\n") (message "%s" "Synta +x OK")) (t (message "%s" "The program has errors.")))))) (t nil))) (add-hook 'after-save-hook 'cw_save_check)
Re: Favorite Hacks in Emacs
by juster (Friar) on May 13, 2009 at 04:58 UTC
    I use C-c C-h p aka M-x cperl-perldoc to lookup module and builtin docs but maybe I should try Sepia! I just recently started using 'Emacs Got Git' (egg) and it's pretty cool.
Re: Favorite Hacks in Emacs
by monarch (Priest) on May 13, 2009 at 14:32 UTC

    <Ctrl>-x, <enter>, f

    Changes encoding of a file (useful when converting to/from DOS/Unix line formats).

    e.g. I might be on a Unix system and I need to create a MS-DOS compatible text file, I type <ctrl>-x, <enter>, f and type "undecided-DOS".

    Or I might be on a Win32 machine and want to save a file in unix format for transfer to a remote system as a shell script. <ctrl>-x, <enter>, f and type "undecided-unix".

Re: Favorite Hacks in Emacs
by jplindstrom (Monsignor) on May 13, 2009 at 14:25 UTC


    • org-mode
    • ediff-buffers / ediff-regions-linewise (bet you didn't know about the last one)
    • SVN integration, with ediff (awesome)
    • Keyboard macros
    • PerlySense <-- on top of cperl-mode
    • project-root
    • sql-mysql - buffer
    • yasnippet


    ;; Display trailing whitespace (use a very very light color) (defun my-turn-on-show-trailing-whitespace () "Set `show-trailing-whitespace' to t." (setq show-trailing-whitespace t)) (mapc (lambda (hook) (add-hook hook 'my-turn-on-show-trailing-whitespace)) '(cperl-mode-hook))
Re: Favorite Hacks in Emacs
by morgon (Curate) on May 13, 2009 at 14:55 UTC
    Don't listen to these people.

    They follow a dangerous cult.

    I'll post "favourite hacks in vim" soon :-)


      Perl and Emacs are very similar - kitchen sink philosophy.

      VI falls in line with Unix toolbox philosophy.

      RDBMSes are a similar software prison to Perl and Emacs.

      Never forget: the car is in the cdr, not the cdr in the car

      You beat me to it morgon :-D

      When a sysadmin on Solaris, my favourite emacs hack was to remove the damn thing - one of 2 scenarios kept recurring (both directly traceable to emacs):

      • filling /tmp ... causing kernel panic.
      • process table filling up - preventing any other operation - self-evidently a hard reset was always required as the fix

      A user level that continues to overstate my experience :-))
Re: Favorite Hacks in Emacs
by Nkuvu (Priest) on May 13, 2009 at 18:47 UTC

    I've seen this in a few places, so you are probably already aware of it:

    ;;run the current perl program (defun run-perl () (interactive "*") (setq perl-buffer-name buffer-file-name) (shell) (setq perl-run-command "perl ") (insert perl-run-command) (insert perl-buffer-name) ) (global-set-key [f7] 'run-perl)

    But I have to say that I don't do many perl-specific things from within emacs. I'd rather jump over to a command window instead (somehow the green letters on black background mean "shell" to me a lot more than an emacs window, and black text on a white background means "write code here").

Re: Favorite Hacks in Emacs
by LanX (Chancellor) on May 13, 2009 at 19:00 UTC
    > What tricks do you commonly use or hacks that have helped you?

    Humor helps a lot!
    ...and of course C-x M-c M-butterfly 8 )

    Cheers Rolf

Re: Favorite Hacks in Emacs
by skangas (Novice) on May 15, 2009 at 06:31 UTC

    I'm sure you've heard about it already, but I like outline-minor-mode. Not at all essential, but still very nice to have sometimes.

    CPerlModeOutlineMode at EmacsWiki.

Re: Favorite Hacks in Emacs
by joojar (Initiate) on May 16, 2009 at 10:43 UTC
      I found a better perl tool for emacs call Sepia and it have everything

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://763582]
Approved by Joost
Front-paged by Arunbear
[Eily]: very useful default translation :P
[Eily]: BTW LanX, you should try typing a few random chars at the beginning of each message. This will prevent expansion :P
[LanX]: qwiud you sthink so?
[LanX]: zxwqbd good idea! :)
LanX embraces his new habit spqopiwjdnq
[ambrus]: qQUkZTmHTuKxStGT- BzTIK9gdudif7TkTLI t3mnF144UaAZjkknXY 8nN-QM19wHBsTrp5vB lEYU_Kksa7X1RIBB4x EWLD5X7SW3jGX5ryfN OMn_yL5FTdQxzjhtyX mKN9sjUCzBNHK5Rrp0 S2WMUvIb1i9aZFgjtq VR0GH1bjPMvm1G16iz hBqc1U6toPd4FbJOFj VsOeT745AN1_pO88rD SRAYKtBZwCZedESZmN mvutrOTHiSNwflB- pRfn_k
[Eily]: so far it seems to work
Your Mother reminds the monks they should be grateful not to share an office, lest they be subjugated to constant inanities like, "Czech please!"
[LanX]: what's strange is that the "Cowboy you said this already" message is missing #dqiwd
[LanX]: YM: BTW learn to mute your humanity

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2017-03-27 16:51 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.