GNU Emacs Frequently Asked Questions with Answers Mon Aug 27 13:24:12 1990 If you are viewing this file in a GNU Emacs Buffer, you can type "M-2 C-x $" to get an overview of just the questions. Then, when you want to look at the text of the answers, just type "C-x $". Notations Used in the Answers (READ THIS SECTION FIRST!) 1. What do things like this mean: C-h, M-C-a, RET, etc.? C-a means while holding down the "Control" key press the "a" key. The ASCII code this sends will generally be the value that would be sent by pressing just "a" minus 96 or 64. Either way it will be a number from 0 to 31. M-a means while holding down the "Meta" key press the "a" key. The ASCII code this sends is the sum of the ASCII code that would be sent by pressing just "a" and 128. M-C-a means while holding down both the "Control" key and the "Meta" key press the "a" key. C-M-a is a synonym for M-C-a. RET means press the "Return" key. RET is the same as C-m. This sends ASCII code 13. LFD means press the "Linefeed" key. LFD is also the same as C-j. This sends ASCII code 10. Under Unix, ASCII code 10 is often called "Newline". DEL means press the "Delete" key. DEL is the same as C-?. This sends ASCII code 127. ESC means press the "Escape" key. ESC is the same as C-[. This sends ASCII code 27. SPC means press the "Space" key. This send ASCII code 32. TAB means press the "Tab" key. TAB is the same as C-i. This send ASCII code 9. Any others I'm missing?? See section ??? of the manual for another explanation. 2. What do you mean when you write things like this: type "ESC a"? I will enclose key sequences that are longer than one key inside double quotes. These notations refer to single keys (some with modifiers): C-x, M-x, M-C-x RET, LFD, DEL, ESC, SPC, TAB I separate these from other keys within double quotes by spaces. Any real spaces that I write inside double quotes can be ignored, only SPC means press the space key. All other characters within double quotes represent single keys (some shifted). 3. What if I don't have a Meta key? Instead of typing M-a, you can type "ESC a" instead. In fact, Emacs converts M-a internally into "ESC a" anyway. 4. What if I don't have an Escape key? Type C-[ instead. This should send ASCII code 27 just like an Escape key would. 5. What does "M-x command" mean? "M-x command" means type M-x, then type the name of the command, then type RET. M-x is simply the default key sequence that invokes the command "execute-extended-command". This command allows you to run any Emacs command if you can remember the command's name. An Emacs "command" is any "interactive" Emacs function. (Your system administrator may have bound other key sequences to invoke execute-extended-command. A function key labeled "Do" is a good candidate for this.) To run non-interactive Emacs functions, use M-ESC instead and type a Lisp form. 6. What do things like this mean: etc/SERVICE, src/config.h, lisp/default.el? These are the names of files that are part of the GNU Emacs distribution. The GNU Emacs distribution is so big that it is divided into several subdirectories; the important subdirectories are named "etc", "lisp", and "src". If you use GNU Emacs, but don't know where it is kept on your system, start Emacs, then in the *scratch* buffer type "exec-directory C-j". The directory name that is displayed by this will be the full pathname of the "etc" directory of your installed GNU Emacs distribution. Some of these files are available individually via FTP or e-mail, see question 16. 7. What are FSF, LPF, OSF, GNU, RMS, and BTW? FSF == Free Software Foundation LPF == League for Programming Freedom OSF == Open Software Foundation (right???) GNU == GNU's Not Unix RMS == Richard M. Stallman BTW == By the way Sources of Information and Help 8. I'm just starting GNU Emacs; how do I do basic editing? Type "C-h t" to invoke the self-paced tutorial. Typing just C-h is how to enter the help system. NOTE: your system administrator may have changed C-h to act like DEL. You can use M-x help-for-help instead to invoke help. To discover what key (if any) invokes help, switch to the *scratch* buffer with "C-x b", and type this: (mapcar 'key-description (where-is-internal 'help-command)) C-j (C-j stands for Control-J, ie., hold the control key and press J.) This will produce a list of the key sequences that invoke help. 9. How do I do XXX in GNU Emacs? There are several methods for finding out how to do things in Emacs. You should become familiar with the online documentation for Emacs. The complete text of the Emacs manual is available online in a hypertext format via the "Info" manual reader. Type "C-h i" to invoke Info. You can order a hardcopy of the manual from the FSF. You can list all of the commands whose names contain a certain word (actually which match a regular expression) using the "command-apropos" command. Type "C-h a" to invoke this command. You can list all of the functions and variables whose names contain a certain word using the "apropos" command. M-x apropos invokes this command. You may find that command-apropos and apropos are extremely slow on your system. This will be fixed in Emacs 19. If you can't wait that long, I can send you the "fast-apropos.el" file that contains the fix. This file also contains a "super-apropos" command that will list all the functions and variables whose documentation strings contain a certain word. There are many other commands in Emacs for getting help and information. To get a list of these commands, type "C-h C-h C-h". 10. Where can I get GNU Emacs on the net (or by snail mail)? Look in the files etc/DISTRIB and etc/FTP for information. If you don't already have GNU Emacs, see question 16. 11. Where can I get help in installing GNU Emacs? Look in the file etc/SERVICE for names of companies and individuals who will sell you this type of service. This file in the 18.55 distribution is not completely up to date. The imminent release of 18.56 will help that. An up-to-date version of the SERVICE file will be available (sometime) on prep.ai.mit.edu. (At last report this file was most recently updated on February 27, 1989!) See question 16 for how to retrieve this file. 12. How do I get a printed copy of the GNU Emacs manual? You can order a printed copy of the GNU Emacs manual from the FSF for $15. The price is $60 for a set of 6 manuals. The full source for the manual also comes with Emacs, if you're daring enough to try to print out this 300 page manual yourself. (We're talking about killing an entire tree here. This kind of printer usage can make you very unpopular. Besides, if you order it from the FSF, the price can be tax-deductible as a business expense.) Carl Witty writes: The Emacs manual is also available online in the Info system, which is available by typing "C-h i". In this form, it has hypertext links and is very easy to browse or search; many people prefer it to the printed manual. 13. Has someone written an GNU Emacs Lisp package that does XXX? Probably. A listing of Emacs Lisp packages, called the Lisp Code Directory, is being maintained by Dylan Kaufman . You can search through this list to find if someone has written something that fits your needs. (Question: does the Lisp Code Directory contain any references to things that aren't in the Emacs Lisp Archive, but have been posted?) This list is file "LCD-datafile.Z" in the Emacs Lisp Archive. (See question 14.) The files "lispdir.el.Z" and "lispdir.doc.Z" in the archive will help you use the list. 14. Where can I get GNU Emacs Lisp packages that don't come with Emacs? First, check the Lisp Code Directory to find the name of the package you are looking for. (See question 13). Then check local archives and the Emacs Lisp Archive to find a copy of the relevant files. Then, if you still haven't found it, you can send e-mail to the author asking for a copy. You can access the Emacs Lisp Archive via: Anonymous FTP: site: tut.cis.ohio-state.edu directory: /pub/gnu/emacs/elisp-archive filename: README.Z NOTE: Any files with names ending in ".Z" are compressed, and you should use "binary" mode in FTP to retrive them. I think you're supposed to send any submissions for the archive to Dave Brennan , but maybe you should send them to Dave Sill , I'm not sure. (No doubt, whichever one of them isn't supposed to receive submissions will get mad at me.) Before submitting anything, first read the file "guidelines.Z", which is available in the archive. 15. Where can I get documentation on GNU Emacs Lisp? Type "C-h f" to get the documentation for a function, "C-h v" for a variable. Also, as a popular USENET saying goes, "Use the Force, Read the Source". There is also a fairly comprehensive Emacs Lisp manual available. You can order it from the FSF for $50. You can also get the Texinfo source for the manual, if you are daring enough to try to print this 550 page manual out yourself. A set of Info files comes with the Texinfo source for the Emacs Lisp manual. (You could also create the Info files from the Texinfo source.) See question 20 for details on how to install these files. 16. What informational files are available? Ok, so this isn't a frequently asked question, but it should be! The following files are available in the "etc" directory of the GNU Emacs distribution, and also the latest versions are available individually via: Anonymous FTP: site: prep.ai.mit.edu directory: /pub/gnu/etc APPLE -- Special Report: Apple's New Look and Feel DISTRIB -- GNU Emacs Availability Information, including the popular "Free Software Foundation Order Form" FTP -- How to get GNU Software by Internet FTP or by UUCP GNU -- The GNU Manifesto INTERVIEW -- Richard Stallman discusses his public-domain UNIX-compatible software system with BYTE editors MACHINES -- Status of GNU Emacs on Various Machines and Systems MAILINGLISTS -- GNU Project Electronic Mailing Lists SERVICE -- GNU Service Directory SUN-SUPPORT -- includes the popular "Using Emacstool with GNU Emacs" These files are available in the "etc" directory of the GNU Emacs distribution: DIFF -- Differences between GNU Emacs and Twenex Emacs CCADIFF -- Differences between GNU Emacs and CCA Emacs GOSDIFF -- Differences between GNU Emacs and Gosling (Unipress??) Emacs COPYING -- GNU Emacs General Public License NEWS -- GNU Emacs News, a history of user-visible changes In addition, all of the above files are available directly from the FSF via e-mail. Of course, please try to get them from a local source first. These files are available from the FSF via e-mail: * GNU's Bulletin, June, 1990 -- includes: GNU'S Who What Is the Free Software Foundation? What Is Copyleft? GNUs Flashes Possible New Terms for GNU Libraries by Richard Stallman "League for Programming Freedom" by Michael Bloom and Richard Stallman Free Software Support GNU Project Status Report GNU Wish List GNU Documentation GNU Software Available Now Contents of the Emacs Release Tape Contents of the Pre-Release Tape Contents of the X11 Tapes VMS Emacs and Compiler Tapes How to Get GNU Software Freemacs, an Extensible Editor for MS-DOS Thank GNUs FSF Order Form * GNU Task List * GNU Coding Standards * Legal issues about contributing code to GNU * GNU Project Status Report 17. What is the current address of the FSF? Snail mail address: Free Software Foundation 675 Massachusetts Avenue Cambridge, MA 02139, USA Phone number: (617) 876-3296 E-mail addresses: gnu@prep.ai.mit.edu (probably read by Len Tower??) gnulists@prep -- what's the full list and the purpose for each address? 18. What is the current address of the LPF? Snail mail address: League for Programming Freedom 1 Kendall Square, Number 143 Post Office Box 9171 Cambridge, MA 02139, USA Phone number: (617) 492-0023 E-mail address: league@prep.ai.mit.edu 19. Where can I get the up-to-date GNU stuff? The most up-to-date official GNU stuff is normally kept on prep.ai.mit.edu and is available for anonymous ftp. See the files etc/DISTRIB and etc/FTP for more information. (To get copies of these files, see question 16.) 20. How do I install a piece of Texinfo documentation? First create Info files from the Texinfo files with M-x texinfo-format-buffer. There is also a program called "makeinfo" that provides better error checking and runs faster. Currently, it comes with the Emacs Lisp manual (which comes on the GNU Emacs tape). (For information about the Texinfo format, read the Texinfo manual which comes with Emacs. This manual also comes installed in Info format, so you can read it online.) Neither texinfo-format-buffer nor the makeinfo program install the resulting Info files in Emacs's Info tree. To install Info files: 1. Move the files to the "info" directory in the installed Emacs distribution. See question 6 if you don't know where that is. 2. Edit the file info/dir in the installed Emacs distribution, and add a line for the top level node in the Info package that you are installing. 21. What is the real legal meaning of the GNU copyleft? Randy Smith is planning to start a regular posting to gnu.announce (also the info-gnu mailing list) answering all of the interesting questions on this topic. In addition, RMS writes: The legal meaning of the GNU copyleft is less important than the spirit, which is that Emacs is a free software project and that work pertaining to Emacs should also be free software. "Free" means that all users have the freedom to study, share, change and improve Emacs. To make sure everyone has this freedom, pass along source code when you distribute any version of Emacs or a related program, and give the recipients the same freedom that you enjoyed. If you still want to find out about the legal meaning of the copyleft, please ask yourself if this means you are not paying attention to the spirit. 22. What are appropriate messages for gnu.emacs/gnu.emacs.bug/comp.emacs etc.? The file etc/MAILINGLISTS discusses the purpose of each GNU mailing-list. (See question 16 on how to get a copy.) For those which are gatewayed with newsgroups, it lists both the newsgroup name and the mailing list address. comp.emacs is for discussion of Emacs programs in general. This includes GNU Emacs along with various other implementations like JOVE, MicroEmacs, Freemacs, MG, Unipress, CCA, etc. Many people post GNU Emacs questions to comp.emacs because they don't receive any of the gnu.* newsgroups. Arguments have been made both for and against posting GNU-Emacs-specific material to comp.emacs. 23. Should I send questions directly to people who post a lot on the net, instead of posting myself? I don't know about the others, but please don't send such messages to me just because you don't want to disturb a lot of people. Send messages to individuals that concern things that individual has written. GNU Emacs, all its Variants, and other Editors 24. Where does the name "Emacs" come from? EMACS originally was an acronym for Editor MACroS. The first Emacs was a set of macros for the editor TECO on a PDP-10. (Is TECO the language or the name of the editor?) 25. What is the latest version of GNU Emacs? GNU Emacs 18.55. GNU Emacs 18.56 is coming out with some bug fixes, but no additional functionality. 26. When will GNU Emacs 19 be available? Good question, I don't know. For that matter, neither do the developers. Among other things, legal troubles have arisen. The latest could be 1992 or 1993, the earliest could be 1990. 27. What will be different about GNU Emacs 19? From the GNU's Bulletin: Version 19 approaches release with a host of new features: before and after change hooks; X selection processing (including CLIPBOARD selections); scrollbars; support for European character sets; floating point numbers; per-buffer mouse commands; interfacing with the X resource manager; mouse-tracking; Lisp-level binding of function keys; and multiple X windows (`screens' to Emacs). Thanks go to Alan Carroll and the people who worked on Epoch for generating initial feedback to a multi-windowed Emacs. Emacs 19 supports two styles of multiple windows, one with a separate screen for the minibuffer, and another with a minibuffer attached to each screen. More features of Version 19 are buffer allocation, which uses a new mechanism capable of returning storage to the system when a buffer is killed, and a new input system---all input now arrives in the form of Lisp objects. Other features being considered for Version 19 include: * Associating property lists with regions of text in a buffer. * Multiple font, color, and pixmaps defined by those properties. * Different visibility conditions for the regions, and for the various windows showing one buffer. * Incremental syntax analysis for various programming languages. * Hooks to be run if point or mouse moves outside a certain range. * Source-level debugging for Emacs Lisp. * Incrementally saving undo history in a file, so that recover-file also reinstalls buffer's undo history. * Static menu bars, and better pop-up menus. * A more sophisticated emacsclient/server model, which would provide network transparent Emacs widget functionality. 28. Is there an Emacs that has better mouse and X window support? Emacs 18 has some limited X Window System support, but there are problems. Emacs 19 will have amazing mouse and window support. Right now, there is a modified version of Emacs 18.55 called "Epoch" which has greatly improved mouse and window support. The latest version of Epoch is available via: Anonymous FTP: site: cs.uiuc.edu directory: ??? filename: epoch-3.2b (b stands for beta) NOTE: Epoch only works with window systems; it does not work on ordinary terminals. 29. Why should I use GNU Emacs instead of vi? Although vi is the default Unix editor and it is available on almost all Unix computers there are a number of reasons why you might want to use GNU Emacs: * GNU Emacs comes with a complete manual available online. * GNU Emacs has numerous other help facilities: a tutorial; commands to describe functions, variables, keybindings, major modes; commands to look up commands, functions, and variables by patterns in their names. * GNU Emacs does multiple windows even on dumb terminals. You can look at many different places in one file in different windows. You can split the screen horizontally or vertically, as many times as there is space on the screen. * GNU Emacs runs under several window systems and has mouse support. (Emacs 19 will have all of this very well integrated.) * GNU Emacs has less mode confusion than vi, where you have to remember whether or not you're in "insert" mode. Most new users find this less confusing. (Please folks, don't try to tell people that Emacs is "modeless". That's just plain false.) * GNU Emacs can edit numerous files simultaneously. (Question: Can vi have unsaved changes in memory for more than one file at a time?) * GNU Emacs correctly edits binary files, including files with NUL characters (ASCII code 0) and files with arbitrarily long lines. * GNU Emacs saves up-to-date "autosave" copies of files on which you are working every 300 keystrokes. (The number 300 is user-configurable.) * GNU Emacs keeps backup copies of files it saves, and can be told to keep any number of older versions of a file. * GNU Emacs provides better undo capabilities. Currently Emacs can undo ~8000 (right?) characters worth of insertions and deletions, and Emacs 19 will have unlimited undo capability. (NOTE: Be careful, don't presume you can undo huge changes to a megabyte size file.) * GNU Emacs saves the last 30 items you have deleted for later recall. (The number 30 is user-configurable.) * GNU Emacs allows *all* of its keybindings to be changed. (Except see the warning in question 41.) * GNU Emacs has an extension language, Emacs Lisp, and in fact is largely written in this language, so it is easy to change (and fix if necessary). * GNU Emacs has an interactive debugger for Emacs Lisp. * GNU Emacs comes with source code so you aren't vulnerably dependent on your vendor. * GNU Emacs is free and can be shared with anyone. * GNU Emacs provides a more complete development environment. For example, M-x compile, M-x grep, M-x shell, etc. * GNU Emacs provides many mechanisms to reduce your need to remember and type long names. For example, abbrevs, dynamic abbrevs (look for similar things in the buffer), symbol completion, filename completion, etc. * GNU Emacs provides major modes that are custom tailored for each different editing need, for example: C, C++, Indented Text, Outline, TeX, Nroff, etc. (Does vi have language sensitive modes?) * GNU Emacs Lisp packages have already been written to do almost any imaginable task. * GNU Emacs or other Emacs variants are available on far more types of computers than vi. In addition, more and more programs are using Emacs-style keybindings. * GNU Emacs comes on some Unix systems instead of vi. GNU Emacs will come with the next release of BSD Unix. * GNU Emacs comes with major modes to emulate vi. (vi can't emulate Emacs.) * GNU Emacs has shell mode. You can run shell commands in an Emacs buffer, call up previous commands, cut and paste command output, review results that have scrolled off the screen, etc. * GNU Emacs has incremental search. This minimizes the number of keys you need to press to find a string in a buffer. You can usually find the exact occurrence of a 20 character identifier you are looking for in 5 or 6 keystrokes. You can also incrementally search for a regular expression. * GNU Emacs has superior, configurable, language sensitive indentation. (vi has ":1,$!cb", but this is slower and less flexible.) * GNU Emacs has "query replace". This is like a global search and replace, except Emacs will show you each occurrence and ask you what to do. You can even edit the occurrence without interrupting the query replace operation. * GNU Emacs has a spell checker. * GNU Emacs can "fill" paragraphs, either manually or automatically. This evens up the length of the lines. * GNU Emacs has a status line for every window showing the file name, relative position within the file, if the file is modified, etc. (This is all user-configurable.) * GNU Emacs has support for reading and sending e-mail without ever leaving Emacs. * GNU Emacs has rectangular cut and paste --- this works on columns of text. * GNU Emacs can recognize sentences and cut and paste them. * GNU Emacs has dired, a file directory editor. * GNU Emacs uses the "point" and "mark" for cutting and pasting and other editing commands. (This is easier than vi.) * GNU Emacs makes it easy to copy text from one file to another. * GNU Emacs can be told to make sure there is a newline at the end of files it saves (or to ask the user). * GNU Emacs updates the screen with every keystroke. (Some versions of vi do not update deletes while in insert mode.) * GNU Emacs prompts for commands that need parameters, thus you don't need to memorize syntax. There are also some reasons why you might prefer vi: * vi comes with almost every Unix system, while GNU Emacs doesn't. (This means you'll have to use vi while you're building and installing GNU Emacs.) * vi starts up much, much, much faster. With Emacs, you should keep an Emacs job running all the time to avoid this problem. This can be a problem if you don't have job control or a window system, or if you don't read your e-mail or news with Emacs and you want to edit messages you're sending. * At the single-user level, you may have to use vi or ed (which shares much of vi's command syntax.) * Setting defaults for Emacs may require more knowledge than for vi. * The installed Emacs takes more file space than vi. * Emacs has no real equivalent to vi's "dot" repeat command. * Emacs depends heavily on the availability of a Meta key. Otherwise, pressing ESC all the time can be a pain. * Some people don't like having to press either the Control key or the Meta key to invoke commands. * vi has a ":set list" command which will show you non-printable characters, even TAB characters. In Emacs, there is no way to distinguish between TAB and SPC characters without moving the cursor over them. * vi has a built-in parentheses matching command. (See question 91.) (Steve, do you want to write up a really good comparison of vi and GNU Emacs like etc/DIFF, etc/CCADIFF, and etc/GOSDIFF? This is getting much too long for a FAQ list, I'd rather just refer to another document.) 30. How do I get Emacs on my PC? GNU Emacs won't run on a PC directly under MS-DOS. You can try a variety of similar programs such as MG, MicroEmacs, Freemacs, etc. Russ Nelson describes Freemacs: * Freemacs is free, and it was designed from the start to be programmable. * Freemacs is the only IBM-PC editor that tries to be like GNU Emacs. * Freemacs can only edit files less than 64K in length. Carl Witty writes about Freemacs: Better is Freemacs, which follows the tradition of ITS and GNU Emacs by having an full, turing-complete extension language which is incompatible with everything else. In fact, it's even closer to ITS Emacs than GNU Emacs is, because Mint (Freemacs' extension language) is absolutely illegible without weeks of study, much like TECO. You can get Freemacs several ways: 1. Anonymous FTP: site: simtel20.army.mil, directory: PD: site: grape.ecs.clarkson.edu [128.153.13.196], directory: /e/freemacs 2. E-mail: address: archive-server@sun.soe.clarkson.edu, or archive-server%sun.soe@omnigate (BITNET), or {smart-host}!sun.soe.clarkson.edu!archive-server (UUCP) subject: ??? probably ignored body: help 3. Snail mail: address: Russell Nelson, 11 Grant St., Potsdam, NY 13676 Send $15 copying fee, and specify preferred floppy disk format: 5.25", 1.2 Meg, or 5.25", 360K, or 3.50", 720K Binding Keys to Commands 31. Why does my key binding fail? Most likely, it failed because "ESC [" was already defined. Do (define-key esc-map "[" nil) first. 32. Why doesn't this [terminal or window-system setup] code work in my .emacs file, but it works just fine after Emacs starts up? This is because you're trying to do something in your .emacs file that needs to be postponed until after the terminal/window-system setup code is loaded. This is a result of the order in which things are done during the startup of Emacs. In order to postpone the execution of Emacs Lisp code until after the terminal/window-system setup, set the value of the variable-at-point term-setup-hook or window-setup-hook to be a function which does what you want. See question 67 for a complete explanation of what Emacs does every time it is started. Here is a simple example of how to set term-setup-hook: (setq term-setup-hook (function (lambda () (if (string-match "^vt220" (or (getenv "TERM") "")) ;; Make vt220's "Do" key behave like M-x: (define-key CSI-map "29~" 'execute-extended-command))))) 33. How do I bind function keys (F1, F2, etc.) on terminal/machine XXX? 34. How do I use function keys under X Windows? Johan Vromans writes: There are a number of tricks that can be helpful. The most elegant solution, however, is to use the function 'x-rebind-key'. This function is commented out in the source for good reasons - it's buggy. It is rather easy to replace this function with the function epoch:rebind-key from the Epoch distribution. After implementing this, all keyboard keys can be configured to send user definable sequences, e.g. (x-rebind-key "KP_F1" 0 "\033OP") This will have the keypad key PF1 send the sequence \eOP, just like an ordinary VTxxx terminal. Another method is to handle the keys in the c source. Although this may be slightly more efficient, it is much less flexible. Finally, some people have established a convention to have the special keys send a sequence of characters that indicate the key and its modifiers instead of a plain escape sequence. This is also a good method. The advantage of sending the plain escape sequences is that you require only one setup for Emacs running under X and on normal terminals, e.g. (x-rebind-key "KP_F1" 0 "\033OP") will have key PF1 send \eOP, and, probably in another setup file: (global-set-key "\eOP" 'specific-function) to bind PF1 to a function. The last statement applies for normal VTxxx terminal also. 35. How do I bind keys to functions (in general)? 36. How do I tell what characters my function keys emit? Use this function by Randal L. Schwartz : (defun see-chars () "Displays characters typed, terminated by a 3-second timeout." (interactive) (let ((chars "") (inhibit-quit t)) (message "Enter characters, terminated by 3-second timeout.") (while (not (sit-for 3)) (setq chars (concat chars (list (read-char))) quit-flag nil)) ; quit-flag maybe set by C-g (message "Characters entered: %s" (key-description chars)))) Problems with Key Bindings and Input 37. Why does Emacs spontaneously go into "I-search:" mode? Your terminal (or something between your terminal and the computer) is sending C-s and C-q for flow control, and Emacs is receiving these characters and interpreting them as commands. (The C-s character normally invokes the isearch-forward command.) 38. What do I do if my terminal is sending C-s and C-q for flow control and I can't disable it? (set-input-mode nil t) 39. How do I make Emacs use C-s and C-q for flow control instead of for commands? Same answer as previous question. 40. How do I use commands bound to C-s and C-q (or any key) if these keys are filtered out? I suggest swapping C-s with C-\ and C-q with C-^: (swap-keys ?\C-s ?\C-\\) (swap-keys ?\C-q ?\C-^) See question 41 for the implementation of swap-keys. 41. How do I "swap" two keys? When Emacs receives a character, you can make Emacs behave as though it received another character by setting the value of keyboard-translate-table. The following Emacs Lisp will do this for you, allowing you to "swap" keys. WARNING: the value of C-g (7) is hard coded in several places both before and after the translation specified by keyboard-translate-table is carried out. Thus, swapping C-g with another key may cause problems; rebinding C-g may also cause problems. (Well, I've never done it, so I don't know for sure.) (defun swap-keys (key1 key2) "Swap keys KEY1 and KEY2 using map-key." (map-key key1 key2 t) (map-key key2 key1)) (defvar map-keys-alist nil "Association list of key mappings currently in effect. If (FROM . TO) is an element, that means key FROM is currently mapped to TO.") (defun map-key (from to &optional no-update) "Make key FROM behave as though key TO was typed instead. If optional argument NO-UPDATE is non-nil, the key-mapping does not take effect until a subsequent map-key or unmap-key." (let ((alist-entry (assq from map-keys-alist))) (if alist-entry (setcdr alist-entry to) (setq map-keys-alist (cons (cons from to) map-keys-alist)))) (or no-update (map-keys-update))) (defun unmap-key (key) "Undo any mapping of key KEY." (setq map-keys-alist (delq (assq key map-keys-alist) map-keys-alist)) (map-keys-update)) ;; Makes keyboard-translate-table reflect the key mappings in ;; map-keys-alist. (defun map-keys-update () (if (null map-keys-alist) ;; Emacs runs fasted if keyboard-translate-table is nil (setq keyboard-translate-table nil) (let ((max-key-mapped ;; Find the mapped key with largest value (apply 'max (mapcar (function (lambda (x) (car x))) map-keys-alist))) (i 0)) ;; keyboard-translate-table doesn't have to be any longer than ;; necessary. This speeds up Emacs. (setq keyboard-translate-table (make-string (1+ max-key-mapped) 0)) (while (<= i max-key-mapped) (aset keyboard-translate-table i (or (cdr (assq i map-keys-alist)) i)) (setq i (1+ i)))))) 42. Why does the "Backspace" key invoke help? The Backspace key (on every keyboard I've used) sends ASCII code 8. C-h sends the same code. In Emacs by default C-h invokes "help-command". The easiest solution to this problem is to use C-h (and Backspace) for help and DEL (the Delete key) for deleting the previous character. For some people this solution may be problematic: 1. They normally use Backspace outside of Emacs for deleting the previous character typed. This can be solved by making DEL be the command for deleting the previous character outside of Emacs. This command will do this on many Unix systems: stty erase ^? 2. The person may prefer using the Backspace key for deleting the previous character because it is more conveniently located on their keyboard or because they don't even have a separate Delete key. In this case, the best solution is to swap C-h and DEL: (swap-keys ?\C-h ?\C-?) See question 41 for the implementation of swap-keys. 43. How do I type DEL on PC terminal emulators? Someone whose name I forgot wrote: Most PCs have deficient keyboards that don't have both Backspace and Delete keys. Whether C-h (backspace) or DEL is generated by the "Backspace" key varies from one terminal emulator to another. If you're lucky, you can reconfigure the keyboard so that it generates DEL. If not, you will have to hunt to figure out what keystroke will do it --- possibilities include various shifted and controlled versions of "Backspace", the "Del" key on the numeric keypad (which might depend on "Shift" or "NumLock"), or perhaps C-? (Control-?). If this is too hard, you may want to swap the delete key with some other key. See question 42. Building/Installing/Porting Emacs and Machine/OS-Specific Bugs: 44. Why do I get an "f68881_used undefined" error, when I build Emacs on my Sun 3? Barry A. Warsaw writes: Some of the code that is being linked on the "ld" line of emacs' build command has been compiled with the -f68881 option. Most common reason is that you're linking with X libraries which were built with -f68881 option set. You need to either remove all dependencies to the 68881 (may mean a recompile of the X libraries with -fswitch or -fsoft option), or you need to link emacs with the 68881 startup file /usr/lib/Mcrt1.o. Make this change to src/ymakefile: change: #define START_FILES crt0.o to: #define START_FILES crt0.o /usr/lib/Mcrt1.o The order of these start files is critical. 45. Why does Emacs crash under SunOS 4.1? There is a bug in the "localtime" routine supplied with SunOS 4.1. A private function called by tzsetwall zeroes the byte just past an eight byte region it mallocs. This corrupts GNU malloc's memory pool. Put "#define SYSTEM_MALLOC" in src/config.h. Or, for the purists: Put "#define SUNOS_LOCALTIME_BUG" in src/config.h and apply the following patch to src/malloc.c. (Patch by Eirik Fuller .) >*** malloc.c~ Fri Apr 7 22:12:10 1989 >--- malloc.c Tue May 8 07:07:22 1990 >*************** >*** 476,482 **** >--- 476,487 ---- > multiple of 8, then figure out which nestf[] area to use. > Both the beginning of the header and the beginning of the > block should be on an eight byte boundary. */ >+ #ifdef SUNOS_LOCALTIME_BUG >+ /* SunOS 4.1 localtime scribbles on the ninth byte. */ >+ nbytes = (n + ((sizeof *p + 15) & ~15) + EXTRA + 15) & ~15; >+ #else > nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7; >+ #endif > { > register unsigned int shiftr = (nbytes - 1) >> 2; > 46. Why does Emacs occasionally cause segmentation faults and machine panics on my DECstation 3100? Bruce Cole writes: > We're running Emacs 18.54 on an Ultrix Risc DECsystem 5400. Three > times we've had the machine hang with the following message: > > panic: tblmod on invalid pte > > Ultrix support tells us this is caused by Emacs. Has anyone > experienced this? DEC says it only happens on RISC boxes. This is due to a MIPS specific Ultrix kernel bug. I sent DEC a description of the bug with a bug fix. The Kernel bug manifests itself with emacs since emacs uses a non-standard data start address on Ultrix MIPS machines. I haven't often seen emacs cause MIPS machines to panic. Usually you just see one of the following errors when you try to start up emacs: segmentation fault (core dumped) emacs: Bad address Out of memory data size rlimit exceeded, pid 6523, process tcsh (for example) Until DEC fixes their kernel, you can avoid the bug by changing the data start address used by emacs. > I have built two newer versions of gnu emacs and it still happens. I > should also mention that these faults happen quite rarely to some > users (I may see it once a month), while other users see it a few > times a week or even daily! The problem only occurs when a MIPS machine is doing a lot of paging. Users who don't cause their workstation to page will not see this problem. Patch to GNU Emacs 18.55: >*** m-pmax.h Thu Jun 8 11:53:55 1989 >--- m-pmax.h.new Mon Jul 9 10:21:21 1990 >*************** >*** 1,3 **** >--- 1,7 ---- > #include "m-mips.h" > #undef LIBS_MACHINE > #undef BIG_ENDIAN >+ #undef LD_SWITCH_MACHINE >+ #undef DATA_START >+ #define DATA_START 0x10000000 >+ #define DATA_SEG_BITS 0x10000000 (I saw another version of this patch that doesn't have the line undeffing LD_SWITCH_MACHINE. Does this make a difference?) 47. How do I get Emacs running on VMS under DECwindows? Johan Vromans writes: Getting Emacs to run on VMS with DECwindows requires a number of changes to the sources. Fortunately this has been done already. Joshua Marantz did most of the work for Emacs 18.52, and the mods were ported to 18.55 by Johan Vromans . Also included is the handling of DEC's LK201 keyboard. You need to apply the changes to a fresh Emacs 18.55 distribution on a Unix system, and then you can copy the sources to VMS to perform the compile/link/build. The set of changes have been posted a number of times three times the last 12 months, so they should be widely available. 48. Why doesn't Emacs work right on a SPARCstation? (Could someone send me a better description of the symptoms ...) I don't know, but have been told this patch fixes it: (Patch by Michael Meissner ?) >*** dist-18.55.dist/src/alloc.c Mon Feb 13 05:23:35 1989 >--- dist-18.55/src/alloc.c Mon Nov 27 23:30:13 1989 >*************** >*** 665,673 **** > #define NSTATICS 200 > >- char staticvec1[NSTATICS * sizeof (Lisp_Object *)] = {0}; >- > int staticidx = 0; > > #define staticvec ((Lisp_Object **) staticvec1) > > /* Put an entry in staticvec, pointing at the variable whose address is given */ >--- 665,676 ---- > #define NSTATICS 200 > > int staticidx = 0; > >+ #ifdef __GNUC__ >+ Lisp_Object *staticvec[NSTATICS] = {0}; >+ #else >+ char staticvec1[NSTATICS * sizeof (Lisp_Object *)] = {0}; > #define staticvec ((Lisp_Object **) staticvec1) >+ #endif > > /* Put an entry in staticvec, pointing at the variable whose address is given */ (Does anyone understand why one might want to declare staticvec as an array of char instead of an array of LispObject?) 49. Why do shells started from Emacs suspend themselves on a SPARCstation? (Is this a problem with 18.55?) I have been told this patch fixes the problem: (Patch by Eirik Fuller ?) >*** /tmp/,RCSt1a12635 Fri Jul 6 11:29:10 1990 >--- process.c Sat Jun 16 14:04:55 1990 >*************** >*** 1031,1036 **** >--- 1031,1039 ---- > int j = open ("/dev/tty", O_RDWR, 0); > ioctl (j, TIOCNOTTY, 0); > close (j); >+ #ifndef USG >+ setpgrp (0, 0); >+ #endif > } > #endif /* TIOCNOTTY */ > 50. Why won't Emacs compile with OpenLook? (Is that the problem, that it won't compile?) Try this patch: >*** dist-18.55.dist/src/x11term.c Wed Aug 2 21:56:42 1989 >--- dist-18.55/src/x11term.c Fri Jul 13 19:22:32 1990 >*************** >*** 1213,1216 **** >--- 1213,1218 ---- > #endif /* not sun */ > >+ static XComposeStatus status; >+ > internal_socket_read(bufp, numchars) > register unsigned char *bufp; >*************** >*** 1223,1227 **** > BLOCK_INPUT_DECLARE (); > XEvent event; >- XComposeStatus status; > KeySym keysym; > >--- 1225,1228 ---- >*************** >*** 1330,1334 **** > nbytes = XLookupString (&event, > mapping_buf, 20, &keysym, >! 0); > /* Someday this will be unnecessary as we will > be able to use XRebindKeysym so XLookupString >--- 1331,1335 ---- > nbytes = XLookupString (&event, > mapping_buf, 20, &keysym, >! &status); > /* Someday this will be unnecessary as we will > be able to use XRebindKeysym so XLookupString Weird/Confusing Problems: 51. Does Emacs have problems with files larger than 8 Megs? Most installed versions of GNU Emacs will use 24 bit signed integers (and 24 bit pointers!) internally. This limits the file size that Emacs can handle to 8388608 bytes. Leonard N. Zubkoff writes: Putting the following two lines in src/config.h before compiling Emacs allows for 26 bit integers and pointers: #define VALBITS 26 #define GCTYPEBITS 5 See question 52 for an explanation. 52. Why does Emacs use 24 bit integers and pointers? David Gillespie writes: Emacs is largely written in a dialect of Lisp; Lisp is a freely-typed language in the sense that you can put any value of any type into any variable, or return it from a function, and so on. So each value must carry a "tag" along with it identifying what kind of thing it is, e.g., integer, pointer to a list, pointer to an editing buffer, and so on. Emacs uses standard 32-bit integers for data objects, taking the top 8 bits for the tag and the bottom 24 bits for the value. So integers (and pointers) are somewhat restricted compared to true C integers and pointers. Emacs uses 8-bit tags because that's a little faster on byte-oriented machines, but there are only really enough tags to require 6 bits. See question 51 to find how to recompile Emacs with 6-bit tags and 26-bit integers and pointers if space is at a premium for you. 53. Why does Emacs start up using the wrong directory? Most likely, you have an environment variable named PWD that is set to a value other than the name of your current directory. This is most likely caused by using two different shell programs. "ksh" and (some versions of) "csh" set and maintain the value of the PWD environment variable, but "sh" doesn't. If you start sh from ksh, change your current directory inside sh, and then start Emacs from inside sh, PWD will have the wrong value but Emacs will use this value. See question 67. 54. How do I edit a file with a "$" in its name? When entering a filename in the minibuffer, type "$$" instead. 55. Why does Shell mode lose track of the shell's current directory? (has no way of knowing when shell actually changes directory, tries to guess by recognizing cd commands) 56. Why doesn't Emacs expand my aliases when sending mail? Separate multiple addresses with commas. Emacs normally only reads .mailrc once per session. (At what point???) If you edit .mailrc, type "M-ESC (build-mail-aliases) RET" manually. 57. Why doesn't setting default-directory always work? There is a separate value of default-directory for each Emacs buffer. The value in the current buffer is the one that is used. 58. Why does my change to load-path not work? If you added file names with tildes (~) in them to your load-path, you'll need to do something like this: (setq-default load-path (mapcar 'expand-file-name load-path)) 59. Why does the cursor always go to the wrong column when I move up or down one line? You have inadvertently typed "C-x C-n" (set-goal-column) which sets the "goal-column" to the column where the cursor was. To undo this type "C-u C-x C-n". If you make this mistake frequently, you might want to unbind this command by doing (define-key ctl-x-map "\C-n" nil). 60. Why don't the command line switches documented in the man page work? The "man page", ie. the file etc/emacs.1, hasn't been updated in a while. The command line switches that it says work with X Windows are for X10. See question 67 for details on what switches are available using X11. 61. Why is catch up slow in Gnews/GNUS? (marking crosspostings read) 62. Why can't I do M-x set-variable XXX? set-variable uses read-variable to get the name of the variable from the user. read-variable won't accept the names of variables that are not considered "user variables". A user variable is one whose documentation string begins with an asterisk. For example, the documentation string of default-directory doesn't begin with an asterisk. You could also use "setq", but since setq isn't a command, you can't call it from M-x. Configuring Emacs for yourself: 63. How do I set up a .emacs file properly? I'm going to be sending out a sample .emacs file in a separate message. It will most likely be a combination of several of the sample .emacs files I've seen. If you have a *well-commented* piece of Emacs Lisp that you think should go into this sample file, send it to me. 64. How do you debug a .emacs file? First start Emacs with the "-q" command line option. Then, in the *scratch* buffer, type the following: (setq debug-on-error t) C-j (load-file "~/.emacs") C-j (C-j stands for Control-J, ie., hold the control key and press J.) If you have an error in your .emacs file, this will invoke the debugger when the error occurs. If you don't know how to use the debugger do (setq stack-trace-on-error t) instead. WARNING: this will not discover errors caused by trying to do something that requires the terminal/window-system initialization code to have been loaded. See question 32. 65. How do I turn on abbrevs by default in mode XXX? Put this in your .emacs file: (condition-case () (read-abbrev-file nil t) (file-error nil)) (setq XXX-mode-hook (function (lambda () (setq abbrev-mode t)))) 66. Can I make an abbrev invoke a command as part of its expansion? Here's an (incomplete) example of the basic technique. For more information, read the documentation (and the source code) on Abbrevs. (define-abbrev-table 'c-mode-abbrev-table '(("if" "if" c-space-hook 112))) (defun c-space-hook () (cond ((and (eq this-command 'self-insert-command) (eq last-command-char ? ) (not (c-in-comment)) (not (c-in-string))) (insert ? ) (insert-parentheses nil) (setq unread-command-char ?\C-?)))) 67. What does Emacs do every time it starts up? This question is not itself frequently asked, but helps to answer other questions. Here is a complete explanation of the order in which things are done during startup. 1. These command line switches are handled, only if they appear before all other command line arguments, and only if they appear in this order: "-map". Only under VMS. Instead of "undumping", under VMS the contents of a dump file are mapped over a section of memory (very quickly initializing lots of variables). "-t". The next argument is treated as the name of a terminal to use instead of whatever is connected to the stdin, stdout, and stderr FILE pointers. "-display" (synonym: "-d"). The next argument is treated as the name of an X Window System server with which to connect. This overrides the DISPLAY environment variable. "-nw". This means don't connect to an X Window server even if the DISPLAY environment variable was set or the "-display" switch was specified. Instead, Emacs talks to a regular dumb terminal. "-batch". Emacs is noninteractive. The variable "noninteractive" is t. This disables any full screen interaction either with a dumb terminal or with a window system. In addition, Emacs will die after processing all command line arguments. All of Emacs's internal data structures are initialized between steps 2 and 5. 2. The "*scratch*" buffer is created and its value of default-directory is set from the result of calling the "getwd" library routine. (getwd does what the "pwd" program does.) 3. If X11 is being used, Emacs determines the name under which it looks for X resource values. (I haven't checked how it does this under X10.) 1. If there is a "-rn" command line switch, it is handled now, no matter where it is on the command line. (Later it will be processed again and ignored.) The next argument is used as Emacs's resource name. 2. If the "-rn" switch was missing, Emacs looks for the WM_RES_NAME environment variable. 3. If neither of the previous two steps succeed, Emacs uses the filename with which it was invoked as its resource name. 4. If X11 is being used, these command line switches are handled now, no matter where they appear in the command line. (Under X10, they are not handled until step 13.) WARNING: this can cause strange interactions with the processing of the remaining command line arguments in step 13. In addition, under both X11 and X10, X resources (ie. the stuff in an .Xdefaults file) are handled now. Command line switches take precedence over resources. After each command line switch are given the equivalent resource names in this format: (X10 name / X11 instance name / X11 class name). "-r". Reverse video. (ReverseVideo/reverseVideo/ReverseVideo) "-font" (synonym: "-fn"). Font. (BodyFont/font/Font) "-wn". Window name (X11 only). (/title/Title) "-in". Icon name (X11 only). (/iconName/Title) "-i". Use built-in icon bitmap. (BitMapIcon//) "-b". Border width (in pixels). (BorderWidth/borderWidth/BorderWidth) "-ib". Internal border width (in pixels) (default: 1). (/internalBorder/BorderWidth) "-geometry" (synonym: "-w"). Window shape and size. "-geometry" is X11 only, but its synonym "-w" was available under X10. (/geometry/Geometry) Color options only: "-fg". Foreground color. (Foreground/foreground/Foreground) "-bg". Background color. (Background/background/Background) "-bd". Border color. (Border/borderColor/BorderColor) "-cr". Cursor color. (Cursor/cursorColor/Foreground) "-ms". Mouse pointer color. (Mouse/pointerColor/Foreground) In addition, under X10, the resource "Keymap" was handled now. 5. If your Emacs isn't "dumped", the default Lisp libraries are "loaded" now. 6. Emacs enters a "recursive edit". The first time Emacs does a recursive edit, steps 7 through 15 are followed, and then Emacs enters its normal editing mode. 7. If the environment variable PWD exists, the value of default-directory in the *scratch* buffer is set to the value of PWD. This often causes problems and confusion when the value of PWD doesn't actually contain the pathname of the current directory. 8. Now the "-no-init-file" (synonym: "-q") and "-user" (synonym: "-u") command line switches are handled. They must follow the switches mentioned in step 1, and must precede any other command line arguments. Actually, both of these options can be specified; whichever is last on the command line wins. 9. The user's ".emacs" file is loaded now, if the -no-init-file option was not specified. If the -user option was specified, that user's .emacs file is loaded instead. A user's .emacs file is a file named ".emacs" in the user's "home" directory. If no such file exists, this step has no effect. 10. The system wide "default" file is loaded now, if the variable inhibit-default-init is nil. The user can set this variable in the .emacs file to skip this step. 11. If the *scratch* buffer still exists now, the value of initial-major-mode is called as a function in this buffer. Normally, this puts this buffer in Lisp Interaction mode. 12. Now the terminal/window-system setup file is loaded. The name of this file is determined as follows: 1. It starts with the value of term-file-prefix. Normally this is "term/", but the user can set it to another value. If this variable is nil, this entire step is skipped. 2. For a window system, the prefix is followed by the name of the value of the variable window-system, followed by "-win". For X Windows, this means the name is "term/x-win". 3. For a terminal, the prefix is followed by the value of the environment variable TERM, for example, "term/vt200". If Emacs cannot find such a file to load, it retries by stripping off suffixes that begin with a hyphen. For example, if TERM is "vt200-40", first Emacs will try "term/vt200-40", and if that fails it will try "term/vt200". 13. The rest of the command line arguments are handled at this point, in the order they appear: "-funcall" (synonyms: "-f", "-e"). The next argument is treated as the name of a function, which is called with no arguments. "-load" (synonym: "-l"). The next argument is treated as the name of a file to load. NOTE: the value of the variable load-path will be restored after this file is done loading. Thus, trying to change load-path in such a file will fail!! "-kill". When this argument is handled, Emacs kills itself. "+DDD", where D is a digit. DDD is used as a line number to go to. When the next ordinary file argument on the command line is handled, Emacs positions point in that file on line DDD. An ordinary filename. Emacs edits this file using the function find-file. If the filename is not an "absolute" filename, it is expanded relative to the value that default-directory in the *scratch* buffer had at the beginning of step 11. The buffer visiting this file becomes the current buffer. "-insert" (synonym: "-i"). The next argument is treated as the name of a file. This file is inserted in the current buffer. Initially, this is the *scratch* buffer. Otherwise it is the buffer visiting the file most recently specified on the command line. Other command line switches may have been created by modifying the value of the variable command-switch-alist. If X Windows is being used, all X-specific switches mentioned above in steps 3 and 4 will be processed. Under X11, they will have already been handled, and will be ignored now. Under X10, they are being handled for the first time. 14. The values of the variables term-setup-hook and window-setup-hook are called as functions with no arguments, in the order listed. 15. If the user did not specify any of the command line options handled in step 13, and the variable inhibit-startup-message is still nil, the familiar Emacs startup message is displayed. 68. What are the valid X resource settings (ie., stuff in .Xdefaults file)? See question 67. WARNING: Don't pay any attention to the documentation in etc/XDOC or etc/emacs.1. It's way out of date. 69. How do I turn down the bell volume in Emacs running under X Windows? (Will whoever posted a solution to this before send it to me please?) Emacs Lisp programming: 70. What dialect of Lisp is Emacs Lisp? It's the dialect of Lisp called Emacs Lisp. (No joke!) It's also called Elisp or E-lisp. 71. How close is Emacs Lisp to Common Lisp? Pretty far. GNU Emacs Lisp is case-sensitive, uses dynamic scoping, doesn't have packages, doesn't have multiple return values, doesn't have reader macros, etc. For people used to Common Lisp, some of the functions in Common Lisp that are not in Emacs Lisp by default are provided in the file lisp/cl.el. There is a Texinfo manual describing these functions in man/cl.texinfo. 72. How do I execute a piece of Emacs Lisp code? C-j in the "*scratch*" buffer, M-C-x in Emacs-Lisp mode, "C-x C-e" in any buffer, M-ESC. If it's in a file, use M-x load-file or the function load in a Lisp form. 73. How do I implement a mark stack? Read the source code in lisp/simple.el in the GNU Emacs distribution for details on how to do this. (Really!) 74. What is a mark(er)? A marker is a magic number that is incremented and decremented as one edits the text around it. For that reason, having a lot of marks in a buffer can slow down editing. So when you're done with a mark, do a (set-marker mark nil) where "mark" is the marker. 75. What is a "function"? (Someone want to write this one?) 76. How do I make a set of operations fully local to a region? Use narrow-to-region inside of save-restriction. 77. How can I highlight a region? (with great difficulty) (can't except under X versions, maybe in Emacs 19) (actually, you can, but it's slow and the highlighting disappears if you scroll or redraw the screen.) 78. How do I change Emacs's idea of the tab character's length? Example: (setq default-tab-width 10). 79. How do I negate a regular expression (regexp)? You can negate a character class like "[A-Z]" by using "^" as in "[^A-Z]". You can negate a single syntax code regexp like "\\sw" by using "\\S" as in "\\Sw". In theory, any regular expression can be negated, but in practice it is difficult. One thing that interferes with easy negation of regexps is the way the implementation keeps track of where each subexpression matched. (That is, the way match-beginning and match-end can tell you where pairs of \( and \) matched.) 80. Why can't I use \sw in a character class like [\sw\s_]? Because that's the way Emacs's implementation of regular expression matching works. Since you want to do this anyway, here are some solutions: 1. Temporarily change the syntax table while you are searching. Thus, you can make \sw match any class of characters you want. This is the technique I use in searching for programming language identifiers, where one usually wants to match what [\sw\s_] should match (or [^\sw\s_]). 2. Explicitly list each character in the class you want to match. Ugh! 3. Modify the source code in src/regex.c so that [\sw\s_] works. :-) 81. What is the difference between (interactive "P") and (interactive "p")? The value that is a result of "P" can be a list, a symbol, or an integer; the value that is a result of "p" is always an integer: Prefix keys typed result of: "P" "p" nothing nil 1 "M-1" 1 1 "C-u 1" 1 1 "M--" '- -1 "C-u -" '- -1 "C-u" (4) 4 "C-u C-u" (16) 16 Carrying Out Common Tasks: 82. How do I insert ">"'s in the beginning of every line in a buffer? Type "M-x replace-regexp RET ^ RET > RET". ("replace-regexp" can be shortened to "repl TAB r".) To do this only in the region, type "C-x n M-x replace-regexp RET ^ RET > RET C-x w". (You're going to remember that, right?) 83. How do I insert "_^H" characters before each character in a paragraph to get an underlined paragraph? M-x underline-region. 84. How do I find the next "long line", ie a line with more than 80 characters? Type "M-x re-search-forward RET C-u 81. RET". ("re-search-forward can be shortened to "re- TAB f".) NOTE: this doesn't realize that TAB characters can occupy more than one "space". 85. How do I force the searching commands to remember the last search string? (Answer still needs to be written.) 86. How do I repeat a command as many times as possible? Make a keyboard macro that invokes the command and then type "M-0 C-x e". 87. How do I search for an unprintable (8-bit) character that appears in a buffer as \237? C-s C-q 2 3 7 (This assumes the value of search-quote-char is 17 (C-q).) 88. How do I control Emacs's case sensitivitiy when searching/replacing? (Feel free to write the text for this answer ...) 89. How do I tell Emacs to automatically indent a new line to the indentation of the previous line? M-x indented-text-mode. (This is a major mode.) 90. How do I make Emacs "typeover" or "overwrite" when I type instead of always inserting? M-x overwrite-mode. (This is a minor mode.) 91. How do I show which parenthese matches the one I'm looking at? If you're looking at a right parenthese (or brace or bracket) you can delete it and reinsert it. Here is some Emacs Lisp that will make the % key show the matching parenthese, like in vi. In addition, if the cursor isn't over a parenthese, it simply inserts a % like normal. By an unknown contributor: (global-set-key "%" 'match-paren) (defun match-paren (arg) "Go to the matching parenthesis if on parenthesis otherwise insert %." (interactive "p") (cond ((looking-at "[([{]") (forward-sexp 1) (backward-char)) ((looking-at "[])}]") (forward-char) (backward-sexp 1)) (t (self-insert-command (or arg 1))))) 92. How do I make Emacs behave like this: when I go up or down, the cursor should stay in the same column even if the line is too short? M-x picture-mode. (This is a minor mode, in theory anyway ...) 93. How do I read news under Emacs? There are at least three news reading packages that operate inside Emacs. "rnews" comes with Emacs. "GNUS" and "Gnews" come separately. (I've never used rnews; could someone write a description? BTW, rnews will be replaced with GNUS in Emacs 19.) Both GNUS and Gnews handle reading news over NNTP. I think both can also read from a local news spool. GNUS also supports reading mail stored in MH folders or articles saved by GNUS. GNUS is written (mostly) by Masanobu Umeda. His (?) latest e-mail address was umerin@tc.Nagasaki.GO.JP, but I don't think he has an e-mail address right now. The latest version is GNUS 3.13. There is a newsgroup for discussion of GNUS called gnu.emacs.gnus. This newsgroup is gatewayed with the mailing list info-gnus-english to subscribe send mail to info-gnus-english-request@cis.ohio-state.edu. There is also a mailing list called info-gnus, which includes discussion in Japanese. Gnews was written by Matthew Wiener . (Could someone tell me the # of the latest version, and how long it has been since anyone has heard from Matthew?). There is a newsgroup for Gnews called gnu.emacs.gnews. 94. In C mode, can I show just the lines that will be left after #ifdef commands are handled by the compiler? M-x hide-ifdef-mode. (This is a minor mode.) You may have to (load "hideif") first. If you want to do this regularly, put this in your .emacs file: (autoload hide-ifdef-mode "hideif" nil t) 95. Is there an equivalent to the "." (dot) command of vi? "." is the redo command in vi. It redoes the last insertion/deletion. (Not really) C-x ESC invokes repeat-complex-command. I use macros whenever I want to repeat something on each line. 96. How do I use emacstool under SunView? Read the files etc/SUN-SUPPORT and etc/emacstool.1. To read emacstool.1, you should format it it with "nroff -man emacstool.1" first. 97. How do I get Emacs to display the current line number on the mode line? There is no "correct" way to constantly display the current line number on the mode line in Emacs 18. Emacs is not a line-oriented editor, and really has no idea what "lines" of the buffer are displayed in the window. It would require a lot of work at the C code level to make Emacs keep track of this. Emacs 19 will probably be able to do this, but probably not with great efficiency. To find out what line of the buffer you are on right now, do "M-x what-line". Typing "C-x l" will also tell you what line you are on, provided the buffer isn't separated into "pages" with C-l characters. In that case, it will only tell you what line of the current "page" you are on. People have written various kludges to display the current line number on the mode line. Look in the Lisp Code Directory. (See question 13.) ---------------------------------------------------------------------- Stuff I haven't worked on yet: how-to use the terminal emulator (this one is rather marginal but difficult enough to be usefull)