Tweakers Anonymous
       John SJ Anderson
            dc.pm
          @genehack
    genehack@genehack.org
An elegant weapon for
 a more civilized age
An elegant weapon for
 a more civilized age
But instead...
But instead...
But instead...
But instead...
• Not editor specific
But instead...
• Not editor specific
• Less about how
But instead...
• Not editor specific
• Less about how
• More about what
But instead...
• Not editor specific
• Less about how
• More about what
• Should be able to apply ideas to any
  programmer’s editor
Programmer’s editor
Programmer’s editor
• Syntax highlighting
Programmer’s editor
• Syntax highlighting
• Indentation support
Programmer’s editor
• Syntax highlighting
• Indentation support
• Programable
Syntax highlighting
Syntax highlighting
• If nothing else, this helps catch stupid typos
  faster
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
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
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
Indentation support
Indentation support
Well, then get one that does do auto-indent.
You can't do good work with bad tools.
 -- Mark Jason Dominus's Good Advice
 #11918
Programable
Programable
• Doesn’t need to be Turing complete or
  anything crazy
Programable
• Doesn’t need to be Turing complete or
  anything crazy
• (Although you may be missing out if it isn’t.)
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
The generic advice
The generic advice
•   Pay some attention to what you’re doing
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
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 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
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
Ever done this?
Ever done this?
$ vim my_awesome_script.pl
Ever done this?
$ vim my_awesome_script.pl

# hack hack hack; !wq
Ever done this?
$ vim my_awesome_script.pl

# hack hack hack; !wq

$ ./my_awesome_script.pl
Ever done this?
$ vim my_awesome_script.pl

# hack hack hack; !wq

$ ./my_awesome_script.pl

bash: ./awesome_script.pl: permission denied
This is fixable:
       auto chmod +x
autocmd BufWritePost *.pl !chmod +x %


(add-hook 'after-save-hook

'executable-make-buffer-file-executable-if-script-p)
Commit messages
Commit messages
• Set up $GIT_EDITOR so you can write
  commit messages in your editor of choice
Commit messages
• Set up $GIT_EDITOR so you can write
  commit messages in your editor of choice
• emacsclient is particularly nice here:
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’
Code Tidying
Code Tidying
• Same idea as “make executable on save”
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
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.
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.
Syntax Checking
Syntax Checking
• Beating the same one-trick pony
Syntax Checking
• Beating the same one-trick pony
• Run ‘perl -c’ after you save
Syntax Checking
• Beating the same one-trick pony
• Run ‘perl -c’ after you save
• Gripe if there are errors
Even Better:
Syntax Checking
Even Better:
Syntax Checking
   On The Fly!
Ill-advised live demo!
Even Betterest:
Syntax Checking


  On The Fly
Even Betterest:
 Syntax Checking
& Static Analysis
   On The Fly
Even more
   ill-advised
live demoing!
Code Browsing
Code Browsing
• Emacs calls this find-file-at-point
Code Browsing
• Emacs calls this find-file-at-point
• ffap!
Code Browsing
• Emacs calls this find-file-at-point
• ffap!
• With add-ons (such as PerlySense) one can
  get quite fancy
Documentation
        Browsing
• Same idea here, really
Auto-Completion
Auto-Completion
While it isn’t possible to do this perfectly,
you can get closer than you might think...
Auto-Completion
While it isn’t possible to do this perfectly,
you can get closer than you might think...
...but it might not be worth the effort
Share & Enjoy
• My editor config:
  https://github.com/genehack/emacs
Thanks!
Questions?
First Ever
DC-Baltimore Perl Workshop
       14 April 2012
        dcbpw.org

Tweakers Anonymous