"Linux Gazette...making Linux just a little more fun!"


Books On The Screen

Reading Electronic Texts With XEmacs

by Larry Ayers


Introduction

During a snowy and windy period this past winter I badly needed something new to read. None of the plentiful books in the house looked appealing and the prospect of driving to town for a visit to the library seemed like an awful lot of trouble, given the poor road conditions caused by drifting snow.

I was vaguely familiar with Project Gutenberg, a cooperative project intending to make public-domain literary texts freely available in digital form, but had never obtained any of these electronic books. A quick search on the net led me to one of the Gutenberg web-sites, where I was surprised to see the extensive listings of novels and other literary works, all either manually retyped or scanned from print editions by numerous volunteers. As the wind whistled around the house I tried reading one of these book-files, interested in determining whether eyestrain would be a problem.

First Impressions

The files are available compressed with a zip archiver; when unarchived on a Linux system those DOS filesystem ^M carriage return symbols terminate each line. The Info Zip unzip utility will automatically strip them from the file if the -a switch is given to the command, as in this example:   unzip -a [filename]. This isn't too useful if Emacs' native jka-compress archive file handler is used (which calls zip and unzip internally), allowing the file to be automatically uncompressed and decompressed when it is respectively opened and closed. In this case the easiest way I've seen for converting DOS-format line-endings to unix-format is a handy pair of Lisp function which Earl Stutes wrote about in LG #10; I'll repeat them here:


(defun dos-unix ()
  (interactive)
  (goto-char (point-min))
  (while (search-forward "\r" nil t) (replace-match "")))

(defun unix-dos ()
  (interactive)
  (goto-char (point-min))
  (while (search-forward "\n" nil t) (replace-match "\r\n")))


With these two functions inserted in your .emacs file, converting a file is simply a matter of typing M-x dos-unix. It could be bound to a keystroke if you find that you use it often.

Well, now the file is more readable but there are other issues which make reading an entire book awkward. It's a pain to find your place in the file between reading sessions; it would also be convenient to be able to load the file without needing to type in the complete path. Two XEmacs modes can be a great help.

Helpful Modes

The obvious method of saving your place is an analog to a bookmark in a hard-copy book, the Emacs bookmark facility. Bookmarking doesn't automatically update, a deficiency which Karl Hegbloom's Where-Was-I database corrects. This mode is toggled on for individual files, since with many files your "place" isn't important. The mode is toggled by typing M-x tog[TAB] wh[TAB]. The tab key is used to automatically complete the expression; it's quicker to type than the full form, M-x toggle where-was-i. Once the mode is activated closing or killing a file saves the point position in a binary database in your root directory. Open the file later and there is the cursor, just where you left off reading. This is especially handy with book-length files, many of which are over a megabyte in size. Hegbloom's package is included in recent versions of XEmacs; in the current betas which use the new package system it is part of the edit-utils package.

The other XEmacs mode which I recommend for general use as well as for reading books is Juergen Nickelsen's recent-files.el, also included with XEmacs and in the edit-utils package. This ingenious mode is activated by inserting these lines in your .emacs file:


(load "recent-files")
(recent-files-initialize)
 

This mode maintains a new menu in the menu-bar with two submenus. The first submenu is a list of the past several files you have loaded into XEmacs; these entries gradually get superseded by newer ones. The other one can contain entries which are permanent. The permanent files are those which you often edit, perhaps certain configuration files or a journal. There are also options on the menu to make a temporary listing permanent or vice-versa.

With both of these excellent modes in action XEmacs' transition to a comfortable displayer of books is nearly complete. One last possibility is to use a TrueType proportional font along with a server such as xfstt; I find these fonts to be easier on the eyes for passive reading.

Another helpful mode is one of the several available dictionary modes which I discussed in LG #34. I've noticed that I'm more likely to look up an unfamiliar word in an on-line than in a paper dictionary. One keystroke to look up a word is certainly convenient.

Conclusion

Until the quality of computer displays improves significantly, reading text on paper will still be preferable for protracted reading sessions. Still, I've enjoyed reading several of the Gutenberg texts, many of which it had never occurred to me to seek out in a library. The ability to cut and paste from a book can be useful --plus you can correct typos!


Last modified: Sun Mar 28 18:18:26 CST 1999


Copyright © 1999, Larry Ayers
Published in Issue 39 of Linux Gazette, April 1999


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next