1 ;;; calc-help.el --- help display functions for Calc,
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
6 ;; Maintainers: D. Goel <deego@gnufans.org>
7 ;; Colin Walters <walters@debian.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY. No author or distributor
13 ;; accepts responsibility to anyone for the consequences of using it
14 ;; or for whether it serves any particular purpose or works at all,
15 ;; unless he says so in writing. Refer to the GNU Emacs General Public
16 ;; License for full details.
18 ;; Everyone is granted permission to copy, modify and redistribute
19 ;; GNU Emacs, but only under the conditions described in the
20 ;; GNU Emacs General Public License. A copy of this license is
21 ;; supposed to have been given to you along with GNU Emacs so you
22 ;; can know your rights and responsibilities. It should be in a
23 ;; file named COPYING. Among other things, the copyright notice
24 ;; and this notice must be preserved on all copies.
30 ;; This file is autoloaded from calc-ext.el.
35 (defun calc-Need-calc-help () nil
)
38 (defun calc-help-prefix (arg)
39 "This key is the prefix for Calc help functions. See calc-help-for-help."
41 (or calc-dispatch-help
(sit-for echo-keystrokes
))
42 (let ((key (calc-read-key-sequence
43 (if calc-dispatch-help
44 "Calc Help options: Help, Info, Tutorial, Summary; Key, Function; ?=more"
45 (format "%s (Type ? for a list of Calc Help options)"
46 (key-description (this-command-keys))))
48 (setq key
(lookup-key calc-help-map key
))
51 (call-interactively key
)
54 (defun calc-help-for-help (arg)
55 "You have typed `h', the Calc help character. Type a Help option:
57 B calc-describe-bindings. Display a table of all key bindings.
58 H calc-full-help. Display all `?' key messages at once.
60 I calc-info. Read the Calc manual using the Info system.
61 T calc-tutorial. Read the Calc tutorial using the Info system.
62 S calc-info-summary. Read the Calc summary using the Info system.
64 C calc-describe-key-briefly. Look up the command name for a given key.
65 K calc-describe-key. Look up a key's documentation in the manual.
66 F calc-describe-function. Look up a function's documentation in the manual.
67 V calc-describe-variable. Look up a variable's documentation in the manual.
69 N calc-view-news. Display Calc history of changes.
71 C-c Describe conditions for copying Calc.
72 C-d Describe how you can get a new copy of Calc or report a bug.
73 C-w Describe how there is no warranty for Calc."
75 (if calc-dispatch-help
77 (save-window-excursion
78 (describe-function 'calc-help-for-help
)
79 (select-window (get-buffer-window "*Help*"))
81 (message "Calc Help options: Help, Info, ... press SPC, DEL to scroll, C-g to cancel")
82 (memq (car (setq key
(calc-read-key t
)))
83 '(? ?\C-h ?\C-? ?\C-v ?\M-v
)))
85 (if (memq (car key
) '(? ?\C-v
))
89 (calc-unread-command (cdr key
))
90 (calc-help-prefix nil
))
91 (let ((calc-dispatch-help t
))
92 (calc-help-prefix arg
))))
94 (defun calc-describe-copying ()
97 (Info-goto-node "Copying"))
99 (defun calc-describe-distribution ()
102 (Info-goto-node "Reporting Bugs"))
104 (defun calc-describe-no-warranty ()
107 (Info-goto-node "Copying")
108 (let ((case-fold-search nil
))
109 (search-forward " NO WARRANTY"))
113 (defun calc-describe-bindings ()
117 (set-buffer "*Help*")
118 (goto-char (point-min))
119 (if (search-forward "Global bindings:" nil t
)
120 (delete-region (match-beginning 0) (point-max)))
121 (goto-char (point-min))
122 (while (re-search-forward "\n[a-z] ESC" nil t
)
124 (delete-region (match-beginning 0) (point)))
125 (goto-char (point-min))
126 (while (re-search-forward "\nESC m" nil t
)
128 (delete-region (match-beginning 0) (point)))
129 (goto-char (point-min))
130 (while (search-forward "\n\n\n" nil t
)
131 (backward-delete-char 1)
133 (goto-char (point-min))
136 "\n[a-z] [0-9]\\(\t\t.*\n\\)\\([a-z] [0-9]\\1\\)*[a-z] \\([0-9]\\)\\1"
138 (let ((dig1 (char-after (1- (match-beginning 1))))
139 (dig2 (char-after (match-beginning 3))))
140 (delete-region (match-end 1) (match-end 0))
141 (goto-char (match-beginning 1))
142 (delete-backward-char 1)
144 (insert (format "%c .. %c" (min dig1 dig2
) (max dig1 dig2
)))))
145 (goto-char (point-min))))
147 (defun calc-describe-key-briefly (key)
148 (interactive "kDescribe key briefly: ")
149 (calc-describe-key key t
))
151 (defun calc-describe-key (key &optional briefly
)
152 (interactive "kDescribe key: ")
153 (let ((defn (if (eq (key-binding key
) 'calc-dispatch
)
154 (let ((key2 (calc-read-key-sequence
155 (format "Describe key briefly: %s-"
156 (key-description key
))
158 (setq key
(concat key key2
))
159 (lookup-key calc-dispatch-map key2
))
160 (if (eq (key-binding key
) 'calc-help-prefix
)
161 (let ((key2 (calc-read-key-sequence
162 (format "Describe key briefly: %s-"
163 (key-description key
))
165 (setq key
(concat key key2
))
166 (lookup-key calc-help-map key2
))
170 (while (or (equal key
"I") (equal key
"H"))
173 (setq hyp
(not hyp
)))
174 (setq key
(read-key-sequence (format "Describe key%s:%s%s "
175 (if briefly
" briefly" "")
178 defn
(key-binding key
)))
179 (let ((desc (key-description key
))
181 (if (string-match "^ESC " desc
)
182 (setq desc
(concat "M-" (substring desc
4))))
183 (while (string-match "^M-# \\(ESC \\|C-\\)" desc
)
184 (setq desc
(concat "M-# " (substring desc
(match-end 0)))))
186 (let ((msg (save-excursion
187 (set-buffer (get-buffer-create "*Calc Summary*"))
188 (if (= (buffer-size) 0)
190 (message "Reading Calc summary from manual...")
191 (save-window-excursion
194 (Info-goto-node "Summary")
195 (goto-char (point-min))
197 (copy-to-buffer "*Calc Summary*"
200 (setq case-fold-search nil
)
201 (re-search-forward "^\\(.*\\)\\[\\.\\. a b")
202 (setq calc-summary-indentation
203 (- (match-end 1) (match-beginning 1)))))
204 (goto-char (point-min))
205 (setq target
(if (and (string-match "[0-9]\\'" desc
)
206 (not (string-match "[d#]" desc
)))
207 (concat (substring desc
0 -
1) "0-9")
209 (if (re-search-forward
210 (format "\n%s%s%s%s[ a-zA-Z]"
211 (make-string (+ calc-summary-indentation
9)
213 (if (string-match "M-#" desc
) " "
215 (if hyp
"I H " " I ")
217 (regexp-quote target
)
218 (make-string (max (- 6 (length target
)) 0)
223 (forward-char calc-summary-indentation
)
226 (buffer-substring pt
(point)))))))
228 (let ((args (substring msg
0 9))
229 (keys (substring msg
9 19))
230 (prompts (substring msg
19 38))
232 (cmd (substring msg
40))
234 (if (string-match "\\` +" args
)
235 (setq args
(substring args
(match-end 0))))
236 (if (string-match " +\\'" args
)
237 (setq args
(substring args
0 (match-beginning 0))))
238 (if (string-match "\\` +" keys
)
239 (setq keys
(substring keys
(match-end 0))))
240 (if (string-match " +\\'" keys
)
241 (setq keys
(substring keys
0 (match-beginning 0))))
242 (if (string-match " [0-9,]+\\'" prompts
)
243 (setq notes
(substring prompts
(1+ (match-beginning 0)))
244 prompts
(substring prompts
0 (match-beginning 0))))
245 (if (string-match " +\\'" prompts
)
246 (setq prompts
(substring prompts
0 (match-beginning 0))))
247 (if (string-match "\\` +" prompts
)
248 (setq prompts
(substring prompts
(match-end 0))))
250 "%s: %s%s`%s'%s%s %s%s"
252 "\\`\\(calc-[-a-zA-Z0-9]+\\) *\\(.*\\)\\'"
254 (prog1 (math-match-substring cmd
1)
255 (setq cmd
(math-match-substring cmd
2)))
257 args
(if (equal args
"") "" " ")
259 (if (equal prompts
"") "" " ") prompts
260 (if (equal cmd
"") "" " => ") cmd
))
261 (message "%s%s%s runs %s%s"
262 (if inv
"I " "") (if hyp
"H " "") desc
264 (if (equal notes
"") ""
265 (format " (?=notes %s)" notes
)))
266 (let ((key (calc-read-key t
)))
267 (if (eq (car key
) ??
)
269 (message "No notes for this command")
270 (while (string-match "," notes
)
271 (aset notes
(match-beginning 0) ?
))
272 (setq notes
(sort (car (read-from-string
273 (format "(%s)" notes
)))
275 (with-output-to-temp-buffer "*Help*"
276 (princ (format "%s\n\n" msg
))
277 (set-buffer "*Calc Summary*")
278 (re-search-forward "^ *NOTES")
281 (format "^ *%d\\. " (car notes
)))
285 (or (re-search-forward "^ ? ?[0-9]+\\. " nil t
)
286 (goto-char (point-max)))
288 (princ (buffer-substring pt
(point))))
289 (setq notes
(cdr notes
)))
290 (print-help-return-message)))
291 (calc-unread-command (cdr key
)))))
292 (if (or (null defn
) (integerp defn
))
293 (message "%s is undefined" desc
)
294 (message "%s runs the command %s"
296 (if (symbolp defn
) defn
(prin1-to-string defn
))))))
297 (if inv
(setq desc
(concat "I " desc
)))
298 (if hyp
(setq desc
(concat "H " desc
)))
299 (calc-describe-thing desc
"Key Index" nil
300 (string-match "[A-Z][A-Z][A-Z]" desc
))))))
302 (defun calc-describe-function (&optional func
)
305 (setq func
(intern (completing-read "Describe function: "
306 obarray nil t
"calcFunc-"))))
307 (setq func
(symbol-name func
))
308 (if (string-match "\\`calc-." func
)
309 (calc-describe-thing func
"Command Index")
310 (calc-describe-thing (if (string-match "\\`calcFunc-." func
)
315 (defun calc-describe-variable (&optional var
)
318 (setq var
(intern (completing-read "Describe variable: "
319 obarray nil t
"var-"))))
320 (setq var
(symbol-name var
))
321 (calc-describe-thing var
"Variable Index"
322 (if (string-match "\\`var-." var
)
326 (defun calc-describe-thing (thing where
&optional target not-quoted
)
327 (message "Looking for `%s' in %s..." thing where
)
328 (let ((savewin (current-window-configuration)))
330 (Info-goto-node where
)
331 (or (let ((case-fold-search nil
))
332 (re-search-forward (format "\n\\* +%s: \\(.*\\)\\."
333 (regexp-quote thing
))
335 (and (string-match "\\`\\([a-z ]*\\)[0-9]\\'" thing
)
336 (re-search-forward (format "\n\\* +%s[01]-9: \\(.*\\)\\."
337 (substring thing
0 -
1))
339 (setq thing
(format "%s9" (substring thing
0 -
1))))
342 (set-window-configuration savewin
)
343 (error "Can't find `%s' in %s" thing where
)))
345 (Info-goto-node (buffer-substring (match-beginning 1) (match-end 1))))
346 (or (let ((case-fold-search nil
))
347 (or (search-forward (format "\\[`%s'\\]\\|(`%s')\\|\\<The[ \n]`%s'"
350 (or target thing
)) nil t
)
352 (let ((case-fold-search t
))
353 (search-forward (or target thing
) nil t
)))
354 (search-forward (format "`%s'" (or target thing
)) nil t
)
355 (search-forward (or target thing
) nil t
)))
356 (let ((case-fold-search t
))
357 (or (search-forward (format "\\[`%s'\\]\\|(`%s')\\|\\<The[ \n]`%s'"
360 (or target thing
)) nil t
)
361 (search-forward (format "`%s'" (or target thing
)) nil t
)
362 (search-forward (or target thing
) nil t
))))
364 (message "Found `%s' in %s" thing where
)))
366 (defun calc-view-news ()
368 (let ((path load-path
))
370 (not (file-exists-p (expand-file-name "calc.el" (car path
)))))
371 (setq path
(cdr path
)))
373 (file-exists-p (expand-file-name "README" (car path
))))
374 (error "Can't locate Calc sources"))
376 (switch-to-buffer "*Help*")
378 (insert-file-contents (expand-file-name "README" (car path
)))
379 (search-forward "Summary of changes")
381 (delete-region (point-min) (point))
382 (goto-char (point-min))))
384 (defun calc-full-help ()
386 (with-output-to-temp-buffer "*Help*"
387 (princ (format "GNU Emacs Calculator version %s of %s.\n"
388 calc-version calc-version-date
))
389 (princ " By Dave Gillespie, daveg@synaptics.com.\n")
390 (princ " Copyright (C) 1990, 1993 Free Software Foundation, Inc.\n\n")
391 (princ "Type `h s' for a more detailed summary.\n")
392 (princ "Or type `h i' to read the full Calc manual on-line.\n\n")
393 (princ "Basic keys:\n")
394 (let* ((calc-full-help-flag t
))
395 (mapcar (function (lambda (x) (princ (format " %s\n" x
))))
396 (nreverse (cdr (reverse (cdr (calc-help))))))
397 (mapcar (function (lambda (prefix)
398 (let ((msgs (condition-case err
403 (if (eq (nth 2 msgs
) ?v
)
404 "\n`v' or `V' prefix (vector/matrix) keys: \n"
407 "\n`%c' prefix (%s) keys:\n"
409 (or (cdr (assq (nth 2 msgs
)
410 calc-help-long-names
))
412 (format "\n%s-modified keys:\n"
413 (capitalize (nth 1 msgs
)))))))
414 (mapcar (function (lambda (x)
415 (princ (format " %s\n" x
))))
417 '(calc-inverse-prefix-help
418 calc-hyperbolic-prefix-help
419 calc-inv-hyp-prefix-help
435 calc-shift-Y-prefix-help
436 calc-shift-Z-prefix-help
437 calc-z-prefix-help
)))
438 (print-help-return-message)))
440 (defvar calc-help-long-names
'((?b .
"binary/business")
443 (?k .
"combinatorics/statistics")
444 (?u .
"units/statistics")))
446 (defun calc-h-prefix-help ()
449 '("Help; Bindings; Info, Tutorial, Summary; News"
450 "describe: Key, C (briefly), Function, Variable")
453 (defun calc-inverse-prefix-help ()
456 '("I + S (arcsin), C (arccos), T (arctan); Q (square)"
457 "I + E (ln), L (exp), B (alog: B^X); f E (lnp1), f L (expm1)"
458 "I + F (ceiling), R (truncate); a S (invert func)"
459 "I + a m (match-not); c h (from-hms); k n (prev prime)"
460 "I + f G (gamma-Q); f e (erfc); k B (etc., lower-tail dists)"
461 "I + V S (reverse sort); V G (reverse grade)"
462 "I + v s (remove subvec); v h (tail)"
463 "I + t + (alt sum), t M (mean with error)"
464 "I + t S (pop std dev), t C (pop covar)")
467 (defun calc-hyperbolic-prefix-help ()
470 '("H + S (sinh), C (cosh), T (tanh); E (exp10), L (log10)"
471 "H + F (float floor), R (float round); P (constant \"e\")"
472 "H + a d (total derivative); k c (permutations)"
473 "H + k b (bern-poly), k e (euler-poly); k s (stirling-2)"
474 "H + f G (gamma-g), f B (beta-B); v h (rhead), v k (rcons)"
475 "H + v e (expand w/filler); V H (weighted histogram)"
476 "H + a S (general solve eqn), j I (general isolate)"
477 "H + a R (widen/root), a N (widen/min), a X (widen/max)"
478 "H + t M (median), t S (variance), t C (correlation coef)"
479 "H + c f/F/c (pervasive float/frac/clean)")
482 (defun calc-inv-hyp-prefix-help ()
485 '("I H + S (arcsinh), C (arccosh), T (arctanh)"
486 "I H + E (log10), L (exp10); f G (gamma-G)"
487 "I H + F (float ceiling), R (float truncate)"
488 "I H + t S (pop variance)"
489 "I H + a S (general invert func); v h (rtail)")
490 "inverse-hyperbolic" nil
))
493 (defun calc-f-prefix-help ()
496 '("miN, maX; Hypot; Im, Re; Sign; [, ] (incr/decr)"
497 "Gamma, Beta, Erf, besselJ, besselY"
498 "SHIFT + int-sQrt; Int-log, Exp(x)-1, Ln(x+1); arcTan2"
499 "SHIFT + Abssqr; Mantissa, eXponent, Scale"
500 "SHIFT + incomplete: Gamma-P, Beta-I")
504 (defun calc-s-prefix-help ()
507 '("Store, inTo, Xchg, Unstore; Recall, 0-9; : (:=); = (=>)"
508 "Let; Copy; Declare; Insert, Perm; Edit"
509 "Negate, +, -, *, /, ^, &, |, [, ]; Map"
510 "SHIFT + Decls, GenCount, TimeZone, Holidays; IntegLimit"
511 "SHIFT + LineStyles, PointStyles, plotRejects; Units"
512 "SHIFT + Eval-, AlgSimp-, ExtSimp-, FitRules")
515 (defun calc-r-prefix-help ()
518 '("digits 0-9: recall, same as `s r 0-9'")
522 (defun calc-j-prefix-help ()
525 '("Select, Additional, Once; eVal, Formula; Rewrite"
526 "More, Less, 1-9, Next, Previous"
527 "Unselect, Clear; Display; Enable; Breakable"
528 "' (replace), ` (edit), +, -, *, /, RET (grab), DEL"
529 "SHIFT + swap: Left, Right; maybe: Select, Once"
530 "SHIFT + Commute, Merge, Distrib, jump-Eqn, Isolate"
531 "SHIFT + Negate, & (invert); Unpack")
535 (defun calc-a-prefix-help ()
538 '("Simplify, Extended-simplify, eVal; \" (exp-formula)"
539 "eXpand, Collect, Factor, Apart, Norm-rat"
540 "GCD, /, \\, % (polys); Polint"
541 "Derivative, Integral, Taylor; _ (subscr)"
542 "suBstitute; Rewrite, Match"
543 "SHIFT + Solve; Root, miN, maX; Poly-roots; Fit"
544 "SHIFT + Map; Tabulate, + (sum), * (prod); num-Integ"
545 "relations: =, # (not =), <, >, [ (< or =), ] (> or =)"
546 "logical: & (and), | (or), ! (not); : (if)"
547 "misc: { (in-set); . (rmeq)")
551 (defun calc-b-prefix-help ()
554 '("And, Or, Xor, Diff, Not; Wordsize, Clip"
555 "Lshift, Rshift, roTate; SHIFT + signed Lshift, Rshift"
556 "SHIFT + business: Pv, Npv, Fv, pMt, #pmts, raTe, Irr"
557 "SHIFT + business: Sln, sYd, Ddb; %ch")
561 (defun calc-c-prefix-help ()
564 '("Deg, Rad, HMS; Float; Polar/rect; Clean, 0-9; %"
569 (defun calc-d-prefix-help ()
572 '("Group, \",\"; Normal, Fix, Sci, Eng, \".\"; Over"
573 "Radix, Zeros, 2, 8, 0, 6; Hms; Date; Complex, I, J"
574 "Why; Line-nums, line-Breaks; <, =, > (justify); Plain"
575 "\" (strings); Truncate, [, ]; SPC (refresh), RET, @"
576 "SHIFT + language: Normal, One-line, Big, Unformatted"
577 "SHIFT + language: C, Pascal, Fortran; TeX, Eqn"
578 "SHIFT + language: Mathematica, W=Maple")
582 (defun calc-g-prefix-help ()
585 '("Fast; Add, Delete, Juggle; Plot, Clear; Quit"
586 "Header, Name, Grid, Border, Key; View-commands, X-display"
587 "x-axis: Range, Title, Log, Zero; lineStyle"
588 "SHIFT + y-axis: Range, Title, Log, Zero; pointStyle"
589 "SHIFT + Print; Device, Output-file; X-geometry"
590 "SHIFT + Num-pts; Command, Kill, View-trail"
591 "SHIFT + 3d: Fast, Add; CTRL + z-axis: Range, Title, Log")
595 (defun calc-k-prefix-help ()
598 '("GCD, LCM; Choose (binomial), Double-factorial"
599 "Random, random-Again, sHuffle"
600 "Factors, Prime-test, Next-prime, Totient, Moebius"
601 "Bernoulli, Euler, Stirling"
602 "SHIFT + Extended-gcd"
603 "SHIFT + dists: Binomial, Chi-square, F, Normal"
604 "SHIFT + dists: Poisson, student's-T")
608 (defun calc-m-prefix-help ()
611 '("Deg, Rad, HMS; Frac; Polar; Inf; Alg, Total; Symb; Vec/mat"
612 "Working; Xtensions; Mode-save"
613 "SHIFT + Shifted-prefixes, mode-Filename; Record; reCompute"
614 "SHIFT + simplify: Off, Num, Default, Bin, Alg, Ext, Units")
618 (defun calc-t-prefix-help ()
621 '("Display; Fwd, Back; Next, Prev, Here, [, ]; Yank"
622 "Search, Rev; In, Out; <, >; Kill; Marker; . (abbrev)"
623 "SHIFT + time: Now; Part; Date, Julian, Unix, Czone"
624 "SHIFT + time: newWeek, newMonth, newYear; Incmonth"
625 "SHIFT + time: +, - (business days)"
626 "digits 0-9: store-to, same as `s t 0-9'")
630 (defun calc-u-prefix-help ()
633 '("Simplify, Convert, Temperature-convert, Base-units"
634 "Autorange; Remove, eXtract; Explain; View-table; 0-9"
635 "Define, Undefine, Get-defn, Permanent"
636 "SHIFT + View-table-other-window"
637 "SHIFT + stat: Mean, G-mean, Std-dev, Covar, maX, miN"
638 "SHIFT + stat: + (sum), - (asum), * (prod), # (count)")
642 (defun calc-v-prefix-help ()
645 '("Pack, Unpack, Identity, Diagonal, indeX, Build"
646 "Row, Column, Subvector; Length; Find; Mask, Expand"
647 "Tranpose, Arrange, reVerse; Head, Kons; rNorm"
648 "SHIFT + Det, & (inverse), LUD, Trace, conJtrn, Cross"
649 "SHIFT + Sort, Grade, Histogram; cNorm"
650 "SHIFT + Apply, Map, Reduce, accUm, Inner-, Outer-prod"
651 "SHIFT + sets: V (union), ^ (intersection), - (diff)"
652 "SHIFT + sets: Xor, ~ (complement), Floor, Enum"
653 "SHIFT + sets: : (span), # (card), + (rdup)"
654 "<, =, > (justification); , (commas); [, {, ( (brackets)"
655 "} (matrix brackets); . (abbreviate); / (multi-lines)")
658 ;;; calc-help.el ends here