aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/calc.texi111
1 files changed, 47 insertions, 64 deletions
diff --git a/man/calc.texi b/man/calc.texi
index a33d9f935f5..2036c40d84f 100644
--- a/man/calc.texi
+++ b/man/calc.texi
@@ -6333,51 +6333,52 @@ then enter the real one in the edit command.
6333 6333
6334@smallexample 6334@smallexample
6335@group 6335@group
63361: 3 1: 3 Keyboard Macro Editor. 63361: 3 1: 3 Calc Macro Edit Mode.
6337 . . Original keys: 1 @key{RET} 2 + 6337 . . Original keys: 1 <return> 2 +
6338 6338
6339 type "1\r" 6339 1 ;; calc digits
6340 type "2" 6340 RET ;; calc-enter
6341 calc-plus 6341 2 ;; calc digits
6342 + ;; calc-plus
6342 6343
6343C-x ( 1 @key{RET} 2 + C-x ) Z K h @key{RET} Z E h 6344C-x ( 1 @key{RET} 2 + C-x ) Z K h @key{RET} Z E h
6344@end group 6345@end group
6345@end smallexample 6346@end smallexample
6346 6347
6347@noindent 6348@noindent
6348This shows the screen display assuming you have the @file{macedit}
6349keyboard macro editing package installed, which is usually the case
6350since a copy of @file{macedit} comes bundled with Calc.
6351
6352A keyboard macro is stored as a pure keystroke sequence. The 6349A keyboard macro is stored as a pure keystroke sequence. The
6353@file{macedit} package (invoked by @kbd{Z E}) scans along the 6350@file{edmacro} package (invoked by @kbd{Z E}) scans along the
6354macro and tries to decode it back into human-readable steps. 6351macro and tries to decode it back into human-readable steps.
6355If a key or keys are simply shorthand for some command with a 6352Descriptions of the keystrokes are given as comments, which begin with
6356@kbd{M-x} name, that name is shown. Anything that doesn't correspond 6353@samp{;;}, and which are ignored when the edited macro is saved.
6357to a @kbd{M-x} command is written as a @samp{type} command. 6354Spaces and line breaks are also ignored when the edited macro is saved.
6355To enter a space into the macro, type @code{SPC}. All the special
6356characters @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL},
6357and @code{NUL} must be written in all uppercase, as must the prefixes
6358@code{C-} and @code{M-}.
6358 6359
6359Let's edit in a new definition, for computing harmonic numbers. 6360Let's edit in a new definition, for computing harmonic numbers.
6360First, erase the three lines of the old definition. Then, type 6361First, erase the four lines of the old definition. Then, type
6361in the new definition (or use Emacs @kbd{M-w} and @kbd{C-y} commands 6362in the new definition (or use Emacs @kbd{M-w} and @kbd{C-y} commands
6362to copy it from this page of the Info file; you can skip typing 6363to copy it from this page of the Info file; you can of course skip
6363the comments that begin with @samp{#}). 6364typing the comments, which begin with @samp{;;}).
6364 6365
6365@smallexample 6366@smallexample
6366calc-kbd-push # Save local values (Z `) 6367Z` ;; calc-kbd-push (Save local values)
6367type "0" # Push a zero 63680 ;; calc digits (Push a zero onto the stack)
6368calc-store-into # Store it in variable 1 6369st ;; calc-store-into (Store it in the following variable)
6369type "1" 63701 ;; calc quick variable (Quick variable q1)
6370type "1" # Initial value for loop 63711 ;; calc digits (Initial value for the loop)
6371calc-roll-down # This is the @key{TAB} key; swap initial & final 6372TAB ;; calc-roll-down (Swap initial and final)
6372calc-kbd-for # Begin "for" loop... 6373Z( ;; calc-kbd-for (Begin the "for" loop)
6373calc-inv # Take reciprocal 6374& ;; calc-inv (Take the reciprocal)
6374calc-store-plus # Add to accumulator 6375s+ ;; calc-store-plus (Add to the following variable)
6375type "1" 63761 ;; calc quick variable (Quick variable q1)
6376type "1" # Loop step is 1 63771 ;; calc digits (The loop step is 1)
6377calc-kbd-end-for # End "for" loop 6378Z) ;; calc-kbd-end-for (End the "for" loop)
6378calc-recall # Now recall final accumulated value 6379sr ;; calc-recall (Recall the final accumulated value)
6379type "1" 63801 ;; calc quick variable (Quick variable q1)
6380calc-kbd-pop # Restore values (Z ') 6381Z' ;; calc-kbd-pop (Restore values)
6381@end smallexample 6382@end smallexample
6382 6383
6383@noindent 6384@noindent
@@ -6392,15 +6393,12 @@ Press @kbd{C-c C-c} to finish editing and return to the Calculator.
6392@end group 6393@end group
6393@end smallexample 6394@end smallexample
6394 6395
6395If you don't know how to write a particular command in @file{macedit} 6396The @file{edmacro} package defines a handy @code{read-kbd-macro} command
6396format, you can always write it as keystrokes in a @code{type} command. 6397which reads the current region of the current buffer as a sequence of
6397There is also a @code{keys} command which interprets the rest of the 6398keystroke names, and defines that sequence on the @kbd{X}
6398line as standard Emacs keystroke names. In fact, @file{macedit} defines 6399(and @kbd{C-x e}) key. Because this is so useful, Calc puts this
6399a handy @code{read-kbd-macro} command which reads the current region 6400command on the @kbd{M-# m} key. Try reading in this macro in the
6400of the current buffer as a sequence of keystroke names, and defines that 6401following form: Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at
6401sequence on the @kbd{X} (and @kbd{C-x e}) key. Because this is so
6402useful, Calc puts this command on the @kbd{M-# m} key. Try reading in
6403this macro in the following form: Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at
6404one end of the text below, then type @kbd{M-# m} at the other. 6402one end of the text below, then type @kbd{M-# m} at the other.
6405 6403
6406@example 6404@example
@@ -30827,33 +30825,19 @@ Once you have bound your keyboard macro to a key, you can use
30827 30825
30828@cindex Keyboard macros, editing 30826@cindex Keyboard macros, editing
30829The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has 30827The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has
30830been defined by a keyboard macro tries to use the @code{edit-kbd-macro} 30828been defined by a keyboard macro tries to use the @code{edmacro} package
30831command to edit the macro. This command may be found in the 30829edit the macro. Type @kbd{C-c C-c} to finish editing and update
30832@file{macedit} package, a copy of which comes with Calc. It decomposes
30833the macro definition into full Emacs command names, like @code{calc-pop}
30834and @code{calc-add}. Type @kbd{C-c C-c} to finish editing and update
30835the definition stored on the key, or, to cancel the edit, kill the 30830the definition stored on the key, or, to cancel the edit, kill the
30836buffer with @kbd{C-x k}. 30831buffer with @kbd{C-x k}.
30837 30832The special characters @code{RET}, @code{LFD}, @code{TAB}, @code{SPC},
30838If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard 30833@code{DEL}, and @code{NUL} must be entered as these three character
30839macro is edited in spelled-out keystroke form. For example, the editing 30834sequences, written in all uppercase, as must the prefixes @code{C-} and
30840buffer might contain the nine characters @w{@samp{1 @key{RET} 2 +}}. When you press 30835@code{M-}. Spaces and line breaks are ignored. Other characters are
30841@kbd{C-c C-c}, the @code{read-kbd-macro} feature of the @file{macedit}
30842package is used to reinterpret these key names. The
30843notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and
30844@code{NUL} must be written in all uppercase, as must the prefixes @code{C-}
30845and @code{M-}. Spaces and line breaks are ignored. Other characters are
30846copied verbatim into the keyboard macro. Basically, the notation is the 30836copied verbatim into the keyboard macro. Basically, the notation is the
30847same as is used in all of this manual's examples, except that the manual 30837same as is used in all of this manual's examples, except that the manual
30848takes some liberties with spaces: When we say @kbd{' [1 2 3] @key{RET}}, we take 30838takes some liberties with spaces: When we say @kbd{' [1 2 3] @key{RET}},
30849it for granted that it is clear we really mean @kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}}, 30839we take it for granted that it is clear we really mean
30850which is what @code{read-kbd-macro} wants to see. 30840@kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}}.
30851
30852If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro
30853in ``raw'' form; the editing buffer simply contains characters like
30854@samp{1^M2+} (here @samp{^M} represents the carriage-return character).
30855Editing in this mode, you will have to use @kbd{C-q} to enter new
30856control characters into the buffer.
30857 30841
30858@kindex M-# m 30842@kindex M-# m
30859@pindex read-kbd-macro 30843@pindex read-kbd-macro
@@ -30861,7 +30845,6 @@ The @kbd{M-# m} (@code{read-kbd-macro}) command reads an Emacs ``region''
30861of spelled-out keystrokes and defines it as the current keyboard macro. 30845of spelled-out keystrokes and defines it as the current keyboard macro.
30862It is a convenient way to define a keyboard macro that has been stored 30846It is a convenient way to define a keyboard macro that has been stored
30863in a file, or to define a macro without executing it at the same time. 30847in a file, or to define a macro without executing it at the same time.
30864The @kbd{M-# m} command works only if @file{macedit} is present.
30865 30848
30866@node Conditionals in Macros, Loops in Macros, Naming Keyboard Macros, Keyboard Macros 30849@node Conditionals in Macros, Loops in Macros, Naming Keyboard Macros, Keyboard Macros
30867@subsection Conditionals in Keyboard Macros 30850@subsection Conditionals in Keyboard Macros