procrastivity

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

skaaikruprincess asked:

Hii! I'm going to recommend you the last thing I read, which was "No Exit" the play by Jean-Paul Sartre, it's soooo goood. Also uhm... i'll tell you a bit about my day: basically i have a lot of homework but i'm procrasting in tumblr, and I would love a blograte! I adore your blog! okay bye

YO that was totally me with homework and school but now I’m just procrastinating life with tumblr which isn’t that much better but what can you do. And No Exit looks so good I’ll add that to my to read :D

url 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | CLARKE GRIFFIN

icon 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | JESSICA JONES

theme 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | DAENERYS TARGARYEN

updates tab 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | SUN BAK

posts 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |  BUFFY SUMMERS

following no(t yet) but ily | now! | ofc babe | YOU’RE THE RAVEN TO MY CLARKE

compliment: I love your navi page the header is very soothing to look at also your selfies how do you take such cute selfies

blograte?

MKS Room went live in Warsaw

MKS Room went live in Warsaw

External image

MKS Room went live in Warsaw

Make Sense kicked off its first MKS Room event ever made in Poland.

Wednesday, January 27, 2016, at OSIR Cycle Culture Cafe, took place the first edition of MKS Room, an event organized by Make Sense, a big worldwide voluntary network of people trying to promote social entrepreneurship. It turned out to be a big success: lots of people, cold beer, live music,…

View On WordPress