Watch on forever-fawkes.tumblr.com

Original Danny Phantom theme song with title sequence.

PROCRAST

(N.) 'pro-krast  Procrasts are the comparatively easy, self-indulgent and unnecessary activities you occupy yourself with while putting off more important tasks. Usage: All of Diwan’s college applications were due January 15th, but he had not even begun to work on them. Instead, as the deadline neared, he distracted himself with countless procrasts—working out, Facebooking, and cleaning his room, though his parents hadn’t even asked him to. 

—§For other time management pitfalls, check out the Wordbirds book—and learn about DELIBEROTTING, NETSHIRKING, and DAYTRAPS—§

Emacs: Stop worrying about indentation

A while back I had the following exchange with a friend:

  • 'Hey Puerco, how do I indent the whole buffer? [in Emacs]'
  • 'Just C-x h '
  • 'But then my cursor is left at the beginning of the buffer'
  • 'Just pop the mark twice'
  • 'The mark? What is that?'
  • 'Like the kill ring but for the mark”
  • 'huh?'

But I digress, I am telling you this because my friend got me thinking, am I as lazy I thought? Why I am doing all this keypresses. So I got to writing:


  (defun indent-buffer ()
    "First Approach"
    (interactive)
    (set-mark 0)
    (end-of-buffer)
    (call-interactively 'indent-region))

But then, there would not be an easy way to return the cursor to where it was. After a quick googling I reached this solution which didn’t move the cursor so didn’t create the problem of returning it. Also it showed me that I was in the wrong frame of mind: trying to do a macro:


  (defun indent-buffer ()
    "indent whole buffer"
    (interactive)
    (delete-trailing-whitespace)
    (indent-region (point-min) (point-max) nil)
    (untabify (point-min) (point-max)))

While pasting on irc, I am frequently admonished that my indentation is wrong, remembering I had a command for that I thought hmm why don’t I automatically indent buffers before saving them.


    (add-hook 'before-save-hook (lambda () (indent-buffer)))
Text
Photo
Quote
Link
Chat
Audio
Video