-
Notifications
You must be signed in to change notification settings - Fork 4
/
curriculum.html
1165 lines (1026 loc) · 41 KB
/
curriculum.html
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2019-10-08 Di 15:38 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Emacs Berlin Beginners Curriculum</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Emacs Berlin" />
<meta name="description" content="A modern beginners guide to setting up and using Emacs."
/>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="css/foundation.css" />
<link rel="stylesheet" href="css/screen.css" />
<link rel="stylesheet" href="css/curriculum.css" />
<script src="js/vendor/modernizr.js"></script>
<link href='http://fonts.googleapis.com/css?family=Lato:400,900,400italic,900italic' rel='stylesheet' type='text/css'>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<h1 class="title">Emacs Berlin Beginners Curriculum</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org14a67d7">1. Installation</a>
<ul>
<li><a href="#org6ffa44b">1.1. Windows</a></li>
<li><a href="#org08aa9cb">1.2. OS X</a></li>
<li><a href="#orgd130371">1.3. Linux</a></li>
</ul>
</li>
<li><a href="#org91d7412">2. First steps</a>
<ul>
<li><a href="#orga3781c6">2.1. Hello, Emacs</a></li>
<li><a href="#org04c5ee2">2.2. A word about key combinations</a></li>
<li><a href="#orgb95c2b2">2.3. Survival Emacs</a></li>
<li><a href="#org28150a5">2.4. Introduction to editing</a></li>
<li><a href="#orgae80f19">2.5. Visiting files</a></li>
<li><a href="#org071503a">2.6. Switching buffers</a></li>
<li><a href="#org19471b2">2.7. Getting help</a></li>
<li><a href="#orga645b7a">2.8. Working with windows</a></li>
</ul>
</li>
<li><a href="#org647363e">3. First steps in Elisp</a>
<ul>
<li><a href="#orgfc627df">3.1. evaluating forms</a></li>
<li><a href="#orge9bf90c">3.2. values, variables, functions, setq</a></li>
</ul>
</li>
<li><a href="#orgb805dad">4. create first .emacs/init.el</a>
<ul>
<li><a href="#org1cce10e">4.1. A blueprint to get started</a></li>
<li><a href="#orgf757ee0">4.2. major/minor modes</a></li>
<li><a href="#orgb827144">4.3. get to a "good enough" initial set up</a></li>
<li><a href="#org7d42b87">4.4. Language specific sections</a></li>
</ul>
</li>
<li><a href="#orgce6a574">5. References</a>
<ul>
<li><a href="#orge78fe3c">5.1. Emacsish glossary</a></li>
</ul>
</li>
<li><a href="#orga2b0269">6. Where next</a>
<ul>
<li><a href="#org3d39b60">6.1. how to use the help system</a></li>
<li><a href="#orgabd8e4f">6.2. a tour of emacs features and packages</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org14a67d7" class="outline-2">
<h2 id="org14a67d7"><span class="section-number-2">1</span> Installation</h2>
<div class="outline-text-2" id="text-1">
<p>
How to install Emacs depends on your operating system. Make sure you install
"GNU Emacs", and not an alternative version like "XEmacs" or "Aquamacs".
</p>
</div>
<div id="outline-container-org6ffa44b" class="outline-3">
<h3 id="org6ffa44b"><span class="section-number-3">1.1</span> Windows</h3>
<div class="outline-text-3" id="text-1-1">
<p>
Windows versions of GNU Emacs are distributed as zip-files, which can be found
on <a href="http://ftpmirror.gnu.org/emacs/windows/">gnu.org ftp mirrors</a>. Find the zip file with the highest version number, at
time of writing this is <code>emacs-24.5-bin-i686-mingw32.zip</code>, and download it.
</p>
<p>
Create a directory where you want to put Emacs, for example <code>C:\Program
Files\Emacs</code> and unpack the zip file there.
</p>
<p>
The <code>runemacs.exe</code> program in the <code>bin</code> directory will start Emacs. The
<code>addpm.exe</code> program will add Emacs to the start menu.
</p>
</div>
</div>
<div id="outline-container-org08aa9cb" class="outline-3">
<h3 id="org08aa9cb"><span class="section-number-3">1.2</span> OS X</h3>
<div class="outline-text-3" id="text-1-2">
<p>
OS X already comes with a version of Emacs installed, but it's very old (Emacs
22), and it doesn't have GUI support, so it only works inside a terminal. You
want to avoid using this version.
</p>
<p>
If you have Homebrew available then that is the most straightforward option.
</p>
<div class="org-src-container">
<pre class="src src-sh">$ brew update
$ brew install emacs --with-cocoa
$ brew linkapps emacs
</pre>
</div>
<p>
Alternatively you can download a <code>.dmg</code> at <a href="https://emacsformacosx.com/">emacsformacosx.com</a>.
</p>
<p>
That should be enough to get you going. Emacs Redux has some more tips on
<a href="http://emacsredux.com/blog/2015/05/09/emacs-on-os-x/">setting up Emacs on OS X</a>.
</p>
</div>
</div>
<div id="outline-container-orgd130371" class="outline-3">
<h3 id="orgd130371"><span class="section-number-3">1.3</span> Linux</h3>
<div class="outline-text-3" id="text-1-3">
<p>
Your package manager should have ready-made packages available. If you have a
graphical package manager look for an "emacs" package, or install the package
from the command line with <code>apt-get</code> or <code>yum</code>.
</p>
</div>
</div>
</div>
<div id="outline-container-org91d7412" class="outline-2">
<h2 id="org91d7412"><span class="section-number-2">2</span> First steps</h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="outline-container-orga3781c6" class="outline-3">
<h3 id="orga3781c6"><span class="section-number-3">2.1</span> Hello, Emacs</h3>
<div class="outline-text-3" id="text-2-1">
<p>
If you've managed to install and start Emacs, you should see a screen that looks like this,
</p>
<div class="figure">
<p><img src="./curriculum/startup_screen.png" alt="startup_screen.png" />
</p>
</div>
<p>
This screen isn't of great interest to us, and in fact we will disable it soon.
The only thing for us to do here is find the Emacs version (look for where it
says "This is GNU Emacs …"). Verify that you have version 24.5 or later.
</p>
<p>
Now you can exit this screen by pressing `q`, and you should now find yourself
in the <code>*scratch*</code> buffer.
</p>
<div class="figure">
<p><img src="./curriculum/scratch_buffer.png" alt="scratch_buffer.png" />
</p>
</div>
<p>
Try typing this line of code
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">dotimes</span> <span style="color: #8abeb7;">(</span>x <span style="color: #81a2be;">10</span><span style="color: #8abeb7;">)</span> <span style="color: #8abeb7;">(</span>insert <span style="color: #8abeb7;">"\nHello Emacs!"</span><span style="color: #8abeb7;">)</span><span style="color: #c5c8c6;">)</span>
</pre>
</div>
<p>
Now place the cursor at the end of the line, so behind the last closing
parenthesis. Press and hold the <code>Ctrl</code> key, and with <code>Ctrl</code> pressed type <code>x</code>
<code>e</code>.
</p>
<p>
Congratulations! You just wrote and executed your first piece of Emacs Lisp code.
</p>
</div>
</div>
<div id="outline-container-org04c5ee2" class="outline-3">
<h3 id="org04c5ee2"><span class="section-number-3">2.2</span> A word about key combinations</h3>
<div class="outline-text-3" id="text-2-2">
</div>
<div id="outline-container-orgd86bf34" class="outline-4">
<h4 id="orgd86bf34"><span class="section-number-4">2.2.1</span> The Control Key</h4>
<div class="outline-text-4" id="text-2-2-1">
<p>
Emacs makes heavy use of key combinations like "ctrl + g" or "alt + x". In the
manual and other documentation key combinations are written using a shorthand
notation. For example,
</p>
<dl class="org-dl">
<dt><code>C-x</code></dt><dd>hold <code>Ctrl</code> and type <code>x</code></dd>
<dt><code>C-x C-e</code></dt><dd>keep <code>Ctrl</code> pressed while typing <code>x</code> <code>e</code></dd>
<dt><code>C-x e</code></dt><dd>press <code>Ctrl</code> and <code>x</code> together, let go of <code>Ctrl</code>, and press <code>e</code></dd>
</dl>
</div>
</div>
<div id="outline-container-org6d626db" class="outline-4">
<h4 id="org6d626db"><span class="section-number-4">2.2.2</span> The Meta (Alt) Key</h4>
<div class="outline-text-4" id="text-2-2-2">
<p>
Besides the <code>Ctrl</code> key, Emacs makes heavy use of the <code>Meta</code> key. This is kind of
sad, because modern keyboards no longer have a <code>Meta</code> key. Instead the "Alt" key
is typically used as "Meta". Some Mac users prefer to use <code>Cmd/⌘</code> as their
<code>Meta</code> key. Depending on where you got your Emacs from it might even be using
"Cmd/⌘" already.
</p>
<p>
The <code>Meta</code> key (Alt or Cmd/⌘) is abbreviated with <code>M-</code>.
</p>
<p>
Here are some key combinations
</p>
<dl class="org-dl">
<dt><code>M-%</code></dt><dd>search and replace</dd>
<dt><code>M-></code></dt><dd>go to the end of the buffer</dd>
<dt><code>M-x emacs-version</code></dt><dd>check the version of your Emacs</dd>
</dl>
<p>
This last one means: press <code>Alt</code> and <code>x</code> together, then type <code>emacs-version</code>,
then press enter. <code>emacs-version</code> is just one of money Emacs command that you
can invoke by typing <code>M-x</code> and then the name of the command.
</p>
<p>
(You don't need to memorize these key combinations for now.)
</p>
</div>
</div>
</div>
<div id="outline-container-orgb95c2b2" class="outline-3">
<h3 id="orgb95c2b2"><span class="section-number-3">2.3</span> Survival Emacs</h3>
<div class="outline-text-3" id="text-2-3">
<p>
From here on it gets real, you should try to practice the commands that follow
until they are committed to memory. It's a good idea to write these on a small
piece of paper or index card. Keep it close to your computer as a reference.
</p>
<p>
To exit Emacs, type <code>C-x C-c</code>.
</p>
<p>
You can quit a partially entered command, type <code>C-g</code>.
</p>
<p>
To close informational "windows" like an error message or help information, type <code>q</code>
</p>
<p>
Let me repeat that
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td><code>C-x C-c</code></td>
<td>Exit Emacs</td>
</tr>
<tr>
<td><code>C-g</code></td>
<td>Quit partially typed command</td>
</tr>
<tr>
<td><code>q</code></td>
<td>Close error message</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org28150a5" class="outline-3">
<h3 id="org28150a5"><span class="section-number-3">2.4</span> Introduction to editing</h3>
<div class="outline-text-3" id="text-2-4">
<p>
Emacs predates the modern terminology of copy/cut/paste. Cut is called <code>kill</code>,
this deletes some text from the buffer, and appends it to the <code>kill ring</code>. To
"paste" it you <code>yank</code> it from the kill ring back to the buffer.
</p>
<p>
The command to "copy" is called <code>kill-ring-save</code>, since it adds a piece of text
to the kill ring, without deleting it from the buffer.
</p>
<p>
<code>C-y</code> / <code>yank</code> inserts at the current cursor position, which in Emacs
terminology is called <code>point</code>.
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col"> </th>
<th scope="col">Emacs command</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>C-y</code></td>
<td>Paste</td>
<td><code>yank</code></td>
</tr>
<tr>
<td><code>C-k</code></td>
<td>Cut until the end of the line</td>
<td><code>kill</code></td>
</tr>
<tr>
<td><code>C-SPC</code></td>
<td>Start selecting text</td>
<td><code>set-mark-comand</code></td>
</tr>
<tr>
<td><code>M-w</code></td>
<td>Copy selected text</td>
<td><code>kill-ring-save</code></td>
</tr>
<tr>
<td><code>C-w</code></td>
<td>Cut selected text</td>
<td><code>kill-region</code></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orgae80f19" class="outline-3">
<h3 id="orgae80f19"><span class="section-number-3">2.5</span> Visiting files</h3>
<div class="outline-text-3" id="text-2-5">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col"> </th>
<th scope="col">Emacs command</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>C-x C-f</code></td>
<td>Open File</td>
<td><code>find-file</code></td>
</tr>
<tr>
<td><code>C-x C-s</code></td>
<td>Save File</td>
<td><code>save-buffer</code></td>
</tr>
<tr>
<td><code>C-x s</code></td>
<td>Save All</td>
<td><code>save-some-buffers</code></td>
</tr>
<tr>
<td><code>C-x k</code></td>
<td>Close File</td>
<td><code>kill-buffer</code></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org071503a" class="outline-3">
<h3 id="org071503a"><span class="section-number-3">2.6</span> Switching buffers</h3>
<div class="outline-text-3" id="text-2-6">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col"> </th>
<th scope="col">Emacs command</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>C-x C-b</code></td>
<td>Get a list of all open files</td>
<td><code>list-buffers</code></td>
</tr>
<tr>
<td><code>C-x b</code></td>
<td>Switch to another open file</td>
<td><code>switch-to-buffer</code></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org19471b2" class="outline-3">
<h3 id="org19471b2"><span class="section-number-3">2.7</span> Getting help</h3>
<div class="outline-text-3" id="text-2-7">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col"> </th>
<th scope="col">Emacs command</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>C-h f</code></td>
<td>See the docstring for a function</td>
<td><code>describe-function</code></td>
</tr>
<tr>
<td><code>C-h k</code></td>
<td>Find which command a key is bound to</td>
<td><code>describe-key</code></td>
</tr>
<tr>
<td><code>C-h i</code></td>
<td>Open the Emacs manual (info pages)</td>
<td><code>info</code></td>
</tr>
<tr>
<td><code>C-h m</code></td>
<td>See documentation of the current major and minor mode</td>
<td><code>describe-mode</code></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orga645b7a" class="outline-3">
<h3 id="orga645b7a"><span class="section-number-3">2.8</span> Working with windows</h3>
<div class="outline-text-3" id="text-2-8">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col"> </th>
<th scope="col">Emacs command</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>C-x 2</code></td>
<td>Split vertically</td>
<td><code>split-window-below</code></td>
</tr>
<tr>
<td><code>C-x 3</code></td>
<td>Split horizontally</td>
<td><code>split-window-right</code></td>
</tr>
<tr>
<td><code>C-x o</code></td>
<td>Go to next window</td>
<td><code>other-window</code></td>
</tr>
<tr>
<td><code>C-x 1</code></td>
<td>Maximize window (close all others)</td>
<td><code>delete-other-windows</code></td>
</tr>
<tr>
<td><code>C-x 0</code></td>
<td>Minimize window (close currentk)</td>
<td><code>delete-window</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="outline-container-org647363e" class="outline-2">
<h2 id="org647363e"><span class="section-number-2">3</span> First steps in Elisp</h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-orgfc627df" class="outline-3">
<h3 id="orgfc627df"><span class="section-number-3">3.1</span> evaluating forms</h3>
<div class="outline-text-3" id="text-3-1">
<p>
You already used the command `eval-last-sexp`, bound to `C-x C-e`, which
evaluates the s-expression preceding <code>point</code> (the cursor position).
</p>
<p>
Another command for evaluating is `C-M-x`, which evaluates the outermost form.
</p>
</div>
</div>
<div id="outline-container-orge9bf90c" class="outline-3">
<h3 id="orge9bf90c"><span class="section-number-3">3.2</span> values, variables, functions, setq</h3>
<div class="outline-text-3" id="text-3-2">
<p>
<b>TODO</b>
</p>
</div>
</div>
</div>
<div id="outline-container-orgb805dad" class="outline-2">
<h2 id="orgb805dad"><span class="section-number-2">4</span> create first .emacs/init.el</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-org1cce10e" class="outline-3">
<h3 id="org1cce10e"><span class="section-number-3">4.1</span> A blueprint to get started</h3>
<div class="outline-text-3" id="text-4-1">
<p>
There are many ways to organize the configuration of your Emacs. We'll give you
a blueprint so you have a structure that you can fill in yourself as time goes
on.
</p>
<p>
Most of the extra functionality will be installed through packages. These can be
installed from multiple places, we'll set things up to download packages from
the two main "package repositories", GNU ELPA and MELPA.
</p>
<p>
A package may require some extra setup or configuration, such as customizing
variables or creating key bindings. To keep that all in one place we'll use a
command called <code>use-package</code>, which is itself installed as… a package.
Package-ception!
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">Install packages from these sources</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">- GNU ELPA: The official GNU package repository, relatively small</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">- MELPA: The main community-run package archive</span>
<span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">setq</span> package-archives
'<span style="color: #8abeb7;">(</span><span style="color: #f0c674;">(</span><span style="color: #8abeb7;">"gnu"</span> . <span style="color: #8abeb7;">"https://elpa.gnu.org/packages/"</span><span style="color: #f0c674;">)</span>
<span style="color: #f0c674;">(</span><span style="color: #8abeb7;">"melpa"</span> . <span style="color: #8abeb7;">"https://melpa.org/packages/"</span><span style="color: #f0c674;">)</span><span style="color: #8abeb7;">)</span><span style="color: #c5c8c6;">)</span>
<span style="color: #c5c8c6;">(</span>package-initialize<span style="color: #c5c8c6;">)</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">Download a list of available packages if we don't have it already</span>
<span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">unless</span> <span style="color: #8abeb7;">(</span>file-exists-p <span style="color: #8abeb7;">"~/.emacs.d/elpa/archives/melpa"</span><span style="color: #8abeb7;">)</span>
<span style="color: #8abeb7;">(</span>package-refresh-contents<span style="color: #8abeb7;">)</span><span style="color: #c5c8c6;">)</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">The `</span><span style="color: #81a2be; font-style: italic;">use-package</span><span style="color: #969896; font-style: italic;">' package makes it easy to install and configure packages</span>
<span style="color: #c5c8c6;">(</span>package-install 'use-package<span style="color: #c5c8c6;">)</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">For example,</span>
<span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">use-package</span> <span style="color: #81a2be;">multiple-cursors</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">install the package if it isn't already</span>
<span style="color: #b294bb;">:ensure</span> t
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">configure key bindings</span>
<span style="color: #b294bb;">:bind</span> <span style="color: #8abeb7;">(</span><span style="color: #f0c674;">(</span><span style="color: #8abeb7;">"C-S-c C-S-c"</span> . mc/edit-lines<span style="color: #f0c674;">)</span>
<span style="color: #f0c674;">(</span><span style="color: #8abeb7;">"C->"</span> . mc/mark-next-like-this<span style="color: #f0c674;">)</span>
<span style="color: #f0c674;">(</span><span style="color: #8abeb7;">"C-<"</span> . mc/mark-previous-like-this<span style="color: #f0c674;">)</span>
<span style="color: #f0c674;">(</span><span style="color: #8abeb7;">"C-c C-<"</span> . mc/mark-all-like-this<span style="color: #f0c674;">)</span><span style="color: #8abeb7;">)</span><span style="color: #c5c8c6;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf757ee0" class="outline-3">
<h3 id="orgf757ee0"><span class="section-number-3">4.2</span> major/minor modes</h3>
</div>
<div id="outline-container-orgb827144" class="outline-3">
<h3 id="orgb827144"><span class="section-number-3">4.3</span> get to a "good enough" initial set up</h3>
</div>
<div id="outline-container-org7d42b87" class="outline-3">
<h3 id="org7d42b87"><span class="section-number-3">4.4</span> Language specific sections</h3>
<div class="outline-text-3" id="text-4-4">
<p>
For each language that you commonly program in, you should at least install a
"major mode". This will provide syntax highlighting and other language-specific
functionality. What follows are some example configs to get you started. Just
copy over the ones that are relevant to you.
</p>
</div>
<div id="outline-container-org72d86a7" class="outline-4">
<h4 id="org72d86a7"><span class="section-number-4">4.4.1</span> Ruby</h4>
<div class="outline-text-4" id="text-4-4-1">
<p>
There is a Ruby major mode already installed with Emacs, all you need to do is enable it
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">use-package</span> <span style="color: #81a2be;">ruby-mode</span><span style="color: #c5c8c6;">)</span>
</pre>
</div>
<p>
Packages you could look into in the future include
</p>
<ul class="org-ul">
<li><code>enh-ruby-mode</code></li>
<li><code>robe</code></li>
<li><code>chruby</code></li>
<li><code>rspec-mode</code></li>
<li><code>inf-ruby-mode</code></li>
</ul>
</div>
</div>
<div id="outline-container-org4a72452" class="outline-4">
<h4 id="org4a72452"><span class="section-number-4">4.4.2</span> Javascript</h4>
<div class="outline-text-4" id="text-4-4-2">
<p>
Emacs comes bundled with a <code>js-mode</code>, however you might prefer <code>js2-mode</code>.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">use-package</span> <span style="color: #81a2be;">js2-mode</span> <span style="color: #b294bb;">:ensure</span> t<span style="color: #c5c8c6;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd3e889f" class="outline-4">
<h4 id="orgd3e889f"><span class="section-number-4">4.4.3</span> CSS</h4>
<div class="outline-text-4" id="text-4-4-3">
<p>
Emacs comes bundled with CSS mode. A nice extra is <code>rainbow-mode</code>, which shows
the color of color codes.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">use-package</span> <span style="color: #81a2be;">css-mode</span>
<span style="color: #b294bb;">:config</span>
<span style="color: #8abeb7;">(</span><span style="color: #b5bd68;">use-package</span> <span style="color: #81a2be;">rainbow-mode</span>
<span style="color: #b294bb;">:ensure</span> t
<span style="color: #b294bb;">:config</span>
<span style="color: #f0c674;">(</span>add-hook 'css-mode-hook 'rainbow-mode<span style="color: #f0c674;">)</span><span style="color: #8abeb7;">)</span><span style="color: #c5c8c6;">)</span>
</pre>
</div>
<p>
Example:
</p>
<div class="org-src-container">
<pre class="src src-css"><span style="color: #de935f;">body </span><span style="color: #c5c8c6;">{</span>
<span style="color: #b5bd68;">color</span>: <span style="color: #ffffff; background-color: #1e1e1e;">#1e1e1e</span>;
<span style="color: #b5bd68;">background</span>: <span style="color: #ffffff; background-color: #3e77ff;">#3e77ff</span>;
<span style="color: #c5c8c6;">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org5828d8f" class="outline-4">
<h4 id="org5828d8f"><span class="section-number-4">4.4.4</span> Clojure</h4>
<div class="outline-text-4" id="text-4-4-4">
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #c5c8c6;">(</span><span style="color: #b5bd68;">use-package</span> <span style="color: #81a2be;">clojure-mode</span>
<span style="color: #b294bb;">:ensure</span> t
<span style="color: #b294bb;">:config</span>
<span style="color: #8abeb7;">(</span>add-hook 'clojure-mode-hook 'cider-mode<span style="color: #8abeb7;">)</span>
<span style="color: #969896; font-style: italic;">;;;; </span><span style="color: #969896; font-style: italic;">Optional: add structural editing</span>
<span style="color: #969896; font-style: italic;">;;</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">(use-package paredit</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">:ensure t</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">:config</span>
<span style="color: #969896; font-style: italic;">;; </span><span style="color: #969896; font-style: italic;">(add-hook 'clojure-mode-hook 'paredit-mode))</span>