Tips for Using Xemacs

Jeffrey D. Oldham

2000 Jan 19

In this document, I hope to give some ideas how to use Xemacs effectively.


Contents

Automatically Entering C++ Mode

When editing a file ending with ``.cc'', ``.cxx'', or ``.cpp'', Xemacs automatically changes to C++-mode. To cause Xemacs to enter C++-mode when editing ``.h'' files, add the following line to your ``~/.emacs'' file:

    (setq auto-mode-alist (cons '("\\.h$" . c++-mode) auto-mode-alist))

Automatic Wordwrap

When editing C++ files, Xemacs will automatically break lines. To do so, open the file ``~/.emacs'' and type the following line:

(setq c++-mode-hook 'turn-on-auto-fill)
The next time you start Xemacs, the command will take effect.

Learning More About Xemacs

To learn more about Xemacs, including the keyboard commands, run the Xemacs tutorial by typing ``Control-h t''.

Line Numbers

To have line numbers appear on the penultimate line of your Xemacs, add the following lines to the file ``~/.emacs'':

(line-number-mode 1)
(column-number-mode 1)

Obtaining Xemacs for My Windows Machine

Installing Linux on your machine and then installing Xemacs is probably the easiest path, but a version exists for Windows. See Xemacs's FTP site. Installing it requires having both gzip and tar installed on your machine. (I do not think that these are installed on Windows machines by default. I do not have time to help people install these programs.)

Matching Parentheses

To have your Xemacs show matching parentheses, select an option for ``Paren Highlighting'' from the ``Options'' menu. Be sure to ``Save Options.'' Thus, when the cursor is after a closing parenthesis, brace, or bracket, highlighting will happen.

Programming with Colors

Xemacs will color your C++ code, using different colors to indicate comments, function names, strings, etc. To select this feature, choose the Options menu, Syntax Highlighting, and then ``In This Buffer.'' This should cause your C++ files to become colored. If you like this feature, choose Options/Save Options before exiting Xemacs.

Telnet and Xemacs

If you are logged into a Linux/Unix system via telnet, you can probably still run Xemacs, but you will not see the menu bar or have access to mouse-based functions. All the keyboard-driven options (described in the tutorial and in the online help) should still work, except that you may need to use the ``ESC'' key instead of the ``Alt'' key as the Xemacs ``Meta'' key. See the tutorial for details of how to do this.

You can also run the text-based version of Xemacs, emacs. This version will probably present you with a menu bar across the top of its text window. To access this menu bar, type Meta-` (backtick). You should then see in the bottom part of the text window instructions on what to do next.

If you need to switch back and forth between editing files with emacs (or Xemacs) and using the shell's command line, you can temporarily suspend emacs by typing ``Control-Z''. This should take you back to the command-line prompt, where you can enter whatever commands you choose. When you are ready to return to emacs, type ``fg'' (abbreviating ``foreground'').

What is ~/.emacs?

When Xemacs (or Emacs) starts, it reads the file called ``.emacs'' in your home directory. This file contains code to customize Xemacs. To modify it, use your favorite editor which is, of course, Xemacs. Right?




2000-01-31