summaryrefslogtreecommitdiffstats
path: root/slackbook/html/emacs.html
blob: 8c6479cd1bada30f6d08cb546af828336a5471c2 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!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>