Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Tweakers Anonymous

1,911 views

Published on

Have you ever spent most of a day getting your editor set up "just right"? Have you justified the time spent on customizing your configuration in terms of the overall productivity gains that are going to result once you remember what key binding you put that new tweak on? Or maybe, whenever you see a tweak described for that _other_ editor, you can't rest until you've duplicated and maybe even expanded upon it for the clearly superior editor you use? If the above hit too close to home -- particularly if you've ever written a program specifically to allow you to more easily deploy your editor configuration on a new machine -- this talk is for you.

We're going to talk about editor tweaks that make writing, testing, running, and otherwise working with Perl faster and easier, so you can focus on the stuff that really matters: beer, go karts, and cool new editor color themes...

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Tweakers Anonymous

  1. 1. Tweakers Anonymous John SJ Anderson dc.pm @genehack genehack@genehack.org
  2. 2. An elegant weapon for a more civilized age
  3. 3. An elegant weapon for a more civilized age
  4. 4. But instead...
  5. 5. But instead...
  6. 6. But instead...
  7. 7. But instead...• Not editor specific
  8. 8. But instead...• Not editor specific• Less about how
  9. 9. But instead...• Not editor specific• Less about how• More about what
  10. 10. But instead...• Not editor specific• Less about how• More about what• Should be able to apply ideas to any programmer’s editor
  11. 11. Programmer’s editor
  12. 12. Programmer’s editor• Syntax highlighting
  13. 13. Programmer’s editor• Syntax highlighting• Indentation support
  14. 14. Programmer’s editor• Syntax highlighting• Indentation support• Programable
  15. 15. Syntax highlighting
  16. 16. Syntax highlighting• If nothing else, this helps catch stupid typos faster
  17. 17. Syntax highlighting• If nothing else, this helps catch stupid typos faster• Can also sometimes obscure the code -- you may want to be able to easily toggle it on and off
  18. 18. Syntax highlighting• If nothing else, this helps catch stupid typos faster• Can also sometimes obscure the code -- you may want to be able to easily toggle it on and off• Not to the angry fruit salad level
  19. 19. Syntax highlighting• If nothing else, this helps catch stupid typos faster• Can also sometimes obscure the code -- you may want to be able to easily toggle it on and off• Not to the angry fruit salad level• Just something that distinguishes keywords from variables from function names
  20. 20. Indentation support
  21. 21. Indentation supportWell, then get one that does do auto-indent.You cant do good work with bad tools. -- Mark Jason Dominuss Good Advice #11918
  22. 22. Programable
  23. 23. Programable• Doesn’t need to be Turing complete or anything crazy
  24. 24. Programable• Doesn’t need to be Turing complete or anything crazy• (Although you may be missing out if it isn’t.)
  25. 25. Programable• Doesn’t need to be Turing complete or anything crazy• (Although you may be missing out if it isn’t.)• If you can send a selection to an external program and replace the selection with the output, you’re probably set
  26. 26. The generic advice
  27. 27. The generic advice• Pay some attention to what you’re doing
  28. 28. The generic advice• Pay some attention to what you’re doing• Set things up so stuff you do most often can be done most easily
  29. 29. The generic advice• Pay some attention to what you’re doing• Set things up so stuff you do most often can be done most easily• E.g., saving a file, closing a file, defining and running macros, etc. etc.
  30. 30. The generic advice• Pay some attention to what you’re doing• Set things up so stuff you do most often can be done most easily• E.g., saving a file, closing a file, defining and running macros, etc. etc.• The F keys are not there just so you can skip tracks in your MP3 player
  31. 31. The generic advice• Pay some attention to what you’re doing• Set things up so stuff you do most often can be done most easily• E.g., saving a file, closing a file, defining and running macros, etc. etc.• The F keys are not there just so you can skip tracks in your MP3 player• Keep your config in git so you can revert it when you screw it up
  32. 32. Ever done this?
  33. 33. Ever done this?$ vim my_awesome_script.pl
  34. 34. Ever done this?$ vim my_awesome_script.pl# hack hack hack; !wq
  35. 35. Ever done this?$ vim my_awesome_script.pl# hack hack hack; !wq$ ./my_awesome_script.pl
  36. 36. Ever done this?$ vim my_awesome_script.pl# hack hack hack; !wq$ ./my_awesome_script.plbash: ./awesome_script.pl: permission denied
  37. 37. This is fixable: auto chmod +xautocmd BufWritePost *.pl !chmod +x %(add-hook after-save-hookexecutable-make-buffer-file-executable-if-script-p)
  38. 38. Commit messages
  39. 39. Commit messages• Set up $GIT_EDITOR so you can write commit messages in your editor of choice
  40. 40. Commit messages• Set up $GIT_EDITOR so you can write commit messages in your editor of choice• emacsclient is particularly nice here:
  41. 41. Commit messages• Set up $GIT_EDITOR so you can write commit messages in your editor of choice• emacsclient is particularly nice here: export GIT_EDITOR=‘emacsclient -t’
  42. 42. Code Tidying
  43. 43. Code Tidying• Same idea as “make executable on save”
  44. 44. Code Tidying• Same idea as “make executable on save”• When you save a file, before the write, run perltidy, and save the output of that instead
  45. 45. Code Tidying• Same idea as “make executable on save”• When you save a file, before the write, run perltidy, and save the output of that instead• If you don’t want to do that, do the world a favor and set up your editor to delete trailing whitespace when you save a file.
  46. 46. Code Tidying• Same idea as “make executable on save”• When you save a file, before the write, run perltidy, and save the output of that instead• If you don’t want to do that, do the world a favor and set up your editor to delete trailing whitespace when you save a file.• Please.
  47. 47. Syntax Checking
  48. 48. Syntax Checking• Beating the same one-trick pony
  49. 49. Syntax Checking• Beating the same one-trick pony• Run ‘perl -c’ after you save
  50. 50. Syntax Checking• Beating the same one-trick pony• Run ‘perl -c’ after you save• Gripe if there are errors
  51. 51. Even Better:Syntax Checking
  52. 52. Even Better:Syntax Checking On The Fly!
  53. 53. Ill-advised live demo!
  54. 54. Even Betterest:Syntax Checking On The Fly
  55. 55. Even Betterest: Syntax Checking& Static Analysis On The Fly
  56. 56. Even more ill-advisedlive demoing!
  57. 57. Code Browsing
  58. 58. Code Browsing• Emacs calls this find-file-at-point
  59. 59. Code Browsing• Emacs calls this find-file-at-point• ffap!
  60. 60. Code Browsing• Emacs calls this find-file-at-point• ffap!• With add-ons (such as PerlySense) one can get quite fancy
  61. 61. Documentation Browsing• Same idea here, really
  62. 62. Auto-Completion
  63. 63. Auto-CompletionWhile it isn’t possible to do this perfectly,you can get closer than you might think...
  64. 64. Auto-CompletionWhile it isn’t possible to do this perfectly,you can get closer than you might think......but it might not be worth the effort
  65. 65. Share & Enjoy• My editor config: https://github.com/genehack/emacs
  66. 66. Thanks!Questions?
  67. 67. First EverDC-Baltimore Perl Workshop 14 April 2012 dcbpw.org

×