cygwin, terms, and emacs
Getting a cygwin terminal emulation to work properly with a remote unix or linux host has been challenging. The problems are primarily when interacting with emacs, but there are various other issues, such as unix curses applications (getting box drawing characters to display correctly).
I’ve recently switched back to the cygwin xterm as my primary terminal emulator. Previously I used rxvt. I switched to xterm for a variety of reasons (read “not well defined”), some of which are:

- I was dissatisfied with the colors in emacs. I started experimenting with colortheme.el, and noticed that the color themes as displayed on the color-theme web page were different from what I saw in my rxvt window. I don’t understand why.
- font issues have been frustrating. I don’t know if I’ll run into these problems with xterm or not. Specifically, I had to jump through hoops (read “use an rsvt specific term setting”) to get line drawing fonts working. That broke other things.
challanges
challenge: get delete working correctly in emacs on solaris via xterm
- discussion: delete should delete the character under the cursor. Delete is the same as backspace on solaris.
- status: solved! I added this to my .emacs:
(define-key function-key-map [delete] [deletechar])
This will likely break something else, especially since I share this .emacs with linux systems. Stay tuned.
challenge: get backspace working correctly in emacs in xterm
- discussion: backspace in emacs should delete the previous character. ^h brings up the emacs help system, “info”. Backspace keys often generate a ^h character.
- status: solved! I created an .Xdefaults with this line “
xterm.*.backarrowKey: false“. Check out the discussion of this in
Squishywishywoo: delete and backspace keys under X (emacs, xterm) under “xterm”.
challenge: get shift-arrow keys to work in rxvt
- discussion: I’m checking out windmove.el and its default key bindings use shift-some arrow key. The keys codes that emacs received were unrecognized.
- status: solved! I installed rxvt.el. I grabbed the 1.4 version and put it in the
~/emacs-lisp/termdirectory. Then I changed my$TERMtype to “rxvt”.
challenge: get cycle-buffer f10 key working
- discussion: The above fix broke one of the keys that works cycle-buffer, f10.
- status: solved! I looked at the rxvt.el file but didn’t see a problem, not that I would recognize a problem if it was in front of my face. I then compared it to the xterm.el file. I decided I would rather go with the smaller and less complicated xterm.el file. So I made a copy of this from /usr/share/emacs/21.2/lisp/term/ and placed it in my ~/emacs-lisp/term directory. I then added key definitions, using the definitions I found in rxvt. With this I now have my long standing key definition problems fixed. Here are the lines I added to my cygwin ~/emacs-lisp/term/xterm.el file:
(define-key function-key-map "\\e[33~" [S-f9])
(define-key function-key-map "\\e[34~" [S-f10])
(define-key function-key-map "\\e[d" [S-left])
(define-key function-key-map "\\e[c" [S-right])
(define-key function-key-map "\\e[a" [S-up])
(define-key function-key-map "\\e[b" [S-down])
(define-key function-key-map "\\e[7~" [home])
(define-key function-key-map "\\e[7^" [C-home])
(define-key function-key-map "\\e[8~" [end])
(define-key function-key-map "\\e[8^" [C-end])
In the process I cleaned up (read “deleted”) my .Xdefaults and .Xresources files – they’re gone. Oh, and windmove.el ROCKS!
Here are some techniques to help you diagnose terminal emulation problems:
| for this | do this |
|---|---|
| display the code being sent when you press a key | ctrl-v [some key] |
| display the code being sent in emacs (describe-key and describe-key-briefly) | C-h k and C-h c |