Trailing whitespace deleted.
[bpt/emacs.git] / etc / refcard.tex
CommitLineData
4cf8444a 1% Reference Card for GNU Emacs version 21 on Unix systems
a933dad1
DL
2%**start of header
3\newcount\columnsperpage
4
5% This file can be printed with 1, 2, or 3 columns per page (see below).
6% Specify how many you want here. Nothing else needs to be changed.
7
8\columnsperpage=1
9
10% Copyright (c) 1987, 1993, 1996, 1997 Free Software Foundation, Inc.
11
12% This file is part of GNU Emacs.
13
14% GNU Emacs is free software; you can redistribute it and/or modify
15% it under the terms of the GNU General Public License as published by
16% the Free Software Foundation; either version 2, or (at your option)
17% any later version.
18
19% GNU Emacs is distributed in the hope that it will be useful,
20% but WITHOUT ANY WARRANTY; without even the implied warranty of
21% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22% GNU General Public License for more details.
23
24% You should have received a copy of the GNU General Public License
25% along with GNU Emacs; see the file COPYING. If not, write to
26% the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27% Boston, MA 02111-1307, USA.
28
29% This file is intended to be processed by plain TeX (TeX82).
30%
31% The final reference card has six columns, three on each side.
32% This file can be used to produce it in any of three ways:
33% 1 column per page
34% produces six separate pages, each of which needs to be reduced to 80%.
35% This gives the best resolution.
36% 2 columns per page
37% produces three already-reduced pages.
38% You will still need to cut and paste.
39% 3 columns per page
40% produces two pages which must be printed sideways to make a
41% ready-to-use 8.5 x 11 inch reference card.
42% For this you need a dvi device driver that can print sideways.
43% Which mode to use is controlled by setting \columnsperpage above.
44%
45% Author:
46% Stephen Gildea
feeb94f7 47% Internet: gildea@stop.mail-abuse.org
a933dad1
DL
48%
49% Thanks to Paul Rubin, Bob Chassell, Len Tower, and Richard Mlynarik
50% for their many good ideas.
51
52% If there were room, it would be nice to see a section on Dired.
53
54\def\versionnumber{2.2}
55\def\year{1997}
56
57\def\shortcopyrightnotice{\vskip 1ex plus 2 fill
58 \centerline{\small \copyright\ \year\ Free Software Foundation, Inc.
59 Permissions on back. v\versionnumber}}
60
61\def\copyrightnotice{
62\vskip 1ex plus 2 fill\begingroup\small
63\centerline{Copyright \copyright\ \year\ Free Software Foundation, Inc.}
4cf8444a 64\centerline{v\versionnumber{} for GNU Emacs version 21, \year}
a933dad1
DL
65\centerline{designed by Stephen Gildea}
66
67Permission is granted to make and distribute copies of
68this card provided the copyright notice and this permission notice
69are preserved on all copies.
70
71For copies of the GNU Emacs manual, write to the Free Software
72Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
73
74\endgroup}
75
76% make \bye not \outer so that the \def\bye in the \else clause below
77% can be scanned without complaint.
78\def\bye{\par\vfill\supereject\end}
79
80\newdimen\intercolumnskip %horizontal space between columns
81\newbox\columna %boxes to hold columns already built
82\newbox\columnb
83
84\def\ncolumns{\the\columnsperpage}
85
177c0ea7 86\message{[\ncolumns\space
a933dad1
DL
87 column\if 1\ncolumns\else s\fi\space per page]}
88
89\def\scaledmag#1{ scaled \magstep #1}
90
91% This multi-way format was designed by Stephen Gildea October 1986.
92% Note that the 1-column format is fontfamily-independent.
93\if 1\ncolumns %one-column format uses normal size
94 \hsize 4in
95 \vsize 10in
96 \voffset -.7in
97 \font\titlefont=\fontname\tenbf \scaledmag3
98 \font\headingfont=\fontname\tenbf \scaledmag2
99 \font\smallfont=\fontname\sevenrm
100 \font\smallsy=\fontname\sevensy
101
102 \footline{\hss\folio}
103 \def\makefootline{\baselineskip10pt\hsize6.5in\line{\the\footline}}
104\else %2 or 3 columns uses prereduced size
105 \hsize 3.2in
106 \vsize 7.95in
107 \hoffset -.75in
108 \voffset -.745in
109 \font\titlefont=cmbx10 \scaledmag2
110 \font\headingfont=cmbx10 \scaledmag1
111 \font\smallfont=cmr6
112 \font\smallsy=cmsy6
113 \font\eightrm=cmr8
114 \font\eightbf=cmbx8
115 \font\eightit=cmti8
116 \font\eighttt=cmtt8
117 \font\eightmi=cmmi8
118 \font\eightsy=cmsy8
119 \textfont0=\eightrm
120 \textfont1=\eightmi
121 \textfont2=\eightsy
122 \def\rm{\eightrm}
123 \def\bf{\eightbf}
124 \def\it{\eightit}
125 \def\tt{\eighttt}
126 \normalbaselineskip=.8\normalbaselineskip
127 \normallineskip=.8\normallineskip
128 \normallineskiplimit=.8\normallineskiplimit
129 \normalbaselines\rm %make definitions take effect
130
131 \if 2\ncolumns
132 \let\maxcolumn=b
133 \footline{\hss\rm\folio\hss}
134 \def\makefootline{\vskip 2in \hsize=6.86in\line{\the\footline}}
135 \else \if 3\ncolumns
136 \let\maxcolumn=c
137 \nopagenumbers
138 \else
139 \errhelp{You must set \columnsperpage equal to 1, 2, or 3.}
140 \errmessage{Illegal number of columns per page}
141 \fi\fi
142
143 \intercolumnskip=.46in
144 \def\abc{a}
145 \output={% %see The TeXbook page 257
146 % This next line is useful when designing the layout.
147 %\immediate\write16{Column \folio\abc\space starts with \firstmark}
148 \if \maxcolumn\abc \multicolumnformat \global\def\abc{a}
149 \else\if a\abc
150 \global\setbox\columna\columnbox \global\def\abc{b}
151 %% in case we never use \columnb (two-column mode)
152 \global\setbox\columnb\hbox to -\intercolumnskip{}
153 \else
154 \global\setbox\columnb\columnbox \global\def\abc{c}\fi\fi}
155 \def\multicolumnformat{\shipout\vbox{\makeheadline
156 \hbox{\box\columna\hskip\intercolumnskip
157 \box\columnb\hskip\intercolumnskip\columnbox}
158 \makefootline}\advancepageno}
159 \def\columnbox{\leftline{\pagebody}}
160
161 \def\bye{\par\vfill\supereject
162 \if a\abc \else\null\vfill\eject\fi
163 \if a\abc \else\null\vfill\eject\fi
177c0ea7 164 \end}
a933dad1
DL
165\fi
166
167% we won't be using math mode much, so redefine some of the characters
168% we might want to talk about
169\catcode`\^=12
170\catcode`\_=12
171
172\chardef\\=`\\
173\chardef\{=`\{
174\chardef\}=`\}
175
176\hyphenation{mini-buf-fer}
177
178\parindent 0pt
179\parskip 1ex plus .5ex minus .5ex
180
181\def\small{\smallfont\textfont2=\smallsy\baselineskip=.8\baselineskip}
182
183% newcolumn - force a new column. Use sparingly, probably only for
184% the first column of a page, which should have a title anyway.
185\outer\def\newcolumn{\vfill\eject}
186
187% title - page title. Argument is title text.
188\outer\def\title#1{{\titlefont\centerline{#1}}\vskip 1ex plus .5ex}
189
190% section - new major section. Argument is section name.
191\outer\def\section#1{\par\filbreak
192 \vskip 3ex plus 2ex minus 2ex {\headingfont #1}\mark{#1}%
193 \vskip 2ex plus 1ex minus 1.5ex}
194
195\newdimen\keyindent
196
197% beginindentedkeys...endindentedkeys - key definitions will be
198% indented, but running text, typically used as headings to group
199% definitions, will not.
200\def\beginindentedkeys{\keyindent=1em}
201\def\endindentedkeys{\keyindent=0em}
202\endindentedkeys
203
204% paralign - begin paragraph containing an alignment.
205% If an \halign is entered while in vertical mode, a parskip is never
206% inserted. Using \paralign instead of \halign solves this problem.
207\def\paralign{\vskip\parskip\halign}
208
209% \<...> - surrounds a variable name in a code example
210\def\<#1>{{\it #1\/}}
211
212% kbd - argument is characters typed literally. Like the Texinfo command.
213\def\kbd#1{{\tt#1}\null} %\null so not an abbrev even if period follows
214
215% beginexample...endexample - surrounds literal text, such a code example.
216% typeset in a typewriter font with line breaks preserved
217\def\beginexample{\par\leavevmode\begingroup
218 \obeylines\obeyspaces\parskip0pt\tt}
219{\obeyspaces\global\let =\ }
220\def\endexample{\endgroup}
221
222% key - definition of a key.
223% \key{description of key}{key-name}
224% prints the description left-justified, and the key-name in a \kbd
225% form near the right margin.
226\def\key#1#2{\leavevmode\hbox to \hsize{\vtop
227 {\hsize=.75\hsize\rightskip=1em
228 \hskip\keyindent\relax#1}\kbd{#2}\hfil}}
229
230\newbox\metaxbox
231\setbox\metaxbox\hbox{\kbd{M-x }}
232\newdimen\metaxwidth
233\metaxwidth=\wd\metaxbox
234
235% metax - definition of a M-x command.
236% \metax{description of command}{M-x command-name}
237% Tries to justify the beginning of the command name at the same place
238% as \key starts the key name. (The "M-x " sticks out to the left.)
239\def\metax#1#2{\leavevmode\hbox to \hsize{\hbox to .75\hsize
240 {\hskip\keyindent\relax#1\hfil}%
241 \hskip -\metaxwidth minus 1fil
242 \kbd{#2}\hfil}}
243
244% threecol - like "key" but with two key names.
245% for example, one for doing the action backward, and one for forward.
246\def\threecol#1#2#3{\hskip\keyindent\relax#1\hfil&\kbd{#2}\hfil\quad
247 &\kbd{#3}\hfil\quad\cr}
248
249%**end of header
250\f
251
252\title{GNU Emacs Reference Card}
253
4cf8444a 254\centerline{(for version 21)}
a933dad1
DL
255
256\section{Starting Emacs}
257
4cf8444a 258To enter GNU Emacs 21, just type its name: \kbd{emacs}
a933dad1
DL
259
260To read in a file to edit, see Files, below.
261
262\section{Leaving Emacs}
263
264\key{suspend Emacs (or iconify it under X)}{C-z}
265\key{exit Emacs permanently}{C-x C-c}
266
267\section{Files}
268
269\key{{\bf read} a file into Emacs}{C-x C-f}
270\key{{\bf save} a file back to disk}{C-x C-s}
271\key{save {\bf all} files}{C-x s}
272\key{{\bf insert} contents of another file into this buffer}{C-x i}
273\key{replace this file with the file you really want}{C-x C-v}
274\key{write buffer to a specified file}{C-x C-w}
275\key{version control checkin/checkout}{C-x C-q}
276
277\section{Getting Help}
278
279The help system is simple. Type \kbd{C-h} (or \kbd{F1}) and follow
280the directions. If you are a first-time user, type \kbd{C-h t} for a
281{\bf tutorial}.
282
283\key{remove help window}{C-x 1}
284\key{scroll help window}{C-M-v}
285
286\key{apropos: show commands matching a string}{C-h a}
287\key{show the function a key runs}{C-h c}
288\key{describe a function}{C-h f}
289\key{get mode-specific information}{C-h m}
290
291\section{Error Recovery}
292
293\key{{\bf abort} partially typed or executing command}{C-g}
294\metax{{\bf recover} a file lost by a system crash}{M-x recover-file}
295\key{{\bf undo} an unwanted change}{C-x u {\rm or} C-_}
296\metax{restore a buffer to its original contents}{M-x revert-buffer}
297\key{redraw garbaged screen}{C-l}
298
299\section{Incremental Search}
300
301\key{search forward}{C-s}
302\key{search backward}{C-r}
303\key{regular expression search}{C-M-s}
304\key{reverse regular expression search}{C-M-r}
305
306\key{select previous search string}{M-p}
307\key{select next later search string}{M-n}
308\key{exit incremental search}{RET}
309\key{undo effect of last character}{DEL}
310\key{abort current search}{C-g}
311
312Use \kbd{C-s} or \kbd{C-r} again to repeat the search in either direction.
313If Emacs is still searching, \kbd{C-g} cancels only the part not done.
314
315\shortcopyrightnotice
316
317\section{Motion}
318
319\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\tabskip=0pt&#\cr
320\threecol{{\bf entity to move over}}{{\bf backward}}{{\bf forward}}
321\threecol{character}{C-b}{C-f}
322\threecol{word}{M-b}{M-f}
323\threecol{line}{C-p}{C-n}
324\threecol{go to line beginning (or end)}{C-a}{C-e}
325\threecol{sentence}{M-a}{M-e}
326\threecol{paragraph}{M-\{}{M-\}}
327\threecol{page}{C-x [}{C-x ]}
328\threecol{sexp}{C-M-b}{C-M-f}
329\threecol{function}{C-M-a}{C-M-e}
330\threecol{go to buffer beginning (or end)}{M-<}{M->}
331}
332
333\key{scroll to next screen}{C-v}
334\key{scroll to previous screen}{M-v}
335\key{scroll left}{C-x <}
336\key{scroll right}{C-x >}
337\key{scroll current line to center of screen}{C-u C-l}
338
339\section{Killing and Deleting}
340
341\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\tabskip=0pt&#\cr
342\threecol{{\bf entity to kill}}{{\bf backward}}{{\bf forward}}
343\threecol{character (delete, not kill)}{DEL}{C-d}
344\threecol{word}{M-DEL}{M-d}
345\threecol{line (to end of)}{M-0 C-k}{C-k}
346\threecol{sentence}{C-x DEL}{M-k}
347\threecol{sexp}{M-- C-M-k}{C-M-k}
348}
349
350\key{kill {\bf region}}{C-w}
351\key{copy region to kill ring}{M-w}
352\key{kill through next occurrence of {\it char}}{M-z {\it char}}
353
354\key{yank back last thing killed}{C-y}
355\key{replace last yank with previous kill}{M-y}
356
357\section{Marking}
358
359\key{set mark here}{C-@ {\rm or} C-SPC}
360\key{exchange point and mark}{C-x C-x}
361
362\key{set mark {\it arg\/} {\bf words} away}{M-@}
363\key{mark {\bf paragraph}}{M-h}
364\key{mark {\bf page}}{C-x C-p}
365\key{mark {\bf sexp}}{C-M-@}
366\key{mark {\bf function}}{C-M-h}
367\key{mark entire {\bf buffer}}{C-x h}
368
369\section{Query Replace}
370
371\key{interactively replace a text string}{M-\%}
372\metax{using regular expressions}{M-x query-replace-regexp}
373
374Valid responses in query-replace mode are
375
376\key{{\bf replace} this one, go on to next}{SPC}
377\key{replace this one, don't move}{,}
378\key{{\bf skip} to next without replacing}{DEL}
379\key{replace all remaining matches}{!}
380\key{{\bf back up} to the previous match}{^}
381\key{{\bf exit} query-replace}{RET}
382\key{enter recursive edit (\kbd{C-M-c} to exit)}{C-r}
383
384\section{Multiple Windows}
385
386When two commands are shown, the second is for ``other frame.''
387
388\key{delete all other windows}{C-x 1}
389
390{\setbox0=\hbox{\kbd{0}}\advance\hsize by 0\wd0
391\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\tabskip=0pt&#\cr
392\threecol{split window, above and below}{C-x 2\ \ \ \ }{C-x 5 2}
393\threecol{delete this window}{C-x 0\ \ \ \ }{C-x 5 0}
394}}
395\key{split window, side by side}{C-x 3}
396
397\key{scroll other window}{C-M-v}
398
399{\setbox0=\hbox{\kbd{0}}\advance\hsize by 2\wd0
400\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\tabskip=0pt&#\cr
401\threecol{switch cursor to another window}{C-x o}{C-x 5 o}
402
403\threecol{select buffer in other window}{C-x 4 b}{C-x 5 b}
404\threecol{display buffer in other window}{C-x 4 C-o}{C-x 5 C-o}
405\threecol{find file in other window}{C-x 4 f}{C-x 5 f}
406\threecol{find file read-only in other window}{C-x 4 r}{C-x 5 r}
407\threecol{run Dired in other window}{C-x 4 d}{C-x 5 d}
408\threecol{find tag in other window}{C-x 4 .}{C-x 5 .}
409}}
410
411\key{grow window taller}{C-x ^}
412\key{shrink window narrower}{C-x \{}
413\key{grow window wider}{C-x \}}
414
415\section{Formatting}
416
417\key{indent current {\bf line} (mode-dependent)}{TAB}
418\key{indent {\bf region} (mode-dependent)}{C-M-\\}
419\key{indent {\bf sexp} (mode-dependent)}{C-M-q}
420\key{indent region rigidly {\it arg\/} columns}{C-x TAB}
421
422\key{insert newline after point}{C-o}
423\key{move rest of line vertically down}{C-M-o}
424\key{delete blank lines around point}{C-x C-o}
425\key{join line with previous (with arg, next)}{M-^}
426\key{delete all white space around point}{M-\\}
427\key{put exactly one space at point}{M-SPC}
428
429\key{fill paragraph}{M-q}
430\key{set fill column}{C-x f}
431\key{set prefix each line starts with}{C-x .}
432
433\key{set face}{M-g}
434
435\section{Case Change}
436
437\key{uppercase word}{M-u}
438\key{lowercase word}{M-l}
439\key{capitalize word}{M-c}
440
441\key{uppercase region}{C-x C-u}
442\key{lowercase region}{C-x C-l}
443
444\section{The Minibuffer}
445
446The following keys are defined in the minibuffer.
447
448\key{complete as much as possible}{TAB}
449\key{complete up to one word}{SPC}
450\key{complete and execute}{RET}
451\key{show possible completions}{?}
452\key{fetch previous minibuffer input}{M-p}
453\key{fetch later minibuffer input or default}{M-n}
454\key{regexp search backward through history}{M-r}
455\key{regexp search forward through history}{M-s}
456\key{abort command}{C-g}
457
458Type \kbd{C-x ESC ESC} to edit and repeat the last command that used the
459minibuffer. Type \kbd{F10} to activate the menu bar using the minibuffer.
460
461\newcolumn
462\title{GNU Emacs Reference Card}
463
464\section{Buffers}
465
466\key{select another buffer}{C-x b}
467\key{list all buffers}{C-x C-b}
468\key{kill a buffer}{C-x k}
469
470\section{Transposing}
471
472\key{transpose {\bf characters}}{C-t}
473\key{transpose {\bf words}}{M-t}
474\key{transpose {\bf lines}}{C-x C-t}
475\key{transpose {\bf sexps}}{C-M-t}
476
477\section{Spelling Check}
478
479\key{check spelling of current word}{M-\$}
480\metax{check spelling of all words in region}{M-x ispell-region}
481\metax{check spelling of entire buffer}{M-x ispell-buffer}
482
483\section{Tags}
484
485\key{find a tag (a definition)}{M-.}
486\key{find next occurrence of tag}{C-u M-.}
487\metax{specify a new tags file}{M-x visit-tags-table}
488
489\metax{regexp search on all files in tags table}{M-x tags-search}
490\metax{run query-replace on all the files}{M-x tags-query-replace}
491\key{continue last tags search or query-replace}{M-,}
492
493\section{Shells}
494
495\key{execute a shell command}{M-!}
496\key{run a shell command on the region}{M-|}
497\key{filter region through a shell command}{C-u M-|}
498\key{start a shell in window \kbd{*shell*}}{M-x shell}
499
500\section{Rectangles}
501
502\key{copy rectangle to register}{C-x r r}
503\key{kill rectangle}{C-x r k}
504\key{yank rectangle}{C-x r y}
505\key{open rectangle, shifting text right}{C-x r o}
506\key{blank out rectangle}{C-x r c}
507\key{prefix each line with a string}{C-x r t}
508
509\section{Abbrevs}
510
511\key{add global abbrev}{C-x a g}
512\key{add mode-local abbrev}{C-x a l}
513\key{add global expansion for this abbrev}{C-x a i g}
514\key{add mode-local expansion for this abbrev}{C-x a i l}
515\key{explicitly expand abbrev}{C-x a e}
516
517\key{expand previous word dynamically}{M-/}
518
519\section{Regular Expressions}
520
521\key{any single character except a newline}{. {\rm(dot)}}
522\key{zero or more repeats}{*}
523\key{one or more repeats}{+}
524\key{zero or one repeat}{?}
525\key{quote regular expression special character {\it c\/}}{\\{\it c}}
526\key{alternative (``or'')}{\\|}
527\key{grouping}{\\( {\rm$\ldots$} \\)}
528\key{same text as {\it n\/}th group}{\\{\it n}}
529\key{at word break}{\\b}
530\key{not at word break}{\\B}
531
532\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\tabskip=0pt&#\cr
533\threecol{{\bf entity}}{{\bf match start}}{{\bf match end}}
534\threecol{line}{^}{\$}
535\threecol{word}{\\<}{\\>}
536\threecol{buffer}{\\`}{\\'}
537
538\threecol{{\bf class of characters}}{{\bf match these}}{{\bf match others}}
539\threecol{explicit set}{[ {\rm$\ldots$} ]}{[^ {\rm$\ldots$} ]}
540\threecol{word-syntax character}{\\w}{\\W}
541\threecol{character with syntax {\it c}}{\\s{\it c}}{\\S{\it c}}
542}
543
544\section{International Character Sets}
545
546\metax{specify principal language}{M-x set-language-environment}
547\metax{show all input methods}{M-x list-input-methods}
548\key{enable or disable input method}{C-\\}
549\key{set coding system for next command}{C-x RET c}
550\metax{show all coding systems}{M-x list-coding-systems}
551\metax{choose preferred coding system}{M-x prefer-coding-system}
552
553\section{Info}
554
555\key{enter the Info documentation reader}{C-h i}
556\key{find specified function or variable in Info}{C-h C-i}
557\beginindentedkeys
558
559Moving within a node:
560
561\key{scroll forward}{SPC}
562\key{scroll reverse}{DEL}
563\key{beginning of node}{. {\rm (dot)}}
564
565Moving between nodes:
566
567\key{{\bf next} node}{n}
568\key{{\bf previous} node}{p}
569\key{move {\bf up}}{u}
570\key{select menu item by name}{m}
571\key{select {\it n\/}th menu item by number (1--9)}{{\it n}}
572\key{follow cross reference (return with \kbd{l})}{f}
573\key{return to last node you saw}{l}
574\key{return to directory node}{d}
575\key{go to any node by name}{g}
576
577Other:
578
579\key{run Info {\bf tutorial}}{h}
580\key{{\bf quit} Info}{q}
581\key{search nodes for regexp}{M-s}
582
583\endindentedkeys
584
585\section{Registers}
586
587\key{save region in register}{C-x r s}
588\key{insert register contents into buffer}{C-x r i}
589
590\key{save value of point in register}{C-x r SPC}
591\key{jump to point saved in register}{C-x r j}
592
593\section{Keyboard Macros}
594
595\key{{\bf start} defining a keyboard macro}{C-x (}
596\key{{\bf end} keyboard macro definition}{C-x )}
597\key{{\bf execute} last-defined keyboard macro}{C-x e}
598\key{append to last keyboard macro}{C-u C-x (}
599\metax{name last keyboard macro}{M-x name-last-kbd-macro}
600\metax{insert Lisp definition in buffer}{M-x insert-kbd-macro}
601
602\section{Commands Dealing with Emacs Lisp}
603
604\key{eval {\bf sexp} before point}{C-x C-e}
605\key{eval current {\bf defun}}{C-M-x}
606\metax{eval {\bf region}}{M-x eval-region}
607\key{read and eval minibuffer}{M-:}
608\metax{load from standard system directory}{M-x load-library}
609
610\section{Simple Customization}
611
612\metax{customize variables and faces}{M-x customize}
613
614% The intended audience here is the person who wants to make simple
615% customizations and knows Lisp syntax.
616
617Making global key bindings in Emacs Lisp (examples):
618
619\beginexample%
620(global-set-key "\\C-cg" 'goto-line)
621(global-set-key "\\M-\#" 'query-replace-regexp)
622\endexample
623
624\section{Writing Commands}
625
626\beginexample%
627(defun \<command-name> (\<args>)
628 "\<documentation>" (interactive "\<template>")
629 \<body>)
630\endexample
631
632An example:
633
634\beginexample%
635(defun this-line-to-top-of-window (line)
636 "Reposition line point is on to top of window.
637With ARG, put point on line ARG."
638 (interactive "P")
639 (recenter (if (null line)
640 0
641 (prefix-numeric-value line))))
642\endexample
643
644The \kbd{interactive} spec says how to read arguments interactively.
645Type \kbd{C-h f interactive} for more details.
646
647\copyrightnotice
648
649\bye
650\f
651% Local variables:
652% compile-command: "tex refcard"
653% End: