Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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?

Comment on Favorite Hacks in Emacs
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.

    --Artist
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 Your Mother (Canon) 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 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 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 jplindstrom (Monsignor) on May 13, 2009 at 14:25 UTC

    Libs

    • 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

    Snippets:

    ;; 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 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 morgon (Deacon) 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 :-)

      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 :-))
      :)

      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

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 (Canon) 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-09-15 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (146 votes), past polls