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 ()
96 (calc-info-goto-node "Copying"))
98 (defun calc-describe-distribution ()
100 (calc-info-goto-node "Reporting Bugs"))
102 (defun calc-describe-no-warranty ()
104 (calc-info-goto-node "Copying")
105 (let ((case-fold-search nil
))
106 (search-forward " NO WARRANTY"))
110 (defun calc-describe-bindings ()
114 (set-buffer "*Help*")
115 (goto-char (point-min))
116 (if (search-forward "Global bindings:" nil t
)
117 (delete-region (match-beginning 0) (point-max)))
118 (goto-char (point-min))
119 (while (re-search-forward "\n[a-z] ESC" nil t
)
121 (delete-region (match-beginning 0) (point)))
122 (goto-char (point-min))
123 (while (re-search-forward "\nESC m" nil t
)
125 (delete-region (match-beginning 0) (point)))
126 (goto-char (point-min))
127 (while (search-forward "\n\n\n" nil t
)
128 (backward-delete-char 1)
130 (goto-char (point-min))
133 "\n[a-z] [0-9]\\(\t\t.*\n\\)\\([a-z] [0-9]\\1\\)*[a-z] \\([0-9]\\)\\1"
135 (let ((dig1 (char-after (1- (match-beginning 1))))
136 (dig2 (char-after (match-beginning 3))))
137 (delete-region (match-end 1) (match-end 0))
138 (goto-char (match-beginning 1))
139 (delete-backward-char 1)
141 (insert (format "%c .. %c" (min dig1 dig2
) (max dig1 dig2
)))))
142 (goto-char (point-min))))
144 (defun calc-describe-key-briefly (key)
145 (interactive "kDescribe key briefly: ")
146 (calc-describe-key key t
))
148 (defun calc-describe-key (key &optional briefly
)
149 (interactive "kDescribe key: ")
150 (let ((defn (if (eq (key-binding key
) 'calc-dispatch
)
151 (let ((key2 (calc-read-key-sequence
152 (format "Describe key briefly: %s-"
153 (key-description key
))
155 (setq key
(concat key key2
))
156 (lookup-key calc-dispatch-map key2
))
157 (if (eq (key-binding key
) 'calc-help-prefix
)
158 (let ((key2 (calc-read-key-sequence
159 (format "Describe key briefly: %s-"
160 (key-description key
))
162 (setq key
(concat key key2
))
163 (lookup-key calc-help-map key2
))
167 (while (or (equal key
"I") (equal key
"H"))
170 (setq hyp
(not hyp
)))
171 (setq key
(read-key-sequence (format "Describe key%s:%s%s "
172 (if briefly
" briefly" "")
175 defn
(key-binding key
)))
176 (let ((desc (key-description key
))
178 (if (string-match "^ESC " desc
)
179 (setq desc
(concat "M-" (substring desc
4))))
180 (while (string-match "^M-# \\(ESC \\|C-\\)" desc
)
181 (setq desc
(concat "M-# " (substring desc
(match-end 0)))))
183 (let ((msg (save-excursion
184 (set-buffer (get-buffer-create "*Calc Summary*"))
185 (if (= (buffer-size) 0)
187 (message "Reading Calc summary from manual...")
188 (save-window-excursion
190 (calc-info-goto-node "Summary")
191 (goto-char (point-min))
193 (copy-to-buffer "*Calc Summary*"
197 (setq case-fold-search nil
)
198 (re-search-forward "^\\(.*\\)\\[\\.\\. a b")
199 (setq calc-summary-indentation
200 (- (match-end 1) (match-beginning 1)))))
201 (goto-char (point-min))
202 (setq target
(if (and (string-match "[0-9]\\'" desc
)
203 (not (string-match "[d#]" desc
)))
204 (concat (substring desc
0 -
1) "0-9")
206 (if (re-search-forward
207 (format "\n%s%s%s%s[ a-zA-Z]"
208 (make-string (+ calc-summary-indentation
9)
210 (if (string-match "M-#" desc
) " "
212 (if hyp
"I H " " I ")
214 (regexp-quote target
)
215 (make-string (max (- 6 (length target
)) 0)
220 (forward-char calc-summary-indentation
)
223 (buffer-substring pt
(point)))))))
225 (let ((args (substring msg
0 9))
226 (keys (substring msg
9 19))
227 (prompts (substring msg
19 38))
229 (cmd (substring msg
40))
231 (if (string-match "\\` +" args
)
232 (setq args
(substring args
(match-end 0))))
233 (if (string-match " +\\'" args
)
234 (setq args
(substring args
0 (match-beginning 0))))
235 (if (string-match "\\` +" keys
)
236 (setq keys
(substring keys
(match-end 0))))
237 (if (string-match " +\\'" keys
)
238 (setq keys
(substring keys
0 (match-beginning 0))))
239 (if (string-match " [0-9,]+\\'" prompts
)
240 (setq notes
(substring prompts
(1+ (match-beginning 0)))
241 prompts
(substring prompts
0 (match-beginning 0))))
242 (if (string-match " +\\'" prompts
)
243 (setq prompts
(substring prompts
0 (match-beginning 0))))
244 (if (string-match "\\` +" prompts
)
245 (setq prompts
(substring prompts
(match-end 0))))
247 "%s: %s%s`%s'%s%s %s%s"
249 "\\`\\(calc-[-a-zA-Z0-9]+\\) *\\(.*\\)\\'"
251 (prog1 (math-match-substring cmd
1)
252 (setq cmd
(math-match-substring cmd
2)))
254 args
(if (equal args
"") "" " ")
256 (if (equal prompts
"") "" " ") prompts
257 (if (equal cmd
"") "" " => ") cmd
))
258 (message "%s%s%s runs %s%s"
259 (if inv
"I " "") (if hyp
"H " "") desc
261 (if (equal notes
"") ""
262 (format " (?=notes %s)" notes
)))
263 (let ((key (calc-read-key t
)))
264 (if (eq (car key
) ??
)
266 (message "No notes for this command")
267 (while (string-match "," notes
)
268 (aset notes
(match-beginning 0) ?
))
269 (setq notes
(sort (car (read-from-string
270 (format "(%s)" notes
)))
272 (with-output-to-temp-buffer "*Help*"
273 (princ (format "%s\n\n" msg
))
274 (set-buffer "*Calc Summary*")
275 (re-search-forward "^ *NOTES")
278 (format "^ *%d\\. " (car notes
)))
282 (or (re-search-forward "^ ? ?[0-9]+\\. " nil t
)
283 (goto-char (point-max)))
285 (princ (buffer-substring pt
(point))))
286 (setq notes
(cdr notes
)))
287 (print-help-return-message)))
288 (calc-unread-command (cdr key
)))))
289 (if (or (null defn
) (integerp defn
))
290 (message "%s is undefined" desc
)
291 (message "%s runs the command %s"
293 (if (symbolp defn
) defn
(prin1-to-string defn
))))))
294 (if inv
(setq desc
(concat "I " desc
)))
295 (if hyp
(setq desc
(concat "H " desc
)))
296 (calc-describe-thing desc
"Key Index" nil
297 (string-match "[A-Z][A-Z][A-Z]" desc
))))))
299 (defvar calc-help-function-list nil
300 "List of functions provided by Calc.")
302 (defvar calc-help-variable-list nil
303 "List of variables provided by Calc.")
305 (defun calc-help-index-entries (&rest indices
)
306 "Create a list of entries from the INDICES in the Calc info manual."
307 (let ((entrylist '())
309 (require 'info nil t
)
314 (Info-goto-node (concat "(Calc)" (car indices
) " Index"))
315 (goto-char (point-min))
316 (while (re-search-forward "\n\\* \\(.*\\): " nil t
)
317 (setq entry
(match-string 1))
318 (if (and (not (string-match "<[1-9]+>" entry
))
319 (not (string-match "(.*)" entry
))
320 (not (string= entry
"Menu")))
321 (unless (assoc entry entrylist
)
322 (setq entrylist
(cons entry entrylist
))))))
324 (setq indices
(cdr indices
)))
327 (defun calc-describe-function (&optional func
)
329 (unless calc-help-function-list
330 (setq calc-help-function-list
331 (calc-help-index-entries "Function" "Command")))
333 (setq func
(completing-read "Describe function: "
334 calc-help-function-list
336 (if (string-match "\\`calc-." func
)
337 (calc-describe-thing func
"Command Index")
338 (calc-describe-thing func
"Function Index")))
340 (defun calc-describe-variable (&optional var
)
342 (unless calc-help-variable-list
343 (setq calc-help-variable-list
344 (calc-help-index-entries "Variable")))
346 (setq var
(completing-read "Describe variable: "
347 calc-help-variable-list
349 (calc-describe-thing var
"Variable Index"))
351 (defun calc-describe-thing (thing where
&optional target not-quoted
)
352 (message "Looking for `%s' in %s..." thing where
)
353 (let ((savewin (current-window-configuration)))
354 (calc-info-goto-node where
)
355 (or (let ((case-fold-search nil
))
356 (re-search-forward (format "\n\\* +%s: \\(.*\\)\\."
357 (regexp-quote thing
))
359 (and (string-match "\\`\\([a-z ]*\\)[0-9]\\'" thing
)
360 (re-search-forward (format "\n\\* +%s[01]-9: \\(.*\\)\\."
361 (substring thing
0 -
1))
363 (setq thing
(format "%s9" (substring thing
0 -
1))))
367 (set-window-configuration savewin
)
368 (error "Can't find `%s' in %s" thing where
)))
370 (Info-goto-node (buffer-substring (match-beginning 1) (match-end 1))))
371 (or (let ((case-fold-search nil
))
372 (or (search-forward (format "\\[`%s'\\]\\|(`%s')\\|\\<The[ \n]`%s'"
375 (or target thing
)) nil t
)
377 (let ((case-fold-search t
))
378 (search-forward (or target thing
) nil t
)))
379 (search-forward (format "`%s'" (or target thing
)) nil t
)
380 (search-forward (or target thing
) nil t
)))
381 (let ((case-fold-search t
))
382 (or (search-forward (format "\\[`%s'\\]\\|(`%s')\\|\\<The[ \n]`%s'"
385 (or target thing
)) nil t
)
386 (search-forward (format "`%s'" (or target thing
)) nil t
)
387 (search-forward (or target thing
) nil t
))))
389 (message "Found `%s' in %s" thing where
)))
391 (defun calc-view-news ()
393 (let ((path load-path
))
395 (not (file-exists-p (expand-file-name "calc.el" (car path
)))))
396 (setq path
(cdr path
)))
398 (file-exists-p (expand-file-name "README" (car path
))))
399 (error "Can't locate Calc sources"))
401 (switch-to-buffer "*Help*")
403 (insert-file-contents (expand-file-name "README" (car path
)))
404 (search-forward "Summary of changes")
406 (delete-region (point-min) (point))
407 (goto-char (point-min))))
409 (defun calc-full-help ()
411 (with-output-to-temp-buffer "*Help*"
412 (princ (format "GNU Emacs Calculator version %s of %s.\n"
413 calc-version calc-version-date
))
414 (princ " By Dave Gillespie, daveg@synaptics.com.\n")
415 (princ " Copyright (C) 1990, 1993 Free Software Foundation, Inc.\n\n")
416 (princ "Type `h s' for a more detailed summary.\n")
417 (princ "Or type `h i' to read the full Calc manual on-line.\n\n")
418 (princ "Basic keys:\n")
419 (let* ((calc-full-help-flag t
))
420 (mapcar (function (lambda (x) (princ (format " %s\n" x
))))
421 (nreverse (cdr (reverse (cdr (calc-help))))))
422 (mapcar (function (lambda (prefix)
423 (let ((msgs (condition-case err
428 (if (eq (nth 2 msgs
) ?v
)
429 "\n`v' or `V' prefix (vector/matrix) keys: \n"
432 "\n`%c' prefix (%s) keys:\n"
434 (or (cdr (assq (nth 2 msgs
)
435 calc-help-long-names
))
437 (format "\n%s-modified keys:\n"
438 (capitalize (nth 1 msgs
)))))))
439 (mapcar (function (lambda (x)
440 (princ (format " %s\n" x
))))
442 '(calc-inverse-prefix-help
443 calc-hyperbolic-prefix-help
444 calc-inv-hyp-prefix-help
460 calc-shift-Y-prefix-help
461 calc-shift-Z-prefix-help
462 calc-z-prefix-help
)))
463 (print-help-return-message)))
465 (defvar calc-help-long-names
'((?b .
"binary/business")
468 (?k .
"combinatorics/statistics")
469 (?u .
"units/statistics")))
471 (defun calc-h-prefix-help ()
474 '("Help; Bindings; Info, Tutorial, Summary; News"
475 "describe: Key, C (briefly), Function, Variable")
478 (defun calc-inverse-prefix-help ()
481 '("I + S (arcsin), C (arccos), T (arctan); Q (square)"
482 "I + E (ln), L (exp), B (alog: B^X); f E (lnp1), f L (expm1)"
483 "I + F (ceiling), R (truncate); a S (invert func)"
484 "I + a m (match-not); c h (from-hms); k n (prev prime)"
485 "I + f G (gamma-Q); f e (erfc); k B (etc., lower-tail dists)"
486 "I + V S (reverse sort); V G (reverse grade)"
487 "I + v s (remove subvec); v h (tail)"
488 "I + t + (alt sum), t M (mean with error)"
489 "I + t S (pop std dev), t C (pop covar)")
492 (defun calc-hyperbolic-prefix-help ()
495 '("H + S (sinh), C (cosh), T (tanh); E (exp10), L (log10)"
496 "H + F (float floor), R (float round); P (constant \"e\")"
497 "H + a d (total derivative); k c (permutations)"
498 "H + k b (bern-poly), k e (euler-poly); k s (stirling-2)"
499 "H + f G (gamma-g), f B (beta-B); v h (rhead), v k (rcons)"
500 "H + v e (expand w/filler); V H (weighted histogram)"
501 "H + a S (general solve eqn), j I (general isolate)"
502 "H + a R (widen/root), a N (widen/min), a X (widen/max)"
503 "H + t M (median), t S (variance), t C (correlation coef)"
504 "H + c f/F/c (pervasive float/frac/clean)")
507 (defun calc-inv-hyp-prefix-help ()
510 '("I H + S (arcsinh), C (arccosh), T (arctanh)"
511 "I H + E (log10), L (exp10); f G (gamma-G)"
512 "I H + F (float ceiling), R (float truncate)"
513 "I H + t S (pop variance)"
514 "I H + a S (general invert func); v h (rtail)")
515 "inverse-hyperbolic" nil
))
518 (defun calc-f-prefix-help ()
521 '("miN, maX; Hypot; Im, Re; Sign; [, ] (incr/decr)"
522 "Gamma, Beta, Erf, besselJ, besselY"
523 "SHIFT + int-sQrt; Int-log, Exp(x)-1, Ln(x+1); arcTan2"
524 "SHIFT + Abssqr; Mantissa, eXponent, Scale"
525 "SHIFT + incomplete: Gamma-P, Beta-I")
529 (defun calc-s-prefix-help ()
532 '("Store, inTo, Xchg, Unstore; Recall, 0-9; : (:=); = (=>)"
533 "Let; Copy; Declare; Insert, Perm; Edit"
534 "Negate, +, -, *, /, ^, &, |, [, ]; Map"
535 "SHIFT + Decls, GenCount, TimeZone, Holidays; IntegLimit"
536 "SHIFT + LineStyles, PointStyles, plotRejects; Units"
537 "SHIFT + Eval-, AlgSimp-, ExtSimp-, FitRules")
540 (defun calc-r-prefix-help ()
543 '("digits 0-9: recall, same as `s r 0-9'")
547 (defun calc-j-prefix-help ()
550 '("Select, Additional, Once; eVal, Formula; Rewrite"
551 "More, Less, 1-9, Next, Previous"
552 "Unselect, Clear; Display; Enable; Breakable"
553 "' (replace), ` (edit), +, -, *, /, RET (grab), DEL"
554 "SHIFT + swap: Left, Right; maybe: Select, Once"
555 "SHIFT + Commute, Merge, Distrib, jump-Eqn, Isolate"
556 "SHIFT + Negate, & (invert); Unpack")
560 (defun calc-a-prefix-help ()
563 '("Simplify, Extended-simplify, eVal; \" (exp-formula)"
564 "eXpand, Collect, Factor, Apart, Norm-rat"
565 "GCD, /, \\, % (polys); Polint"
566 "Derivative, Integral, Taylor; _ (subscr)"
567 "suBstitute; Rewrite, Match"
568 "SHIFT + Solve; Root, miN, maX; Poly-roots; Fit"
569 "SHIFT + Map; Tabulate, + (sum), * (prod); num-Integ"
570 "relations: =, # (not =), <, >, [ (< or =), ] (> or =)"
571 "logical: & (and), | (or), ! (not); : (if)"
572 "misc: { (in-set); . (rmeq)")
576 (defun calc-b-prefix-help ()
579 '("And, Or, Xor, Diff, Not; Wordsize, Clip"
580 "Lshift, Rshift, roTate; SHIFT + signed Lshift, Rshift"
581 "SHIFT + business: Pv, Npv, Fv, pMt, #pmts, raTe, Irr"
582 "SHIFT + business: Sln, sYd, Ddb; %ch")
586 (defun calc-c-prefix-help ()
589 '("Deg, Rad, HMS; Float; Polar/rect; Clean, 0-9; %"
594 (defun calc-d-prefix-help ()
597 '("Group, \",\"; Normal, Fix, Sci, Eng, \".\"; Over"
598 "Radix, Zeros, 2, 8, 0, 6; Hms; Date; Complex, I, J"
599 "Why; Line-nums, line-Breaks; <, =, > (justify); Plain"
600 "\" (strings); Truncate, [, ]; SPC (refresh), RET, @"
601 "SHIFT + language: Normal, One-line, Big, Unformatted"
602 "SHIFT + language: C, Pascal, Fortran; TeX, Eqn"
603 "SHIFT + language: Mathematica, W=Maple")
607 (defun calc-g-prefix-help ()
610 '("Fast; Add, Delete, Juggle; Plot, Clear; Quit"
611 "Header, Name, Grid, Border, Key; View-commands, X-display"
612 "x-axis: Range, Title, Log, Zero; lineStyle"
613 "SHIFT + y-axis: Range, Title, Log, Zero; pointStyle"
614 "SHIFT + Print; Device, Output-file; X-geometry"
615 "SHIFT + Num-pts; Command, Kill, View-trail"
616 "SHIFT + 3d: Fast, Add; CTRL + z-axis: Range, Title, Log")
620 (defun calc-k-prefix-help ()
623 '("GCD, LCM; Choose (binomial), Double-factorial"
624 "Random, random-Again, sHuffle"
625 "Factors, Prime-test, Next-prime, Totient, Moebius"
626 "Bernoulli, Euler, Stirling"
627 "SHIFT + Extended-gcd"
628 "SHIFT + dists: Binomial, Chi-square, F, Normal"
629 "SHIFT + dists: Poisson, student's-T")
633 (defun calc-m-prefix-help ()
636 '("Deg, Rad, HMS; Frac; Polar; Inf; Alg, Total; Symb; Vec/mat"
637 "Working; Xtensions; Mode-save"
638 "SHIFT + Shifted-prefixes, mode-Filename; Record; reCompute"
639 "SHIFT + simplify: Off, Num, Default, Bin, Alg, Ext, Units")
643 (defun calc-t-prefix-help ()
646 '("Display; Fwd, Back; Next, Prev, Here, [, ]; Yank"
647 "Search, Rev; In, Out; <, >; Kill; Marker; . (abbrev)"
648 "SHIFT + time: Now; Part; Date, Julian, Unix, Czone"
649 "SHIFT + time: newWeek, newMonth, newYear; Incmonth"
650 "SHIFT + time: +, - (business days)"
651 "digits 0-9: store-to, same as `s t 0-9'")
655 (defun calc-u-prefix-help ()
658 '("Simplify, Convert, Temperature-convert, Base-units"
659 "Autorange; Remove, eXtract; Explain; View-table; 0-9"
660 "Define, Undefine, Get-defn, Permanent"
661 "SHIFT + View-table-other-window"
662 "SHIFT + stat: Mean, G-mean, Std-dev, Covar, maX, miN"
663 "SHIFT + stat: + (sum), - (asum), * (prod), # (count)")
667 (defun calc-v-prefix-help ()
670 '("Pack, Unpack, Identity, Diagonal, indeX, Build"
671 "Row, Column, Subvector; Length; Find; Mask, Expand"
672 "Tranpose, Arrange, reVerse; Head, Kons; rNorm"
673 "SHIFT + Det, & (inverse), LUD, Trace, conJtrn, Cross"
674 "SHIFT + Sort, Grade, Histogram; cNorm"
675 "SHIFT + Apply, Map, Reduce, accUm, Inner-, Outer-prod"
676 "SHIFT + sets: V (union), ^ (intersection), - (diff)"
677 "SHIFT + sets: Xor, ~ (complement), Floor, Enum"
678 "SHIFT + sets: : (span), # (card), + (rdup)"
679 "<, =, > (justification); , (commas); [, {, ( (brackets)"
680 "} (matrix brackets); . (abbreviate); / (multi-lines)")
683 ;;; arch-tag: 2d347593-7591-449e-a64a-93dab5f2f686
684 ;;; calc-help.el ends here