Archive for the ‘Cygwin’ Category

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"
    (save-excursion (indent-region (point-min) (point-max) nil))

I found the above function at

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"
    (save-excursion (untabify (point-min) (point-max)))

(defun tab-to-spaces ()
    "Convert tab to spaces"
    (save-excursion (untabify (point-min) (point-max)))

I then found this page, which has the best indent/format buffer function.

(defun indent-buffer-2 ()
    "Indent the buffer 2"
        (indent-region (point-min) (point-max) nil)
        (untabify (point-min) (point-max))

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.

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

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


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

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

This is what it looks like

Cygwin Custom Colors persuasion movie

Fluxbox 1.0.0 for cygwin

Friday, May 2nd, 2008

I have built fluxbox for cygwin and tested it on 2 PCs now. I felt I should share it. Heres how to install it.

Firstly you should install cygwin and xorg-base for

Download the fluxbox 1.0.0 tar bz2 file and extract the file into cygwins root.

tar -xvjf fluxbox-1.0.0.tar.bz2 -C /

Now add fluxbox to your ~/.xinitrc file. Mine contains just the one line


Dont forget to ensure the defaultserverargs value in the /usr/X11R6/bin/startx file doesnt have the multiwindow argument. I.e change the line

defaultserverargs="-multiwindow -clipboard"



download knockaround guyYou should get something like this once you run startx

cygwin and blackbox 0.70.1

Monday, April 28th, 2008

Here is a step to step guide to get blackbox working with cygwin.

Firstly you should have cygwin and xorg-x11 too. You should check the default xserver works. I.e you should be able to start a xterm. Once you have that we can concentrate on getting blackbox installed.

Download blackbox-0.70.1.tar.bz2


tar -xvjf blackbox-0.70.1.tar.gz -C /

Edit ~/.xinitrc and add blackbox to your the file. In my case this is the only line in my file.


Edit /usr/X11R6/bin/startx

defaultserverargs="-multiwindow -clipboard"



Fire it up and you should see this

Blacbox WM 0.70.1

Warning: I had to disable Unicode fonts in blackbox to get it working with cygwin. I have no idea why, but if blackbox tries to use unicode fonts all you get is boxes instead of the correct font renderings.