Archive for the ‘win32’ Category

Controlling Word the Lispy Way

Tuesday, January 29th, 2008

In my last post I asked whether anyone knew how to replace automatically numbered paragraphs in MS Word with their textual (non-auto) equivalents.

No one replied.

So I had to do it myself. Startlingly simple for my humble needs, the solution consists of a key-code invoking a macro which shells out to cscript running a Jscript program. The slightly interesting point is that this last is generated by Parenscript, and looks like so:

(defvar wd-app (*get-object "" "Word.Application"))
(defvar a-doc wd-app.*active-document)

(defun de-number ()
  (let ((cnt a-doc.*lists.*count))
    (dotimes (i cnt)
      (let ((lst (slot-value (a-doc.*lists 1)
        (lst.*convert-numbers-to-text 3)))))

This is obviously far from being great style, but it gets the job done and has me wondering about all the other things I could be doing with parentheses…

In praise of VBacs

Wednesday, January 9th, 2008

For my sins I spend most of the (work) day in Microsoft Word. In order to make this experience bearable I turn off as many of the automatic mangling features as I can and install VBacs, which provides a basic set of Emacs keybindings for Word. This means I can C-x C-f, C-x C-s, C-s, C-r, M-%, M-w, C-y etc. to my heart’s content. VBacs doesn’t turn Word into Emacs, but it does help me concentrate on changing the text rather than where simple keybindings might be.

VBacs – give it a go if you’re sentenced to Word.

PS. Does anyone have a programmatic way to replace the furshlugginer automatic numbering in a Word document with its textual equivalents? (That is, replace the automatically inserted numbering “1.13” with the text “1.13”.)

Emacs newbies – don’t swap Ctrl and Caps Lock

Monday, July 23rd, 2007

Newcomers to Common Lisp are encouraged to use Emacs (see also Finseth) so that they can use the fabulous Slime (and one should not forget paredit) as a development environment. Those that don’t insist they’ll stick with Vim (and then unaccountably fail to develop slim-vim), or try Cusp, will at some early point be advised to swap their Control and Caps Lock keys to save wear and tear on the pinkie. Even EmacsWiki points to typically forthright Steve Yegge piece which leads off with this advice.

I say – No. The proper place for the Control key is not “on the home row” but on each side of the Space Bar, where Tom
Knight and the mothership intended them to be. And outside the Control keys should be the Meta keys, and outside them should be the Super keys, and finally the Hyper keys. This allows for what I think is a very natural way of typing key-chords – the modifiers with one hand, and the letter/symbol with the other. These are, after all, the sorts of keyboards on which Emacs was first developed.

How you do this will depend on your OS and your keyboard. For Windows, you might like to start here or here.* In OSX you can look in System Preferences > Keyboard & Mouse > Modifier Keys. For Linux, there are a thousand xmodmap and xkb tutorials…

The other keyboard reconfiguration I recommend is, where possible, to put the parentheses on unshifted keys (swapping with the [square] brackets works on some keyboards). Of course, if, like me, you live/work in a locale with all manner of chicken scratchings on top of proper latin letters this may not be possible or convenient. (Eric Naggum’s more radical approach can be seen here.)

So, my advice for Emacs (Climacs, VBacs) newbies would be: don’t swap Caps-Lock and Control, swap Alt, Ctrl, Windows, Application, AltGr…

* For example, if my Windows XP notebook had the following key configuration to the left of the spacebar
(from right to left, inside to outside)
Alt Windows Ctrl and I wanted it to be Ctrl Alt Windows, I would do the following:

  1. Fire up regedt32.exe and navigate to HKEY_CURRENT_USER\Keyboard Layout.
  2. Create a new entry Scancode Map (using Edit > New > Binary Value).
  3. Edit the new entry (using Edit > Modify Binary Data) to contain the following:
        0000   00 00 00 00 00 00 00 00
        0008   04 00 00 00 1D 00 38 00
        0010   38 00 5B E0 5B E0 1D 00
        0018   00 00 00 00

    The table is in little-endian form. The first 8 bytes are header (all zeroes). The next four bytes contain the count of entries (4, including the sentinel). The three following four byte entries swap Left Alt (0x38) with Left Ctrl 0x1D), Left Win (0xE058) with Left Alt, and Left Ctrl with Left Win. The last 4 bytes are a null terminator/sentinel.

  4. Close up, log off, log on, and enjoy.

If you did this, of course, it would be entirely at your own risk.

… on a stick

Sunday, November 5th, 2006

Climacs on Windows

What do you get when you put SBCL‘s windows port (helpfully packaged by Nikodemus Siivola), EmacsW32, Slime, McClim and Xming on a USB stick?

A nice little portable development environment with cross-platform GUI, of course!