Archive for the ‘emacs’ Category

modding bs.el for emacs

Wednesday, August 6th, 2008

I use bs.el to switch between buffers in emacs.  I have bs-cycle-next mapped to C-Tab and bs-cycle-previous mapped to C-Shift-Tab .  The problem is when I quickly page through my buffers, the buffer list that shows up in the mini window rotates and the current buffer doesn’t show up in the list,

1-2-3-4-5 c-tab

2-3-4-5-6 c-tab

the position of buffers doesn’t remain the same, which makes it hard to quickly go to the desired buffer.  I wanted behaviour like this

(6) 1 2 3 4 5

6   (1)  2  3 4 5

6   1  (2)  3 4 5

With the included file, bs.el now behaves in the way I prefer.   This is the first serious lisp programming I have ever done, also the first mod I have made to emacs.

TODO: figure out font-face-lock to get the current buffer highlighted instead of surrounded with pipes ||


Wednesday, November 21st, 2007

I have started attending lispnyc events. Wow, what a group. This is the smartest room full of programmers I have ever been in. It is also a surprisingly approachable group. Whether or not you care about about lisp or functional programming I recommend that you attend. Not everyone there programs in lisp or even a functional language for their day job, they all care about programming though. As I learn more about lisp, through events like this, more and more thoughts pop into my head which enhances my code in less functional languages.

Re mapping the caps lock key in OS X

Wednesday, May 2nd, 2007

I have heard tales for a while of the joy of having your caps lock key remapped to a more useful modifier key. For me the most useful modifier key that I know of is ESC, for vim. Alas, this seems to be very dificult to do in OS X. Here are some of the false starts I made when trying to do this.

in vim you remap keys with the following command
this is great and a very useful feature, unfortunately I can’t directly map the caps lock key with mmap.

System Preferences
at least in 10.4, OS X lets you remap the caps lock key to Control, Command, Alt, or Nothing. This is great for most people, but it doesn’t help me make it ESC. It also doesn’t help me map it to ESC for one app (Vim) and nothing for other apps.
You can find this option in
System Preferences > Keyboard & Mouse > Modifier Keys

.inputRC / xmodmap
These are files that BASH (maybe all shells) and X11 read on startup to map keys. I didn’t examine them too much. From what I hear it is possible to remap the Caps Lock key with xmodmap, but I don’t run X11 regularly

Ukelele / .keylayout files
Ukelele is a program for creating key layout files, it comes highly recommended, I wasn’t impressed. I found it easier to hand edit the xml key layout files that OS X uses. You can read about their schema here. I found out that the caps lock key should generated a key code of 55 or 57 depending on whether it’s being turned on or off. On OS X they don’t generate that key code for a keylayout file to manipulate.

Writing A C program to modify keycodes
I ran across this code example OS X Internals and this code. Now I was on to something. I had one program that modifies key codes, and another one that traps the caps lock key (or any other modifier key being pressed. I was able to hack the code to generate a key code of “74″ (unused in the keylayouts I am using) every time the caps lock key is pressed. I was enormously satisfied with this.