slackware-current/slackbook/html/emacs.html
Patrick J Volkerding 75a4a592e5 Slackware 13.37
Mon Apr 25 13:37:00 UTC 2011
Slackware 13.37 x86_64 stable is released!

Thanks to everyone who pitched in on this release: the Slackware team,
the folks producing upstream code, and linuxquestions.org for providing
a great forum for collaboration and testing.

The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a
dual-sided
32-bit/64-bit x86/x86_64 DVD.  Please consider supporting the Slackware
project by picking up a copy from store.slackware.com.  We're taking
pre-orders now, and offer a discount if you sign up for a subscription.

As always, thanks to the Slackware community for testing, suggestions,
and feedback.  :-)

Have fun!
2018-05-31 22:45:18 +02:00

173 lines
7.6 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>Emacs</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
<link rel="PREVIOUS" title="Vi Keys" href="vi-keys.html" />
<link rel="NEXT" title="Buffers" href="emacs-buffers.html" />
<link rel="STYLESHEET" type="text/css" href="docbook.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="CHAPTER" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="NAVHEADER">
<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<th colspan="3" align="center">Slackware Linux Essentials</th>
</tr>
<tr>
<td width="10%" align="left" valign="bottom"><a href="vi-keys.html"
accesskey="P">Prev</a></td>
<td width="80%" align="center" valign="bottom"></td>
<td width="10%" align="right" valign="bottom"><a href="emacs-buffers.html"
accesskey="N">Next</a></td>
</tr>
</table>
<hr align="LEFT" width="100%" />
</div>
<div class="CHAPTER">
<h1><a id="EMACS" name="EMACS"></a>Chapter 17 Emacs</h1>
<div class="TOC">
<dl>
<dt><b>Table of Contents</b></dt>
<dt>17.1 <a href="emacs.html#EMACS-STARTING">Starting emacs</a></dt>
<dt>17.2 <a href="emacs-buffers.html">Buffers</a></dt>
<dt>17.3 <a href="emacs-modes.html">Modes</a></dt>
<dt>17.4 <a href="emacs-basic-editing.html">Basic Editing</a></dt>
<dt>17.5 <a href="emacs-saving-files.html">Saving Files</a></dt>
</dl>
</div>
<p>While <tt class="COMMAND">vi</tt> (with its clones) is without a doubt the most
ubiquitous editor on Unix-like systems, Emacs comes in a good second. Instead of using
different &#8220;modes&#8221;, like <tt class="COMMAND">vi</tt> does, it uses <b
class="KEYCAP">Control</b> and <b class="KEYCAP">Alt</b> key combinations to enter
commands, in much the same way that you can use <b class="KEYCAP">Control</b> and <b
class="KEYCAP">Alt</b> key combinations in a word processor and indeed in many other
applications to execute certain functions. (Though it should be noted that the commands
rarely correspond; so while many modern applications use <b class="KEYCAP">Ctrl</b>-<b
class="KEYCAP">C</b>/ <b class="KEYCAP">X</b>/ <b class="KEYCAP">V</b> for copying,
cutting and pasting, Emacs uses different keys and actually a somewhat different
mechanism for this.)</p>
<p>Also unlike <tt class="COMMAND">vi</tt>, which is an (excellent) editor and nothing
more, Emacs is a program with near endless capabilities. Emacs is (for the most part)
written in Lisp, which is a very powerful programming language that has the peculiar
property that every program written in it is automatically a Lisp compiler of its own.
This means that the user can extend Emacs, and in fact write completely new programs
&#8220;in Emacs&#8221;.</p>
<p>As a result, Emacs is not just an editor anymore. There are many add-on packages for
Emacs available (many come with the program's source) that provide all sorts of
functionality. Many of these are related to text editing, which is after all Emacs' basic
task, but it doesn't stop there. There are for example several spreadsheet programs for
Emacs, there are databases, games, mail and news clients (the top one being Gnus),
etc.</p>
<p>There are two main versions of Emacs: GNU Emacs (which is the version that comes with
Slackware) and XEmacs. The latter is <span class="emphasis"><i
class="EMPHASIS">not</i></span> a version for Emacs running under X. In fact, both Emacs
and XEmacs run on the console as well as under X. XEmacs was once started as a project to
tidy up the Emacs code. Currently, both versions are being actively developed, and there
is in fact much interaction between the two development teams. For the present chapter,
it is immaterial whether you use Emacs or XEmacs, the differences between them are not
relevant to the normal user.</p>
<div class="SECT1">
<h1 class="SECT1"><a id="EMACS-STARTING" name="EMACS-STARTING">17.1 Starting
emacs</a></h1>
<p>Emacs can be started from the shell by simply typing <tt class="COMMAND">emacs</tt>.
When you are running X, Emacs will (normally) come up with its own X window, usually with
a menu bar at the top, where you can find the most important functions. On startup, Emacs
will first show a welcome message, and then after a few seconds will drop you in the
*scratch* buffer. (See <a href="emacs-buffers.html">Section 17.2</a>.)</p>
<div class="INFORMALFIGURE"><a id="AEN5971" name="AEN5971"></a>
<p><img src="emacs/emacs.png" /></p>
</div>
<p>You can also start Emacs on an existing file by typing</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">emacs /etc/resolv.conf</kbd>
</pre>
</td>
</tr>
</table>
<p>This will cause Emacs to load the specified file when it starts up, skipping the
welcome message.</p>
<div class="SECT2">
<h2 class="SECT2"><a id="EMACS-COMMAND-KEYS" name="EMACS-COMMAND-KEYS">17.1.1 Command
Keys</a></h2>
<p>As mentioned above, Emacs uses <b class="KEYCAP">Control</b> and <b
class="KEYCAP">Alt</b> combinations for commands. The usual convention is to write these
with <b class="KEYCAP">C</b>-<b class="KEYCAP">letter</b> and <b class="KEYCAP">M</b>-<b
class="KEYCAP">letter</b>, respectively. So <b class="KEYCAP">C</b>-<b
class="KEYCAP">x</b> means <b class="KEYCAP">Control</b>+<b class="KEYCAP">x</b>, and <b
class="KEYCAP">M</b>-<b class="KEYCAP">x</b> means <b class="KEYCAP">Alt</b>+<b
class="KEYCAP">x</b>. (The letter <b class="KEYCAP">M</b> is used instead of A because
originally the key was not the <b class="KEYCAP">Alt</b> key but the <b
class="KEYCAP">Meta</b> key. The <b class="KEYCAP">Meta</b> key has all but disappeared
from computer keyboards, and in Emacs the <b class="KEYCAP">Alt</b> key has taken over
its function.)</p>
<p>Many Emacs commands consist of sequences of keys and key combinations. For example, <b
class="KEYCAP">C</b>-<b class="KEYCAP">x</b> <b class="KEYCAP">C</b>-<b
class="KEYCAP">c</b> (that is <b class="KEYCAP">Control</b>-<b class="KEYCAP">x</b>
followed by <b class="KEYCAP">Control</b>-<b class="KEYCAP">c</b> ) quits Emacs, <b
class="KEYCAP">C</b>-<b class="KEYCAP">x</b> <b class="KEYCAP">C</b>-<b
class="KEYCAP">s</b> saves the current file. Keep in mind that <b class="KEYCAP">C</b>-<b
class="KEYCAP">x</b> <b class="KEYCAP">C</b>-<b class="KEYCAP">b</b> is <span
class="emphasis"><i class="EMPHASIS">not</i></span> the same as <b
class="KEYCAP">C</b>-<b class="KEYCAP">x</b> <b class="KEYCAP">b</b>. The former means <b
class="KEYCAP">Control</b>-<b class="KEYCAP">x</b> followed by <b
class="KEYCAP">Control</b>-<b class="KEYCAP">b</b>, while the latter means <b
class="KEYCAP">Control</b>-<b class="KEYCAP">x</b> followed by just '<b
class="KEYCAP">b</b>'.</p>
</div>
</div>
</div>
<div class="NAVFOOTER">
<hr align="LEFT" width="100%" />
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="vi-keys.html"
accesskey="P">Prev</a></td>
<td width="34%" align="center" valign="top"><a href="index.html"
accesskey="H">Home</a></td>
<td width="33%" align="right" valign="top"><a href="emacs-buffers.html"
accesskey="N">Next</a></td>
</tr>
<tr>
<td width="33%" align="left" valign="top">Vi Keys</td>
<td width="34%" align="center" valign="top">&nbsp;</td>
<td width="33%" align="right" valign="top">Buffers</td>
</tr>
</table>
</div>
</body>
</html>