The GNU Emacs FAQ
This is the GNU Emacs FAQ.
This FAQ is maintained as a part of GNU Emacs. If you find any errors, or have any suggestions, please use M-x report-emacs-bug to report them.
This is the version of the FAQ distributed with Emacs 29.1.90, and mainly describes that version. Although there is some information on older versions, details about very old releases (now only of historical interest) have been removed. If you are interested in this, consult either the version of the FAQ distributed with older versions of Emacs, or the history of this document in the Emacs source repository.
Since Emacs releases are very stable, we recommend always running the latest release.
This FAQ is not updated very frequently. When you have a question about Emacs, the Emacs manual is often the best starting point.
Copyright © 2001–2024 Free Software Foundation, Inc.
Copyright © 1994–2000 Reuven M. Lerner
Copyright © 1992–1993 Steven Byrnes
Copyright © 1990–1992 Joseph Brian Wells
This list of frequently asked questions about GNU Emacs with answers (“FAQ”) may be translated into other languages, transformed into other formats (e.g., Texinfo, Info, HTML, PDF), and updated with new information.
The same conditions apply to any derivative of the FAQ as apply to the FAQ itself. Every copy of the FAQ must include this notice or an approved translation, information on who is currently maintaining the FAQ and how to contact them (including their e-mail address), and information on where the latest version of the FAQ is archived.
The FAQ may be copied and redistributed under these conditions, except that the FAQ may not be embedded in a larger literary work unless that work itself allows free copying and redistribution.
Table of Contents
- 1 FAQ notation
- 2 General questions
- 3 Getting help
- 3.1 I’m just starting Emacs; how do I do basic editing?
- 3.2 How do I find out how to do something in Emacs?
- 3.3 How do I get a printed copy of the Emacs manual?
- 3.4 Where can I get documentation on Emacs Lisp?
- 3.5 How do I install a piece of Texinfo documentation?
- 3.6 How do I print a Texinfo file?
- 3.7 Can I view Info files without using Emacs?
- 3.8 What informational files are available for Emacs?
- 3.9 Where can I get help in installing Emacs?
- 3.10 Where can I get the latest version of this FAQ?
- 4 History of Emacs
- 4.1 Where does the name “Emacs” come from?
- 4.2 What is the latest version of Emacs?
- 4.3 What is different about Emacs 29?
- 4.4 What is different about Emacs 28?
- 4.5 What is different about Emacs 27?
- 4.6 What is different about Emacs 26?
- 4.7 What is different about Emacs 25?
- 4.8 What is different about Emacs 24?
- 4.9 What is different about Emacs 23?
- 4.10 What is different about Emacs 22?
- 4.11 What is different about Emacs 21?
- 4.12 What is different about Emacs 20?
- 4.13 What was XEmacs?
- 5 Common requests
- 5.1 How do I set up an init file properly?
- 5.2 How do I start using Customize?
- 5.3 How do I get colors and syntax highlighting on a TTY?
- 5.4 How do I debug an init file?
- 5.5 How do I make Emacs display the current line (or column) number?
- 5.6 How can I modify the titlebar to contain the current file name?
- 5.7 How do I turn on abbrevs by default just in mode mymode?
- 5.8 How do I make Emacs use a certain major mode for certain files?
- 5.9 How can I replace highlighted text with what I type?
- 5.10 How do I control Emacs’s case-sensitivity when searching/replacing?
- 5.11 How do I search for, delete, or replace unprintable (eight-bit or control) characters?
- 5.12 How do I input a newline character in isearch or query-replace?
- 5.13 How do I copy text from the kill ring into the search string?
- 5.14 How do I make Emacs wrap words for me?
- 5.15 How do I turn on
auto-fill-mode
by default? - 5.16 How do I change
load-path
? - 5.17 How do I use an already running Emacs from another window?
- 5.18 How do I make Emacs recognize my compiler’s funny error messages?
- 5.19 How do I change the indentation for
switch
? - 5.20 How to customize indentation in C, C++, and Java buffers?
- 5.21 How do I make Emacs “typeover” or “overwrite” instead of inserting?
- 5.22 How do I stop Emacs from beeping on a terminal?
- 5.23 How do I turn down the bell volume in Emacs running under X?
- 5.24 How do I tell Emacs to automatically indent a new line to the indentation of the previous line?
- 5.25 How do I show which parenthesis matches the one I’m looking at?
- 5.26 In C mode, can I show just the lines that will be left after
#ifdef
commands are handled by the compiler? - 5.27 How do I repeat a command as many times as possible?
- 5.28 What are the valid X resource settings (i.e., stuff in .Xdefaults)?
- 5.29 How do I execute (“evaluate”) a piece of Emacs Lisp code?
- 5.30 How do I change Emacs’s idea of the TAB character’s length?
- 5.31 How do I insert <some text> at the beginning of every line?
- 5.32 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?
- 5.33 How do I tell Emacs to iconify itself?
- 5.34 How do I use regexps (regular expressions) in Emacs?
- 5.35 How do I perform a replace operation across more than one file?
- 5.36 Where is the documentation for
etags
? - 5.37 How do I disable backup files?
- 5.38 How do I disable
auto-save-mode
? - 5.39 Making Emacs write all auxiliary files somewhere else
- 5.40 How can I go to a certain line given its number?
- 5.41 How can I create or modify new pull-down menu options?
- 5.42 How do I delete menus and menu options?
- 5.43 How do I turn on syntax highlighting?
- 5.44 How can I force Emacs to scroll only one line when I move past the bottom of the screen?
- 5.45 How can I edit MS-DOS files using Emacs?
- 5.46 How can I tell Emacs to fill paragraphs with a single space after each period?
- 5.47 Why these strange escape sequences from
ls
from the Shell mode? - 5.48 How can I start Emacs in fullscreen mode on MS-Windows?
- 5.49 How can I alleviate the limitations of the Linux console?
- 6 Bugs and problems
- 6.1 Does Emacs have problems with large files?
- 6.2 How do I get rid of ‘^M’ or echoed commands in my shell buffer?
- 6.3 Why do I get an error message when I try to run M-x shell?
- 6.4 Where is the termcap/terminfo entry for terminal type ‘emacs’?
- 6.5 Why does Emacs say ‘Error in init file’?
- 6.6 Why does Emacs ignore my X resources (my .Xdefaults file)?
- 6.7 Why don’t my customizations of the frame parameters work?
- 6.8 How do I edit a file with a ‘$’ in its name?
- 6.9 Why does shell mode lose track of the shell’s current directory?
- 6.10 Are there any security risks in Emacs?
- 6.11 Dired says, ‘no file on this line’ when I try to do something.
- 7 Compiling and installing Emacs
- 8 Finding Emacs and related packages
- 9 Key bindings
- 9.1 How do I bind keys (including function keys) to commands?
- 9.2 Why does Emacs say ‘Key sequence XXX uses invalid prefix characters’?
- 9.3 Why doesn’t this [terminal or window-system setup] code work in my init file, but it works just fine after Emacs starts up?
- 9.4 How do I tell what characters or symbols my function or arrow keys emit?
- 9.5 How do I set the X key “translations” for Emacs?
- 9.6 Why does the Backspace key invoke help?
- 9.7 How do I swap two keys?
- 9.8 How do I produce C-XXX with my keyboard?
- 9.9 What if I don’t have a Meta key?
- 9.10 What if I don’t have an Escape key?
- 9.11 Can I make my Compose Character key behave like a Meta key?
- 9.12 How do I bind a combination of modifier key and function key?
- 9.13 Why doesn’t my Meta key work in an
xterm
window?
- 10 Alternate character sets
- 11 Mail and news
- 11.1 How do I change the included text prefix in mail/news followups?
- 11.2 How do I save a copy of outgoing mail?
- 11.3 Why doesn’t Emacs expand my aliases when sending mail?
- 11.4 How can I sort the messages in my Rmail folder?
- 11.5 Why does Rmail need to write to /var/spool/mail?
- 11.6 How can I force Rmail to reply to the sender of a message, but not the other recipients?
- 11.7 How do I make Emacs automatically start my mail/news reader?
- 11.8 How do I read news under Emacs?
- 11.9 How do I make Gnus faster?
- 11.10 How do I catch up all newsgroups in Gnus?
- Concept Index
Next: General questions, Up: The GNU Emacs FAQ [Contents][Index]
1 FAQ notation
This chapter describes notation used in the GNU Emacs FAQ, as well as in the Emacs documentation. Consult this section if this is the first time you are reading the FAQ, or if you are confused by notation or terms used in the FAQ.
- What do these mean: C-h, C-M-a, RET, ESC a, etc.?
- What does M-x command mean?
- How do I read topic XXX in the Emacs manual?
- What are src/config.h, site-lisp/default.el, etc.?
- What are FSF, GNU, RMS, and GPL?
Next: What does M-x command mean?, Up: FAQ notation [Contents][Index]
1.1 What do these mean: C-h, C-M-a, RET, ESC a, etc.?
- C-x: press the x key while holding down the Control key
- M-x: press the x key while holding down the Meta key (if your computer doesn’t have a Meta key, see What if I don’t have a Meta key?)
- M-C-x: press the x key while holding down both Control and Meta
- C-M-x: a synonym for the above
- LFD: Linefeed or Newline; same as C-j
- RET: Return, sometimes marked Enter; same as C-m
- DEL: Delete, usually not the same as Backspace; same as C-? (see Why does the Backspace key invoke help?, if deleting invokes Emacs help)
- ESC: Escape; same as C-[
- TAB: Tab; same as C-i
- SPC: Space bar
Key sequences longer than one key (and some single-key sequences) are written inside quotes or on lines by themselves, like this:
M-x frobnicate-while-foo RET
Any real spaces in such a key sequence should be ignored; only SPC really means press the space key.
The ASCII code sent by C-x (except for C-?) is the value that would be sent by pressing just x minus 96 (or 64 for upper-case X) and will be from 0 to 31. On Unix and GNU/Linux terminals, the ASCII code sent by M-x is the sum of 128 and the ASCII code that would be sent by pressing just x. Essentially, Control turns off bits 5 and 6 and Meta turns on bit 71.
C-? (aka DEL) is ASCII code 127. It is a misnomer to call C-? a “control” key, since 127 has both bits 5 and 6 turned ON. Also, on very few keyboards does C-? generate ASCII code 127.
See Keys in The GNU Emacs Manual.
Next: How do I read topic XXX in the Emacs manual?, Previous: What do these mean: C-h, C-M-a, RET, ESC a, etc.?, Up: FAQ notation [Contents][Index]
1.2 What does M-x command mean?
M-x command means type M-x, then type the name of the command, then type RET. (See What do these mean: C-h, C-M-a, RET, ESC a, etc.?, if you’re not sure what M-x and RET mean.)
M-x (by default) invokes the command
execute-extended-command
. This command allows you to run any
Emacs command if you can remember the command’s name. If you can’t
remember the command’s name, you can type TAB and SPC for
completion, ? for a list of possibilities, and M-p and
M-n (or up-arrow and down-arrow) to see previous commands entered.
An Emacs command is an interactive Emacs function.
If you need to run non-interactive Emacs functions, see How do I execute (“evaluate”) a piece of Emacs Lisp code?.
Next: What are src/config.h, site-lisp/default.el, etc.?, Previous: What does M-x command mean?, Up: FAQ notation [Contents][Index]
1.3 How do I read topic XXX in the Emacs manual?
When we refer you to some topic in the Emacs manual, you can read this manual node inside Emacs by typing C-h i m emacs RET m topic RET.
This invokes Info, the GNU hypertext documentation browser. If you don’t already know how to use Info, type ? from within Info.
If we refer to topic:subtopic, type C-h i m emacs RET m topic RET m subtopic RET.
(If these commands don’t work as expected, your system may be missing the Info files, or they may not be installed properly.)
If you are reading this FAQ in Info, you can simply press RET on a reference to follow it.
See How do I get a printed copy of the Emacs manual?, if you would like a paper copy of the Emacs manual.
Next: What are FSF, GNU, RMS, and GPL?, Previous: How do I read topic XXX in the Emacs manual?, Up: FAQ notation [Contents][Index]
1.4 What are src/config.h, site-lisp/default.el, etc.?
These are files that come with Emacs. The Emacs distribution is divided into subdirectories; e.g., etc, lisp, and src. Some of these (e.g., etc and lisp) are present both in an installed Emacs and in the sources, but some (e.g., src) are only found in the sources.
If you use Emacs, but don’t know where it is kept on your system, start
Emacs, then type C-h v data-directory RET. The directory
name displayed by this will be the full pathname of the installed
etc directory. (This full path is recorded in the Emacs variable
data-directory
, and C-h v displays the value and the
documentation of a variable.)
The location of your Info directory (i.e., where Info documentation is
stored) is kept in the variable Info-directory-list
. Use
C-h v Info-directory-list RET to see the value of this
variable, which will be a list of directory names (after Info has been
started). The last directory in that list is probably where most Info
files are stored. By default, Emacs Info documentation is placed in
/usr/local/share/info.
For information on some of the files in the etc directory, see What informational files are available for Emacs?.
Previous: What are src/config.h, site-lisp/default.el, etc.?, Up: FAQ notation [Contents][Index]
1.5 What are FSF, GNU, RMS, and GPL?
- FSF
Free Software Foundation
- GNU
GNU’s Not Unix
- RMS
Richard Matthew Stallman
- GPL
GNU General Public License
See the GNU web site for more information about the GPL.
The word “free” in the title of the Free Software Foundation refers to “freedom,” not “zero cost.” Anyone can charge any price for GPL-covered software that they want to. However, in practice, the freedom enforced by the GPL leads to low prices, because you can always get the software for less money from someone else, since everyone has the right to resell or give away GPL-covered software.
Next: Getting help, Previous: FAQ notation, Up: The GNU Emacs FAQ [Contents][Index]
2 General questions
This chapter contains general questions having to do with Emacs, the Free Software Foundation, and related organizations.
- What are appropriate messages for the various Emacs mailing lists?
- Where can I read archives for
help-gnu-emacs
and other GNU lists? - Where should I report bugs and other problems with Emacs?
- How do I unsubscribe from a mailing list?
- How do I contact the FSF?
Next: Where can I read archives for help-gnu-emacs
and other GNU lists?, Up: General questions [Contents][Index]
2.1 What are appropriate messages for the various Emacs mailing lists?
There are various Emacs mailing lists, described at the Emacs Savannah page.
The main ones are: help-gnu-emacs
, bug-gnu-emacs
,
and emacs-devel
.
Messages advocating “non-free” software are considered unacceptable on any of the GNU mailing lists, except for the gnu-misc-discuss mailing list. “Non-free” software includes any software for which the end user can’t freely modify the source code and exchange enhancements. Please remove GNU mailing lists from the recipients when posting a reply that recommends such software.
Some of the GNU mailing lists are gatewayed to newsgroups (although the connection is occasionally unreliable). For example, sending an email to The bug-gnu-emacs list has the effect of posting on the newsgroup news:gnu.emacs.help).
Finally, we recommend reading the GNU Kind Communications Guidelines before posting to any GNU lists or newsgroups.
Next: Where should I report bugs and other problems with Emacs?, Previous: What are appropriate messages for the various Emacs mailing lists?, Up: General questions [Contents][Index]
2.2 Where can I read archives for help-gnu-emacs
and other GNU lists?
The FSF has maintained archives of all of the GNU mailing lists for many years, although there may be some unintentional gaps in coverage. The archive can be browsed over the web at the GNU mail archive.
Some web-based Usenet search services also archive the gnu.*
newsgroups.
Next: How do I unsubscribe from a mailing list?, Previous: Where can I read archives for help-gnu-emacs
and other GNU lists?, Up: General questions [Contents][Index]
2.3 Where should I report bugs and other problems with Emacs?
Please see the Emacs manual for information on how to report bugs. See Checklist for Bug Reports in The GNU Emacs Manual.
Sending bug reports to the help-gnu-emacs mailing list is undesirable because it takes the time of an unnecessarily large group of people, most of whom are just users and have no idea how to fix these problem. The bug-gnu-emacs list reaches a much smaller group of people who are more likely to know what to do and have expressed a wish to receive more messages about Emacs than the others.
If you have reported a bug and you don’t hear about a possible fix, then after a suitable delay (such as a week) it is okay to post on the help list asking if anyone can help you.
If you are unsure whether you have found a bug, consider the following non-exhaustive list, courtesy of RMS:
If Emacs crashes, that is a bug. If Emacs gets compilation errors while building, that is a bug. If Emacs crashes while building, that is a bug. If Lisp code does not do what the documentation says it does, that is a bug.
Anything sent to bug-gnu-emacs@gnu.org also appears in the newsgroup news:gnu.emacs.bug, but please use e-mail instead of news to submit the bug report. This ensures a reliable return address so you can be contacted for further details.
Next: How do I contact the FSF?, Previous: Where should I report bugs and other problems with Emacs?, Up: General questions [Contents][Index]
2.4 How do I unsubscribe from a mailing list?
If you are receiving a GNU mailing list named list, you should be able to unsubscribe from it by sending a request to the address list-request@gnu.org. Mailing lists mails normally contain information in either the message header (‘List-Unsubscribe:’) or as a footer that tells you how to unsubscribe.
Previous: How do I unsubscribe from a mailing list?, Up: General questions [Contents][Index]
2.5 How do I contact the FSF?
For up-to-date information, see the FSF contact web-page. You can send general correspondence to info@fsf.org.
For details on how to order items directly from the FSF, see the FSF on-line store.
Next: History of Emacs, Previous: General questions, Up: The GNU Emacs FAQ [Contents][Index]
3 Getting help
This chapter tells you how to get help with Emacs.
- I’m just starting Emacs; how do I do basic editing?
- How do I find out how to do something in Emacs?
- How do I get a printed copy of the Emacs manual?
- Where can I get documentation on Emacs Lisp?
- How do I install a piece of Texinfo documentation?
- How do I print a Texinfo file?
- Can I view Info files without using Emacs?
- What informational files are available for Emacs?
- Where can I get help in installing Emacs?
- Where can I get the latest version of this FAQ?
3.1 I’m just starting Emacs; how do I do basic editing?
Type C-h t to invoke the self-paced tutorial. Just typing C-h enters the help system. The tutorial is available in many foreign languages such as French, German, Japanese, Russian, etc. Use M-x help-with-tutorial-spec-language RET to choose your language and start the tutorial.
Your system administrator may have changed C-h to act like DEL to deal with local keyboards. You can use M-x help-for-help instead to invoke help. To discover what key (if any) invokes help on your system, type M-x where-is RET help-for-help RET. This will print a comma-separated list of key sequences in the echo area. Ignore the last character in each key sequence listed. Each of the resulting key sequences (e.g., F1 is common) invokes help.
Emacs help works best if it is invoked by a single key whose value
should be stored in the variable help-char
.
Some Emacs slides and tutorials can be found at http://web.psung.name/emacs/.
Next: How do I get a printed copy of the Emacs manual?, Previous: I’m just starting Emacs; how do I do basic editing?, Up: Getting help [Contents][Index]
3.2 How do I find out how to do something in Emacs?
There are several methods for finding out how to do things in Emacs.
- The complete text of the Emacs manual is available via the Info hypertext reader. Type C-h r to display the manual in Info mode. Typing h immediately after entering Info will provide a short tutorial on how to use it.
- To quickly locate the section of the manual which discusses a certain issue, or describes a command or a variable, type C-h i m emacs RET i topic RET, where topic is the name of the topic, the command, or the variable which you are looking for. If this does not land you on the right place in the manual, press , (comma) repeatedly until you find what you need. (The i and , keys invoke the index-searching functions, which look for the topic you type in all the indices of the Emacs manual.)
- You can list all of the commands whose names contain a certain word (actually which match a regular expression) using C-h a (M-x command-apropos).
-
The command C-h F (
Info-goto-emacs-command-node
) prompts for the name of a command, and then attempts to find the section in the Emacs manual where that command is described. - You can list all of the functions and variables whose names contain a certain word using M-x apropos.
- You can list all of the functions and variables whose documentation matches a regular expression or a string, using M-x apropos-documentation.
- You can order a hardcopy of the manual from the FSF. See How do I get a printed copy of the Emacs manual?.
- You can get a printed reference card listing commands and keys to invoke them. You can order one from the FSF, or you can print your own from the etc/refcards/refcard.tex or etc/refcards/refcard.pdf files in the Emacs distribution. The Emacs distribution comes with translations of the reference card into several languages; look for files named etc/refcards/lang-refcard.*, where lang is a two-letter code of the language. For example, the German version of the reference card is in the files etc/refcards/de-refcard.tex and etc/refcards/de-refcard.pdf.
- There are many other commands in Emacs for getting help and information. To get a list of these commands, type ‘?’ after C-h.
Next: Where can I get documentation on Emacs Lisp?, Previous: How do I find out how to do something in Emacs?, Up: Getting help [Contents][Index]
3.3 How do I get a printed copy of the Emacs manual?
You can order a printed copy of the Emacs manual from the FSF. For details see the FSF on-line store.
The full Texinfo source for the manual also comes in the doc/emacs directory of the Emacs distribution, if you’re daring enough to try to print out this several-hundred-page manual yourself (see How do I print a Texinfo file?).
If you absolutely have to print your own copy, and you don’t have TeX, you can get a PostScript or PDF (or HTML) version from
https://www.gnu.org/software/emacs/manual/
See How do I find out how to do something in Emacs?, for how to view the manual from Emacs.
Next: How do I install a piece of Texinfo documentation?, Previous: How do I get a printed copy of the Emacs manual?, Up: Getting help [Contents][Index]
3.4 Where can I get documentation on Emacs Lisp?
Within Emacs, you can type C-h f to get the documentation for a function, C-h v for a variable.
For more information, the Emacs Lisp Reference Manual is available in Info format (see Emacs Lisp in The Emacs Lisp Reference Manual).
You can also order a hardcopy of the manual from the FSF, for details see the FSF on-line store. (This manual is not always in print.)
An HTML version of the Emacs Lisp Reference Manual is available at
Next: How do I print a Texinfo file?, Previous: Where can I get documentation on Emacs Lisp?, Up: Getting help [Contents][Index]
3.5 How do I install a piece of Texinfo documentation?
Emacs releases come with pre-built Info files, and the normal install process places them in the correct location. This is true for most applications that provide Info files. The following section is only relevant if you want to install extra Info files by hand.
First, you must turn the Texinfo source files into Info files. You may do this using the stand-alone makeinfo program, available as part of the Texinfo package at
https://www.gnu.org/software/texinfo/
For information about the Texinfo format, read the Texinfo manual which comes with the Texinfo package. This manual also comes installed in Info format, so you can read it from Emacs; type C-h i m texinfo RET.
Alternatively, you could use the Emacs command M-x texinfo-format-buffer, after visiting the Texinfo source file of the manual you want to convert.
Neither texinfo-format-buffer
nor makeinfo installs the
resulting Info files in Emacs’s Info tree. To install Info files,
perform these steps:
- Move the files to the info directory in the installed Emacs distribution. See What are src/config.h, site-lisp/default.el, etc.?, if you don’t know where that is.
- Run the
install-info
command, which is part of the Texinfo distribution, to update the main Info directory menu, like this:install-info --info-dir=dir-path dir-path/file
where dir-path is the full path to the directory where you copied the produced Info file(s), and file is the name of the Info file you produced and want to install.
If you don’t have the
install-info
command installed, you can 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. Follow the examples already in this file. The format is:* Topic: (relative-pathname). Short description of topic.
If you want to install Info files and you don’t have the necessary privileges, you have several options:
- Info files don’t actually need to be installed before being used.
You can use a prefix argument for the
info
command and specify the name of the Info file in the minibuffer. This goes to the node named ‘Top’ in that file. For example, to view an Info file named info-file in your home directory, you can type this:C-u C-h i ~/info-file RET
Alternatively, you can feed a file name to the
Info-goto-node
command (invoked by pressing g in Info mode) by typing the name of the file in parentheses, like this:C-h i g (~/info-file) RET
- You can create your own Info directory. You can tell Emacs where that
Info directory is by adding its pathname to the value of the variable
Info-default-directory-list
. For example, to use a private Info directory which is a subdirectory of your home directory named Info, you could put this in your init file (see How do I set up an init file properly?):(add-to-list 'Info-default-directory-list "~/Info/")
You will need a top-level Info file named dir in this directory which has everything the system dir file has in it, except it should list only entries for Info files in that directory. You might not need it if (fortuitously) all files in this directory were referenced by other dir files. The node lists from all dir files in
Info-default-directory-list
are merged by the Info system.
Next: Can I view Info files without using Emacs?, Previous: How do I install a piece of Texinfo documentation?, Up: Getting help [Contents][Index]
3.6 How do I print a Texinfo file?
You can’t get nicely printed output from Info files; you must still have the original Texinfo source file for the manual you want to print.
Assuming you have TeX installed on your system, follow these steps:
- Make sure the first line of the Texinfo file looks like this:
\input texinfo
You may need to change ‘texinfo’ to the full pathname of the texinfo.tex file, which comes with Emacs as doc/misc/texinfo.tex (or copy or link it into the current directory).
- Type texi2dvi texinfo-source, where texinfo-source is
the name of the Texinfo source file for which you want to produce a
printed copy. The ‘texi2dvi’ script is part of the GNU Texinfo
distribution.
Alternatively, ‘texi2pdf’ produces PDF files.
- Print the DVI file texinfo-source.dvi in the normal way for
printing DVI files at your site. For example, if you have a PostScript
printer, run the
dvips
program to print the DVI file on that printer.
To get more general instructions, retrieve the latest Texinfo package (see How do I install a piece of Texinfo documentation?).
Next: What informational files are available for Emacs?, Previous: How do I print a Texinfo file?, Up: Getting help [Contents][Index]
3.7 Can I view Info files without using Emacs?
Yes. Here are some alternative programs:
-
info
, a stand-alone version of the Info program, comes as part of the Texinfo package. See How do I install a piece of Texinfo documentation?, for details. - Tkinfo, an Info viewer that runs under X Window system and uses Tcl/Tk. You can get Tkinfo at http://math-www.uni-paderborn.de/~axel/tkinfo/.
Next: Where can I get help in installing Emacs?, Previous: Can I view Info files without using Emacs?, Up: Getting help [Contents][Index]
3.8 What informational files are available for Emacs?
This isn’t a frequently asked question, but it should be! A variety of informational files about Emacs and relevant aspects of the GNU project are available for you to read.
The following files (and others) are available in the etc directory of the Emacs distribution (see What are src/config.h, site-lisp/default.el, etc.?, if you’re not sure where that is). Many of these files are available via the Emacs ‘Help’ menu, or by typing C-h ? (M-x help-for-help).
- COPYING
GNU General Public License
- DISTRIB
Emacs Availability Information
- MACHINES
Status of Emacs on Various Machines and Systems
- NEWS
Emacs news, a history of recent user-visible changes
More GNU and FSF information is available at
Next: Where can I get the latest version of this FAQ?, Previous: What informational files are available for Emacs?, Up: Getting help [Contents][Index]
3.9 Where can I get help in installing Emacs?
See How do I install Emacs?, for some basic installation hints, and see What should I do if I have trouble building Emacs?, if you have problems with the installation.
The GNU Service directory lists companies and individuals willing to sell you help in installing or using Emacs and other GNU software.
Previous: Where can I get help in installing Emacs?, Up: Getting help [Contents][Index]
3.10 Where can I get the latest version of this FAQ?
The Emacs FAQ is distributed with Emacs in Info format. You can read it by selecting the ‘Emacs FAQ’ option from the ‘Help’ menu of the Emacs menu bar at the top of any Emacs frame, or by typing C-h C-f (M-x view-emacs-FAQ). The very latest version is available in the Emacs development repository (see What is the latest version of Emacs?).
Next: Common requests, Previous: Getting help, Up: The GNU Emacs FAQ [Contents][Index]
4 History of Emacs
- Where does the name “Emacs” come from?
- What is the latest version of Emacs?
- What is different about Emacs 29?
- What is different about Emacs 28?
- What is different about Emacs 27?
- What is different about Emacs 26?
- What is different about Emacs 25?
- What is different about Emacs 24?
- What is different about Emacs 23?
- What is different about Emacs 22?
- What is different about Emacs 21?
- What is different about Emacs 20?
- What was XEmacs?
Next: What is the latest version of Emacs?, Up: History of Emacs [Contents][Index]
4.1 Where does the name “Emacs” come from?
Emacs originally was an acronym for Editor MACroS. RMS says he “picked the name Emacs because E was not in use as an abbreviation on ITS at the time.” The first Emacs was a set of macros written in 1976 at MIT by RMS for the editor TECO (Text Editor and COrrector, originally Tape Editor and COrrector) under ITS (the Incompatible Timesharing System) on a PDP-10. RMS had already extended TECO with a “real-time” full-screen mode with reprogrammable keys. Emacs was started by Guy Steele as a project to unify the many divergent TECO command sets and key bindings at MIT, and completed by RMS.
Many people have said that TECO code looks a lot like line noise; you can read more on Wikipedia. Someone has written a TECO implementation in Emacs Lisp (to find it, see Where can I get Emacs Lisp packages that don’t come with Emacs?); it would be an interesting project to run the original TECO Emacs inside of Emacs.
For some not-so-serious alternative reasons for Emacs to have that name, check out the file etc/JOKES (see What are src/config.h, site-lisp/default.el, etc.?).
Next: What is different about Emacs 29?, Previous: Where does the name “Emacs” come from?, Up: History of Emacs [Contents][Index]
4.2 What is the latest version of Emacs?
Emacs 29.1.90 is the current version as of this writing. A version number with two components (e.g., ‘28.1’) indicates a released version; three components indicate a development version (e.g., ‘29.0.50’ is what will eventually become ‘29.1’).
Emacs is under active development, hosted at Savannah. Follow the instructions given there to clone the project repository.
Because Emacs undergoes many changes before a release, the version number of a development version is not especially meaningful. It is better to refer to the date on which the sources were retrieved from the development repository. The development version is usually quite robust for every-day use, but if stability is more important to you than the latest features, you may want to stick to the releases.
The following sections list some of the major new features in the last few Emacs releases. For full details of the changes in any version of Emacs, type C-h C-n (M-x view-emacs-news). You can give this command a prefix argument to read about which features were new in older versions.
Next: What is different about Emacs 28?, Previous: What is the latest version of Emacs?, Up: History of Emacs [Contents][Index]
4.3 What is different about Emacs 29?
Here’s a list of the most important changes in Emacs 29 as compared to Emacs 28 (the full list is too long, and can be read in the Emacs NEWS file by typing C-h n inside Emacs).
- Emacs can now be built with the
tree-sitter
library, which provides incremental parsing capabilities for several
programming languages. Emacs comes with several major modes which use
this library for syntax highlighting (a.k.a. “fontification”),
indentation, Imenu support, etc. These modes have names
lang-ts-mode
, where lang is the programming language. For example,c-ts-mode
,ruby-ts-mode
, etc. There are several new font-lock faces, such asfont-lock-number-face
andfont-lock-operator-face
, intended to be used with these modes. - Emacs can now be built in the PGTK (“pure GTK”) configuration, which supports running Emacs on window systems other than X, such as Wayland and Broadway.
- Emacs now has built-in support for accessing SQLite databases. This requires Emacs to be built with the optional sqlite3 library.
- Emacs comes with the popular
use-package
package bundled. - Emacs can now display WebP images, if it was built with the optional libwebp library.
- On X window system, Emacs now supports the XInput2 specification for input events.
- Emacs now comes with a client library for using Language Server
Protocol (LSP) servers. This library, named eglot.el
(the name stands for “Emacs polyGlot”) provides LSP support for
various software development and maintenance features, such as
xref
, Imenu, ElDoc, etc. - Emacs can now cope with files with very long lines much better. It no longer hangs when displaying such long lines, and allows reasonably-responsive editing when such lines are present in the visible portion of a buffer.
- Emacs now supports the latest version 15.0 of the Unicode Standard.
- The new mode
pixel-scroll-precision-mode
allows precise and smooth scrolling of the display at pixel resolution, if your mouse supports this. - Emacs now supports 24-bit true colors on more terminals.
- On capable X terminal emulators, Emacs now supports setting the X primary selection on TTY frames.
- New convenient commands are now available for inserting, searching,
listing, and describing Emoji. These commands are on the C-x 8 e prefix key. The commands C-u C-x =
(
what-cursor-position
) and M-x describe-char now show the names of Emoji sequences at point. - The Help commands were enhanced:
- - M-x apropos-variable shows the values of the matching variables.
- - C-h b activates
outline-minor-mode
in the buffer, which makes it easier to browse long lists of key bindings. - - I in the *Help* buffer displays the corresponding documentation in the Emacs Lisp Reference manual.
- - New command
help-quick
displays a buffer with overview of common Help commands.
- Outline Minor mode uses buttons to hide and show outlines.
- Deleted frames can now be undeleted using C-x 5 u, if the
optional
undelete-frame-mode
is enabled. - You can now delete the entire composed sequence of characters with
Delete and edits the composed sequence by turning on the
composition-break-at-point
option. - Support is added for many old scripts and writing systems, such as Tai Tham, Brahmi, Tirhuta, Modi, Lepcha, and many others.
- New translations of the Emacs tutorial: Ukrainian and Greek.
- New major modes for Typescript, Csharp, CMake, Go, Rust, and Yaml.
Next: What is different about Emacs 27?, Previous: What is different about Emacs 29?, Up: History of Emacs [Contents][Index]
4.4 What is different about Emacs 28?
Emacs 28 has too many new features and changes to list all of them here. We list below a small selection; consult the Emacs NEWS file (C-h n) for the full list of changes in Emacs 28.
- Emacs now optionally supports native compilation of Lisp files. This can improves performance significantly in some cases. To enable this, configure Emacs with the --with-native-compilation option.
- The new NonGNU ELPA archive is enabled by default alongside GNU ELPA.
Thus, packages on NonGNU ELPA will appear by default in the list shown
by the
list-packages
command. - The Cairo graphics library is now used by default if present.
- On GNU/Linux, Emacs now supports loading Secure Computing filters. To
use this feature, invoke Emacs with the --seccomp=file
command-line switch, where file names a binary file that defines
the filtering. See the manual page of the
seccomp
system call for more details. - The new themes ‘modus-vivendi’ and ‘modus-operandi’ have been added. They are designed to conform with the highest standard for color-contrast accessibility (WCAG AAA).
- On capable systems, Emacs now correctly displays Emoji and Emoji sequences by default, provided that a suitable font is available.
- New system for displaying documentation for groups of functions (M-x shortdoc-display-group RET).
- Emacs can now support 24-bit color text-mode terminals even if their
terminfo database doesn’t state this support in a standard way. Set
the
COLORTERM
environment variable to the value ‘truecolor’ to activate this. - The
strike-through
face attribute is now supported on capable text-mode terminals. -
xterm-mouse-mode
supports TTY menus. - A new minor mode
context-menu-mode
causesmouse-3
(a.k.a. “right-clicks”) of the mouse to pop up context-dependent menus. - Prefix commands to control the display of the results of the next command. C-x 4 4 command displays the result of command in a new window. C-x 5 5 command displays the results of command in a new frame.
- Emacs now supports “transient” input methods. A transient input
method is enabled for inserting a single character, and is then
automatically disabled. Select a transient input method with C-u
C-x \; enable it (for inserting a single character) with C-x \.
New input methods
compose
(based on X Window System Multi_key sequences) andiso-transl
are especially convenient with this feature, when you need to insert a single special character. - M-y, when invoked after a command that is not a yank command, allows selection of one of the previous kills.
- New minor mode
repeat-mode
allows to repeat commands with fewer keystrokes. - Among the many internal changes in this release, we would like to
highlight that all files in the tree now use
lexical-binding
.
Next: What is different about Emacs 26?, Previous: What is different about Emacs 28?, Up: History of Emacs [Contents][Index]
4.5 What is different about Emacs 27?
- Emacs now uses the GNU Multiple Precision (GMP) library to support integers whose size is too large to support natively. The integers supported natively are known as “fixnums”, while the larger ones are “bignums”. All the arithmetic, comparison, and logical (also known as “bitwise”) operations where bignums make sense now support both fixnums and bignums.
- Emacs now uses HarfBuzz as its default shaping engine.
- Native support for JSON parsing that is much faster than json.el.
- Cairo drawing is no longer experimental.
- Emacs now uses a “portable dumper” instead of unexec. This improves compatibility with memory allocation on modern systems, and in particular better supports the Address Space Layout Randomization (ASLR) feature, a security technique used by most modern operating systems.
- Emacs can now use the XDG convention for init files.
- Emacs can now be configured using an early init file. The primary purpose is to allow customizing how the package system is initialized given that initialization now happens before loading the regular init file.
- Built-in support for tabs (tab bar and tab line).
- Support for resizing and rotating of images without ImageMagick.
Consult the Emacs NEWS.27 file for the full list of changes in Emacs 27.
Next: What is different about Emacs 25?, Previous: What is different about Emacs 27?, Up: History of Emacs [Contents][Index]
4.6 What is different about Emacs 26?
- Emacs now provides a limited form of concurrency with Lisp threads.
-
Emacs now supports
systemd
. The new command-line option --fg-daemon is part of this support, it causes Emacs to run in the foreground instead of forking, as under --daemon. - Emacs now supports 24-bit true color on text terminals which provide that feature. See How do I get colors and syntax highlighting on a TTY?.
- Emacs on X now supports double-buffering, which eliminates display flickering in most situations.
- You can now scroll the Emacs display horizontally using the mouse or touchpad.
-
Emacs display now includes an optional feature for display of line
numbers via the
display-line-numbers-mode
command. This feature is much faster than the equivalent display offered by packages such aslinum
, and also provides many optional features like relative line numbers. - The automatic horizontal scrolling of the window display when lines are truncated can now optionally be enabled only for the current line, the line where Emacs shows the cursor. Under this mode, all the other window lines are not scrolled to show characters outside of the viewport.
- Letter-case conversions now honor special cases in Turkish and Greek scripts.
- Support for Enchant is now part of the Emacs spell-checking commands.
- Tramp now supports Google Drive filesystems.
- Emacs can now be built while omitting the details of the machine on which it was built, thus making it easier to produce reproducible builds.
- Security vulnerability related to Enriched Text mode is removed.
Enriched mode previously allowed saving
display
properties as part of text; those properties support evaluating arbitrary Lisp code, which opens a vulnerability for Emacs users receiving Enriched Text from external sources. Execution of arbitrary Lisp forms indisplay
properties decoded by Enriched Text mode is now disabled by default. - Emacs 26.2 comes with data files imported from the latest Unicode Standard version 11.0.0.
Consult the Emacs NEWS.26 file for the full list of changes in Emacs 26.
Next: What is different about Emacs 24?, Previous: What is different about Emacs 26?, Up: History of Emacs [Contents][Index]
4.7 What is different about Emacs 25?
- Emacs can now embed native widgets inside Emacs buffers, if you have gtk3 and webkitgtk3 installed. E.g., to access the embedded webkit browser widget, type M-x xwidget-webkit-browse-url.
- Emacs can now dynamically load external modules compiled as shared libraries.
- C-x 8 has new shorthands for several popular characters, type C-x 8 C-h to list shorthands.
-
A new minor mode
global-eldoc-mode
is enabled by default, and shows in the echo area or in the mode line the argument list of the Emacs Lisp form at point. - On text terminals that support the “bracketed paste mode” Emacs now uses that mode by default. This mode allows Emacs to distinguish between pasted text and text typed by the user.
- Emacs 25 comes with data files imported from the latest Unicode Standard version 9.0.0.
- The support for bidirectional editing was updated to include all the features mandated by the latest Unicode Standard version 9.0.0.
- Search command can now perform character folding in matches. This is analogous to case folding, but instead of disregarding case variants, it disregards wider classes of distinctions between similar characters, such as matching different variants of double quote characters, ignoring diacritics, etc.
- The Emacs Web Browser EWW was extended to render text using variable-pitch fonts, and got other new features.
- Rmail can now render HTML mail messages, if Emacs is built with libxml2 or if you have the Lynx browser installed.
-
VC now has basic support for
push
commands, implemented for Bzr, Git, and Hg. -
Hide-IfDef mode now support full C/C++ expressions in macros,
macro argument expansion, interactive macro evaluation and automatic
scanning of
#define
d symbols. - New package Xref replaces Etags’s front-end and UI. Xref provides a generic framework and new commands to find and move to definitions of functions, macros, data structures etc., as well as go back to the location where you were before moving to a definition. It supersedes and obsoletes many Etags commands, while still using the etags.el code that reads the TAGS tables as one of its back-ends. As result, the popular key bindings M-. and M-, have been changed to invoke Xref commands.
- The new package Project provides generic infrastructure for dealing with projects.
- Emacs can now draw horizontal scroll bars on some platforms that provide toolkit scroll bars, namely Gtk+, Lucid, Motif and Windows.
Consult the Emacs NEWS.25 file for the full list of changes in Emacs 25.
Next: What is different about Emacs 23?, Previous: What is different about Emacs 25?, Up: History of Emacs [Contents][Index]
4.8 What is different about Emacs 24?
- Emacs now includes a package manager. Type M-x list-packages to get started. You can use this to download and automatically install many more Lisp packages.
-
Emacs Lisp now supports lexical binding on a per-file basis. In
lexical binding, variable references must be located textually
within the binding construct. This contrasts with dynamic
binding, where programs can refer to variables defined outside their
local textual scope. A Lisp file can use a local variable setting of
lexical-binding: t
to indicate that the contents should be interpreted using lexical binding. See the Emacs Lisp Reference Manual for more details. - Some human languages, such as English, are written from left to right. Others, such as Arabic, are written from right to left. Emacs now has support for any mixture of these forms—this is “bidirectional text”.
- Handling of text selections has been improved, and now integrates better with external clipboards.
- A new command customize-themes allows you to easily change the appearance of your Emacs.
- Emacs can be compiled with the GTK+ 3 toolkit.
- Support for several new external libraries can be included at compile
time:
- “Security-Enhanced Linux” (SELinux) is a Linux kernel feature that provides more sophisticated file access controls than ordinary “Unix-style” file permissions.
- The ImageMagick display library. This allows you to display many more image format in Emacs, as well as carry out transformations such as rotations.
- The GnuTLS library for secure network communications. Emacs uses this transparently for email if your mail server supports it.
- The libxml2 library for parsing XML structures.
- Much more flexibility in the handling of windows and buffer display.
Consult the Emacs NEWS.24 file for the full list of changes in Emacs 24.
Next: What is different about Emacs 22?, Previous: What is different about Emacs 24?, Up: History of Emacs [Contents][Index]
4.9 What is different about Emacs 23?
- Emacs has a new font code that can use multiple font backends, including freetype and fontconfig. Emacs can use the Xft library for anti-aliasing, and the otf and m17n libraries for complex text layout and text shaping.
- The Emacs character set is now a superset of Unicode. Several new language environments have been added.
- Emacs now supports using both X displays and ttys in the same session (‘multi-tty’).
- Emacs can be started as a daemon in the background.
- There is a new NeXTstep port of Emacs. This supports GNUstep and Mac OS X (via the Cocoa libraries). The Carbon port of Emacs, which supported Mac OS X in Emacs 22, has been removed.
- Directory-local variables can now be defined, in a similar manner to file-local variables.
- Transient Mark mode is on by default.
Other changes include: support for serial port access; D-Bus bindings; a new Visual Line mode for line-motion; improved completion; a new mode (‘DocView’) for viewing of PDF, PostScript, and DVI documents; nXML mode (for editing XML documents) is included; VC has been updated for newer version control systems; etc.
Consult the Emacs NEWS.23 file for the full list of changes in Emacs 23.
Next: What is different about Emacs 21?, Previous: What is different about Emacs 23?, Up: History of Emacs [Contents][Index]
4.10 What is different about Emacs 22?
- Emacs can be built with GTK+ widgets, and supports drag-and-drop operation on X.
- Emacs 22 features support for GNU/Linux systems on S390 and x86-64 machines, as well as support for the Mac OS X and Cygwin operating systems.
- The native MS-Windows, and Mac OS X builds include full support for images, toolbar, and tooltips.
- Font Lock mode, Auto Compression mode, and File Name Shadow Mode are enabled by default.
- The maximum size of buffers is increased: on 32-bit machines, it is 256 MBytes for Emacs 23.1, and 512 MBytes for Emacs 23.2 and above.
- Links can be followed with mouse-1, in addition to mouse-2.
- Mouse wheel support is enabled by default.
- Window fringes are customizable.
- The mode line of the selected window is now highlighted.
- The minibuffer prompt is displayed in a distinct face.
- Abbrev definitions are read automatically at startup.
- Grep mode is separate from Compilation mode and has many new options and commands specific to grep.
- The original Emacs macro system has been replaced by the new Kmacro package, which provides many new commands and features and a simple interface that uses the function keys F3 and F4. Macros are stored in a macro ring, and can be debugged and edited interactively.
- The Grand Unified Debugger (GUD) can be used with a full graphical user interface to GDB; this provides many features found in traditional development environments, making it easy to manipulate breakpoints, add watch points, display the call stack, etc. Breakpoints are visually indicated in the source buffer.
- Many new modes and packages have been included in Emacs, such as Calc, TRAMP, URL, IDO, CUA, ERC, rcirc, Table, Image-Dired, SES, Ruler, Org, PGG, Flymake, Password, Printing, Reveal, wdired, t-mouse, longlines, savehist, Conf mode, Python mode, DNS mode, etc.
-
Leim is now part of Emacs. Unicode support has been much improved, and
the following input methods have been added: belarusian, bulgarian-bds,
bulgarian-phonetic, chinese-sisheng, croatian, dutch, georgian,
latin-alt-postfix, latin-postfix, latin-prefix, latvian-keyboard,
lithuanian-numeric, lithuanian-keyboard, malayalam-inscript, rfc1345,
russian-computer, sgml, slovenian, tamil-inscript, ucs,
ukrainian-computer, vietnamese-telex, and welsh.
The following language environments have also been added: Belarusian, Bulgarian, Chinese-EUC-TW, Croatian, French, Georgian, Italian, Latin-6, Latin-7, Latvian, Lithuanian, Malayalam, Russian, Slovenian, Swedish, Tajik, Tamil, UTF-8, Ukrainian, Welsh, and Windows-1255.
- In addition, Emacs 22 now includes the Emacs Lisp Reference Manual (see Where can I get documentation on Emacs Lisp?) and the Emacs Lisp Intro.
Consult the Emacs NEWS.22 file for the full list of changes in Emacs 22.
Next: What is different about Emacs 20?, Previous: What is different about Emacs 22?, Up: History of Emacs [Contents][Index]
4.11 What is different about Emacs 21?
Emacs 21 features a thorough rewrite of the display engine. The new display engine supports variable-size fonts, images, and can play sounds on platforms which support that. As a result, the visual appearance of Emacs, when it runs on a windowed display, is much more reminiscent of modern GUI programs, and includes 3D widgets (used for the mode line and the scroll bars), a configurable and extensible toolbar, tooltips (a.k.a. balloon help), and other niceties.
In addition, Emacs 21 supports faces on text-only terminals. This means
that you can now have colors when you run Emacs on a GNU/Linux console
and on xterm
with emacs -nw.
Consult the Emacs NEWS.21 file for the full list of changes in Emacs 21.
Next: What was XEmacs?, Previous: What is different about Emacs 21?, Up: History of Emacs [Contents][Index]
4.12 What is different about Emacs 20?
The differences between Emacs versions 18 and 19 were rather dramatic; the introduction of frames, faces, and colors on windowing systems was obvious to even the most casual user.
There are differences between Emacs versions 19 and 20 as well, but many are more subtle or harder to find. Among the changes are the inclusion of MULE code for languages that use non-Latin characters and for mixing several languages in the same document; the “Customize” facility for modifying variables without having to use Lisp; and automatic conversion of files from Macintosh, Microsoft, and Unix platforms.
Consult the Emacs NEWS.20 file for the full list of changes in Emacs 20.
Previous: What is different about Emacs 20?, Up: History of Emacs [Contents][Index]
4.13 What was XEmacs?
XEmacs was a branch version of Emacs that is no longer actively developed. Originally known as “Lucid Emacs”, XEmacs was forked from a prerelease version of Emacs 19. XEmacs last released a new version on January 30, 2009, which lacks many important features that exist in Emacs. Since its development has stopped, we do not expect to see any new releases.
In the past, it was not uncommon for Emacs packages to include code for compatibility with XEmacs. Nowadays, most built-in and third party packages have either stopped supporting XEmacs or were developed exclusively for Emacs.
If you want to talk about these two versions and distinguish them, please call them “Emacs” and “XEmacs.” To contrast “XEmacs” with “GNU Emacs” would be misleading, since XEmacs too has its origin in the work of the GNU Project. Terms such as “Emacsen” and “(X)Emacs” are not wrong, but they are not very clear, so it is better to write “Emacs and XEmacs.”
Next: Bugs and problems, Previous: History of Emacs, Up: The GNU Emacs FAQ [Contents][Index]
5 Common requests
- How do I set up an init file properly?
- How do I start using Customize?
- How do I get colors and syntax highlighting on a TTY?
- How do I debug an init file?
- How do I make Emacs display the current line (or column) number?
- How can I modify the titlebar to contain the current file name?
- How do I turn on abbrevs by default just in mode mymode?
- How do I make Emacs use a certain major mode for certain files?
- How can I replace highlighted text with what I type?
- How do I control Emacs’s case-sensitivity when searching/replacing?
- How do I search for, delete, or replace unprintable (eight-bit or control) characters?
- How do I input a newline character in isearch or query-replace?
- How do I copy text from the kill ring into the search string?
- How do I make Emacs wrap words for me?
- How do I turn on
auto-fill-mode
by default? - How do I change
load-path
? - How do I use an already running Emacs from another window?
- How do I make Emacs recognize my compiler’s funny error messages?
- How do I change the indentation for
switch
? - How to customize indentation in C, C++, and Java buffers?
- How do I make Emacs “typeover” or “overwrite” instead of inserting?
- How do I stop Emacs from beeping on a terminal?
- How do I turn down the bell volume in Emacs running under X?
- How do I tell Emacs to automatically indent a new line to the indentation of the previous line?
- How do I show which parenthesis matches the one I’m looking at?
- In C mode, can I show just the lines that will be left after
#ifdef
commands are handled by the compiler? - How do I repeat a command as many times as possible?
- What are the valid X resource settings (i.e., stuff in .Xdefaults)?
- How do I execute (“evaluate”) a piece of Emacs Lisp code?
- How do I change Emacs’s idea of the TAB character’s length?
- How do I insert <some text> at the beginning of every line?
- 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?
- How do I tell Emacs to iconify itself?
- How do I use regexps (regular expressions) in Emacs?
- How do I perform a replace operation across more than one file?
- Where is the documentation for
etags
? - How do I disable backup files?
- How do I disable
auto-save-mode
? - Making Emacs write all auxiliary files somewhere else
- How can I go to a certain line given its number?
- How can I create or modify new pull-down menu options?
- How do I delete menus and menu options?
- How do I turn on syntax highlighting?
- How can I force Emacs to scroll only one line when I move past the bottom of the screen?
- How can I edit MS-DOS files using Emacs?
- How can I tell Emacs to fill paragraphs with a single space after each period?
- Why these strange escape sequences from
ls
from the Shell mode? - How can I start Emacs in fullscreen mode on MS-Windows?
- How can I alleviate the limitations of the Linux console?
Next: How do I start using Customize?, Up: Common requests [Contents][Index]
5.1 How do I set up an init file properly?
When Emacs is started, it normally tries to load a Lisp program from an initialization file, or init file for short. This file, if it exists, specifies how to initialize Emacs for you. Traditionally, file ~/.emacs is used as the init file, although Emacs also looks at ~/.emacs.el, ~/.emacs.d/init.el, ~/.config/emacs/init.el, or other locations. See Init File in The GNU Emacs Manual.
Emacs includes the Customize facility (see How do I start using Customize?). This allows users who are unfamiliar with Emacs Lisp to modify their init files in a relatively straightforward way, using menus rather than Lisp code.
While Customize might indeed make it easier to configure Emacs, consider taking a bit of time to learn Emacs Lisp and modifying your init file directly. Simple configuration options are described rather completely in Init File in The GNU Emacs Manual, for users interested in performing frequently requested, basic tasks.
In general, new Emacs users should not be provided with init files, because this can cause confusing non-standard behavior. Then they send questions to the help-gnu-emacs mailing list asking why Emacs isn’t behaving as documented.
Next: How do I get colors and syntax highlighting on a TTY?, Previous: How do I set up an init file properly?, Up: Common requests [Contents][Index]
5.2 How do I start using Customize?
The main Customize entry point is M-x customize RET. This command takes you to a buffer listing all the available Customize groups. From there, you can access all customizable options and faces, change their values, and save your changes to your init file. See Easy Customization in The GNU Emacs Manual.
If you know the name of the group in advance (e.g., “shell”), use M-x customize-group RET.
If you wish to customize a single option, use M-x customize-option RET. This command prompts you for the name of the option to customize, with completion.
Next: How do I debug an init file?, Previous: How do I start using Customize?, Up: Common requests [Contents][Index]
5.3 How do I get colors and syntax highlighting on a TTY?
Colors and faces are supported in non-windowed mode, i.e., on Unix and
GNU/Linux text-only terminals and consoles, and when invoked as
‘emacs -nw’ on X, MS-DOS and MS-Windows. Emacs automatically
detects color support at startup and uses it if available. If you
think that your terminal supports colors, but Emacs won’t use them,
check the termcap
entry for your display type for color-related
capabilities.
The command M-x list-colors-display pops up a window which exhibits all the colors Emacs knows about on the current display.
Syntax highlighting is also on by default on text-only terminals.
Emacs 26.1 and later support direct color mode in terminals. If Emacs finds Terminfo capabilities ‘setb24’ and ‘setf24’, 24-bit direct color mode is used. The capability strings are expected to take one 24-bit pixel value as argument and transform the pixel to a string that can be used to send 24-bit colors to the terminal.
Standard terminal definitions don’t support these capabilities and therefore custom definition is needed.
$ cat terminfo-custom.src xterm-emacs|xterm with 24-bit direct color mode for Emacs, use=xterm-256color, setb24=\E[48\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&\ %d\:%p1%{255}%&%dm, setf24=\E[38\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&\ %d\:%p1%{255}%&%dm, $ tic -x -o ~/.terminfo terminfo-custom.src $ TERM=xterm-emacs emacs -nw
Emacs 27.1 and later support Terminfo capability ‘RGB’ for detecting 24-bit direct color mode. Multiple standard terminal definitions support this capability.
$ TERM=xterm-direct infocmp | grep seta[bf] setab=\E[%?%p1%{8}%<%t4%p1%d%e48\:2\:\:%p1%{65536}%/\ %d\:%p1%{256}%/%{255}%&%d\:%p1%{255}%&%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e38\:2\:\:%p1%{65536}%/\ %d\:%p1%{256}%/%{255}%&%d\:%p1%{255}%&%d%;m, $ TERM=xterm-direct emacs -nw
If your terminal is incompatible with XTerm, you may have to use
another TERM
definition. Any terminal whose name includes
‘direct’ should be a candidate. The toe
command can be
used to find out which of these are installed on your system:
$ toe | grep '\-direct' konsole-direct konsole with direct-color indexing vte-direct vte with direct-color indexing st-direct st with direct-color indexing xterm-direct2 xterm with direct-color indexing (old) xterm-direct xterm with direct-color indexing
If Terminfo database is not available, but 24-bit direct color mode is
supported, it can still be enabled by defining the environment
variable COLORTERM
to ‘truecolor’.
Terminals with ‘RGB’ capability treat pixels #000001 - #000007 as indexed colors to maintain backward compatibility with applications that are unaware of direct color mode. Therefore the seven darkest blue shades may not be available. If this is a problem, you can always use custom terminal definition with ‘setb24’ and ‘setf24’.
Next: How do I make Emacs display the current line (or column) number?, Previous: How do I get colors and syntax highlighting on a TTY?, Up: Common requests [Contents][Index]
5.4 How do I debug an init file?
Start Emacs with the ‘-debug-init’ command-line option. This enables the Emacs Lisp debugger before evaluating your init file, and places you in the debugger if something goes wrong. The top line in the trace-back buffer will be the error message, and the second or third line of that buffer will display the Lisp code from your init file that caused the problem.
You can also evaluate an individual function or argument to a function in your init file by moving the cursor to the end of the function or argument and typing C-x C-e (M-x eval-last-sexp).
Use C-h v (M-x describe-variable) to check the value of variables which you are trying to set or use.
Next: How can I modify the titlebar to contain the current file name?, Previous: How do I debug an init file?, Up: Common requests [Contents][Index]
5.5 How do I make Emacs display the current line (or column) number?
By default, Emacs displays the current line number of the point in the
mode line. You can toggle this feature off or on with the command
M-x line-number-mode, or by setting the variable
line-number-mode
. Note that Emacs will not display the line
number if the buffer’s size in bytes is larger than the value of the
variable line-number-display-limit
.
You can similarly display the current column with M-x column-number-mode, or by putting the form
(setq column-number-mode t)
in your init file (see How do I set up an init file properly?). This feature is off by default.
The "%c"
format specifier in the variable mode-line-format
will insert the current column’s value into the mode line. See the
documentation for mode-line-format
(using C-h v
mode-line-format RET) for more information on how to set and use
this variable.
The ‘display-line-numbers’ package (added to Emacs in version
26.1) displays line numbers in the text area, before each line, like
the “set number” capability of ‘vi’. Customize the
buffer-local variable display-line-numbers
to activate this
optional display. Alternatively, you can use the
display-line-numbers-mode
minor mode or the global
global-display-line-numbers-mode
. When using these modes,
customize display-line-numbers-type
with the same value as you
would use with display-line-numbers
.
Next: How do I turn on abbrevs by default just in mode mymode?, Previous: How do I make Emacs display the current line (or column) number?, Up: Common requests [Contents][Index]
5.6 How can I modify the titlebar to contain the current file name?
The contents of an Emacs frame’s titlebar is controlled by the variable
frame-title-format
, which has the same structure as the variable
mode-line-format
. (Use C-h v or M-x
describe-variable to get information about one or both of these
variables.)
By default, the titlebar for a frame does contain the name of the buffer
currently being visited, except if there is a single frame. In such a
case, the titlebar contains Emacs invocation name and the name of the
machine at which Emacs was invoked. This is done by setting
frame-title-format
to the default value of
(multiple-frames "%b" ("" "%b - GNU Emacs at " system-name))
To modify the behavior such that frame titlebars contain the buffer’s name regardless of the number of existing frames, include the following in your init file (see How do I set up an init file properly?):
(setq frame-title-format "%b")
Next: How do I make Emacs use a certain major mode for certain files?, Previous: How can I modify the titlebar to contain the current file name?, Up: Common requests [Contents][Index]
5.7 How do I turn on abbrevs by default just in mode mymode?
Abbrev mode expands abbreviations as you type them. To turn it on in a specific buffer, use M-x abbrev-mode. To turn it on in every buffer by default, put this in your init file (see How do I set up an init file properly?):
(setq-default abbrev-mode t)
To turn it on in a specific mode, use:
(add-hook 'mymode-mode-hook (lambda () (setq abbrev-mode t)))
Next: How can I replace highlighted text with what I type?, Previous: How do I turn on abbrevs by default just in mode mymode?, Up: Common requests [Contents][Index]
5.8 How do I make Emacs use a certain major mode for certain files?
If you want to use a certain mode foo for all files whose names end with the extension .bar, this will do it for you:
(add-to-list 'auto-mode-alist '("\\.bar\\'" . foo-mode))
Alternatively, put this somewhere in the first line of any file you want to edit in the mode foo (in the second line, if the first line begins with ‘#!’):
-*- foo -*-
The variable interpreter-mode-alist
specifies which mode to use
when loading an interpreted script (e.g., shell, python, etc.). Emacs
determines which interpreter you’re using by examining the first line of
the script. Use C-h v (or M-x describe-variable) on
interpreter-mode-alist
to learn more.
Next: How do I control Emacs’s case-sensitivity when searching/replacing?, Previous: How do I make Emacs use a certain major mode for certain files?, Up: Common requests [Contents][Index]
5.9 How can I replace highlighted text with what I type?
Use delete-selection-mode
, which you can start automatically by
placing the following Lisp form in your init file (see How do I set up an init file properly?):
(delete-selection-mode 1)
According to the documentation string for delete-selection-mode
(which you can read using M-x describe-function RET
delete-selection-mode RET):
When Delete Selection mode is enabled, typed text replaces the selection if the selection is active. Otherwise, typed text is just inserted at point regardless of any selection.
This mode also allows you to delete (not kill) the highlighted region by pressing DEL.
Next: How do I search for, delete, or replace unprintable (eight-bit or control) characters?, Previous: How can I replace highlighted text with what I type?, Up: Common requests [Contents][Index]
5.10 How do I control Emacs’s case-sensitivity when searching/replacing?
The value of the variable case-fold-search
determines whether
searches are case sensitive:
(setq case-fold-search nil) ; make searches case sensitive (setq case-fold-search t) ; make searches case insensitive
Similarly, for replacing, the variable case-replace
determines
whether replacements preserve case.
You can also toggle case sensitivity at will in isearch with M-c.
To change the case sensitivity just for one major mode, use the major mode’s hook. For example:
(add-hook 'foo-mode-hook (lambda () (setq case-fold-search nil)))
Next: How do I input a newline character in isearch or query-replace?, Previous: How do I control Emacs’s case-sensitivity when searching/replacing?, Up: Common requests [Contents][Index]
5.11 How do I search for, delete, or replace unprintable (eight-bit or control) characters?
To search for a single character that appears in the buffer as, for example, ‘\237’, you can type C-s C-q 2 3 7. Searching for all unprintable characters is best done with a regular expression (regexp) search. The easiest regexp to use for the unprintable chars is the complement of the regexp for the printable chars.
- Regexp for the printable chars: ‘[\t\n\r\f -~]’
- Regexp for the unprintable chars: ‘[^\t\n\r\f -~]’
To type these special characters in an interactive argument to
isearch-forward-regexp
or re-search-forward
, you need to
use C-q. (‘\t’, ‘\n’, ‘\r’, and ‘\f’ stand
respectively for TAB, LFD, RET, and C-l.) So,
to search for unprintable characters using re-search-forward
:
M-x re-search-forward RET [^ TAB C-q LFD C-q RET C-q C-l SPC -~] RET
Using isearch-forward-regexp
:
C-M-s [^ TAB LFD C-q RET C-q C-l SPC -~]
To delete all unprintable characters, simply use replace-regexp:
M-x replace-regexp RET [^ TAB C-q LFD C-q RET C-q C-l SPC -~] RET RET
Replacing is similar to the above. To replace all unprintable characters with a colon, use:
M-x replace-regexp RET [^ TAB C-q LFD C-q RET C-q C-l SPC -~] RET : RET
Next: How do I copy text from the kill ring into the search string?, Previous: How do I search for, delete, or replace unprintable (eight-bit or control) characters?, Up: Common requests [Contents][Index]
5.12 How do I input a newline character in isearch or query-replace?
Use C-q C-j. For more information, see Special Input for Incremental Search in The GNU Emacs Manual.
Next: How do I make Emacs wrap words for me?, Previous: How do I input a newline character in isearch or query-replace?, Up: Common requests [Contents][Index]
5.13 How do I copy text from the kill ring into the search string?
Use M-y. See Isearch Yank in The GNU Emacs Manual.
Next: How do I turn on auto-fill-mode
by default?, Previous: How do I copy text from the kill ring into the search string?, Up: Common requests [Contents][Index]
5.14 How do I make Emacs wrap words for me?
Use auto-fill-mode
, activated by typing M-x auto-fill-mode.
The default maximum line width is 70, determined by the variable
fill-column
. To learn how to turn this on automatically, see
How do I turn on auto-fill-mode
by default?.
Next: How do I change load-path
?, Previous: How do I make Emacs wrap words for me?, Up: Common requests [Contents][Index]
5.15 How do I turn on auto-fill-mode
by default?
To turn on auto-fill-mode
just once for one buffer, use M-x
auto-fill-mode.
To turn it on for every buffer in a certain mode, you must use the
hook for that mode. For example, to turn on auto-fill
mode for
all text buffers, including the following in your init file
(see How do I set up an init file properly?):
(add-hook 'text-mode-hook 'turn-on-auto-fill)
If you want auto-fill
mode on in all major modes, do this:
(setq-default auto-fill-function 'do-auto-fill)
Next: How do I use an already running Emacs from another window?, Previous: How do I turn on auto-fill-mode
by default?, Up: Common requests [Contents][Index]
5.16 How do I change load-path
?
In general, you should only add to the load-path
. You can add
directory /dir/subdir to the load path like this:
(add-to-list 'load-path "/dir/subdir/")
To do this relative to your home directory:
(add-to-list 'load-path "~/mysubdir/")
Next: How do I make Emacs recognize my compiler’s funny error messages?, Previous: How do I change load-path
?, Up: Common requests [Contents][Index]
5.17 How do I use an already running Emacs from another window?
emacsclient
, which comes with Emacs, is for editing a file using
an already running Emacs rather than starting up a new Emacs. It does
this by sending a request to the already running Emacs, which must be
expecting the request.
- Setup:
Emacs must have executed the
server-start
function for ‘emacsclient’ to work. This can be done either by a command line option:emacs -f server-start
or by invoking
server-start
from init file (see How do I set up an init file properly?):(if (some conditions are met) (server-start))
To get your news reader, mail reader, etc., to invoke ‘emacsclient’, try setting the environment variable
EDITOR
(or sometimesVISUAL
) to the value ‘emacsclient’. You may have to specify the full pathname of the ‘emacsclient’ program instead. Examples:# csh commands: setenv EDITOR emacsclient # using full pathname setenv EDITOR /usr/local/emacs/etc/emacsclient # sh command: EDITOR=emacsclient ; export EDITOR
- Normal use:
When ‘emacsclient’ is run, it connects to the socket and passes its command line options to Emacs, which at the next opportunity will visit the files specified. (Line numbers can be specified just like with Emacs.) The user will have to switch to the Emacs window by hand. When the user is done editing a file, the user can type C-x # (or M-x server-edit) to indicate this. If there is another buffer requested by
emacsclient
, Emacs will switch to it; otherwiseemacsclient
will exit, signaling the calling program to continue.
For more information, See Emacs Server in The GNU Emacs Manual.
Next: How do I change the indentation for switch
?, Previous: How do I use an already running Emacs from another window?, Up: Common requests [Contents][Index]
5.18 How do I make Emacs recognize my compiler’s funny error messages?
Customize the compilation-error-regexp-alist
variable.
Next: How to customize indentation in C, C++, and Java buffers?, Previous: How do I make Emacs recognize my compiler’s funny error messages?, Up: Common requests [Contents][Index]
5.19 How do I change the indentation for switch
?
Many people want to indent their switch
statements like this:
f() { switch(x) { case A: x1; break; case B: x2; break; default: x3; } }
To achieve this, add the following line to your init file (see How do I set up an init file properly?):
(c-set-offset 'case-label '+)
Next: How do I make Emacs “typeover” or “overwrite” instead of inserting?, Previous: How do I change the indentation for switch
?, Up: Common requests [Contents][Index]
5.20 How to customize indentation in C, C++, and Java buffers?
The Emacs cc-mode
features an interactive procedure for
customizing the indentation style, which is fully explained in the
CC Mode manual that is part of the Emacs distribution, see
Customization Indentation in The CC Mode Manual. Here’s a short summary of the procedure:
- Go to the beginning of the first line where you don’t like the indentation and type C-c C-o. Emacs will prompt you for the syntactic symbol; type RET to accept the default it suggests.
- Emacs now prompts for the offset of this syntactic symbol, showing the
default (the current definition) inside parentheses. You can choose
one of these:
0
No extra indentation.
+
Indent one basic offset.
-
Outdent one basic offset.
++
Indent two basic offsets
--
Outdent two basic offsets.
*
Indent half basic offset.
/
Outdent half basic offset.
- After choosing one of these symbols, type C-c C-q to reindent the line or the block according to what you just specified.
- If you don’t like the result, go back to step 1. Otherwise, add the
following line to your init file (see How do I set up an init file properly?):
(c-set-offset 'syntactic-symbol offset)
where syntactic-symbol is the name Emacs shows in the minibuffer when you type C-c C-o at the beginning of the line, and offset is one of the indentation symbols listed above (
+
,/
,0
, etc.) that you’ve chosen during the interactive procedure. - Go to the next line whose indentation is not to your liking and repeat the process there.
It is recommended to put all the resulting (c-set-offset ...)
customizations inside a C mode hook, like this:
(defun my-c-mode-hook () (c-set-offset ...) (c-set-offset ...)) (add-hook 'c-mode-hook 'my-c-mode-hook)
Using c-mode-hook
avoids the need to put a (require 'cc-mode)
into your init file, because c-set-offset
might be
unavailable when cc-mode
is not loaded.
Note that c-mode-hook
runs for C source files only; use
c++-mode-hook
for C++ sources, java-mode-hook
for
Java sources, etc. If you want the same customizations to be in
effect in all languages supported by cc-mode
, use
c-mode-common-hook
.
Next: How do I stop Emacs from beeping on a terminal?, Previous: How to customize indentation in C, C++, and Java buffers?, Up: Common requests [Contents][Index]
5.21 How do I make Emacs “typeover” or “overwrite” instead of inserting?
M-x overwrite-mode (a minor mode). This toggles
overwrite-mode
on and off, so exiting from overwrite-mode
is as easy as another M-x overwrite-mode.
On some systems, Insert toggles overwrite-mode
on and off.
Next: How do I turn down the bell volume in Emacs running under X?, Previous: How do I make Emacs “typeover” or “overwrite” instead of inserting?, Up: Common requests [Contents][Index]
5.22 How do I stop Emacs from beeping on a terminal?
Martin R. Frank writes:
Tell Emacs to use the visible bell instead of the audible bell, and set the visible bell to nothing.
That is, put the following in your TERMCAP
environment variable
(assuming you have one):
... :vb=: ...
And evaluate the following Lisp form:
(setq visible-bell t)
Next: How do I tell Emacs to automatically indent a new line to the indentation of the previous line?, Previous: How do I stop Emacs from beeping on a terminal?, Up: Common requests [Contents][Index]
5.23 How do I turn down the bell volume in Emacs running under X?
On X Window system, you can adjust the bell volume and duration for all
programs with the shell command xset
.
Invoking xset
without any arguments produces some basic
information, including the following:
usage: xset [-display host:dpy] option ... To turn bell off: -b b off b 0 To set bell volume, pitch and duration: b [vol [pitch [dur]]] b on
Next: How do I show which parenthesis matches the one I’m looking at?, Previous: How do I turn down the bell volume in Emacs running under X?, Up: Common requests [Contents][Index]
5.24 How do I tell Emacs to automatically indent a new line to the indentation of the previous line?
Such behavior is automatic (in Text mode). From the etc/NEWS file for Emacs 20.2:
** In Text mode, now only blank lines separate paragraphs. This makes
it possible to get the full benefit of Adaptive Fill mode in Text mode,
and other modes derived from it (such as Mail mode). TAB in Text
mode now runs the command indent-relative
; this makes a practical
difference only when you use indented paragraphs.
If you want spaces at the beginning of a line to start a paragraph, use
the new mode, Paragraph Indent Text mode.
If you have auto-fill-mode
turned on (see How do I turn on auto-fill-mode
by default?), you can tell Emacs to prefix every line with a certain
character sequence, the fill prefix. Type the prefix at the
beginning of a line, position point after it, and then type C-x .
(set-fill-prefix
) to set the fill prefix. Thereafter,
auto-filling will automatically put the fill prefix at the beginning of
new lines, and M-q (fill-paragraph
) will maintain any fill
prefix when refilling the paragraph.
If you have paragraphs with different levels of indentation, you will have to set the fill prefix to the correct value each time you move to a new paragraph. There are many packages available to deal with this (see Where can I get Emacs Lisp packages that don’t come with Emacs?). Look for “fill” and “indent” keywords for guidance.
Next: In C mode, can I show just the lines that will be left after #ifdef
commands are handled by the compiler?, Previous: How do I tell Emacs to automatically indent a new line to the indentation of the previous line?, Up: Common requests [Contents][Index]
5.25 How do I show which parenthesis matches the one I’m looking at?
By default, show-paren-mode
is enabled in all editing buffers.
Alternatives to this mode include:
- If you’re looking at a right parenthesis (or brace or bracket) you can delete it and reinsert it. Emacs will momentarily move the cursor to the matching parenthesis.
- C-M-f (
forward-sexp
) and C-M-b (backward-sexp
) will skip over one set of balanced parentheses, so you can see which parentheses match. (You can train it to skip over balanced brackets and braces at the same time by modifying the syntax table.) -
Here is some Emacs Lisp that will make the % key show the matching
parenthesis, like in
vi
. In addition, if the cursor isn’t over a parenthesis, it simply inserts a % like normal.;; By an unknown contributor (global-set-key "%" 'match-paren) (defun match-paren (arg) "Go to the matching paren if on a paren; otherwise insert %." (interactive "p") (cond ((looking-at "\\s(") (forward-list 1) (backward-char 1)) ((looking-at "\\s)") (forward-char 1) (backward-list 1)) (t (self-insert-command (or arg 1)))))
Next: How do I repeat a command as many times as possible?, Previous: How do I show which parenthesis matches the one I’m looking at?, Up: Common requests [Contents][Index]
5.26 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 might also want to investigate cpp.el, which is distributed with Emacs.
Next: What are the valid X resource settings (i.e., stuff in .Xdefaults)?, Previous: In C mode, can I show just the lines that will be left after #ifdef
commands are handled by the compiler?, Up: Common requests [Contents][Index]
5.27 How do I repeat a command as many times as possible?
Use the repeat
command (C-x z) to repeat the last
command. If you preface it with a prefix argument, the prefix arg is
applied to the command.
You can also type C-x ESC ESC
(repeat-complex-command
) to reinvoke commands that used the
minibuffer to get arguments. In repeat-complex-command
you can
type M-p and M-n (and also up-arrow and down-arrow, if your
keyboard has these keys) to scan through all the different complex
commands you’ve typed.
To repeat a set of commands, use keyboard macros. Use C-x ( and C-x ) to make a keyboard macro that invokes the command and then type C-x e. See Keyboard Macros in The GNU Emacs Manual.
If you’re really desperate for the .
command in vi
that
redoes the last insertion/deletion, use VIPER, a vi
emulation
mode which comes with Emacs, and which appears to support it.
Next: How do I execute (“evaluate”) a piece of Emacs Lisp code?, Previous: How do I repeat a command as many times as possible?, Up: Common requests [Contents][Index]
5.28 What are the valid X resource settings (i.e., stuff in .Xdefaults)?
See X Resources in The GNU Emacs Manual.
You can also use a resource editor, such as editres (for X11R5 and onwards), to look at the resource names for the menu bar, assuming Emacs was compiled with the X toolkit.
Next: How do I change Emacs’s idea of the TAB character’s length?, Previous: What are the valid X resource settings (i.e., stuff in .Xdefaults)?, Up: Common requests [Contents][Index]
5.29 How do I execute (“evaluate”) a piece of Emacs Lisp code?
There are a number of ways to execute (evaluate, in Lisp lingo) an Emacs Lisp form:
- If you want it evaluated every time you run Emacs, put it in a file named .emacs.d/init.el in your home directory. This is known as “your init file,” and contains all of your personal customizations (see How do I set up an init file properly?).
- You can type the form in the *scratch* buffer, and then type LFD (or C-j) after it. The result of evaluating the form will be inserted in the buffer.
- In
emacs-lisp-mode
, typing C-M-x evaluates a top-level form before or around point. - Typing C-x C-e in any buffer evaluates the Lisp form immediately before point and prints its value in the echo area.
- Typing M-: or M-x eval-expression allows you to type a Lisp form in the minibuffer which will be evaluated once you press RET.
- You can use M-x load-file to have Emacs evaluate all the Lisp
forms in a file. (To do this from Lisp use the function
load
instead.)The functions
load-library
,eval-region
,eval-buffer
,require
, andautoload
are also useful; see Where can I get documentation on Emacs Lisp?, if you want to learn more about them.
Next: How do I insert <some text> at the beginning of every line?, Previous: How do I execute (“evaluate”) a piece of Emacs Lisp code?, Up: Common requests [Contents][Index]
5.30 How do I change Emacs’s idea of the TAB character’s length?
Set the default value of the variable tab-width
. For example, to set
TAB stops every 10 characters, insert the following in your
init file (see How do I set up an init file properly?):
(setq-default tab-width 10)
Do not confuse variable tab-width
with variable
tab-stop-list
. The former is used for the display of literal
TAB characters. The latter controls what characters are inserted
when you press the TAB character in certain modes.
Next: 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?, Previous: How do I change Emacs’s idea of the TAB character’s length?, Up: Common requests [Contents][Index]
5.31 How do I insert <some text> at the beginning of every line?
To do this to an entire buffer, type M-< M-x replace-regexp RET ^ RET your text RET.
To do this to a region, use string-insert-rectangle
.
Set the mark (C-SPC) at the beginning of the first line you
want to prefix, move the cursor to last line to be prefixed, and type
M-x string-insert-rectangle RET. To do this for the whole
buffer, type C-x h M-x string-insert-rectangle RET.
If you are trying to prefix a yanked mail message with ‘>’, you
might want to set the variable mail-yank-prefix
. In Message
buffers, you can even use M-; to cite yanked messages (M-;
runs the function comment-region
, it is a general-purpose
mechanism to comment regions) (see How do I change the included text prefix in mail/news followups?).
Next: How do I tell Emacs to iconify itself?, Previous: How do I insert <some text> at the beginning of every line?, Up: Common requests [Contents][Index]
5.32 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?
Use M-x picture-mode.
See also the variable track-eol
and the command
set-goal-column
bound to C-x C-n
(see Moving Point in The GNU Emacs Manual).
Next: How do I use regexps (regular expressions) in Emacs?, Previous: 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?, Up: Common requests [Contents][Index]
5.33 How do I tell Emacs to iconify itself?
C-z iconifies Emacs when running under X and suspends Emacs otherwise. See Frame Commands in The GNU Emacs Manual.
Next: How do I perform a replace operation across more than one file?, Previous: How do I tell Emacs to iconify itself?, Up: Common requests [Contents][Index]
5.34 How do I use regexps (regular expressions) in Emacs?
See Regexp Backslash in The GNU Emacs Manual.
The or
operator is ‘\|’, not ‘|’, and the grouping operators
are ‘\(’ and ‘\)’. Also, the string syntax for a backslash is
‘\\’. To specify a regular expression like ‘xxx\(foo\|bar\)’
in a Lisp string, use ‘xxx\\(foo\\|bar\\)’.
Note the doubled backslashes!
- Unlike in Unix grep, sed, etc., a complement character set (‘[^...]’) can match a newline character (LFD a.k.a. C-j a.k.a. ‘\n’), unless newline is mentioned as one of the characters not to match.
- The character syntax regexps (e.g., ‘\sw’) are not meaningful inside character set regexps (e.g., ‘[aeiou]’). (This is actually typical for regexp syntax.)
Next: Where is the documentation for etags
?, Previous: How do I use regexps (regular expressions) in Emacs?, Up: Common requests [Contents][Index]
5.35 How do I perform a replace operation across more than one file?
Dired mode (M-x dired RET, or C-x d) supports the
command dired-do-find-regexp-and-replace
(Q), which allows
users to replace regular expressions in multiple files.
You can use this command to perform search/replace operations on multiple files by following the following steps:
- Assemble a list of files you want to operate on with either
find-dired
,find-name-dired
orfind-grep-dired
. - Mark all files in the resulting Dired buffer using t.
- Use Q to start a
query-replace-regexp
session on the marked files. - To accept all replacements in each file, hit !.
Another way to do the same thing is to use the “tags” feature of
Emacs: it includes the command tags-query-replace
which performs
a query-replace across all the files mentioned in the TAGS file.
See Identifier Search in The GNU Emacs Manual.
Next: How do I disable backup files?, Previous: How do I perform a replace operation across more than one file?, Up: Common requests [Contents][Index]
5.36 Where is the documentation for etags
?
The etags
man page should be in the same place as the
emacs
man page.
Quick command-line switch descriptions are also available. For example, ‘etags -H’.
Next: How do I disable auto-save-mode
?, Previous: Where is the documentation for etags
?, Up: Common requests [Contents][Index]
5.37 How do I disable backup files?
You probably don’t want to do this, since backups are useful, especially when something goes wrong.
To avoid seeing backup files (and other “uninteresting” files) in
Dired, load dired-x
by adding the following to your init file
(see How do I set up an init file properly?):
(with-eval-after-load 'dired (require 'dired-x))
With dired-x
loaded, C-x M-o toggles omitting in each dired buffer.
You can make omitting the default for new dired buffers by putting the
following in your init file:
(add-hook 'dired-mode-hook 'dired-omit-mode)
If you’re tired of seeing backup files whenever you do an ‘ls’ at
the Unix shell, try GNU ls
with the ‘-B’ option. GNU
ls
is part of the GNU Fileutils package, available from
https://ftp.gnu.org and its mirrors (see Where can I get other up-to-date GNU stuff?).
To disable or change the way backups are made, see Backup Names in The GNU Emacs Manual.
You can control where Emacs puts backup files by customizing the
variable backup-directory-alist
. This variable’s value
specifies that files whose names match specific patterns should have
their backups put in certain directories. A typical use is to add the
element ("." . dir)
to force Emacs to put all
backup files in the directory dir.
Next: Making Emacs write all auxiliary files somewhere else, Previous: How do I disable backup files?, Up: Common requests [Contents][Index]
5.38 How do I disable auto-save-mode
?
You probably don’t want to do this, since auto-saving is useful, especially when Emacs or your computer crashes while you are editing a document.
Instead, you might want to change the variable
auto-save-interval
, which specifies how many keystrokes Emacs
waits before auto-saving. Increasing this value forces Emacs to wait
longer between auto-saves, which might annoy you less.
You might also want to look into Sebastian Kremer’s auto-save
package (see Where can I get Emacs Lisp packages that don’t come with Emacs?). This
package also allows you to place all auto-save files in one directory,
such as /tmp.
To disable or change how auto-save-mode
works,
see Auto Save in The GNU Emacs Manual.
Next: How can I go to a certain line given its number?, Previous: How do I disable auto-save-mode
?, Up: Common requests [Contents][Index]
5.39 Making Emacs write all auxiliary files somewhere else
By default, Emacs may create many new files in the directory where you’re editing a file. If you’re editing the file /home/user/foo.txt, Emacs will create the lock file /home/user/.#foo.txt, the auto-save file /home/user/#foo.txt#, and when you save the file, Emacs will create the backup file /home/user/foo.txt~. (The first two files are deleted when you save the file.)
This may be inconvenient in some setups, so Emacs has mechanisms for changing the locations of all these files.
auto-save-file-name-transforms
(see Auto-Saving in GNU Emacs Lisp Reference Manual).
lock-file-name-transforms
(see File Locks in GNU Emacs Lisp Reference Manual).
backup-directory-alist
(see Making Backups in GNU Emacs Lisp Reference Manual).
For instance, to write all these things to ~/.emacs.d/aux/:
(setq lock-file-name-transforms '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/aux/\\1" t))) (setq auto-save-file-name-transforms '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/aux/\\1" t))) (setq backup-directory-alist '((".*" . "~/.emacs.d/aux/")))
Next: How can I create or modify new pull-down menu options?, Previous: Making Emacs write all auxiliary files somewhere else, Up: Common requests [Contents][Index]
5.40 How can I go to a certain line given its number?
Are you sure you indeed need to go to a line by its number? Perhaps all you want is to display a line in your source file for which a compiler printed an error message? If so, compiling from within Emacs using the M-x compile and M-x recompile commands is a much more effective way of doing that. Emacs automatically intercepts the compile error messages, inserts them into a special buffer called *compilation*, and lets you visit the locus of each message in the source. Type C-x ` to step through the offending lines one by one (you can also use M-g M-p and M-g M-n to go to the previous and next matches directly). Click mouse-2 or press RET on a message text in the *compilation* buffer to go to the line whose number is mentioned in that message.
But if you indeed need to go to a certain text line, type M-g M-g
(which is the default binding of the goto-line
function).
Emacs will prompt you for the number of the line and go to that line.
You can do this faster by invoking goto-line
with a numeric
argument that is the line’s number. For example, C-u 286 M-g M-g
will jump to line number 286 in the current buffer.
Next: How can I force Emacs to scroll only one line when I move past the bottom of the screen?, Previous: How do I delete menus and menu options?, Up: Common requests [Contents][Index]
5.43 How do I turn on syntax highlighting?
font-lock-mode
is the standard way to have Emacs perform syntax
highlighting in the current buffer. It is enabled by default.
With font-lock-mode
turned on, different types of text will
appear in different colors. For instance, in a programming mode,
variables will appear in one face, keywords in a second, and comments in
a third.
To turn font-lock-mode
off within an existing buffer, use
M-x font-lock-mode RET.
Highlighting a buffer with font-lock-mode
can take quite a while,
and cause an annoying delay in display, so several features exist to
work around this.
Turning on font-lock-mode
automatically activates
Just-In-Time fontification provided by jit-lock-mode
.
jit-lock-mode
defers the fontification of portions of buffer
until you actually need to see them, and can also fontify while Emacs
is idle. This makes display of the visible portion of a buffer almost
instantaneous. For details about customizing jit-lock-mode
,
type C-h f jit-lock-mode RET.
Different levels of decoration are available, from slight to gaudy.
More decoration means you need to wait more time for a buffer to be
fontified (or a faster machine). To control how decorated your
buffers should become, set the value of
font-lock-maximum-decoration
in your init file (see How do I set up an init file properly?), with a nil
value indicating default
(usually minimum) decoration, and a t
value indicating the
maximum decoration. For the gaudiest possible look, then, include the
line
(setq font-lock-maximum-decoration t)
in your init file. You can also set this variable such that
different modes are highlighted in a different ways; for more
information, see the documentation for
font-lock-maximum-decoration
with C-h v (or M-x
describe-variable RET).
Also see the documentation for the function font-lock-mode
,
available by typing C-h f font-lock-mode (M-x
describe-function RET font-lock-mode RET).
To print buffers with the faces (i.e., colors and fonts) intact, use
M-x ps-print-buffer-with-faces or M-x
ps-print-region-with-faces. You will need a way to send text to a
PostScript printer, or a PostScript interpreter such as Ghostscript;
consult the documentation of the variables ps-printer-name
,
ps-lpr-command
, and ps-lpr-switches
for more details.
Next: How can I edit MS-DOS files using Emacs?, Previous: How do I turn on syntax highlighting?, Up: Common requests [Contents][Index]
5.44 How can I force Emacs to scroll only one line when I move past the bottom of the screen?
Customize the scroll-conservatively
variable with M-x
customize-variable RET scroll-conservatively RET and set it
to a large value like, say, 10000. For an explanation of what this
means, see Auto Scrolling in The GNU Emacs Manual.
Alternatively, use the following Lisp form in your init file (see How do I set up an init file properly?):
(setq scroll-conservatively most-positive-fixnum)
Next: How can I tell Emacs to fill paragraphs with a single space after each period?, Previous: How can I force Emacs to scroll only one line when I move past the bottom of the screen?, Up: Common requests [Contents][Index]
5.45 How can I edit MS-DOS files using Emacs?
Detection and handling of MS-DOS (and Windows) files is performed transparently. You can open MS-DOS files on a Unix system, edit it, and save it without having to worry about the file format.
When editing an MS-DOS style file, the mode line will indicate that it is a DOS file. On Unix and GNU/Linux systems, and also on a Macintosh, the string ‘(DOS)’ will appear near the left edge of the mode line; on DOS and Windows, where the DOS end-of-line (EOL) format is the default, a backslash (‘\’) will appear in the mode line.
Next: Why these strange escape sequences from ls
from the Shell mode?, Previous: How can I edit MS-DOS files using Emacs?, Up: Common requests [Contents][Index]
5.46 How can I tell Emacs to fill paragraphs with a single space after each period?
Add the following line to your init file (see How do I set up an init file properly?):
(setq sentence-end-double-space nil)
Next: How can I start Emacs in fullscreen mode on MS-Windows?, Previous: How can I tell Emacs to fill paragraphs with a single space after each period?, Up: Common requests [Contents][Index]
5.47 Why these strange escape sequences from ls
from the Shell mode?
In many systems, ls
is aliased to ‘ls --color’, which
prints using ANSI color escape sequences. Emacs includes the
ansi-color
package, which lets Shell mode recognize these
escape sequences. It is enabled by default.
Next: How can I alleviate the limitations of the Linux console?, Previous: Why these strange escape sequences from ls
from the Shell mode?, Up: Common requests [Contents][Index]
5.48 How can I start Emacs in fullscreen mode on MS-Windows?
Beginning with Emacs 24.4 either run Emacs with the ‘--maximized’ command-line option or put the following form in your init file (see How do I set up an init file properly?):
(add-hook 'emacs-startup-hook 'toggle-frame-maximized)
With older versions use the function w32-send-sys-command
. For
example, you can put the following in your init file:
(add-hook 'emacs-startup-hook (lambda () (w32-send-sys-command ?\xF030)))
To avoid the slightly distracting visual effect of Emacs starting with
its default frame size and then growing to fullscreen, you can add an
‘Emacs.Geometry’ entry to the Windows Registry settings. See X
Resources in The GNU Emacs Manual. To compute the correct
values for width and height you use in the Registry settings, first
maximize the Emacs frame and then evaluate (frame-height)
and
(frame-width)
with M-:.
Alternatively, you can avoid the visual effect of Emacs changing its frame size entirely in your init file (i.e., without using the Registry), like this:
(setq frame-resize-pixelwise t) (set-frame-position nil 0 0) (set-frame-size nil (display-pixel-width) (display-pixel-height) t)
Previous: How can I start Emacs in fullscreen mode on MS-Windows?, Up: Common requests [Contents][Index]
5.49 How can I alleviate the limitations of the Linux console?
If possible, we recommend running Emacs inside fbterm
, when
in a Linux console. This brings the Linux console on par with most
terminal emulators under X. To do this, install fbterm
, for
example with the package manager of your GNU/Linux distribution, and
execute the command
$ fbterm
This will create a sample configuration file ~/.fbtermrc in
your home directory. Edit that file and change the options
font-names
and font-size
if necessary. For the former,
you can choose one or more of the lines in the output of the following
command, separated by commas:
$ fc-list :spacing=mono family | sed 's/ /\\ /g'
Note that you can fine-tune the appearance of the fonts by adding attribute-value pairs, separated by colons, after each font name. For example,
font-names=DejaVu\ Sans\ Mono:style=bold:antialias=false
selects the bold style of the DejaVu Sans Mono font, and disables anti-aliasing.
You can now start Emacs inside fbterm
with the command
$ fbterm -- env TERM=fbterm emacs
In some versions of fbterm
, setting TERM
to
‘fbterm’ can be omitted. To check whether it is needed, start
Emacs inside fbterm
with the command
$ fbterm -- emacs
and type M-x list-colors-display. If only 8 colors are displayed, it is necessary; if 256 colors are displayed, it isn’t.
You may want to add an alias for that command in your shell configuration file. For example, if you use Bash, you can add the following line to your ~/.bashrc file:
alias emacs="fbterm -- env TERM=fbterm emacs"
or, if you use Emacs both in the Linux console and under X:
[[ "$(tty)" =~ "/dev/tty" ]] && alias emacs="fbterm -- env TERM=fbterm emacs"
The fbterm
terminal emulator may define a number of key
bindings for its own use, some of which conflict with those that Emacs
uses. Execute the following two commands as root to ensure that
fbterm
does not define these key bindings:
# chmod a-s `which fbterm` # setcap cap_sys_tty_config=-ep `which fbterm`
If you use Emacs as root, the above is not enough however, because the
root user has all privileges. You can use the following command to
start Emacs inside fbterm
as root while ensuring that
fbterm
does not define any key bindings for its own use:
# capsh --drop=cap_sys_tty_config -- -c "fbterm -- env TERM=fbterm emacs"
Again you may want to add a shortcut for that command in the shell configuration file of the root user. In this case however, it is not possible to use an alias, because the command line arguments passed to Emacs need to be inserted in the string at the end of the command. A wrapper script or a function can be used to do that. For example, if you use Bash, you can add the following function in the root user ~/.bashrc file:
function emacs () { CMD="fbterm -- env TERM=fbterm emacs " for ARG in "$@" do CMD="$CMD '$ARG' " done capsh --drop=cap_sys_tty_config -- -c "$CMD" }
Next: Compiling and installing Emacs, Previous: Common requests, Up: The GNU Emacs FAQ [Contents][Index]
6 Bugs and problems
The Emacs manual lists some common kinds of trouble users could get into, see Dealing with Emacs Trouble in The GNU Emacs Manual, so you might look there if the problem you encounter isn’t described in this chapter. If you decide you’ve discovered a bug, see Reporting Bugs in The GNU Emacs Manual, for instructions how to do that.
The file etc/PROBLEMS in the Emacs distribution lists various known problems with building and using Emacs on specific platforms; type C-h C-p to read it.
- Does Emacs have problems with large files?
- How do I get rid of ‘^M’ or echoed commands in my shell buffer?
- Why do I get an error message when I try to run M-x shell?
- Where is the termcap/terminfo entry for terminal type ‘emacs’?
- Why does Emacs say ‘Error in init file’?
- Why does Emacs ignore my X resources (my .Xdefaults file)?
- Why don’t my customizations of the frame parameters work?
- How do I edit a file with a ‘$’ in its name?
- Why does shell mode lose track of the shell’s current directory?
- Are there any security risks in Emacs?
- Dired says, ‘no file on this line’ when I try to do something.
Next: How do I get rid of ‘^M’ or echoed commands in my shell buffer?, Up: Bugs and problems [Contents][Index]
6.1 Does Emacs have problems with large files?
Emacs has an inherent fixed limitation on the size of buffers. This limit is stricter than the maximum size of objects supported by other programs on the same architecture.
The maximum buffer size on 32-bit machines is 512 MBytes. If Emacs
was built using the --with-wide-int
flag, the maximum buffer
size on 32-bit machines is 2 GB.
Emacs compiled on a 64-bit machine can handle much larger buffers; up
to most-positive-fixnum
(2.3 exabytes).
Due to things like decoding of multibyte characters, you can only visit files with a size that is roughly half the buffer size limit. When visiting compressed archives, the file size limit will be smaller than that due to decompression.
Next: Why do I get an error message when I try to run M-x shell?, Previous: Does Emacs have problems with large files?, Up: Bugs and problems [Contents][Index]
6.2 How do I get rid of ‘^M’ or echoed commands in my shell buffer?
Try typing M-x comint-strip-ctrl-m RET while in shell-mode
to
make them go away. If that doesn’t work, you have several options:
For tcsh
, put this in your .cshrc (or .tcshrc)
file:
if ($?INSIDE_EMACS && $?tcsh) unset edit stty -icrnl -onlcr -echo susp ^Z endif
Or put this in your .emacs_tcsh or ~/.emacs.d/init_tcsh.sh file:
unset edit stty -icrnl -onlcr -echo susp ^Z
Alternatively, use csh
in your shell buffers instead of
tcsh
. One way is:
(setq explicit-shell-file-name "/bin/csh")
and another is to do this in your .cshrc (or .tcshrc) file:
setenv ESHELL /bin/csh
(You must start Emacs over again with the environment variable properly set for this to take effect.)
You can also set the ESHELL
environment variable in Emacs Lisp
with the following Lisp form,
(setenv "ESHELL" "/bin/csh")
The above solutions try to prevent the shell from producing the ‘^M’ characters in the first place. If this is not possible (e.g., if you use a Windows shell), you can get Emacs to remove these characters from the buffer by adding this to your init file (see How do I set up an init file properly?):
(add-hook 'comint-output-filter-functions #'comint-strip-ctrl-m)
On a related note: if your shell is echoing your input line in the shell
buffer, you might want to customize the comint-process-echoes
variable in your shell buffers, or try the following command in your
shell start-up file:
stty -icrnl -onlcr -echo susp ^Z
Next: Where is the termcap/terminfo entry for terminal type ‘emacs’?, Previous: How do I get rid of ‘^M’ or echoed commands in my shell buffer?, Up: Bugs and problems [Contents][Index]
6.3 Why do I get an error message when I try to run M-x shell?
This might happen because Emacs tries to look for the shell in a wrong
place. If you know where your shell executable is, set the variable
explicit-shell-file-name
in your init file (see How do I set up an init file properly?) to point to its full file name.
Some people have trouble with Shell Mode on MS-Windows because of intrusive antivirus software; disabling the resident antivirus program solves the problems in those cases.
Next: Why does Emacs say ‘Error in init file’?, Previous: Why do I get an error message when I try to run M-x shell?, Up: Bugs and problems [Contents][Index]
6.4 Where is the termcap/terminfo entry for terminal type ‘emacs’?
The termcap entry for terminal type ‘emacs’ is ordinarily put in the ‘TERMCAP’ environment variable of subshells. It may help in certain situations (e.g., using rlogin from shell buffer) to add an entry for ‘emacs’ to the system-wide termcap file. Here is a correct termcap entry for ‘emacs’:
emacs:tc=unknown:
To make a terminfo entry for ‘emacs’, use tic
or
captoinfo
. You need to generate
/usr/lib/terminfo/e/emacs. It may work to simply copy
/usr/lib/terminfo/d/dumb to /usr/lib/terminfo/e/emacs.
Having a termcap/terminfo entry will not enable the use of full screen programs in shell buffers. Use M-x term for that instead.
A workaround to the problem of missing termcap/terminfo entries is to
change terminal type ‘emacs’ to type ‘dumb’ or ‘unknown’
in your shell start up file. csh
users could put this in their
.cshrc files:
if ("$term" == emacs) set term=dumb
Next: Why does Emacs ignore my X resources (my .Xdefaults file)?, Previous: Where is the termcap/terminfo entry for terminal type ‘emacs’?, Up: Bugs and problems [Contents][Index]
6.5 Why does Emacs say ‘Error in init file’?
An error occurred while loading either your init file or the system-wide file site-lisp/default.el. Emacs pops the *Messages* buffer, and puts there some additional information about the error, to provide some hints for debugging.
For information on how to debug your init file, see How do I debug an init file?.
It may be the case that you need to load some package first, or use a hook that will be evaluated after the package is loaded. A common case of this is explained in Why doesn’t this [terminal or window-system setup] code work in my init file, but it works just fine after Emacs starts up?.
Next: Why don’t my customizations of the frame parameters work?, Previous: Why does Emacs say ‘Error in init file’?, Up: Bugs and problems [Contents][Index]
6.6 Why does Emacs ignore my X resources (my .Xdefaults file)?
Emacs searches for X resources in the files specified by the following environment variables:
-
XFILESEARCHPATH
-
XUSERFILESEARCHPATH
-
XAPPLRESDIR
This emulates the functionality provided by programs written using the Xt toolkit.
XFILESEARCHPATH
and XUSERFILESEARCHPATH
should be a list
of file names separated by colons. XAPPLRESDIR
should be a list
of directories separated by colons.
Emacs searches for X resources:
- specified on the command line, with the ‘-xrm RESOURCESTRING’ option,
- then in the value of the ‘XENVIRONMENT’ environment variable,
- - or if that is unset, in the file named ~/.Xdefaults-hostname if it exists (where hostname is the name of the machine Emacs is running on),
- then in the screen-specific and server-wide resource properties provided
by the server,
- - or if those properties are unset, in the file named ~/.Xdefaults if it exists,
- then in the files listed in ‘XUSERFILESEARCHPATH’,
- - or in files named lang/Emacs in directories listed in
‘XAPPLRESDIR’ (where lang is the value of the
LANG
environment variable), if the ‘LANG’ environment variable is set, - - or in files named Emacs in the directories listed in ‘XAPPLRESDIR’
- - or in ~/lang/Emacs (if the
LANG
environment variable is set), - - or in ~/Emacs,
- - or in files named lang/Emacs in directories listed in
‘XAPPLRESDIR’ (where lang is the value of the
- then in the files listed in
XFILESEARCHPATH
.
Next: How do I edit a file with a ‘$’ in its name?, Previous: Why does Emacs ignore my X resources (my .Xdefaults file)?, Up: Bugs and problems [Contents][Index]
6.7 Why don’t my customizations of the frame parameters work?
This probably happens because you have set the frame parameters in the
variable initial-frame-alist
. That variable holds parameters
used only for the first frame created when Emacs starts. To customize
the parameters of all frames, change the variable
default-frame-alist
instead.
These two variables exist because many users customize the initial frame in a special way. For example, you could determine the position and size of the initial frame, but would like to control the geometry of the other frames by individually positioning each one of them.
Next: Why does shell mode lose track of the shell’s current directory?, Previous: Why don’t my customizations of the frame parameters work?, Up: Bugs and problems [Contents][Index]
6.8 How do I edit a file with a ‘$’ in its name?
When entering a file name in the minibuffer, Emacs will attempt to expand a ‘$’ followed by a word as an environment variable. To suppress this behavior, type $$ instead.
Next: Are there any security risks in Emacs?, Previous: How do I edit a file with a ‘$’ in its name?, Up: Bugs and problems [Contents][Index]
6.9 Why does shell mode lose track of the shell’s current directory?
Emacs has no way of knowing when the shell actually changes its directory. This is an intrinsic limitation of Unix. So it tries to guess by recognizing ‘cd’ commands. If you type cd followed by directory with a variable reference (cd $HOME/bin) or with a shell metacharacter (cd ../lib*), Emacs will fail to correctly guess the shell’s new current directory. A huge variety of fixes and enhancements to shell mode for this problem have been written to handle this problem (see How do I find an Emacs Lisp package that does XXX?).
You can tell Emacs the shell’s current directory with the command M-x dirs.
Next: Dired says, ‘no file on this line’ when I try to do something., Previous: Why does shell mode lose track of the shell’s current directory?, Up: Bugs and problems [Contents][Index]
6.10 Are there any security risks in Emacs?
- Third party packages.
Any package you install into Emacs can run arbitrary code with the same privileges as the Emacs process itself. Be aware of this when you use the package system (e.g.
M-x list-packages
) with third party archives. Use only third parties that you can trust! - The
file-local-variable
feature. (Yes, a risk, but easy to change.)There is an Emacs feature that allows the setting of local values for variables when editing a file by including specially formatted text near the end of the file. This feature also includes the ability to have arbitrary Emacs Lisp code evaluated when the file is visited. Obviously, there is a potential for Trojan horses to exploit this feature.
Emacs has a list of local variables that are known to be safe to set. If a file tries to set any variable outside this list, it asks the user to confirm whether the variables should be set. You can also tell Emacs whether to allow the evaluation of Emacs Lisp code found at the bottom of files by setting the variable
enable-local-eval
.See File Variables in The GNU Emacs Manual.
- Browsing the web.
Emacs relies on C libraries to parse images, and historically, many of these have had exploitable weaknesses. If you’re browsing the web with the eww browser, it will usually download and display images using these libraries. If an image library has a weakness, it may be used by an attacker to gain access.
Previous: Are there any security risks in Emacs?, Up: Bugs and problems [Contents][Index]
6.11 Dired says, ‘no file on this line’ when I try to do something.
Dired uses a regular expression to find the beginning of a file name. In a long Unix-style directory listing (‘ls -l’), the file name starts after the date. The regexp has thus been written to look for the date. By default, it should understand dates and times regardless of the language, but if your directory listing has an unusual format, Dired may get confused.
There are two approaches to solving this. The first one involves setting things up so that ‘ls -l’ outputs a more standard format. See your OS manual for more information.
The second approach involves changing the regular expression used by
dired, directory-listing-before-filename-regexp
.
Next: Finding Emacs and related packages, Previous: Bugs and problems, Up: The GNU Emacs FAQ [Contents][Index]
7 Compiling and installing Emacs
- How do I install Emacs?
- Where can I get Emacs for macOS, MS Windows, etc?
- What should I do if I have trouble building Emacs?
Next: Where can I get Emacs for macOS, MS Windows, etc?, Up: Compiling and installing Emacs [Contents][Index]
7.1 How do I install Emacs?
This answer is meant for users of Unix and Unix-like systems. Users of other operating systems should see See Where can I get Emacs for macOS, MS Windows, etc?.
Most GNU/Linux distributions provide pre-built Emacs packages. If Emacs is not installed already, you can install it by running (as root) a command such as ‘dnf install emacs’ (Red Hat and derivatives; use ‘yum’ in older distributions) or ‘apt-get install emacs’ (Debian and derivatives).
If you want to compile Emacs yourself, read the file INSTALL in the source distribution. In brief:
- First download the Emacs sources. See Where can I get other up-to-date GNU stuff?, for
a list of sites that make them available. On https://ftp.gnu.org,
the main GNU distribution site, sources are available as
https://ftp.gnu.org/pub/gnu/emacs/emacs-VERSION.tar.xz
(Replace ‘VERSION’ with the relevant version number, e.g., ‘28.1’.)
- Next uncompress and extract the source files. This requires
the
xz
andtar
programs, which are standard utilities. If your system does not have them, these can also be downloaded from https://ftp.gnu.org.GNU
tar
can uncompress and extract in a single-step:tar -axvf emacs-VERSION.tar.xz
- At this point, the Emacs sources should be sitting in a directory called
emacs-VERSION. On most common Unix and Unix-like systems,
you should be able to compile Emacs with the following commands:
cd emacs-VERSION ./configure # configure Emacs for your particular system make # use Makefile to build components, then Emacs
If the
make
completes successfully, you can go on to install it. (See What should I do if I have trouble building Emacs?, if you weren’t successful.) - By default, Emacs is installed in /usr/local. To actually
install files, become the superuser and type
make install
Note that ‘make install’ will overwrite /usr/local/bin/emacs and any Emacs Info files that might be in /usr/local/share/info/.
Next: What should I do if I have trouble building Emacs?, Previous: How do I install Emacs?, Up: Compiling and installing Emacs [Contents][Index]
7.2 Where can I get Emacs for macOS, MS Windows, etc?
Emacs supports macOS natively. See the file nextstep/INSTALL in the distribution.
There is a separate FAQ for Emacs on MS-Windows, see FAQ for Emacs on MS Windows.
Emacs supports GNUstep natively. See the file nextstep/INSTALL in the distribution.
To build Emacs from source for MS-DOS, see the instructions in the file msdos/INSTALL in the distribution. The DOS port builds and runs on plain DOS, and also on all versions of MS-Windows from version 3.X onwards, including Windows XP and Vista. Pre-built binaries may be available at https://www.delorie.com/pub/djgpp/current/v2gnu/emacs.README
For a list of other implementations of Emacs (and Emacs look-alikes), consult the list of “Emacs implementations and literature,” available at
https://www.finseth.com/emacs.html
Note that while many of these programs look similar to Emacs, they often lack certain features, such as the Emacs Lisp extension language.
Previous: Where can I get Emacs for macOS, MS Windows, etc?, Up: Compiling and installing Emacs [Contents][Index]
7.3 What should I do if I have trouble building Emacs?
First look in the file etc/PROBLEMS (where you unpack the Emacs source) to see if there is already a solution for your problem. Next, look for other questions in this FAQ that have to do with Emacs installation and compilation problems.
If you’d like to have someone look at your problem and help solve it, see Where can I get help in installing Emacs?.
If you cannot find a solution in the documentation, please report the problem (see Where should I report bugs and other problems with Emacs?).
Next: Alternate character sets, Previous: Finding Emacs and related packages, Up: The GNU Emacs FAQ [Contents][Index]
9 Key bindings
- How do I bind keys (including function keys) to commands?
- Why does Emacs say ‘Key sequence XXX uses invalid prefix characters’?
- Why doesn’t this [terminal or window-system setup] code work in my init file, but it works just fine after Emacs starts up?
- How do I tell what characters or symbols my function or arrow keys emit?
- How do I set the X key “translations” for Emacs?
- Why does the Backspace key invoke help?
- How do I swap two keys?
- How do I produce C-XXX with my keyboard?
- What if I don’t have a Meta key?
- What if I don’t have an Escape key?
- Can I make my Compose Character key behave like a Meta key?
- How do I bind a combination of modifier key and function key?
- Why doesn’t my Meta key work in an
xterm
window?
Next: Why does Emacs say ‘Key sequence XXX uses invalid prefix characters’?, Up: Key bindings [Contents][Index]
9.1 How do I bind keys (including function keys) to commands?
Keys can be bound to commands either interactively or in your init file (see How do I set up an init file properly?). To interactively bind keys for all modes, type M-x global-set-key RET key cmd RET.
To bind a key just in the current major mode, type M-x local-set-key RET key cmd RET.
See Key Bindings in The GNU Emacs Manual.
To make the process of binding keys interactively easier, use the following “trick”: First bind the key interactively, then immediately type C-x ESC ESC C-a C-k C-g. Now, the command needed to bind the key is in the kill ring, and can be yanked into your init file. If the key binding is global, no changes to the command are required. For example,
(global-set-key [f1] 'help-for-help)
can be placed directly into your init file. If the key binding is local, the command is used in conjunction with the ‘add-hook’ function. For example, in TeX mode, a local binding might be
(add-hook 'tex-mode-hook (lambda () (local-set-key [f1] 'help-for-help)))
- Control characters in key sequences, in the form yanked from the kill ring are given in their graphic form—i.e., CTRL is shown as ‘^’, TAB as a set of spaces (usually 8), etc. You may want to convert these into their vector or string forms.
- If a prefix key of the character sequence to be bound is already
bound as a complete key, then you must unbind it before the new
binding. For example, if ESC { is previously bound:
(global-unset-key [?\e ?{]) ;; or (local-unset-key [?\e ?{])
- Aside from commands and “lambda lists,” a vector or string also
can be bound to a key and thus treated as a macro. For example:
(global-set-key [f10] [?\C-x?\e?\e?\C-a?\C-k?\C-g]) ;; or (global-set-key [f10] "\C-x\e\e\C-a\C-k\C-g")
Next: Why doesn’t this [terminal or window-system setup] code work in my init file, but it works just fine after Emacs starts up?, Previous: How do I bind keys (including function keys) to commands?, Up: Key bindings [Contents][Index]
9.2 Why does Emacs say ‘Key sequence XXX uses invalid prefix characters’?
Usually, one of two things has happened. In one case, the control character in the key sequence has been misspecified (e.g., ‘C-f’ used instead of ‘\C-f’ within a Lisp expression). In the other case, a prefix key in the keystroke sequence you were trying to bind was already bound as a complete key. Historically, the ‘ESC [’ prefix was usually the problem, in which case you should evaluate either of these forms before attempting to bind the key sequence:
(global-unset-key [?\e ?[]) ;; or (global-unset-key "\e[")
Next: How do I tell what characters or symbols my function or arrow keys emit?, Previous: Why does Emacs say ‘Key sequence XXX uses invalid prefix characters’?, Up: Key bindings [Contents][Index]
9.3 Why doesn’t this [terminal or window-system setup] code work in my init file, but it works just fine after Emacs starts up?
During startup, Emacs initializes itself according to a given code/file order. If some of the code executed in your init file (see How do I set up an init file properly?) needs to be postponed until the initial terminal or window-system setup code has been executed but is not, then you will experience this problem (this code/file execution order is not enforced after startup).
To postpone the execution of Emacs Lisp code until after terminal or
window-system setup, treat the code as a lambda list and add it to
emacs-startup-hook
(or tty-setup-hook
in Emacs 24.4 and
newer). For example,
(add-hook 'emacs-startup-hook (lambda () (when (string-match "\\`vt220" (or (getenv "TERM") "")) ;; Make vt220's "Do" key behave like M-x: (global-set-key [do] 'execute-extended-command))))
For information on what Emacs does every time it is started, see the lisp/startup.el file.
Next: How do I set the X key “translations” for Emacs?, Previous: Why doesn’t this [terminal or window-system setup] code work in my init file, but it works just fine after Emacs starts up?, Up: Key bindings [Contents][Index]
9.4 How do I tell what characters or symbols my function or arrow keys emit?
Type C-h c then the function or arrow keys. The command will return either a function key symbol or character sequence (see the Emacs documentation for an explanation). This works for other keys as well.
Next: Why does the Backspace key invoke help?, Previous: How do I tell what characters or symbols my function or arrow keys emit?, Up: Key bindings [Contents][Index]
9.5 How do I set the X key “translations” for Emacs?
Emacs is not written using the Xt library by default, so there are no “translations” to be set. (We aren’t sure how to set such translations if you do build Emacs with Xt; please let us know if you’ve done this!)
The only way to affect the behavior of keys within Emacs is through
xmodmap
(outside Emacs) or define-key
(inside Emacs). The
define-key
command should be used in conjunction with the
local-function-key-map
map. For instance,
(define-key function-key-map [M-TAB] [?\M-\t])
defines the M-TAB key sequence.
Next: How do I swap two keys?, Previous: How do I set the X key “translations” for Emacs?, Up: Key bindings [Contents][Index]
9.6 Why does the Backspace key invoke help?
The Backspace key (on most keyboards) generates ASCII code 8. C-h sends the same code. In Emacs by default C-h invokes help-command. This is intended to be easy to remember since the first letter of ‘help’ is ‘h’. 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 many people this solution may be problematic:
- They normally use Backspace outside of Emacs for deleting the
previous character. This can be solved by making DEL the command
for deleting the previous character outside of Emacs. On many Unix
systems, this command will remap DEL:
stty erase '^?'
- The user may prefer 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 Backspace key should be made to behave like
Delete. There are several methods.
- - Some terminals (e.g., VT3## terminals) and terminal emulators (e.g., TeraTerm) allow the character generated by the Backspace key to be changed from a setup menu.
- - You may be able to get a keyboard that is completely programmable, or a terminal emulator that supports remapping of any key to any other key.
- - You can control the effect of the Backspace and Delete
keys, on both dumb terminals and a windowed displays, by customizing
the option
normal-erase-is-backspace-mode
, or by invoking M-x normal-erase-is-backspace. See the documentation of these symbols (see Where can I get documentation on Emacs Lisp?) for more info. - - It is possible to swap the Backspace and DEL keys inside
Emacs:
(keyboard-translate ?\C-h ?\C-?)
This is the recommended method of forcing Backspace to act as DEL, because it works even in modes which bind DEL to something other than
delete-backward-char
.Similarly, you could remap DEL to act as C-d, which by default deletes forward:
(keyboard-translate ?\C-? ?\C-d)
See How do I swap two keys?, for further details about
keyboard-translate
. - - Another approach is to switch key bindings and put help on C-x h
instead:
(global-set-key "\C-h" 'delete-backward-char) ;; overrides mark-whole-buffer (global-set-key "\C-xh" 'help-command)
This method is not recommended, though: it only solves the problem for those modes which bind DEL to
delete-backward-char
. Modes which bind DEL to something else, such asview-mode
, will not work as you expect when you press the Backspace key. For this reason, we recommend thekeyboard-translate
method, shown above.Other popular key bindings for help are M-? and C-x ?.
Don’t try to bind DEL to
help-command
, because there are many modes that have local bindings of DEL that will interfere.
When Emacs runs on a windowed display, it binds the Delete key to a command which deletes the character at point, to make Emacs more consistent with keyboard operation on these systems.
For more information about troubleshooting this problem, see If DEL Fails to Delete in The GNU Emacs Manual.
Next: How do I produce C-XXX with my keyboard?, Previous: Why does the Backspace key invoke help?, Up: Key bindings [Contents][Index]
9.7 How do I swap two keys?
You can swap two keys (or key sequences) by using the
keyboard-translate
function. For example, to turn C-h
into DEL and DEL to C-h, use
(keyboard-translate ?\C-h ?\C-?) ; translate 'C-h' to DEL (keyboard-translate ?\C-? ?\C-h) ; translate DEL to 'C-h'.
The first key sequence of the pair after the function identifies what is produced by the keyboard; the second, what is matched for in the keymaps.
However, in the specific case of C-h and DEL, you should
toggle normal-erase-is-backspace-mode
instead of calling
keyboard-translate
.
See DEL Does Not Delete in The GNU Emacs Manual.
Keyboard translations are not the same as key bindings in keymaps. Emacs contains numerous keymaps that apply in different situations, but there is only one set of keyboard translations, and it applies to every character that Emacs reads from the terminal. Keyboard translations take place at the lowest level of input processing; the keys that are looked up in keymaps contain the characters that result from keyboard translation.
Next: What if I don’t have a Meta key?, Previous: How do I swap two keys?, Up: Key bindings [Contents][Index]
9.8 How do I produce C-XXX with my keyboard?
On terminals (but not under X), some common “aliases” are:
- C-2 or C-SPC
C-@
- C-6
C-^
- C-7 or C-S--
C-_
- C-4
C-\
- C-5
C-]
- C-/
C-?
Often other aliases exist; use the C-h c command and try CTRL with all of the digits on your keyboard to see what gets generated. You can also try the C-h w command if you know the name of the command.
Next: What if I don’t have an Escape key?, Previous: How do I produce C-XXX with my keyboard?, Up: Key bindings [Contents][Index]
9.9 What if I don’t have a Meta key?
On many keyboards, the Alt key acts as Meta, so try it.
Instead of typing M-a, you can type ESC a. In fact,
Emacs converts M-a internally into ESC a anyway
(depending on the value of meta-prefix-char
). Note that you
press Meta and a together, but with ESC, you press
ESC, release it, and then press a.
Next: Can I make my Compose Character key behave like a Meta key?, Previous: What if I don’t have a Meta key?, Up: Key bindings [Contents][Index]
9.10 What if I don’t have an Escape key?
Type C-[ instead. This should send ASCII code 27 just like an Escape key would. C-3 may also work on some terminal (but not under X). For many terminals (notably DEC terminals) F11 generates ESC. If not, the following form can be used to bind it:
;; F11 is the documented ESC replacement on DEC terminals. (define-key function-key-map [f11] [?\e])
Next: How do I bind a combination of modifier key and function key?, Previous: What if I don’t have an Escape key?, Up: Key bindings [Contents][Index]
9.11 Can I make my Compose Character key behave like a Meta key?
On a dumb terminal such as a VT220, no. It is rumored that certain
VT220 clones could have their Compose key configured this way. If
you’re using X, you might be able to do this with the xmodmap
command.
Next: Why doesn’t my Meta key work in an xterm
window?, Previous: Can I make my Compose Character key behave like a Meta key?, Up: Key bindings [Contents][Index]
9.12 How do I bind a combination of modifier key and function key?
You can represent modified function keys in vector format by adding prefixes to the function key symbol. For example (from the Emacs documentation):
(global-set-key [?\C-x right] 'forward-page)
where ‘?\C-x’ is the Lisp character constant for the character C-x.
You can use the modifier keys Control, Meta, Hyper, Super, Alt, and Shift with function keys. To represent these modifiers, prepend the strings ‘C-’, ‘M-’, ‘H-’, ‘s-’, ‘A-’, and ‘S-’ to the symbol name. Here is how to make H-M-RIGHT move forward a word:
(global-set-key [H-M-right] 'forward-word)
- Not all modifiers are permitted in all situations. Hyper, Super, and Alt are not available on Unix character terminals. Non-ASCII keys and mouse events (e.g., C-= and mouse-1) also fall under this category.
See How do I bind keys (including function keys) to commands?, for general key binding instructions.
Previous: How do I bind a combination of modifier key and function key?, Up: Key bindings [Contents][Index]
9.13 Why doesn’t my Meta key work in an xterm
window?
See Single-Byte Character Set Support in The GNU Emacs Manual.
If the advice in the Emacs manual fails, try all of these methods before asking for further help:
- You may have big problems using
mwm
as your window manager. (Does anyone know a good generic solution to allow the use of the Meta key in Emacs with mwm?) - For X11: Make sure it really is a Meta key. Use
xev
to find out what keysym your Meta key generates. It should be eitherMeta_L
orMeta_R
. If it isn’t, use xmodmap to fix the situation. If Meta does generateMeta_L
orMeta_R
, but M-x produces a non-ASCII character, put this in your ~/.Xdefaults file:XTerm*eightBitInput: false XTerm*eightBitOutput: true
- Make sure the
pty
thexterm
is using is passing 8 bit characters. ‘stty -a’ (or ‘stty everything’) should show ‘cs8’ somewhere. If it shows ‘cs7’ instead, use ‘stty cs8 -istrip’ (or ‘stty pass8’) to fix it. - If there is an
rlogin
connection betweenxterm
and Emacs, the ‘-8’ argument may need to be given to rlogin to make it pass all 8 bits of every character. - If all else fails, you can make
xterm
generate ESC W when you type M-W, which is the same conversion Emacs would make if it got the M-W anyway. In X11R4, the following resource specification will do this:XTerm.VT100.EightBitInput: false
(This changes the behavior of the
insert-eight-bit
action.)With older
xterm
s, you can specify this behavior with a translation:XTerm.VT100.Translations: #override \ Meta<KeyPress>: string(0x1b) insert()
You might have to replace ‘Meta’ with ‘Alt’.
Next: Mail and news, Previous: Key bindings, Up: The GNU Emacs FAQ [Contents][Index]
10 Alternate character sets
- How do I make Emacs display 8-bit characters?
- How do I input eight-bit characters?
- Where is an Emacs that can handle Semitic (right-to-left) alphabets?
- How do I add fonts for use with Emacs?
10.1 How do I make Emacs display 8-bit characters?
See Single-byte Character Set Support in The GNU
Emacs Manual. On a Unix, when Emacs runs on a text-only terminal
display or is invoked with ‘emacs -nw’, you typically need to use
set-terminal-coding-system
to tell Emacs what the terminal can
display, even after setting the language environment; otherwise
non-ASCII characters will display as ‘?’. On other operating
systems, such as MS-DOS and MS-Windows, Emacs queries the OS about the
character set supported by the display, and sets up the required
terminal coding system automatically.
Next: Where is an Emacs that can handle Semitic (right-to-left) alphabets?, Previous: How do I make Emacs display 8-bit characters?, Up: Alternate character sets [Contents][Index]
10.2 How do I input eight-bit characters?
Various methods are available for input of eight-bit characters. See Single-byte Character Set Support in The GNU Emacs Manual. For more sophisticated methods, see Input Methods in The GNU Emacs Manual.
Next: How do I add fonts for use with Emacs?, Previous: How do I input eight-bit characters?, Up: Alternate character sets [Contents][Index]
10.3 Where is an Emacs that can handle Semitic (right-to-left) alphabets?
Emacs supports display and editing of bidirectional scripts, such as Arabic, Farsi, and Hebrew.
Previous: Where is an Emacs that can handle Semitic (right-to-left) alphabets?, Up: Alternate character sets [Contents][Index]
10.4 How do I add fonts for use with Emacs?
First, download and install the BDF font files and any auxiliary packages they need. The GNU Intlfonts distribution can be found on the GNU Software Directory Web site.
Next, if you are on X Window system, issue the following two commands from the shell’s prompt:
xset +fp /usr/local/share/emacs/fonts xset fp rehash
(Modify the first command if you installed the fonts in a directory that is not /usr/local/share/emacs/fonts.) You also need to arrange for these two commands to run whenever you log in, e.g., by adding them to your window-system startup file, such as ~/.xsessionrc or ~/.gnomerc.
Now, add the following line to your init file (see How do I set up an init file properly?):
(add-to-list 'bdf-directory-list "/usr/share/emacs/fonts/bdf")
(Again, modify the file name if you installed the fonts elsewhere.)
Finally, if you wish to use the installed fonts with ps-print
,
add the following line to your init file:
(setq ps-multibyte-buffer 'bdf-font-except-latin)
You can now use the Emacs font menu to select the ‘bdf: 16-dot medium’ fontset, or you can select it by setting the default font in your init file:
(set-frame-font "fontset-bdf")
Next: Concept Index, Previous: Alternate character sets, Up: The GNU Emacs FAQ [Contents][Index]
11 Mail and news
- How do I change the included text prefix in mail/news followups?
- How do I save a copy of outgoing mail?
- Why doesn’t Emacs expand my aliases when sending mail?
- How can I sort the messages in my Rmail folder?
- Why does Rmail need to write to /var/spool/mail?
- How can I force Rmail to reply to the sender of a message, but not the other recipients?
- How do I make Emacs automatically start my mail/news reader?
- How do I read news under Emacs?
- How do I make Gnus faster?
- How do I catch up all newsgroups in Gnus?
Next: How do I save a copy of outgoing mail?, Up: Mail and news [Contents][Index]
11.1 How do I change the included text prefix in mail/news followups?
If you read mail with Rmail, set the variable mail-yank-prefix
.
For Gnus, set message-yank-prefix
. For VM, set
vm-included-text-prefix
. For mh-e, set mh-ins-buf-prefix
.
For fancier control of citations, use Supercite (see the Supercite Manual in The Supercite Manual).
To prevent Emacs from including various headers of the replied-to
message, set the value of mail-yank-ignored-headers
to an
appropriate regexp.
Next: Why doesn’t Emacs expand my aliases when sending mail?, Previous: How do I change the included text prefix in mail/news followups?, Up: Mail and news [Contents][Index]
11.2 How do I save a copy of outgoing mail?
You can either mail yourself a copy by including a ‘BCC’ header in the mail message, or store a copy of the message directly to a file by including an ‘FCC’ header.
If you use standard mail, you can automatically create a ‘BCC’ to yourself by putting
(setq mail-self-blind t)
in your init file (see How do I set up an init file properly?). You can automatically include an ‘FCC’ field by putting something like the following in your init file:
(setq mail-archive-file-name (expand-file-name "~/outgoing"))
The output file will be in Unix mail format.
If you use mh-e
, add an ‘FCC’ or ‘BCC’ field to your
components file.
It does not work to put ‘set record filename’ in the .mailrc file.
Next: How can I sort the messages in my Rmail folder?, Previous: How do I save a copy of outgoing mail?, Up: Mail and news [Contents][Index]
11.3 Why doesn’t Emacs expand my aliases when sending mail?
See The Emacs Manual in The Emacs Manual.
- Normally, Emacs expands aliases when you send the message. To expand them before this, use M-x expand-mail-aliases.
- Emacs normally only reads the .mailrc file once per session, when you start to compose your first mail message. If you edit the file after this, you can use M-x build-mail-aliases to make Emacs reread it.
- If you like, you can expand mail aliases as abbrevs, as soon as you
type them in. To enable this feature, execute the following:
(add-hook 'mail-mode-hook 'mail-abbrevs-setup)
Note that the aliases are expanded automatically only after you type a word-separator character (e.g., RET or ,). You can force their expansion by moving point to the end of the alias and typing C-x a e (M-x expand-abbrev).
Next: Why does Rmail need to write to /var/spool/mail?, Previous: Why doesn’t Emacs expand my aliases when sending mail?, Up: Mail and news [Contents][Index]
11.4 How can I sort the messages in my Rmail folder?
In Rmail, type C-c C-s C-h to get a list of sorting functions and their key bindings.
Next: How can I force Rmail to reply to the sender of a message, but not the other recipients?, Previous: How can I sort the messages in my Rmail folder?, Up: Mail and news [Contents][Index]
11.5 Why does Rmail need to write to /var/spool/mail?
This is the behavior of the movemail
program which Rmail uses.
This indicates that movemail
is configured to use lock files.
RMS writes:
Certain systems require lock files to interlock access to mail files. On these systems,
movemail
must write lock files, or you risk losing mail. You simply must arrange to letmovemail
write them.Other systems use the
flock
system call to interlock access. On these systems, you should configuremovemail
to useflock
.
Next: How do I make Emacs automatically start my mail/news reader?, Previous: Why does Rmail need to write to /var/spool/mail?, Up: Mail and news [Contents][Index]
11.6 How can I force Rmail to reply to the sender of a message, but not the other recipients?
Ron Isaacson says: When you hit r to reply in Rmail, by default it Ccs all of the original recipients (everyone on the original ‘To’ and ‘CC’ lists). With a prefix argument (i.e., typing C-u before r), it replies only to the sender. However, going through the whole C-u business every time you want to reply is a pain. This is the best fix I’ve been able to come up with:
(defun rmail-reply-t () "Reply only to the sender of the current message. (See rmail-reply.)" (interactive) (rmail-reply t)) (add-hook 'rmail-mode-hook (lambda () (define-key rmail-mode-map "r" 'rmail-reply-t) (define-key rmail-mode-map "R" 'rmail-reply)))
Next: How do I read news under Emacs?, Previous: How can I force Rmail to reply to the sender of a message, but not the other recipients?, Up: Mail and news [Contents][Index]
11.7 How do I make Emacs automatically start my mail/news reader?
To start Emacs in Gnus:
emacs -f gnus
in Rmail:
emacs -f rmail
A more convenient way to start with Gnus:
alias gnus 'emacs -f gnus' gnus
It is probably unwise to automatically start your mail or news reader from your init file. This would cause problems if you needed to run two copies of Emacs at the same time. Also, this would make it difficult for you to start Emacs quickly when you needed to.
Next: How do I make Gnus faster?, Previous: How do I make Emacs automatically start my mail/news reader?, Up: Mail and news [Contents][Index]
11.8 How do I read news under Emacs?
Use M-x gnus. For more information on Gnus, see the Gnus Manual in The Gnus Manual, which includes the Gnus FAQ in The Gnus Manual.
Next: How do I catch up all newsgroups in Gnus?, Previous: How do I read news under Emacs?, Up: Mail and news [Contents][Index]
11.9 How do I make Gnus faster?
From the Gnus FAQ (see How do I read news under Emacs?):
If you have a slow machine, or are just really impatient, there are a few things you can do to make Gnus run faster.
Set
gnus-check-new-newsgroups
andgnus-check-bogus-newsgroups
tonil
to make startup faster.Set
gnus-show-threads
,gnus-use-cross-reference
andgnus-nov-is-evil
tonil
to make entering and exiting the summary buffer faster.
Previous: How do I make Gnus faster?, Up: Mail and news [Contents][Index]
11.10 How do I catch up all newsgroups in Gnus?
In the *Newsgroup* buffer, type M-< C-x ( c y C-x ) M-0 C-x e
Leave off the initial M-< if you only want to catch up from point to the end of the *Newsgroup* buffer.
Previous: Mail and news, Up: The GNU Emacs FAQ [Contents][Index]
Concept Index
Jump to: | #
$
-
.
/
2
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
---|
Jump to: | #
$
-
.
/
2
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
---|