Home : Emacs tips : Advanced
These are the things that, in my opinion, makes emacs worthwhile; I use them constantly.
Within a manpage buffer:
If you invoke man from a shell (as the hardcore Unix hackers do), then the formatted manual page comes to the standard output, flying rapidly off the top of the window. In order to be able to actually read the page, it used to be that one had to pipe the output through a "pager" program, e.g. more (or the FSF analogue less), which stopped and prompted the user after each screenful, and also allowed context searching, among other features. It amazes me that even now, with bitmapped displays and cheap memory, people still use such things. Given that I am already in emacs, I find it so much easier to use the shell buffer for running shell commands, and to look at man pages in man-mode buffers using the M-x man command.
Similarly, instead of doing "ls -l | less" to see a long-format directory listing of the current directory, in emacs you can do "M-x dired RET RET" (or "C-x d RET") to see the same listing in a "dired mode" buffer. The dired buffer can be scrolled forward and backward as by less, and searched somewhat more efficiently. Better still, dired mode also allows you to manipulate the files (edit, rename, delete, change permissions, etc.) with single-character commands. See the "Editing directory listings with C-x d" section for more information.
The other approach is to turn off paging entirely (by doing "setenv PAGER cat" in csh), and view the whole man page or ls listing in the shell buffer. But for most purposes, I find it easier to keep these in separate buffers, where they are randomly accessible and don't interfere with whatever I'm trying to accomplish in the shell.
Note that it doesn't make a difference whether you are running emacs under a graphical user interface, or through the rawest terminal emulator over a telnet connection. The emacs user interface looks almost the same, and a pager is more of a hindrance than a help in either case.
man cmdname | more
But on most systems, this is no longer necessary.
Tcl editing support for inferior Tcl:
dired is an ancient and well-developed feature of emacs; the summary below only scratches the surface of what it can do. [and needs more work in any case. -- rgr, 19-Feb-01.]
This sets up a tags table, conventionally called TAGS, for finding stuff in a given directory. Let's assume that the "~/c-prog/" directory contains a program written in C.
cd ~/c-prog etags *.[ch]You need to create the TAGS file initially, and may need to redo it periodically if emacs can't find something (usually because you've moved a definition from one file to another).
M-x visit RET ~/c-prog/ RETIf you are already in the ~/c-prog/ directory, then M-x visit RET RET" will be sufficient. In any case, you must do this every time you restart emacs.
(setq tags-table-list (list (expand-file-name "~/c-prog/TAGS")))in your .emacs file.
If you install the mouse commands in the rgr-hacks package, you can click M-mouse-1 (that is, hold down the "Meta" modifier while clicking the left mouse button) to invoke find-tag on the definition name under the mouse.
Setting up an ArsDigita bootcamp machine:
This sets up a tags table, conventionally called TAGS, for finding stuff in the ACS system, as modified by you on your machine. You should be able to do this with a command like "etags *.tcl", but etags doesn't know about Tcl syntax, and certainly not about proc_doc, hence the arcana.
cd /web/studentXX/ makeYou need to initialize this once, and may need to redo it periodically if emacs can't find something (because you've moved a definition from one file to another, etc.).
M-x visit RET /web/studentXX/ RETYou must do this every time you restart emacs.
(setq tags-table-list '("/web/studentXX/TAGS"))in your .emacs file.
grep -n 'room-view' *.tclfinds all occurrences of the string "room-view" in all tcl files in the current buffer's default directory (so it matters what buffer you're in when you invoke this command). These are presumably links that invoke the room-view.tcl script. grep uses a more powerful regular expression language than tcl (but not as powerful as emacs or perl); see "M-x man RET grep RET" for more information.
By itself, grep is quite useful, but emacs makes it more so. M-x grep runs grep itself to search for occurrences of a regular expression in a set of files, putting the result in a buffer. Then, C-x ` visits the lines where the regular expression matches (called "hits") one at a time.
grep -n 'room-view' `find . ../admin -name '*.tcl'`but be sure to keep your backquotes and apostrophes straight. (This is just a standard application of the Unix find command, by the way.)
[finish. -- rgr, 8-Nov-99.]
Other resources for more advanced emacs
Bob Rogers <email@example.com> Last modified: Sat Jun 25 18:36:50 EDT 2011