daveg@csvax.cs.caltech.edu (David Gillespie) (10/15/90)
Posting-number: Volume 15, Issue 46 Submitted-by: daveg@csvax.cs.caltech.edu (David Gillespie) Archive-name: calc-1.05/part19 #!/bin/sh # this is part 19 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file calc.patch continued # CurArch=19 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 sed 's/^X//' << 'SHAR_EOF' >> calc.patch X lines of text in this buffer as numbers or formulas, replaces the X original stack elements in the original buffer with these new values, X*************** X*** 8233,8240 **** X continues to exist during editing, but for best results you should be X careful not to change it until you have finished the edit. You can X also cancel the edit simply by killing the @samp{*Calc Edit*} buffer X! with @kbd{C-x k} (@code{kill-buffer}). X X @node Programming, Installation, Kill and Yank, Top X @chapter Programming the Calculator X X--- 13335,13357 ---- X continues to exist during editing, but for best results you should be X careful not to change it until you have finished the edit. You can X also cancel the edit simply by killing the @samp{*Calc Edit*} buffer X! with @kbd{C-x k} (@code{kill-buffer}).@refill X! X! If the @code{calc-edit} command involves more than one stack entry, X! each line of the @samp{*Calc Edit*} buffer is interpreted as a X! separate formula. Otherwise, the entire buffer is interpreted as X! one formula, with line breaks ignored. (You can use @kbd{C-o} to X! insert a newline in the buffer without pressing @key{RET}.) X! X! As a special exception, if one stack entry is being edited and that X! stack entry is a single variable which has a stored value, then the X! value of the variable is edited rather than the stack entry itself. X! When you finish editing the new value is stored back in that variable. X X+ The @kbd{`} key also works during numeric or algebraic entry. The X+ text entered so far is moved to the @code{*Calc Edit*} buffer for X+ more extensive editing than is convenient in the minibuffer. X+ X @node Programming, Installation, Kill and Yank, Top X @chapter Programming the Calculator X X*************** X*** 8290,8300 **** X The @kbd{Z D} command first prompts for the key to define. For example, X press @kbd{Z D a} to define the new key sequence @kbd{z a}. You are then X prompted for the name of the Calculator command that this key should X! run. For example, the @code{calc-hypot} (hypotenuse) command is not normally X! available on a key. Typing @kbd{Z D h hypot @key{RET}} programs the X! @kbd{z h} key sequence to run @code{calc-hypot}. This definition will remain X in effect for the rest of this Emacs session, or until you redefine X! @kbd{z h} to be something else. X X You can actually bind any Emacs command to a @kbd{z} key sequence by X backspacing over the @samp{calc-} when you are prompted for the command name. X--- 13407,13417 ---- X The @kbd{Z D} command first prompts for the key to define. For example, X press @kbd{Z D a} to define the new key sequence @kbd{z a}. You are then X prompted for the name of the Calculator command that this key should X! run. For example, the @code{calc-sincos} command is not normally X! available on a key. Typing @kbd{Z D s sincos @key{RET}} programs the X! @kbd{z s} key sequence to run @code{calc-sincos}. This definition will remain X in effect for the rest of this Emacs session, or until you redefine X! @kbd{z s} to be something else. X X You can actually bind any Emacs command to a @kbd{z} key sequence by X backspacing over the @samp{calc-} when you are prompted for the command name. X*************** X*** 8312,8318 **** X @kindex Z U X @pindex calc-user-undefine X The @kbd{Z U} (@code{calc-user-undefine}) command unbinds a user key. X! For example, the key sequence @kbd{Z U h} will undefine the @code{hypot} X key we defined above. X X @kindex Z P X--- 13429,13435 ---- X @kindex Z U X @pindex calc-user-undefine X The @kbd{Z U} (@code{calc-user-undefine}) command unbinds a user key. X! For example, the key sequence @kbd{Z U s} will undefine the @code{sincos} X key we defined above. X X @kindex Z P X*************** X*** 8323,8330 **** X The @kbd{Z P} (@code{calc-user-define-permanent}) command makes a key X binding permanent so that it will remain in effect even in future Emacs X sessions. (It does this by adding a suitable bit of Lisp code into X! your @file{.emacs} file.) For example, @kbd{Z P h} would register X! our @code{hypot} command permanently. If you later wish to unregister X this command you must edit your @file{.emacs} file by hand. X X @kindex Z E X--- 13440,13447 ---- X The @kbd{Z P} (@code{calc-user-define-permanent}) command makes a key X binding permanent so that it will remain in effect even in future Emacs X sessions. (It does this by adding a suitable bit of Lisp code into X! your @file{.emacs} file.) For example, @kbd{Z P s} would register X! our @code{sincos} command permanently. If you later wish to unregister X this command you must edit your @file{.emacs} file by hand. X X @kindex Z E X*************** X*** 8406,8419 **** X The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has X been defined by a keyboard macro tries to use the @code{edit-kbd-macro} X command to edit the macro. This command may be found in the X! @file{macedit} package, a copy of which comes with Calc. If X! @code{edit-kbd-macro} is not available, or if you give a negative X! numeric prefix argument, @kbd{Z E} uses a variant of @code{calc-edit} X! with the contents of the buffer being the keyboard macro in ``raw'' X! form. In either case, type @kbd{C-c C-c} to finish editing and update X the definition stored on the key, or, to cancel the edit, just kill the X macro-editing buffer with @kbd{C-x k}.@refill X X @node Conditionals in Macros, Loops in Macros, Naming Keyboard Macros, Keyboard Macros X @subsection Conditionals in Keyboard Macros X X--- 13523,13550 ---- X The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has X been defined by a keyboard macro tries to use the @code{edit-kbd-macro} X command to edit the macro. This command may be found in the X! @file{macedit} package, a copy of which comes with Calc. It decomposes X! the macro definition into full Emacs command names, like @code{calc-pop} X! and @code{calc-add}. Type @kbd{C-c C-c} to finish editing and update X the definition stored on the key, or, to cancel the edit, just kill the X macro-editing buffer with @kbd{C-x k}.@refill X X+ If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard X+ macro is edited in spelled-out keystroke form. For example, the editing X+ buffer might contain the nine characters @samp{1 RET 2 +}. When you press X+ @kbd{C-c C-c}, the @code{read-kbd-macro} feature of the @file{macedit} X+ package is used to reinterpret these key names. The X+ notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and X+ @code{NUL} must be written in all uppercase, as must the prefixes @code{C-} X+ and @code{M-}. Spaces and line breaks are ignored. Other characters are X+ copied verbatim into the keyboard macro.@refill X+ X+ If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro X+ in ``raw'' form; the editing buffer simply contains characters like X+ @samp{1^M2+} (here @samp{^M} represents the carriage-return character). X+ Editing in this mode, you will have to use @kbd{C-q} to enter more X+ control characters into the buffer.@refill X+ X @node Conditionals in Macros, Loops in Macros, Naming Keyboard Macros, Keyboard Macros X @subsection Conditionals in Keyboard Macros X X*************** X*** 9545,9550 **** X--- 14676,14687 ---- X The elements of @var{vals} are assumed to be valid Calc objects, and X are not evaluated or renormalized in any way. If @var{vals} is an X empty list, nothing happens.@refill X+ X+ The stack elements are pushed without any sub-formula selections. X+ You can give an optional third argument to this function, which must X+ be a list the same size as @var{vals} of selections. Each selection X+ must be @code{eq} to some sub-formula of the corresponding formula X+ in @var{vals}, or @code{nil} if that formula should have no selection. X @end defun X X @defun calc-top-list n m X*************** X*** 9558,9563 **** X--- 14695,14714 ---- X range, the command is aborted with a suitable error message. If @var{n} X is zero, the function returns an empty list. The stack elements are not X evaluated or renormalized.@refill X+ X+ If any stack elements contain selections, and selections have not X+ been disabled by the @kbd{j e} (@code{calc-enable-selections}) command, X+ this function returns the selection portions rather than the entire X+ stack elements. It can be given a third ``selection-mode'' argument X+ which selection other behaviors. If it is the symbol @code{t}, then X+ a selection in any of the requested stack elements produces an X+ ``illegal operation on selections'' error. If it the symbol @code{full}, X+ the whole stack entry is always returned regardless of selections. X+ If is the symbol @code{sel}, the selected portion is always returned, X+ or @code{nil} if there is no selection. (This mode ignores the @kbd{j e} X+ command.) If the symbol is @code{entry}, the complete stack entry in X+ list form is returned; the first element of this list will be the whole X+ formula, and the third element will be the selection (or @code{nil}). X @end defun X X @defun calc-pop-stack n m X*************** X*** 9564,9569 **** X--- 14715,14726 ---- X Remove the specified elements from the stack. The parameters @var{n} X and @var{m} are defined the same as for @code{calc-top-list}. The return X value of @code{calc-pop-stack} is uninteresting. X+ X+ If there are any selected sub-formulas among the popped elements, and X+ @kbd{j e} has not been used to disable selections, this produces an X+ error without changing the stack. If you supply an optional third X+ argument of @code{t}, the stack elements are popped even if they X+ contain selections. X @end defun X X @defun calc-record-list vals tag X*************** X*** 9590,9601 **** X commands should use this in preference to @code{calc-top-list}; the only X standard Calc commands that operate on the stack without normalizing X are stack management commands like @code{calc-enter} and @code{calc-roll-up}. X @end defun X X @defun calc-top-n m X This function is a convenient form of @code{calc-top-list-n} in which only X a single element of the stack is taken and returned, rather than a list X! of elements. X @end defun X X @defun calc-enter-result n tag vals X--- 14747,14760 ---- X commands should use this in preference to @code{calc-top-list}; the only X standard Calc commands that operate on the stack without normalizing X are stack management commands like @code{calc-enter} and @code{calc-roll-up}. X+ This function accepts the same optional selection-mode argument as X+ @code{calc-top-list}. X @end defun X X @defun calc-top-n m X This function is a convenient form of @code{calc-top-list-n} in which only X a single element of the stack is taken and returned, rather than a list X! of elements. This also accepts an optional selection-mode argument. X @end defun X X @defun calc-enter-result n tag vals X*************** X*** 9610,9615 **** X--- 14769,14788 ---- X (calc-enter-result @var{n} @var{tag} (cons 'calcFunc-@var{func} X (calc-top-list-n @var{n}))) X @end example X+ X+ If any of the @var{n} stack elements replaced contain sub-formula X+ selections, and selections have not been disabled by @kbd{j e}, X+ this function takes one of two courses of action. If @var{n} is X+ equal to the number of elements in @var{vals}, then each element of X+ @var{vals} is spliced into the corresponding selection; this is what X+ happens when you use the @key{TAB} key, or when you use a unary X+ arithmetic operation like @code{sqrt}. If @var{vals} has only one X+ element but @var{n} is greater than one, there must be only one X+ selection among the top @var{n} stack elements; the element from X+ @var{vals} is spliced into that selection. This is what happens when X+ you use a binary arithmetic operation like @kbd{+}. Any other X+ combination of @var{n} and @var{vals} when selections are present X+ is an error. X @end defun X X @defun calc-unary-op tag func arg X*************** X*** 9907,9912 **** X--- 15080,15086 ---- X error in the series evaluation without doing extra work which would be X lost when the result is rounded back down to the current precision. X In @code{defmath}, this can be written @samp{(~= @var{x} @var{y})}. X+ @var{X} and @var{y} can be numbers of any time, including complex. X @end defun X X @defun nearly-zerop x y X*************** X*** 9914,9920 **** X checks whether @var{x} plus @var{y} would by be @code{nearly-equal} X to @var{y} itself, to within the current precision, in other words, X if adding @var{x} to @var{y} would have a negligible effect on @var{y} X! due to roundoff error. X @end defun X X @defun is-true x X--- 15088,15095 ---- X checks whether @var{x} plus @var{y} would by be @code{nearly-equal} X to @var{y} itself, to within the current precision, in other words, X if adding @var{x} to @var{y} would have a negligible effect on @var{y} X! due to roundoff error. @var{X} may be a real or complex number, but X! @var{y} must be real. X @end defun X X @defun is-true x X*************** X*** 10410,10418 **** X The functions described here operate on symbolic formulas in the X Calculator. X X @defun simplify expr X Simplify the expression @var{expr} by applying various algebraic rules. X! This is what the @kbd{a s} (@code{calc-simplify}) command uses. X @end defun X X @defun simplify-extended expr X--- 15585,15688 ---- X The functions described here operate on symbolic formulas in the X Calculator. X X+ @defun calc-prepare-selection num X+ Prepare a stack entry for selection operations. If @var{num} is X+ omitted, the stack entry containing the cursor is used; otherwise, X+ it is the number of the stack entry to use. This function stores X+ useful information about the current stack entry into a set of X+ variables. @code{calc-selection-cache-num} contains the number of X+ the stack entry involved (equal to @var{num} if you specified it); X+ @code{calc-selection-cache-entry} contains the stack entry as a X+ list (such as @code{calc-top-list} would return with @code{entry} X+ as the selection mode); and @code{calc-selection-cache-comp} contains X+ a special ``tagged'' composition (@pxref{Formatting Lisp Functions}) X+ which allows Calc to relate cursor positions in the buffer with X+ their corresponding sub-formulas. X+ X+ A slight complication arises in the selection mechanism because X+ formulas may contain small integers. For example, in the vector X+ @samp{[1, 2, 1]} the first and last elements are @code{eq} to each X+ other; selections are recorded as the actual Lisp object that X+ appears somewhere in the tree of the whole formula, but storing X+ @code{1} would falsely select both @code{1}'s in the vector. So X+ @code{calc-prepare-selection} also checks the stack entry and X+ replaces any plain integers with ``complex number'' lists of the form X+ @samp{(cplx @var{n} 0)}. This list will be displayed the same as a X+ plain @var{n} and the change will be completely invisible to the X+ user, but it will guarantee that no two sub-formulas of the stack X+ entry will be @code{eq} to each other. Next time the stack entry X+ is involved in a computation, @code{calc-normalize} will replace X+ these lists with plain numbers again, again invisibly to the user. X+ @end defun X+ X+ @defun calc-find-selected-part X+ Find the smallest sub-formula of the current formula that contains X+ the cursor. This assumes @code{calc-prepare-selection} has been X+ called already. If the cursor is not actually on any part of the X+ formula, this returns @code{nil}. X+ @end defun X+ X+ @defun calc-change-current-selection selection X+ Change the currently prepared stack element's selection to X+ @var{selection}, which should be @code{eq} to some sub-formula X+ of the stack element, or @code{nil} to unselect the formula. X+ The stack element's appearance in the Calc buffer is adjusted X+ to reflect the new selection. X+ @end defun X+ X+ @defun calc-find-nth-part expr n X+ Return the @var{n}th sub-formula of @var{expr}. This function is used X+ by the selection commands, and (unless @kbd{j b} has been used) treats X+ sums and products as flat many-element formulas. Thus if @var{expr} X+ is @samp{((a + b) - c) + d}, calling @code{calc-find-nth-part} with X+ @var{n} equal to four will return @samp{d}. X+ @end defun X+ X+ @defun calc-find-parent-formula expr part X+ Return the sub-formula of @var{expr} which immediately contains X+ @var{part}. If @var{expr} is @samp{a*b + (c+1)*d} and @var{part} X+ is @code{eq} to the @samp{c+1} term of @var{expr}, then this function X+ will return @samp{(c+1)*d}. If @var{part} turns out not to be a X+ sub-formula of @var{expr}, the function returns @code{nil}. If X+ @var{part} is @code{eq} to @var{expr}, the function returns @code{t}. X+ This function does not take associativity into account. X+ @end defun X+ X+ @defun calc-find-assoc-parent-formula expr part X+ This is the same as @code{calc-find-parent-formula}, except that X+ (unless @kbd{j b} has been used) it continues widening the selection X+ to contain a complete level of the formula. Given @samp{a} from X+ @samp{((a + b) - c) + d}, @code{calc-find-parent-formula} will X+ return @samp{a + b} but @code{calc-find-assoc-parent-formula} will X+ return the whole expression. X+ @end defun X+ X+ @defun calc-grow-assoc-formula expr part X+ This expands sub-formula @var{part} of @var{expr} to encompass a X+ complete level of the formula. If @var{part} and its immediate X+ parent are not compatible associative operators, or if @kbd{j b} X+ has been used, this simply returns @var{part}. X+ @end defun X+ X+ @defun calc-find-sub-formula expr part X+ This finds the immediate sub-formula of @var{expr} which contains X+ @var{part}. It returns an index @var{n} such that X+ @samp{(calc-find-nth-part @var{expr} @var{n})} would return @var{part}. X+ If @var{part} is not a sub-formula of @var{expr}, it returns @code{nil}. X+ If @var{part} is @code{eq} to @var{expr}, it returns @code{t}. This X+ function does not take associativity into account. X+ @end defun X+ X+ @defun calc-replace-sub-formula expr old new X+ This function returns a copy of formula @var{expr}, with the X+ sub-formula that is @code{eq} to @var{old} replaced by @var{new}. X+ @end defun X+ X @defun simplify expr X Simplify the expression @var{expr} by applying various algebraic rules. X! This is what the @kbd{a s} (@code{calc-simplify}) command uses. This X! always returns a copy of the expression; the structure @var{expr} points X! to remains unchanged in memory. X @end defun X X @defun simplify-extended expr X*************** X*** 10529,10551 **** X default, as described above, is infinitely many times.@refill X @end defun X X! @defun apply-rewrite expr old new cond X! Apply a rewrite rule at the top level of @var{expr}, if possible, and X! return the rewritten expression. If the rule does not match, return X! @code{nil}. X @end defun X! X! @defun check-rewrite-rules rules X! Make sure @var{rules} is a Calc expression in a form suitable for use X! as rewrite rules (i.e., a vector of two or three elements, a vector X! of such vectors, or a variable whose definition is a valid set of X! rewrite rules). If so, return it in the form of a Lisp list of rewrite X! rules. If it is not valid, call @code{error} to abort the command. X! @end defun X! X! @defun apply-rewrite-rules expr rules X! Apply a Lisp list of rewrite rules at the top level of an expression. X! Use the first rule that applies; if none apply, return @code{nil}. X @end defun X X @defun deriv expr var value symb X--- 15799,15843 ---- X default, as described above, is infinitely many times.@refill X @end defun X X! @defun compile-rewrites rules X! Compile the rewrite rule set specified by @var{rules}, which should X! be a formula that is either a vector or a variable name. If the latter, X! the compiled rules are saved so that later @code{compile-rules} calls X! for that same variable can return immediately. If there are problems X! with the rules, this function calls @code{error} with a suitable X! message. X! @end defun X! X! @defun apply-rewrites expr crules heads X! Apply the compiled rewrite rule set @var{crules} to the expression X! @var{expr}. This will make only one rewrite and only checks at the X! top level of the expression. The result @code{nil} if no rules X! matched, or if the only rules that matched did not actually change X! the expression. The @var{heads} argument is optional; if is given, X! it should be a list of all function names that (may) appear in X! @var{expr}. The rewrite compiler tags each rule with the X! rarest-looking function name in the rule; if you specify @var{heads}, X! @code{apply-rewrites} can use this information to narrow its search X! down to just a few rules in the rule set. X! @end defun X! X! @defun rewrite-heads expr X! Compute a @var{heads} list for @var{expr} suitable for use with X! @code{apply-rewrites}, as discussed above. X! @end defun X! X! @defun rewrite expr rules many X! This is an all-in-one rewrite function. It compiles the rule set X! specified by @var{rules}, then uses @code{map-tree} to apply the X! rules throughout @var{expr} up to @var{many} (default infinity) X! times. X @end defun X! X! @defun match-patterns pat vec not-flag X! Given a Calc vector @var{vec} and an uncompiled pattern set or X! pattern set variable @var{pat}, this function returns a new vector X! of all elements of @var{vec} which do (or don't, if @var{not-flag} is X! non-@code{nil}) match any of the patterns in @var{pat}. X @end defun X X @defun deriv expr var value symb X*************** X*** 10560,10575 **** X @code{deriv} returns @code{nil} instead. X X Derivatives of an function of one argument can be defined by X! adding a @code{math-derivative} property to the function's property X! list. The value of the property should be a Lisp function of one X! argument (which is the argument that appears in the function call being X! differentiated), which should return a formula for the derivative. X! For example, the derivative of @code{ln} is defined by X X @example X! (put 'calcFunc-ln 'math-derivative X (function (lambda (u) (math-div 1 u)))) X @end example X @end defun X X @defun tderiv expr var value symb X--- 15852,15877 ---- X @code{deriv} returns @code{nil} instead. X X Derivatives of an function of one argument can be defined by X! adding a @code{math-derivative-@var{n}} property to the property list X! of the symbol for the function's derivative, which will be the X! function name followed by an apostrophe. Here @var{n} is the number X! of arguments to the function. The value of the property should be a X! Lisp function; it is called with the same arguments as the original X! function call that is being differentiated. It should return a formula X! for the derivative. For example, the derivative of @code{ln} is defined by X X @example X! (put 'calcFunc-ln\' 'math-derivative-1 X (function (lambda (u) (math-div 1 u)))) X @end example X+ X+ The two-argument @code{log} function has two derivatives, X+ @example X+ (put 'calcFunc-log\' 'math-derivative-2 ; d(log(x,b)) / dx X+ ... ) X+ (put 'calcFunc-log\'2 'math-derivative-2 ; d(log(x,b)) / db X+ ... ) X+ @end example X @end defun X X @defun tderiv expr var value symb X*************** X*** 10647,10657 **** X--- 15949,15973 ---- X if the caller requested a non-``full'' solution. X @end defun X X+ @defun solve-eqn expr var full X+ This version of @code{solve-for} takes an expression which will X+ typically be an equation or inequality. (If it is not, it will be X+ interpreted as the equation @samp{@var{expr} = 0}.) It returns an X+ equation or inequality, or @code{nil} if no solution could be found. X+ @end defun X+ X @defun expr-contains expr var X Returns the number of occurrences of @var{var} as a subexpression X of @var{expr}, or @code{nil} if there are no occurrences. Thus, X this function can be used as a Lisp predicate or as an actual counting X function.@refill X+ X+ When used as a predicate, this function seems at first to be identical X+ to @code{calc-find-sub-formula}. The key difference is that X+ @code{expr-contains} uses @code{equal} to test for matches, whereas X+ @code{calc-find-sub-formula} uses @code{eq}. In the formula X+ @samp{f(a, a)}, the two @samp{a}'s will be @code{equal} but not X+ @code{eq} to each other. X @end defun X X @defun expr-depends expr var X*************** X*** 10876,10881 **** X--- 16192,16206 ---- X surrounded by parentheses unless it is a plain number or variable name. X @end defun X X+ @defun format-nice-expr a width X+ This is like @code{format-flat-expr} (with @var{prec} equal to 0), X+ except that newlines will be inserted to keep lines down to the X+ specified @var{width}, and vectors of vectors (not necessarily X+ strict matrices) are written in a pseudo-matrix format. The X+ @code{calc-edit} command uses this when only a stack entry is X+ being edited. X+ @end defun X+ X @defun format-value a width X Convert the Calc number or formula @var{a} to string form, using the X format seen in the stack buffer. Beware the the string returned may X*************** X*** 10942,10953 **** X @node Hooks, , Lisp Variables, Internals X @subsubsection Hooks X X! (This section is currently unfinished.) X X @node Installation, Reporting Bugs, Programming, Top X @chapter Installation X X! Calc 1.04 comes as a pair of Emacs Lisp files, generally called X @file{calc.el} and @file{calc-ext.el}. The first contains the basic X foundations of the Calculator, and is as small as possible to promote X quick loading. The second contains all the more advanced commands and X--- 16267,16406 ---- X @node Hooks, , Lisp Variables, Internals X @subsubsection Hooks X X! Hooks are variables which contain Lisp functions (or lists of functions) X! which are called at various times. Calc defines a number of hooks X! that help you to customize it in various ways. Calc uses the Lisp X! function @code{run-hooks} to invoke the hooks shown below. Several X! other customization-related variables are also described here. X! X! @defvar calc-start-hook X! This hook is called as the last step in a @kbd{M-x calc} command. X! At this point, the Calc buffer has been created and initialized if X! necessary, the Calc window and trail window have been created, X! and the ``Welcome to Calc'' message has been displayed. X! @end defvar X! X! @defvar calc-mode-hook X! This hook is called when the Calc buffer is being created. Usually X! this will only happen once per Emacs session. The hook is called X! after Emacs has switched to the new buffer, the mode-settings file X! has been read if necessary, and all other buffer-local variables X! have been set up. After this hook returns, Calc will perform a X! @code{calc-refresh} operation, set up the mode line display, then X! evaluate @code{calc-defs} if present. X! @end defvar X! X! @defvar calc-trail-mode-hook X! This hook is called when the Calc Trail buffer is being created. X! It is called as the very last step of setting up the Trail buffer. X! Like @code{calc-mode-hook}, this will normally happen only once X! per Emacs session. X! @end defvar X! X! @defvar calc-end-hook X! This hook is called by @code{calc-quit}, generally because the user X! presses @key{q} or @kbd{M-#} while in Calc. The Calc buffer will X! be the current buffer. The hook is called as the very first X! step, before the Calc window has been destroyed. X! @end defvar X! X! @defvar calc-window-hook X! If this hook exists, it is called to create the Calc window. X! Upon return, this new Calc window should be the current window. X! (The Calc buffer will already be the current buffer when the X! hook is called.) If the hook is not defined, Calc will X! generally use @code{split-window}, @code{set-window-buffer}, X! and @code{select-window} to create the Calc window. X! @end defvar X! X! @defvar calc-trail-window-hook X! If this hook exists, it is called to create the Calc Trail window. X! The variable @code{calc-trail-buffer} will contain the buffer X! which the window should use. Unlike @code{calc-window-hook}, X! this hook must @emph{not} switch into the new window. X! @end defvar X! X! @defvar calc-edit-mode-hook X! This hook is called by @code{calc-edit} (and a few other similar X! commands) when the temporary editing buffer is being created. X! The buffer will have been selected and set up to be in X! @code{calc-edit-mode}, but will not yet have been filled with X! text. (In fact it may still have leftover text from a previous X! @code{calc-edit} command.) X! @end defvar X! X! @defvar calc-mode-save-hook X! This hook is called by the @code{calc-save-modes} command, X! after Calc's own mode features have been inserted into the X! @file{.emacs} buffer and just before the ``End of mode settings'' X! message is inserted. X! @end defvar X! X! @defvar calc-other-modes X! This variable contains a list of strings. The strings are X! concatenated at the end of the modes portion of the Calc X! mode line (after standard modes such as ``Deg'', ``Inv'' and X! ``Hyp''). Each string should be a short, single word followed X! by a space. The variable is @code{nil} by default. X! @end defvar X! X! @defvar calc-mode-map X! This is the keymap that is used by Calc mode. The best time X! to adjust it is probably in a @code{calc-mode-hook}. If the X! Calc extensions package (@file{calc-ext.el}) has not yet been X! loaded, many of these keys will be bound to @code{calc-missing-key}, X! which is a command that loads the extensions package and X! ``retypes'' the key. If your @code{calc-mode-hook} rebinds X! one of these keys, it will probably be overridden when the X! extensions are loaded. X! @end defvar X! X! @defvar calc-digit-map X! This is the keymap that is used during numeric entry. Numeric X! entry uses the minibuffer, but this map binds every non-numeric X! key to @code{calcDigit-nondigit} which generally calls X! @code{exit-minibuffer} and ``retypes'' the key. X! @end defvar X! X! @defvar calc-alg-ent-map X! This is the keymap that is used during algebraic entry. This is X! mostly a copy of @code{minibuffer-local-map}. X! @end defvar X! X! @defvar calc-store-var-map X! This is the keymap that is used during entry of variable names for X! commands like @code{calc-store} and @code{calc-recall}. This is X! mostly a copy of @code{minibuffer-local-completion-map}. X! @end defvar X! X! @defvar calc-edit-mode-map X! This is the (sparse) keymap used by @code{calc-edit} and other X! temporary editing commands. It binds @key{RET}, @key{LFD}, X! and @kbd{C-c C-c} to @code{calc-edit-finish}. X! @end defvar X! X! @defvar calc-mode-var-list X! This is a list of variables which are saved by @code{calc-save-modes}. X! Each entry is a list of two items, the variable (as a Lisp symbol) X! and its default value. When modes are being saved, each variable X! is compared with its default value (using @code{equal}) and any X! non-default variables are written out. X! @end defvar X! X! @defvar calc-local-var-list X! This is a list of variables which should be buffer-local to the X! Calc buffer. Each entry is a variable name (as a Lisp symbol). X! These variables also have their default values manipulated by X! the @code{calc} and @code{calc-quit} commands; @pxref{Multiple Calculators}. X! Since @code{calc-mode-hook} is called after this list has been X! used the first time, your hook should add a variable to the X! list and also call @code{make-local-variable} itself. X! @end defvar X X @node Installation, Reporting Bugs, Programming, Top X @chapter Installation X X! Calc 1.05 comes as a pair of Emacs Lisp files, generally called X @file{calc.el} and @file{calc-ext.el}. The first contains the basic X foundations of the Calculator, and is as small as possible to promote X quick loading. The second contains all the more advanced commands and X*************** X*** 10955,10960 **** X--- 16408,16462 ---- X @kbd{M-#} command auto-loads only the first part, and the second part is X auto-loaded whenever the first advanced feature is used.@refill X X+ To install Calc, just follow these simple steps. If you want more X+ information, each step is discussed at length in the sections below. X+ X+ @enumerate X+ @item X+ Create a ``home'' directory for Calc in a suitable place. X+ X+ @item X+ Place the files @file{calc.el}, @file{calc-ext.el}, @file{macedit.el}, X+ and @file{calc.texinfo} in this home directory.@refill X+ X+ @item X+ Execute the command, @samp{emacs -batch -l calc.el -f calc-install} X+ in the home directory. (This will split the two @file{.el} files X+ into many smaller files for even faster loading, compile all of X+ those files, compile @file{macedit.el}, and format the manual X+ for use with the Emacs Info system.)@refill X+ X+ @item X+ Add all of the @code{autoload} and @code{global-set-key} commands shown X+ below to your @file{.emacs} file (if you are installing Calc just X+ for yourself) or to the system @file{default} file (if you X+ are installing Calc for your whole system).@refill X+ X+ @item X+ If you wish to use the GNUPLOT-based graphics commands, you may have X+ to set up a few things in your @file{.emacs} or @file{default} file X+ as described below.@refill X+ X+ @item X+ Test your installation as described at the end of these instructions. X+ X+ @item X+ (Optional.) To print a hardcopy of the Calc manual (about 300 pages), X+ move to the Calc home directory and type @file{tex calc.texinfo}, X+ then @file{texindex calc.??}, then @file{tex calc.texinfo} again. X+ Now print the resulting @file{calc.dvi} file using whatever command X+ is appropriate on your system. X+ @end enumerate X+ X+ Calc is now installed and ready to go! X+ X+ If you are pressed for disk space, you can remove the @file{.el} files X+ after @code{calc-install} has run, but @emph{not} the @file{.elc} or X+ @file{.elX} files! (The @file{.elX} files are copies of the original X+ @file{.el} files made by @code{calc-install} before it splits those X+ files into parts. You will need them to install patches for future X+ versions of Calc.)@refill X+ X @section Compilation X X Calc is written in a way that maximizes performance when its code has been X*************** X*** 10964,10971 **** X is used to compile an Emacs Lisp file. Compile each of @file{calc.el} and X @file{calc-ext.el} to obtain byte-code files @file{calc.elc} and X @file{calc-ext.elc}. You may find you need to do @kbd{M-x load-file X! calc.elc} before compiling @file{calc-ext.el} will work. X X For your convenience, the FTP distribution of Calc, obtainable from X anonymous FTP on @samp{csvax.cs.caltech.edu}, includes already-compiled X versions of both of these files. X--- 16466,16476 ---- X is used to compile an Emacs Lisp file. Compile each of @file{calc.el} and X @file{calc-ext.el} to obtain byte-code files @file{calc.elc} and X @file{calc-ext.elc}. You may find you need to do @kbd{M-x load-file X! calc.elc} before compiling @file{calc-ext.el} will work.@refill X X+ The @code{calc-install} command does all necessary byte-compilation X+ for you. X+ X For your convenience, the FTP distribution of Calc, obtainable from X anonymous FTP on @samp{csvax.cs.caltech.edu}, includes already-compiled X versions of both of these files. X*************** X*** 10978,10989 **** X file (if you are installing Calc publicly). X X @example X! (autoload 'calc ".../calc.elc" "Calculator Mode" t nil) X! (autoload 'calc-extensions ".../calc-ext.elc" nil nil nil) X! (autoload 'quick-calc ".../calc.elc" "Quick Calculator" t nil) X! (autoload 'full-calc ".../calc.elc" "Full-screen Calculator" t nil) X! (autoload 'calc-eval ".../calc.elc" "Call Calculator" nil nil) X! (autoload 'calc-grab-region ".../calc-ext.elc" nil t nil) X (autoload 'defmath ".../calc-ext.elc" nil t t) X @end example X X--- 16483,16494 ---- X file (if you are installing Calc publicly). X X @example X! (autoload 'calc ".../calc.elc" "Calculator Mode" t) X! (autoload 'calc-extensions ".../calc-ext.elc" nil) X! (autoload 'quick-calc ".../calc.elc" "Quick Calculator" t) X! (autoload 'full-calc ".../calc.elc" "Full-screen Calculator" t) X! (autoload 'calc-eval ".../calc.elc" "Use Calculator from Lisp") X! (autoload 'calc-grab-region ".../calc-ext.elc" nil t) X (autoload 'defmath ".../calc-ext.elc" nil t t) X @end example X X*************** X*** 10990,10996 **** X where @file{.../calc.elc} represents the full path to the @file{calc.elc} X file, and similarly for @file{.../calc-ext.elc}. If you have installed X these files in Emacs' main @file{lisp/} directory, you can just write X! @samp{"calc.elc"} and @samp{"calc-ext.elc"}. X X The @code{autoload} command for @code{calc} is what loads @file{calc.elc} X when you type @kbd{M-x calc}. The @code{autoload} for @code{calc-extensions} X--- 16495,16504 ---- X where @file{.../calc.elc} represents the full path to the @file{calc.elc} X file, and similarly for @file{.../calc-ext.elc}. If you have installed X these files in Emacs' main @file{lisp/} directory, you can just write X! @samp{"calc.elc"} and @samp{"calc-ext.elc"}. If you have used the X! @code{calc-install} method and the home directory you chose is called, X! say, @file{/usr/gnu/src/calc}, then you would need to write X! @samp{"/usr/gnu/src/calc/calc.elc"} and similarly for @samp{calc-ext.elc}. X X The @code{autoload} command for @code{calc} is what loads @file{calc.elc} X when you type @kbd{M-x calc}. The @code{autoload} for @code{calc-extensions} X*************** X*** 11011,11027 **** X X @section Splitting @file{calc-ext} X X! On the other hand, you may find that @file{calc-ext.el} is too big to load X! quickly. You can split the Calculator into still more parts using the X! @code{calc-split} command. This command splits the file X! @file{calc-ext.el} into about 20 small files with names like X! @file{calc-cplx.el} and @file{calc-mode.el} in the same directory X! as @file{calc-ext.el}. First, load the file @file{calc-ext.el} with X! @kbd{C-x C-f}. Move to the end of the buffer and type @kbd{C-x C-e} X! at the indicated position. Now type @kbd{M-x calc-split}. X! This moves most of the text out of @file{calc-ext.el} and into X! other files. All necessary @code{autoload} commands are inserted X! into @file{calc-ext.el}.@refill X X The @code{calc-split} command prompts for a directory name; the new X files are placed in this directory, and the @code{autoload} commands are X--- 16519,16571 ---- X X @section Splitting @file{calc-ext} X X! On the other hand, you may find that @file{calc.el} and @file{calc-ext.el} X! are too big to load quickly. You can split the Calculator into still X! more parts using the @code{calc-install} or @code{calc-split} commands. X! The former command does everything necessary to split Calc in a typical X! installation. Simply use @kbd{M-x cd} to change to the directory where X! you have installed @file{calc.el} and @file{calc-ext.el}. Now use X! @kbd{M-x load-file} to load @file{calc.el}. Finally, type X! @kbd{M-x calc-install}. This command will split the two original X! Calc files into many smaller, quick-loading parts. It will then X! byte-compile all of those parts for you. This process automatically X! inserts the necessary @code{autoload} commands into @file{calc.el} and X! the @file{calc-ext.el} to refer to the parts of them that were moved X! to other files. These @code{autoload} commands point to the directory X! you did your @code{calc-install} in, so if you move Calc to a new home X! you'll have to do the @code{calc-install} over again there. X! Note that you will still need to install the @code{autoload} commands X! shown above so that Emacs can find the two main Calc files.@refill X! X! The @code{calc-install} command also formats the manual, assuming X! you have placed @file{calc.texinfo} in the same directory. X! X! If you'd rather split and compile the Calculator from the Unix shell X! or a Makefile, you can use the command X! X! @example X! cd @var{...} ; emacs -batch -l calc.el -f calc-install X! @end example X! X! where again @file{...} represents the directory where Calc resides. X! X! Note that when patches are made available for new versions of Calc, they X! will refer to the old, unsplit version of the files @file{calc.el} and X! @file{calc-ext.el}. The @code{calc-install} command makes copies of X! these under the names @file{calc.elX} and @file{calc-ext.elX}; be sure X! to keep them around so you can rename them back to @file{calc.el} and X! @file{calc-ext.el} before installing new patches. You can then re-split X! your updated version of Calc with another @code{calc-install} X! command.@refill X! X! X! The @code{calc-split} command gives you better control over the splitting X! process. To use it, type @kbd{C-x C-f} to load @file{calc-ext.el}. X! Move to the end of the buffer and type @kbd{C-x C-e} at the indicated X! position. Now type @kbd{M-x calc-split}. This moves most of the text X! out of @file{calc-ext.el} and into other files. You can now load X! @file{calc.el} and give another @code{calc-split} command in it to X! complete the splitting process.@refill X X The @code{calc-split} command prompts for a directory name; the new X files are placed in this directory, and the @code{autoload} commands are X*************** X*** 11029,11036 **** X backspace over the default directory name and enter a blank name, in X which case the @code{autoload} commands will be written without X directory names on the assumption that Emacs can find the Calc files in X! one of the default places. Some people prefer to put the Calc files in X! a subdirectory by themselves.@refill X X The @code{calc-split} command also offers to byte-compile all Calc files X automatically. Note that @file{calc.el} must have been byte-compiled X--- 16573,16581 ---- X backspace over the default directory name and enter a blank name, in X which case the @code{autoload} commands will be written without X directory names on the assumption that Emacs can find the Calc files in X! one of the default places, such as the main @file{emacs/lisp} directory. X! Some people prefer instead to put the Calc files in a subdirectory of X! their own, in which case you should answer with that directory's name.@refill X X The @code{calc-split} command also offers to byte-compile all Calc files X automatically. Note that @file{calc.el} must have been byte-compiled X*************** X*** 11037,11054 **** X and loaded already, just as if you were compiling @file{calc-ext} whole. X If you choose to compile by hand, you will need to compile @file{calc.el} X first, load it, compile the new @file{calc-ext.el} and load it, then X! compile each of the new component files. Also, note that the X! @code{autoload} commands shown above are still correct for use in X! your startup file.@refill X X! If you do decide to use @code{calc-split}, note that when patches X! are made available for new versions of Calc, they will refer to X! the old, unsplit version of the file @file{calc-ext.el}. The X! @code{calc-split} command makes a copy of this under the name X! @file{calc-old.el}; be sure to keep it around so you can rename X! it back to @file{calc-ext.el} before installing new patches. X! You can then use @code{calc-split} again to re-split your updated X! version of Calc.@refill X X @section Key Bindings X X--- 16582,16592 ---- X and loaded already, just as if you were compiling @file{calc-ext} whole. X If you choose to compile by hand, you will need to compile @file{calc.el} X first, load it, compile the new @file{calc-ext.el} and load it, then X! compile each of the new component files. If you are using X! @code{calc-install} this is all handled for you.@refill X X! The @code{calc-install} command basically does all of the above X! steps for you, first for @file{calc.el}, then for @file{calc-ext.el}.@refill X X @section Key Bindings X X*************** X*** 11055,11061 **** X You may wish to bind the @code{calc} command to a key. The X recommended keystroke is @kbd{M-#} (i.e., Meta-Shift-3). To set up X this key binding, include this command in your @file{.emacs} or X! @file{lisp/default} file: X X @example X (global-set-key "\e#" 'calc) X--- 16593,16599 ---- X You may wish to bind the @code{calc} command to a key. The X recommended keystroke is @kbd{M-#} (i.e., Meta-Shift-3). To set up X this key binding, include this command in your @file{.emacs} or X! @file{lisp/default} file:@refill X X @example X (global-set-key "\e#" 'calc) X*************** X*** 11064,11069 **** X--- 16602,16616 ---- X There are no standard key assignments for @code{quick-calc} and X @code{calc-grab-region}, but you may wish to define some. X X+ @vindex calc-scan-for-dels X+ Another key binding issue is the @key{DEL} key. Some installations X+ use a different key (such as backspace) for this purpose. Calc X+ normally scans the entire keymap and maps all keys defined like X+ @key{DEL} to the @code{calc-pop} command. However, this may be X+ slow. You can set the variable @code{calc-scan-for-dels} to X+ @code{nil} to cause only the actual @key{DEL} key to be mapped to X+ @code{calc-pop}; this will speed loading of Calc. X+ X @section The @file{macedit} Package X X The file @file{macedit.el} contains another useful Emacs extension X*************** X*** 11073,11091 **** X To autoload it, you will want to include the commands, X X @example X! (autoload 'edit-kbd-macro ".../macedit.elc" "Edit Keyboard Macro" t nil) X! (autoload 'edit-last-kbd-macro ".../macedit.elc" "Edit Keyboard Macro" t nil) X @end example X X @section Documentation X X The documentation for Calc (i.e., this manual) comes in a file X! @file{calc.texinfo}. To format this for use as an on-line manual, X! open this file for editing in Emacs and give the command X @kbd{M-x texinfo-format-buffer}. When this finishes, type @kbd{C-x C-s} X to save. The result will be a collection of files whose names begin X! with @file{calc-info}. You can also format this into a printable X! document using @TeX{}, but beware, the manual is about 170 printed pages! X X @vindex calc-info-filename X There is a Lisp variable called @code{calc-info-filename} which holds X--- 16620,16650 ---- X To autoload it, you will want to include the commands, X X @example X! (autoload 'edit-kbd-macro ".../macedit.elc" "Edit Keyboard Macro" t) X! (autoload 'edit-last-kbd-macro ".../macedit.elc" "Edit Keyboard Macro" t) X! (autoload 'read-kbd-macro ".../macedit.elc" "Read Keyboard Macro" t) X @end example X X+ @section The GNUPLOT Program X+ X+ Calc's graphing commands use the GNUPLOT program. If you have GNUPLOT X+ but you must type some command other than @file{gnuplot} to get X+ it, you should add a command to set the Lisp variable @code{calc-gnuplot-name} X+ to the appropriate file name. You may also need to change the variables X+ @code{calc-gnuplot-plot-command} and @code{calc-gnuplot-print-command} in X+ order to get correct displays and hardcopies, respectively, of your X+ plots.@refill X+ X @section Documentation X X The documentation for Calc (i.e., this manual) comes in a file X! @file{calc.texinfo}. To format this for use as an on-line manual, open X! this file for editing in Emacs (with @kbd{C-x C-f}) and give the command X @kbd{M-x texinfo-format-buffer}. When this finishes, type @kbd{C-x C-s} X to save. The result will be a collection of files whose names begin X! with @file{calc-info}. The @code{calc-install} command does this for you. X! You can also format this into a printable document using @TeX{}, X! but beware, the manual is almost 300 printed pages! X X @vindex calc-info-filename X There is a Lisp variable called @code{calc-info-filename} which holds X*************** X*** 11100,11106 **** X X @noindent X in your @file{.emacs} or @file{lisp/default} file, where again @file{...} X! represents the directory containing the Info files. X X @section Settings File X X--- 16659,16666 ---- X X @noindent X in your @file{.emacs} or @file{lisp/default} file, where again @file{...} X! represents the directory containing the Info files. Again, if you X! use @code{calc-install} this is handled for you. X X @section Settings File X X*************** X*** 11121,11131 **** X @kbd{i} to make sure Calc can find its Info documentation. Press @kbd{q} X to exit the Info system and @kbd{M-#} to re-enter the Calculator. X Type @kbd{20 S} to compute the sine of 20 degrees; this will test the X! autoloading of the extensions module. The result should be 0.342020143326. X Finally, press @kbd{M-#} again to make sure the Calculator can exit. X X (The above text is included in both the Calc documentation and the X! file INSTALL in the Calc distribution directory.) X X @node Reporting Bugs, Key Index, Installation, Top X @chapter Reporting Bugs X--- 16681,16696 ---- X @kbd{i} to make sure Calc can find its Info documentation. Press @kbd{q} X to exit the Info system and @kbd{M-#} to re-enter the Calculator. X Type @kbd{20 S} to compute the sine of 20 degrees; this will test the X! autoloading of the extensions module (and the split submodules, if you X! have used this feature). The result should be 0.342020143326. X Finally, press @kbd{M-#} again to make sure the Calculator can exit. X X+ You may also wish to test the GNUPLOT interface; to plot a sine wave, X+ type @kbd{' [0 .. 360], sin(x) RET g f}. X+ X+ X (The above text is included in both the Calc documentation and the X! file calc-INSTALL in the Calc distribution directory.) X X @node Reporting Bugs, Key Index, Installation, Top X @chapter Reporting Bugs X*** newmacedit.el Thu Oct 4 19:35:37 1990 X--- ../dist/newmacedit.el Tue Oct 9 16:42:53 1990 X*************** X*** 0 **** X--- 1,691 ---- X+ ;; Keyboard macro editor for GNU Emacs. Version 1.02. X+ ;; Copyright (C) 1990 Dave Gillespie, daveg@csvax.caltech.edu. X+ X+ ;; This file is part of GNU Emacs. X+ X+ ;; GNU Emacs is distributed in the hope that it will be useful, X+ ;; but WITHOUT ANY WARRANTY. No author or distributor X+ ;; accepts responsibility to anyone for the consequences of using it X+ ;; or for whether it serves any particular purpose or works at all, X+ ;; unless he says so in writing. Refer to the GNU Emacs General Public X+ ;; License for full details. X+ X+ ;; Everyone is granted permission to copy, modify and redistribute X+ ;; GNU Emacs, but only under the conditions described in the X+ ;; GNU Emacs General Public License. A copy of this license is X+ ;; supposed to have been given to you along with GNU Emacs so you X+ ;; can know your rights and responsibilities. It should be in a X+ ;; file named COPYING. Among other things, the copyright notice X+ ;; and this notice must be preserved on all copies. X+ X+ ;; Installation: X+ ;; (autoload 'edit-kbd-macro "macedit" "Edit a named keyboard macro" t) X+ ;; (autoload 'edit-last-kbd-macro "macedit" "Edit a keyboard macro" t) X+ ;; (autoload 'read-kbd-macro "macedit" "Parse region as keyboard macro" t) X+ X+ X+ X+ ;; To use, type `M-x edit-last-kbd-macro' to edit the most recently X+ ;; defined keyboard macro. If you have used `M-x name-last-kbd-macro' X+ ;; to give a keyboard macro a name, type `M-x edit-kbd-macro' to edit X+ ;; the macro by name. When you are done editing, type `C-c C-c' to X+ ;; record your changes back into the original keyboard macro. X+ X+ X+ X+ X+ ;;; The user-level commands for editing macros. X+ X+ (defun edit-last-kbd-macro (&optional prefix buffer hook) X+ "Edit the most recently defined keyboard macro." X+ (interactive "P") X+ (MacEdit-edit-macro last-kbd-macro X+ (function (lambda (x arg) (setq last-kbd-macro x))) X+ prefix buffer hook) X+ ) X+ X+ (defun edit-kbd-macro (cmd &optional prefix buffer hook in-hook out-hook) X+ "Edit a keyboard macro which has been assigned a name by name-last-kbd-macro. X+ \(See also edit-last-kbd-macro.)" X+ (interactive "CCommand name: \nP") X+ (and cmd X+ (MacEdit-edit-macro (if in-hook X+ (funcall in-hook cmd) X+ (symbol-function cmd)) X+ (or out-hook X+ (list 'lambda '(x arg) X+ (list 'fset X+ (list 'quote cmd) X+ 'x))) X+ prefix buffer hook cmd)) X+ ) X+ X+ (defun read-kbd-macro (start end) X+ "Read the region as a keyboard macro definition. X+ The region is interpreted as spelled-out keystrokes, e.g., `M-x abc RET'. X+ The resulting macro is installed as the \"current\" keyboard macro. X+ X+ Symbols: RET, SPC, TAB, DEL, LFD, NUL; C-key; M-key. (Must be uppercase.) X+ REM marks the rest of a line as a comment. X+ Whitespace is ignored; other characters are copied into the macro." X+ (interactive "r") X+ (setq last-kbd-macro (MacEdit-parse-keys (buffer-substring start end))) X+ (if (and (string-match "\\`\C-x(" last-kbd-macro) X+ (string-match "\C-x)\\'" last-kbd-macro)) X+ (setq last-kbd-macro (substring last-kbd-macro 2 -2))) X+ ) X+ X+ X+ X+ X+ ;;; Formatting a keyboard macro as human-readable text. X+ X+ (defun MacEdit-print-macro (macro-str local-map) X+ (let ((save-map (current-local-map)) X+ (print-escape-newlines t) X+ key-symbol key-str key-last prefix-arg this-prefix) X+ (unwind-protect X+ (progn X+ (use-local-map local-map) X+ (while (MacEdit-peek-char) X+ (MacEdit-read-key) X+ (setq this-prefix prefix-arg) X+ (or (memq key-symbol '(digit-argument X+ negative-argument X+ universal-argument)) X+ (null prefix-arg) X+ (progn X+ (cond ((consp prefix-arg) X+ (insert (format "prefix-arg (%d)\n" X+ (car prefix-arg)))) X+ ((eq prefix-arg '-) X+ (insert "prefix-arg -\n")) X+ ((numberp prefix-arg) X+ (insert (format "prefix-arg %d\n" prefix-arg)))) X+ (setq prefix-arg nil))) X+ (cond ((null key-symbol) X+ (insert "type \"") X+ (MacEdit-insert-string macro-str) X+ (insert "\"\n") X+ (setq macro-str "")) X+ ((eq key-symbol 'digit-argument) X+ (MacEdit-prefix-arg key-last nil prefix-arg)) X+ ((eq key-symbol 'negative-argument) X+ (MacEdit-prefix-arg ?- nil prefix-arg)) X+ ((eq key-symbol 'universal-argument) X+ (let* ((c-u 4) (argstartchar key-last) X+ (char (MacEdit-read-char))) X+ (while (= char argstartchar) X+ (setq c-u (* 4 c-u) X+ char (MacEdit-read-char))) X+ (MacEdit-prefix-arg char c-u nil))) X+ ((eq key-symbol 'self-insert-command) X+ (insert "insert ") X+ (if (and (>= key-last 32) (<= key-last 126)) X+ (let ((str "")) X+ (while (or (and (eq key-symbol X+ 'self-insert-command) X+ (< (length str) 60) X+ (>= key-last 32) X+ (<= key-last 126)) X+ (and (memq key-symbol X+ '(backward-delete-char X+ delete-backward-char X+ backward-delete-char-untabify)) X+ (> (length str) 0))) X+ (if (eq key-symbol 'self-insert-command) X+ (setq str (concat str X+ (char-to-string key-last))) X+ (setq str (substring str 0 -1))) X+ (MacEdit-read-key)) X+ (insert "\"" str "\"\n") X+ (MacEdit-unread-chars key-str)) X+ (insert "\"") X+ (MacEdit-insert-string (char-to-string key-last)) X+ (insert "\"\n"))) SHAR_EOF echo "End of part 19, continue with part 20" echo "20" > s2_seq_.tmp exit 0