Indent/Format the whole buffer in Emacs

Monday, February 8th, 2010

I have had an indent-buffer command like this for some time, which formats the whole current buffer. I used it for java, c++, css, html, xml and lisp.

(defun indent-buffer ()
    "Indent the current buffer"
    (interactive)
    (save-excursion (indent-region (point-min) (point-max) nil))
)

I found the above function at http://www.emacswiki.org/cgi-bin/wiki/ReformatBuffer

Recently I noticed that it was leaving tabs in (which I hate) and trailing spaces.  It was simply just indenting the buffer.

After some more searching today I found the untabify command and I created the following commands.  Mainly because I expected the command to be called something like tab-???

(defun untabify-buffer ()
    "Untabify current buffer"
    (interactive)
    (save-excursion (untabify (point-min) (point-max)))
)
 
(defun tab-to-spaces ()
    "Convert tab to spaces"
    (interactive)
    (save-excursion (untabify (point-min) (point-max)))
)

I then found this page, http://emacsblog.org/2007/01/17/indent-whole-buffer/ which has the best indent/format buffer function.

(defun indent-buffer-2 ()
    "Indent the buffer 2"
    (interactive)
    (save-excursion
        (delete-trailing-whitespace)
        (indent-region (point-min) (point-max) nil)
        (untabify (point-min) (point-max))
    )
)

Home and End key with rxvt

Tuesday, March 31st, 2009

I use cygwins rxvt at work and have had problems with the End and Home key not working.

I also had the same issue at home using rxvt-unicode

on gentoo.

After lots of search last night I finally found the fix for urxvt.

Simply add this to your ~/.inputrc file

# home and end keys for rxvt
"\e[7~":beginning-of-line
"\e[8~":end-of-line

when harry met sally movie download suicide blonde movie download

I then tried this at work this morning and found it works on cygwins rxvt too.

My emacs startup script for cygwin

Tuesday, March 24th, 2009

This is my emacs script for cygwin. It runs the Windows Emacs version and runs just 1 instance of emacs in most cases.

cassandra s dream movie download

gremlins 2 the new batch dvd

Typing emacs on its own simply starts a new version of emacs.

the tiger s tail download онлайн порно со зрелыми бесплатные русские порнофильмы

Type emacs and a file will try to open the document in a running version if its started else it will start emacs.

#!/bin/bash
 
if [ -z $1 ]
then
    d:/apps/emacs-22.2/bin/emacs.exe
else
    d:/apps/emacs-22.2/bin/emacsclient.exe -n \
    -a d:/apps/emacs-22.2/bin/emacs.exe $@ \
    >/dev/null 2>&1
fi

SSH and rsync through a socks proxy

Wednesday, December 17th, 2008

I’ve been using Dropbox for quite some time to transfer files from work to my home PCs. This is worked well for months, but I finally filled my dropbox account.

watch life less ordinary a online As I have a linux box at work and a linux box at home I decided to try and setup some simply one way mirroring system.  I.e. mirror documents from work to my home PC.

I looked at using unison, which I used to mirror many other directories but I couldnt get it to connect out from my work PC.   It appears to lack socks support.  I know I could use ssh port forwarding to sync via sockets but this would be more complicated.

I decided to use rsync

dreamland online download

via ssh.

There was one main issue though, I needed to get ssh to work over our proxies.  We have a few http proxies and 1 socks proxy.  The http proxies will not connect to arbitrary ports so I ended up using the socks server.

download religulous dvd

I knew the socks server worked as I’ve used it with putty watch hannah montana the movie online for years, so I just needed to figure out how to setup ssh to use it.

After lots of search and finding articles regarding port forwarding and nothing about using a socks proxy I found 1 good article.

I use gentoo linux so I emerged net-misc/connect which supports socks servers.

emerge -auv net-misc/connect

Once I had the connect utility installed I needed to edit my ssh config file.  I only have 1 user configured on my linux box at work so I edited the ~/.ssh/config file.

This is what I added

Host stokebloke.com
ProxyCommand connect -S user@socks-server:1080 %h %p

Host www.stokebloke.com
ProxyCommand connect -S user@socks-server:1080 %h %p

Host homebox.homelinux.net
ProxyCommand connect -S user@socks-server:1080 %h %p

You can also do the same thing with cygwin too.  Instead of using connect program its called connect-proxy in the network section of the cygwin installer.

After I got this far I needed to configure rsync to work via this ssh connection which, it turns out, is very simple.

rsync --progress -avrz -e ssh src_dir/ user@homebox.homelinux.net:~/dest_dir/

This results in the src_dir existing inside the dest_dir.

Cygwin .Xresources for rxvt.

Thursday, September 18th, 2008

I dont actually like the default colors for rxvt.   So I thought there may be more people who dont like it either.

Here is my .Xresources I use for my cygwin rxvt executable.

rxvt.font:            Lucida Console-14
rxvt.scrollBar:       True
rxvt.scrollBar_right: True
rxvt.visualBell:      True
rxvt.loginShell:      True
rxvt.geometry:        140x25
rxvt.background:      Black
rxvt.foreground:      White
rxvt.cursorColor:     Green
rxvt.cursorColor1:    Pink
rxvt.colorBD:         Red
rxvt.colorUL:         Yellow
rxvt.saveLines:       200

! My custom colors
rxvt*color0:    #000000
rxvt*color1:    #FF2020
rxvt*color2:    #20FF20
rxvt*color3:    #FFFF00
rxvt*color4:    #4040FF
rxvt*color5:    #A800A8
rxvt*color6:    #00A8A8
rxvt*color7:    #D8D8D8
rxvt*color8:    #000000
rxvt*color9:    #FF2020
rxvt*color10:   #20FF20
rxvt*color11:   #FFFF00
rxvt*color12:   #4040FF
rxvt*color13:   #A800A8
rxvt*color14:   #00A8A8
rxvt*color15:   #D8D8D8

black book online download download chaos theory movie

This is what it looks like

Cygwin Custom Colors persuasion movie

there will be blood download