Archive for March, 2004

cygwin, terms, and emacs

Posted in cygwin, emacs, linux, shell, unix on March 17, 2004 by Kelly Felkins

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:
6.png

  • 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/term directory. Then I changed my $TERM type 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

resources:

Installing Cygwin

Posted in cygwin on March 6, 2004 by Kelly Felkins

Cygwin is a collection of unix/linux style tools that run on Windows. I primarily use cygwin for xterms, ssh tools (ssh, scp), and rsync, but I sometimes use unix style tools to operate on the window system files.

The first thing you need to know is that cygwin is *not* unix or linux on windows — rather, it is a set of unix/linux tools that run on windows. Don’t expect a windows application to suddenly act like a unix application just because you see a familiar bash prompt.

I’ve used cygwin a long time and it has evolved quite a bit. It is simple and easy to install and use the basic tools. I’ve had trouble though when I’ve tried to run other applications, like mutt.

Here are my recommendations for installing and running cygwin.

Directory Structure

  • Create a separate, permanent location for the setup application. I use c:/cygwin-setup. The setup application stores setup configuration information in this directory and things will run smoother if it is there the next time you run setup.
  • I accept the default for the cygwin installation directory, c:/cygwin.

Packages

The cygwin setup application is similar in concept to unix/linux package management systems like Debian’s. It provides a windows gui interface listing packages. After you select packages it will download those selected packages and all other packages required for a successful install of the selected packages.

The setup application will also download updates to any already installed packages that have updates. This surprised me the first time I decided to install some new small package and noticed setup was updating everything else I had previously installed. I now have the habit of periodically updating my cygwin installation by running setup and simply clicking through all of the options taking all of the defaults.

I recommend you start small — don’t install everything all at once. When I get a new windows system I start by installing

  • openssh (getting me ssh and scp)
  • rsync
  • x enabled emacs

These items depend on the cygwin core, which includes bash and basic unix file system utilities. The x enabled emacs depends on the x window system so that will be installed too.

Setup will download the appropriate packages and create and populate the directory structure. It will put an icon on the desktop to the cygwin console – which I never use.

I don’t like the cygwin console. Instead I use the xterm. However, as of this writing, I don’t think cygwin has a convenient way to start xterms. This is what I do:

  • install the package that gives you x start up scripts (sorry! forgot what its called). This will place in your /usr/X11R6/bin directory a file called startxwin.bat.
  • place two copies of startxwin.bat on your desktop — call one ’startxwin.bat’, call the other ’startxterm.bat’.
  • edit the version name ’startxterm.bat’. Comment out the ‘run XWin line’.

Now, to run an x application (or to get the first xterm), simply double click on the startxwin.bat. This will start the x-server and 1 xterm. The x-server will continue running even when you kill the xterm window. (The x server adds the x icon to the system tray.) You only need one x-server to run which is why we created the file startxterm.bat.

To start subsequent xterms (once the x-server is running) simply double click on the startxterm.bat file.

Other Suggestions

Cygwin creates unix directory structure in the c:/cygwin directory. When you start an xterm you will be placed in a directory like /home/username. The windows path to that directory is c:/cygwin/home/username.

I used to recommend that you sym link this directory to your windows “My Documents” directory. In the long run I think this is more trouble than it is worth.

I do create sym links to windows “My Documents” and desktop, called simply “documents” and “desktop”. These links make it pretty convenient to find files in the windows file system.

You reference the windows drives via the “cygdrive” directory. For example, to get to c:/, go to /cygdrive/c.

For more info visit http://www.cygwin.com/.