1 |
Author: fauli |
2 |
Date: 2009-07-02 08:58:45 +0000 (Thu, 02 Jul 2009) |
3 |
New Revision: 1286 |
4 |
|
5 |
Modified: |
6 |
emacsguide/emacsguide.xml |
7 |
Log: |
8 |
Some more sections regrouped |
9 |
|
10 |
|
11 |
Modified: emacsguide/emacsguide.xml |
12 |
=================================================================== |
13 |
--- emacsguide/emacsguide.xml 2009-07-02 08:51:55 UTC (rev 1285) |
14 |
+++ emacsguide/emacsguide.xml 2009-07-02 08:58:45 UTC (rev 1286) |
15 |
@@ -251,6 +251,104 @@ |
16 |
</chapter> |
17 |
|
18 |
<chapter> |
19 |
+ <title>Basics</title> |
20 |
+ <section> |
21 |
+ <title>Emacs Lisp</title> |
22 |
+ <p> |
23 |
+ You could use the lisp interpreter to make lists or do some |
24 |
+ simple math. Type these in and then type control-x, control-e |
25 |
+ with the cursor at the end of them. Watch the minibuffer at the |
26 |
+ bottom of the screen. |
27 |
+ </p> |
28 |
+ <pre caption="Code Sample"> |
29 |
+ (list 'a 'b 'c) |
30 |
+ (+ 1 2 3) |
31 |
+ (* (* 2 2) (/ 22 7)) |
32 |
+ (message "%s" "This is an introduction to using Emacs in Gentoo.") |
33 |
+ </pre> |
34 |
+ <p> |
35 |
+ Understanding how to navigate the cursor over lists is quite |
36 |
+ useful. With the cursor pointed on a [, (, or {, use M-C-f to |
37 |
+ go to the end. Use M-C-b to go to the beginning of the list. |
38 |
+ That is escape, control-f and escape, control-b |
39 |
+ respectively. |
40 |
+ </p> |
41 |
+ <p>You could load your elisp.</p> |
42 |
+ <pre caption="Code Sample"> |
43 |
+ M-x load-file |
44 |
+ </pre> |
45 |
+ <p> |
46 |
+ Now, you may want to clean up your code or make replacements in a |
47 |
+ function. Click and drag or use control-space to set a mark. |
48 |
+ </p> |
49 |
+ <pre caption="Code Sample"> |
50 |
+ M-x transient-mark-mode |
51 |
+ </pre> |
52 |
+ <p> |
53 |
+ That will toggle the highlighting of selected text. Now, M-% will |
54 |
+ prompt you to search and replace or query-replace. Also, |
55 |
+ global-font-lock-mode will toggle the syntax highlighting; |
56 |
+ indent-region will nicely indent nested code blocks or HTML. A quick |
57 |
+ comment comes from M-; or escape-semicolon. |
58 |
+ </p> |
59 |
+ </section> |
60 |
+ <section> |
61 |
+ <title>Invoking Processes</title> |
62 |
+ <body> |
63 |
+ <p>Emacs can start subprocesses, like a shell or a debugger or even find and grep.</p> |
64 |
+ <pre caption="Code Sample"> |
65 |
+ M-x shell |
66 |
+ M-x gdb |
67 |
+ M-x find-grep |
68 |
+ </pre> |
69 |
+ <figure link="emacs.jpg" short="Find and Grep" caption="Search in Emacs"/> |
70 |
+ |
71 |
+ <note>Emacs can be used on compressed text in the gzip and bzip2 formats by invoking decompressors.</note> |
72 |
+ </body> |
73 |
+ </section> |
74 |
+ <section> |
75 |
+ <title>Emacs and Bash Equivalents</title> |
76 |
+ <body> |
77 |
+ <p>Bash has some keystrokes in common with Emacs. You can search |
78 |
+ your shell history with control-r but not control-s. If you try |
79 |
+ control-s in bash, it will hide your typing. You can type |
80 |
+ control-q to see input to bash again. To cancel a search, type |
81 |
+ control-g. Just like Emacs, you can kill text several times with |
82 |
+ control-k and get it back with control-y. You can then use |
83 |
+ escape-y repetitions. You can suspend Emacs with control-z. Try |
84 |
+ the jobs command to see what is suspended. Then type fg or fg 1 |
85 |
+ to get back to Emacs.</p> |
86 |
+ </body> |
87 |
+ </section> |
88 |
+ <section> |
89 |
+ <title>Complete Text</title> |
90 |
+ <body> |
91 |
+ <p>Now is where some completion becomes useful. There is M-/ to complete a string and also some elisp that does much more.</p> |
92 |
+ <pre caption="Code Sample"> |
93 |
+ M-x hippie-expand |
94 |
+ </pre> |
95 |
+ |
96 |
+ <p> |
97 |
+ This has try-expand-list, try-expand-line, |
98 |
+ try-complete-file-name and many other things. It will cycle |
99 |
+ through trying to match what is immediately on the left of the |
100 |
+ cursor. It is much nicer to bind this to a key. |
101 |
+ </p> |
102 |
+ <pre caption="Code Sample"> |
103 |
+ M-x global-set-key |
104 |
+ </pre> |
105 |
+ |
106 |
+ <p>This could be persistent in a .emacs file.</p> |
107 |
+ <pre caption="Code Sample"> |
108 |
+ $ echo "(global-set-key [(f2)] 'hippie-expand)" >> ~/.emacs.d/init.el |
109 |
+ </pre> |
110 |
+ |
111 |
+ <note><c>man man</c> has this tip: (global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word))))</note> |
112 |
+ </body> |
113 |
+ </section> |
114 |
+ </chapter> |
115 |
+ |
116 |
+ <chapter> |
117 |
<title>Useful functions in GNU Emacs</title> |
118 |
<section> |
119 |
<title>Dired</title> |
120 |
@@ -329,107 +427,6 @@ |
121 |
</chapter> |
122 |
|
123 |
<chapter> |
124 |
- <title>Invoking Processes</title> |
125 |
- <body> |
126 |
- <p>Emacs can start subprocesses, like a shell or a debugger or even find and grep.</p> |
127 |
- <pre caption="Code Sample"> |
128 |
- M-x shell |
129 |
- M-x gdb |
130 |
- M-x find-grep |
131 |
- </pre> |
132 |
- <figure link="emacs.jpg" short="Find and Grep" caption="Search in Emacs"/> |
133 |
- |
134 |
- <note>Emacs can be used on compressed text in the gzip and bzip2 formats by invoking decompressors.</note> |
135 |
- </body> |
136 |
- </chapter> |
137 |
- |
138 |
- <chapter> |
139 |
- <title>Emacs and Bash Equivalents</title> |
140 |
- <body> |
141 |
- <p>Bash has some keystrokes in common with Emacs. You can search |
142 |
- your shell history with control-r but not control-s. If you try |
143 |
- control-s in bash, it will hide your typing. You can type |
144 |
- control-q to see input to bash again. To cancel a search, type |
145 |
- control-g. Just like Emacs, you can kill text several times with |
146 |
- control-k and get it back with control-y. You can then use |
147 |
- escape-y repetitions. You can suspend Emacs with control-z. Try |
148 |
- the jobs command to see what is suspended. Then type fg or fg 1 |
149 |
- to get back to Emacs.</p> |
150 |
- </body> |
151 |
- </chapter> |
152 |
- |
153 |
- <chapter> |
154 |
- <title>Complete Text</title> |
155 |
- <body> |
156 |
- <p>Now is where some completion becomes useful. There is M-/ to complete a string and also some elisp that does much more.</p> |
157 |
- <pre caption="Code Sample"> |
158 |
- M-x hippie-expand |
159 |
- </pre> |
160 |
- |
161 |
- <p> |
162 |
- This has try-expand-list, try-expand-line, |
163 |
- try-complete-file-name and many other things. It will cycle |
164 |
- through trying to match what is immediately on the left of the |
165 |
- cursor. It is much nicer to bind this to a key. |
166 |
- </p> |
167 |
- <pre caption="Code Sample"> |
168 |
- M-x global-set-key |
169 |
- </pre> |
170 |
- |
171 |
- <p>This could be persistent in a .emacs file.</p> |
172 |
- <pre caption="Code Sample"> |
173 |
- $ echo "(global-set-key [(f2)] 'hippie-expand)" >> ~/.emacs.d/init.el |
174 |
- </pre> |
175 |
- |
176 |
- <note><c>man man</c> has this tip: (global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word))))</note> |
177 |
- </body> |
178 |
- </chapter> |
179 |
- |
180 |
- <chapter> |
181 |
- <title>Emacs Lisp</title> |
182 |
- <p> |
183 |
- You could use the lisp interpreter to make lists or do some |
184 |
- simple math. Type these in and then type control-x, control-e |
185 |
- with the cursor at the end of them. Watch the minibuffer at the |
186 |
- bottom of the screen. |
187 |
- </p> |
188 |
- <pre caption="Code Sample"> |
189 |
- (list 'a 'b 'c) |
190 |
- (+ 1 2 3) |
191 |
- (* (* 2 2) (/ 22 7)) |
192 |
- (message "%s" "This is an introduction to using Emacs in Gentoo.") |
193 |
- </pre> |
194 |
- <p> |
195 |
- Understanding how to navigate the cursor over lists is quite |
196 |
- useful. With the cursor pointed on a [, (, or {, use M-C-f to |
197 |
- go to the end. Use M-C-b to go to the beginning of the list. |
198 |
- That is escape, control-f and escape, control-b |
199 |
- respectively. |
200 |
- </p> |
201 |
- |
202 |
- <p>You could load your elisp.</p> |
203 |
- <pre caption="Code Sample"> |
204 |
- M-x load-file |
205 |
- </pre> |
206 |
- |
207 |
- <p> |
208 |
- Now, you may want to clean up your code or make replacements in a |
209 |
- function. Click and drag or use control-space to set a mark. |
210 |
- </p> |
211 |
- <pre caption="Code Sample"> |
212 |
- M-x transient-mark-mode |
213 |
- </pre> |
214 |
- |
215 |
- <p> |
216 |
- That will toggle the highlighting of selected text. Now, M-% will |
217 |
- prompt you to search and replace or query-replace. Also, |
218 |
- global-font-lock-mode will toggle the syntax highlighting; |
219 |
- indent-region will nicely indent nested code blocks or HTML. A quick |
220 |
- comment comes from M-; or escape-semicolon. |
221 |
- </p> |
222 |
- </chapter> |
223 |
- |
224 |
- <chapter> |
225 |
<title>Remove Comments</title> |
226 |
<p> |
227 |
One common thing for Gentoo users is to strip comments from |