Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [361]

By Root 1428 0
with your own Emacs LISP functions, and so on. Furthermore, an Emacs mode called RMAIL lets you read your electronic mail right within Emacs, but we won't discuss it here because most people prefer standalone mailers. (Usually, these mailers let you choose Emacs as your editor for email messages.)

Similar to the RMAIL mail interface is GNUS, the Emacs-based newsreader, which you can start with the M-x gnus command. After startup (and a bit of chewing on your .newsrc file), a list of newsgroups will be presented, along with a count of unread articles for each, as shown in Figure 19-24.

Figure 19-23. Mail in Emacs

Figure 19-24. Newsgroup reading in Emacs

GNUS is an example of the power of using Emacs interfaces to other tools. You get all the convenience of Emacs's navigation, search, and macro capabilities, along with specific key sequences appropriate for the tool you're using.

Using the arrow keys, you can select a newsgroup to read. Press the spacebar to begin reading articles from that group. Two buffers will be displayed: one containing a list of articles and the other displaying the current article.

Using n and p, move to the next and previous articles, respectively. Then use f and F to post a follow-up to the current article (either including or excluding the current article), and r and R to reply to the article via electronic mail. There are many other GNUS commands; use C-h m to get a list of them. If you're used to a newsreader, such as rn, GNUS will be somewhat familiar.

Emacs provides a number of modes for editing various types of files. For example, there is C mode for editing C source code, and TEX mode for editing (surprise) TEX source. Each mode boasts features that make editing the appropriate type of file easier.

For example, within C mode, you can use the command M-x compile, which, by default, runs make -k in the current directory and redirects errors to another buffer. For example, the compilation buffer may contain the following:

cd /home/loomer/mdw/pgmseq/

make -k

gcc -O -O2 -I. -I../include -c stream_load.c -o stream_load.o

stream_load.c:217: syntax error before `struct'

stream_load.c:217: parse error before `struct'

You can move the cursor to a line containing an error message and press C-c C-c to make the cursor jump to that line in the corresponding source buffer. Emacs opens a buffer for the appropriate source file if one does not already exist. Now you can edit and compile programs entirely within Emacs.

Emacs also provides a complete interface to the gdb debugger, which is described in "Using Emacs with gdb" in Chapter 21.

Usually, Emacs selects the appropriate mode for the buffer based on the filename extension. For example, editing a file with the extension .c in the filename automatically selects C mode for that buffer.

Shell mode is one of the most popular Emacs extensions. Shell mode allows you to interact with the shell in an Emacs buffer, using the command M-x shell. You can edit, cut, and paste command lines with standard Emacs commands. You can also run single shell commands from Emacs using M-!. If you use M-| instead, the contents of the current region are piped to the given shell command as standard input. This is a general interface for running subprograms from within Emacs.

Tailoring Emacs

The Emacs online documentation should be sufficient to get you on track for learning more about the system and growing accustomed to it. However, sometimes it is hard to locate some of the most helpful hints for getting started. Here we present a rundown on certain customization options many Emacs users choose to employ to make life easier.

The Emacs personal customization file is .emacs, which should reside in your home directory. This file should contain code, written in Emacs LISP, that runs or defines functions to customize your Emacs environment. (If you've never written LISP before, don't worry; most customizations using it are quite simple.)

One of the most common things users customize are key bindings. For instance, if you use Emacs to edit SGML

Return Main Page Previous Page Next Page

®Online Book Reader