*** empty log message ***
[emacs.git] / etc / refcard.tex
blob6f0b3c1645fb40e12fdf13de45835247734deb95
1 % Reference Card for GNU Emacs version 20 on Unix systems
2 %**start of header
3 \newcount\columnsperpage
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.
8 \columnsperpage=1
10 % Copyright (c) 1987, 1993, 1996, 1997 Free Software Foundation, Inc.
12 % This file is part of GNU Emacs.
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.
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.
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.
29 % This file is intended to be processed by plain TeX (TeX82).
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.
45 % Author:
46 % Stephen Gildea
47 % Internet: gildea@mit.edu
49 % Thanks to Paul Rubin, Bob Chassell, Len Tower, and Richard Mlynarik
50 % for their many good ideas.
52 % If there were room, it would be nice to see a section on Dired.
54 \def\versionnumber{2.2}
55 \def\year{1997}
57 \def\shortcopyrightnotice{\vskip 1ex plus 2 fill
58 \centerline{\small \copyright\ \year\ Free Software Foundation, Inc.
59 Permissions on back. v\versionnumber}}
61 \def\copyrightnotice{
62 \vskip 1ex plus 2 fill\begingroup\small
63 \centerline{Copyright \copyright\ \year\ Free Software Foundation, Inc.}
64 \centerline{v\versionnumber{} for GNU Emacs version 20, June \year}
65 \centerline{designed by Stephen Gildea}
67 Permission is granted to make and distribute copies of
68 this card provided the copyright notice and this permission notice
69 are preserved on all copies.
71 For copies of the GNU Emacs manual, write to the Free Software
72 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74 \endgroup}
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}
80 \newdimen\intercolumnskip %horizontal space between columns
81 \newbox\columna %boxes to hold columns already built
82 \newbox\columnb
84 \def\ncolumns{\the\columnsperpage}
86 \message{[\ncolumns\space
87 column\if 1\ncolumns\else s\fi\space per page]}
89 \def\scaledmag#1{ scaled \magstep #1}
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
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
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
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}}
161 \def\bye{\par\vfill\supereject
162 \if a\abc \else\null\vfill\eject\fi
163 \if a\abc \else\null\vfill\eject\fi
164 \end}
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
172 \chardef\\=`\\
173 \chardef\{=`\{
174 \chardef\}=`\}
176 \hyphenation{mini-buf-fer}
178 \parindent 0pt
179 \parskip 1ex plus .5ex minus .5ex
181 \def\small{\smallfont\textfont2=\smallsy\baselineskip=.8\baselineskip}
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}
187 % title - page title. Argument is title text.
188 \outer\def\title#1{{\titlefont\centerline{#1}}\vskip 1ex plus .5ex}
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}
195 \newdimen\keyindent
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
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}
209 % \<...> - surrounds a variable name in a code example
210 \def\<#1>{{\it #1\/}}
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
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}
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}}
230 \newbox\metaxbox
231 \setbox\metaxbox\hbox{\kbd{M-x }}
232 \newdimen\metaxwidth
233 \metaxwidth=\wd\metaxbox
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}}
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}
249 %**end of header
252 \title{GNU Emacs Reference Card}
254 \centerline{(for version 20)}
256 \section{Starting Emacs}
258 To enter GNU Emacs 20, just type its name: \kbd{emacs}
260 To read in a file to edit, see Files, below.
262 \section{Leaving Emacs}
264 \key{suspend Emacs (or iconify it under X)}{C-z}
265 \key{exit Emacs permanently}{C-x C-c}
267 \section{Files}
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}
277 \section{Getting Help}
279 The help system is simple. Type \kbd{C-h} (or \kbd{F1}) and follow
280 the directions. If you are a first-time user, type \kbd{C-h t} for a
281 {\bf tutorial}.
283 \key{remove help window}{C-x 1}
284 \key{scroll help window}{C-M-v}
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}
291 \section{Error Recovery}
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}
299 \section{Incremental Search}
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}
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}
312 Use \kbd{C-s} or \kbd{C-r} again to repeat the search in either direction.
313 If Emacs is still searching, \kbd{C-g} cancels only the part not done.
315 \shortcopyrightnotice
317 \section{Motion}
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->}
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}
339 \section{Killing and Deleting}
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}
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}}
354 \key{yank back last thing killed}{C-y}
355 \key{replace last yank with previous kill}{M-y}
357 \section{Marking}
359 \key{set mark here}{C-@ {\rm or} C-SPC}
360 \key{exchange point and mark}{C-x C-x}
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}
369 \section{Query Replace}
371 \key{interactively replace a text string}{M-\%}
372 \metax{using regular expressions}{M-x query-replace-regexp}
374 Valid responses in query-replace mode are
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}
384 \section{Multiple Windows}
386 When two commands are shown, the second is for ``other frame.''
388 \key{delete all other windows}{C-x 1}
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}
395 \key{split window, side by side}{C-x 3}
397 \key{scroll other window}{C-M-v}
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}
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 .}
411 \key{grow window taller}{C-x ^}
412 \key{shrink window narrower}{C-x \{}
413 \key{grow window wider}{C-x \}}
415 \section{Formatting}
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}
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}
429 \key{fill paragraph}{M-q}
430 \key{set fill column}{C-x f}
431 \key{set prefix each line starts with}{C-x .}
433 \key{set face}{M-g}
435 \section{Case Change}
437 \key{uppercase word}{M-u}
438 \key{lowercase word}{M-l}
439 \key{capitalize word}{M-c}
441 \key{uppercase region}{C-x C-u}
442 \key{lowercase region}{C-x C-l}
444 \section{The Minibuffer}
446 The following keys are defined in the minibuffer.
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}
458 Type \kbd{C-x ESC ESC} to edit and repeat the last command that used the
459 minibuffer. Type \kbd{F10} to activate the menu bar using the minibuffer.
461 \newcolumn
462 \title{GNU Emacs Reference Card}
464 \section{Buffers}
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}
470 \section{Transposing}
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}
477 \section{Spelling Check}
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}
483 \section{Tags}
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}
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-,}
493 \section{Shells}
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}
500 \section{Rectangles}
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}
509 \section{Abbrevs}
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}
517 \key{expand previous word dynamically}{M-/}
519 \section{Regular Expressions}
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}
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}{\\`}{\\'}
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}}
544 \section{International Character Sets}
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}
553 \section{Info}
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
559 Moving within a node:
561 \key{scroll forward}{SPC}
562 \key{scroll reverse}{DEL}
563 \key{beginning of node}{. {\rm (dot)}}
565 Moving between nodes:
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}
577 Other:
579 \key{run Info {\bf tutorial}}{h}
580 \key{{\bf quit} Info}{q}
581 \key{search nodes for regexp}{M-s}
583 \endindentedkeys
585 \section{Registers}
587 \key{save region in register}{C-x r s}
588 \key{insert register contents into buffer}{C-x r i}
590 \key{save value of point in register}{C-x r SPC}
591 \key{jump to point saved in register}{C-x r j}
593 \section{Keyboard Macros}
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}
602 \section{Commands Dealing with Emacs Lisp}
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}
610 \section{Simple Customization}
612 \metax{customize variables and faces}{M-x customize}
614 % The intended audience here is the person who wants to make simple
615 % customizations and knows Lisp syntax.
617 Making global key bindings in Emacs Lisp (examples):
619 \beginexample%
620 (global-set-key "\\C-cg" 'goto-line)
621 (global-set-key "\\M-\#" 'query-replace-regexp)
622 \endexample
624 \section{Writing Commands}
626 \beginexample%
627 (defun \<command-name> (\<args>)
628 "\<documentation>" (interactive "\<template>")
629 \<body>)
630 \endexample
632 An example:
634 \beginexample%
635 (defun this-line-to-top-of-window (line)
636 "Reposition line point is on to top of window.
637 With ARG, put point on line ARG."
638 (interactive "P")
639 (recenter (if (null line)
641 (prefix-numeric-value line))))
642 \endexample
644 The \kbd{interactive} spec says how to read arguments interactively.
645 Type \kbd{C-h f interactive} for more details.
647 \copyrightnotice
649 \bye
651 % Local variables:
652 % compile-command: "tex refcard"
653 % End: