]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-help.el
(calc-original-buffer): Declare it.
[gnu-emacs] / lisp / calc / calc-help.el
index ad3fbe4e905f5a88b497f2c1a0c61e880b838116..a8de197fab1741a0dea11c778646036bbab01f33 100644 (file)
@@ -1,6 +1,10 @@
-;; Calculator for GNU Emacs, part II [calc-help.el]
-;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
-;; Written by Dave Gillespie, daveg@synaptics.com.
+;;; calc-help.el --- help display functions for Calc,
+
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2004
+;;           Free Software Foundation, Inc.
+
+;; Author: David Gillespie <daveg@synaptics.com>
+;; Maintainer: Jay Belanger <belanger@truman.edu>
 
 ;; This file is part of GNU Emacs.
 
@@ -19,7 +23,9 @@
 ;; file named COPYING.  Among other things, the copyright notice
 ;; and this notice must be preserved on all copies.
 
+;;; Commentary:
 
+;;; Code:
 
 ;; This file is autoloaded from calc-ext.el.
 (require 'calc-ext)
@@ -43,8 +49,7 @@
     (message "")
     (if key
        (call-interactively key)
-      (beep)))
-)
+      (beep))))
 
 (defun calc-help-for-help (arg)
   "You have typed `h', the Calc help character.  Type a Help option:
@@ -84,70 +89,56 @@ C-w  Describe how there is no warranty for Calc."
        (calc-unread-command (cdr key))
        (calc-help-prefix nil))
     (let ((calc-dispatch-help t))
-      (calc-help-prefix arg)))
-)
+      (calc-help-prefix arg))))
 
 (defun calc-describe-copying ()
   (interactive)
-  (calc-info)
-  (Info-goto-node "Copying")
-)
+  (calc-info-goto-node "Copying"))
 
 (defun calc-describe-distribution ()
   (interactive)
-  (calc-info)
-  (Info-goto-node "Reporting Bugs")
-)
+  (calc-info-goto-node "Reporting Bugs"))
 
 (defun calc-describe-no-warranty ()
   (interactive)
-  (calc-info)
-  (Info-goto-node "Copying")
+  (calc-info-goto-node "Copying")
   (let ((case-fold-search nil))
     (search-forward "     NO WARRANTY"))
   (beginning-of-line)
-  (recenter 0)
-)
+  (recenter 0))
 
 (defun calc-describe-bindings ()
   (interactive)
   (describe-bindings)
   (save-excursion
     (set-buffer "*Help*")
-    (goto-char (point-min))
-    (if (search-forward "Global bindings:" nil t)
-       (delete-region (match-beginning 0) (point-max)))
-    (goto-char (point-min))
-    (while (re-search-forward "\n[a-z] ESC" nil t)
-      (end-of-line)
-      (delete-region (match-beginning 0) (point)))
-    (goto-char (point-min))
-    (while (re-search-forward "\nESC m" nil t)
-      (end-of-line)
-      (delete-region (match-beginning 0) (point)))
-    (goto-char (point-min))
-    (while (search-forward "\n\n\n" nil t)
-      (backward-delete-char 1)
-      (backward-char 2))
-    (goto-char (point-min))
-    (while
-       (re-search-forward
-        "\n[a-z] [0-9]\\(\t\t.*\n\\)\\([a-z] [0-9]\\1\\)*[a-z] \\([0-9]\\)\\1"
-        nil t)
-      (let ((dig1 (char-after (1- (match-beginning 1))))
-           (dig2 (char-after (match-beginning 3))))
-       (delete-region (match-end 1) (match-end 0))
-       (goto-char (match-beginning 1))
-       (delete-backward-char 1)
-       (delete-char 1)
-       (insert (format "%c .. %c" (min dig1 dig2) (max dig1 dig2)))))
-    (goto-char (point-min)))
-)
+    (let ((inhibit-read-only t))
+      (goto-char (point-min))
+      (when (search-forward "Major Mode Bindings:" nil t)
+        (delete-region (point-min) (point))
+        (insert "Calc Mode Bindings:"))
+      (when (search-forward "Global bindings:" nil t)
+        (forward-line -1)
+        (delete-region (point) (point-max)))
+      (goto-char (point-min))
+      (while
+          (re-search-forward
+           "\n[a-z] [0-9]\\( .*\n\\)\\([a-z] [0-9]\\1\\)*[a-z] \\([0-9]\\)\\1"
+           nil t)
+        (let ((dig1 (char-after (1- (match-beginning 1))))
+              (dig2 (char-after (match-beginning 3))))
+          (delete-region (match-end 1) (match-end 0))
+          (goto-char (match-beginning 1))
+          (delete-backward-char 1)
+          (delete-char 5)
+          (insert (format "%c .. %c" (min dig1 dig2) (max dig1 dig2)))))
+      (goto-char (point-min)))))
 
 (defun calc-describe-key-briefly (key)
   (interactive "kDescribe key briefly: ")
-  (calc-describe-key key t)
-)
+  (calc-describe-key key t))
+
+(defvar Info-history)
 
 (defun calc-describe-key (key &optional briefly)
   (interactive "kDescribe key: ")
@@ -167,7 +158,8 @@ C-w  Describe how there is no warranty for Calc."
                      (lookup-key calc-help-map key2))
                  (key-binding key))))
        (inv nil)
-       (hyp nil))
+       (hyp nil)
+        calc-summary-indentation)
     (while (or (equal key "I") (equal key "H"))
       (if (equal key "I")
          (setq inv (not inv))
@@ -191,13 +183,13 @@ C-w  Describe how there is no warranty for Calc."
                             (message "Reading Calc summary from manual...")
                             (save-window-excursion
                               (save-excursion
-                                (calc-info)
-                                (Info-goto-node "Summary")
+                                (calc-info-goto-node "Summary")
                                 (goto-char (point-min))
                                 (forward-line 1)
                                 (copy-to-buffer "*Calc Summary*"
                                                 (point) (point-max))
-                                (Info-last)))
+                                 (if Info-history
+                                     (Info-last))))
                             (setq case-fold-search nil)
                             (re-search-forward "^\\(.*\\)\\[\\.\\. a b")
                             (setq calc-summary-indentation
@@ -298,40 +290,64 @@ C-w  Describe how there is no warranty for Calc."
        (if inv (setq desc (concat "I " desc)))
        (if hyp (setq desc (concat "H " desc)))
        (calc-describe-thing desc "Key Index" nil
-                            (string-match "[A-Z][A-Z][A-Z]" desc)))))
-)
+                            (string-match "[A-Z][A-Z][A-Z]" desc))))))
+
+(defvar calc-help-function-list nil
+  "List of functions provided by Calc.")
+
+(defvar calc-help-variable-list nil
+  "List of variables provided by Calc.")
+
+(defun calc-help-index-entries (&rest indices)
+  "Create a list of entries from the INDICES in the Calc info manual."
+  (let ((entrylist '())
+        entry)
+    (require 'info nil t)
+    (while indices
+      (condition-case nil
+          (with-temp-buffer
+            (Info-mode)
+            (Info-goto-node (concat "(Calc)" (car indices) " Index"))
+            (goto-char (point-min))
+            (while (re-search-forward "\n\\* \\(.*\\): " nil t)
+              (setq entry (match-string 1))
+              (if (and (not (string-match "<[1-9]+>" entry))
+                       (not (string-match "(.*)" entry))
+                       (not (string= entry "Menu")))
+                  (unless (assoc entry entrylist)
+                    (setq entrylist (cons entry entrylist))))))
+        (error nil))
+      (setq indices (cdr indices)))
+    entrylist))
 
 (defun calc-describe-function (&optional func)
   (interactive)
+  (unless calc-help-function-list
+    (setq calc-help-function-list 
+          (calc-help-index-entries "Function" "Command")))
   (or func
-      (setq func (intern (completing-read "Describe function: "
-                                         obarray nil t "calcFunc-"))))
-  (setq func (symbol-name func))
+      (setq func (completing-read "Describe function: "
+                                  calc-help-function-list 
+                                  nil t)))
   (if (string-match "\\`calc-." func)
       (calc-describe-thing func "Command Index")
-    (calc-describe-thing (if (string-match "\\`calcFunc-." func)
-                            (substring func 9)
-                          func)
-                        "Function Index"))
-)
+    (calc-describe-thing func "Function Index")))
 
 (defun calc-describe-variable (&optional var)
   (interactive)
+  (unless calc-help-variable-list
+    (setq calc-help-variable-list 
+          (calc-help-index-entries "Variable")))
   (or var
-      (setq var (intern (completing-read "Describe variable: "
-                                        obarray nil t "var-"))))
-  (setq var (symbol-name var))
-  (calc-describe-thing var "Variable Index"
-                      (if (string-match "\\`var-." var)
-                          (substring var 4)
-                        var))
-)
+      (setq var (completing-read "Describe variable: "
+                                 calc-help-variable-list
+                                 nil t)))
+  (calc-describe-thing var "Variable Index"))
 
 (defun calc-describe-thing (thing where &optional target not-quoted)
   (message "Looking for `%s' in %s..." thing where)
   (let ((savewin (current-window-configuration)))
-    (calc-info)
-    (Info-goto-node where)
+    (calc-info-goto-node where)
     (or (let ((case-fold-search nil))
          (re-search-forward (format "\n\\* +%s: \\(.*\\)\\."
                                     (regexp-quote thing))
@@ -342,7 +358,8 @@ C-w  Describe how there is no warranty for Calc."
                                nil t)
             (setq thing (format "%s9" (substring thing 0 -1))))
        (progn
-         (Info-last)
+          (if Info-history
+              (Info-last))
          (set-window-configuration savewin)
          (error "Can't find `%s' in %s" thing where)))
     (let (Info-history)
@@ -365,8 +382,7 @@ C-w  Describe how there is no warranty for Calc."
              (search-forward (format "`%s'" (or target thing)) nil t)
              (search-forward (or target thing) nil t))))
     (beginning-of-line)
-    (message "Found `%s' in %s" thing where))
-)
+    (message "Found `%s' in %s" thing where)))
 
 (defun calc-view-news ()
   (interactive)
@@ -384,10 +400,13 @@ C-w  Describe how there is no warranty for Calc."
     (search-forward "Summary of changes")
     (forward-line -1)
     (delete-region (point-min) (point))
-    (goto-char (point-min)))
-)
-
+    (goto-char (point-min))))
 
+(defvar calc-help-long-names '((?b . "binary/business")
+                              (?g . "graphics")
+                              (?j . "selection")
+                              (?k . "combinatorics/statistics")
+                              (?u . "units/statistics")))
 
 (defun calc-full-help ()
   (interactive)
@@ -395,7 +414,6 @@ C-w  Describe how there is no warranty for Calc."
     (princ (format "GNU Emacs Calculator version %s of %s.\n"
                   calc-version calc-version-date))
     (princ "  By Dave Gillespie, daveg@synaptics.com.\n")
-    (princ (format "  Installed %s.\n" calc-installed-date))
     (princ "  Copyright (C) 1990, 1993 Free Software Foundation, Inc.\n\n")
     (princ "Type `h s' for a more detailed summary.\n")
     (princ "Or type `h i' to read the full Calc manual on-line.\n\n")
@@ -444,23 +462,14 @@ C-w  Describe how there is no warranty for Calc."
                calc-shift-Y-prefix-help
                calc-shift-Z-prefix-help
                calc-z-prefix-help)))
-    (print-help-return-message))
-)
-
-(defvar calc-help-long-names '( ( ?b . "binary/business" )
-                               ( ?g . "graphics" )
-                               ( ?j . "selection" )
-                               ( ?k . "combinatorics/statistics" )
-                               ( ?u . "units/statistics" )
-))
+    (print-help-return-message)))
 
 (defun calc-h-prefix-help ()
   (interactive)
   (calc-do-prefix-help
    '("Help; Bindings; Info, Tutorial, Summary; News"
      "describe: Key, C (briefly), Function, Variable")
-   "help" ?h)
-)
+   "help" ?h))
 
 (defun calc-inverse-prefix-help ()
   (interactive)
@@ -474,8 +483,7 @@ C-w  Describe how there is no warranty for Calc."
      "I + v s (remove subvec); v h (tail)"
      "I + t + (alt sum), t M (mean with error)"
      "I + t S (pop std dev), t C (pop covar)")
-   "inverse" nil)
-)
+   "inverse" nil))
 
 (defun calc-hyperbolic-prefix-help ()
   (interactive)
@@ -490,8 +498,7 @@ C-w  Describe how there is no warranty for Calc."
      "H + a R (widen/root), a N (widen/min), a X (widen/max)"
      "H + t M (median), t S (variance), t C (correlation coef)"
      "H + c f/F/c (pervasive float/frac/clean)")
-   "hyperbolic" nil)
-)
+   "hyperbolic" nil))
 
 (defun calc-inv-hyp-prefix-help ()
   (interactive)
@@ -501,8 +508,7 @@ C-w  Describe how there is no warranty for Calc."
      "I H + F (float ceiling), R (float truncate)"
      "I H + t S (pop variance)"
      "I H + a S (general invert func); v h (rtail)")
-   "inverse-hyperbolic" nil)
-)
+   "inverse-hyperbolic" nil))
 
 
 (defun calc-f-prefix-help ()
@@ -513,8 +519,7 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + int-sQrt; Int-log, Exp(x)-1, Ln(x+1); arcTan2"
      "SHIFT + Abssqr; Mantissa, eXponent, Scale"
      "SHIFT + incomplete: Gamma-P, Beta-I")
-   "functions" ?f)
-)
+   "functions" ?f))
 
 
 (defun calc-s-prefix-help ()
@@ -526,15 +531,13 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + Decls, GenCount, TimeZone, Holidays; IntegLimit"
      "SHIFT + LineStyles, PointStyles, plotRejects; Units"
      "SHIFT + Eval-, AlgSimp-, ExtSimp-, FitRules")
-   "store" ?s)
-)
+   "store" ?s))
 
 (defun calc-r-prefix-help ()
   (interactive)
   (calc-do-prefix-help
    '("digits 0-9: recall, same as `s r 0-9'")
-   "recall" ?r)
-)
+   "recall" ?r))
 
 
 (defun calc-j-prefix-help ()
@@ -547,8 +550,7 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + swap: Left, Right; maybe: Select, Once"
      "SHIFT + Commute, Merge, Distrib, jump-Eqn, Isolate"
      "SHIFT + Negate, & (invert); Unpack")
-   "select" ?j)
-)
+   "select" ?j))
 
 
 (defun calc-a-prefix-help ()
@@ -564,8 +566,7 @@ C-w  Describe how there is no warranty for Calc."
      "relations: =, # (not =), <, >, [ (< or =), ] (> or =)"
      "logical: & (and), | (or), ! (not); : (if)"
      "misc: { (in-set); . (rmeq)")
-   "algebra" ?a)
-)
+   "algebra" ?a))
 
 
 (defun calc-b-prefix-help ()
@@ -575,8 +576,7 @@ C-w  Describe how there is no warranty for Calc."
      "Lshift, Rshift, roTate; SHIFT + signed Lshift, Rshift"
      "SHIFT + business: Pv, Npv, Fv, pMt, #pmts, raTe, Irr"
      "SHIFT + business: Sln, sYd, Ddb; %ch")
-   "binary/bus" ?b)
-)
+   "binary/bus" ?b))
 
 
 (defun calc-c-prefix-help ()
@@ -584,8 +584,7 @@ C-w  Describe how there is no warranty for Calc."
   (calc-do-prefix-help
    '("Deg, Rad, HMS; Float; Polar/rect; Clean, 0-9; %"
      "SHIFT + Fraction")
-   "convert" ?c)
-)
+   "convert" ?c))
 
 
 (defun calc-d-prefix-help ()
@@ -594,12 +593,11 @@ C-w  Describe how there is no warranty for Calc."
    '("Group, \",\"; Normal, Fix, Sci, Eng, \".\"; Over"
      "Radix, Zeros, 2, 8, 0, 6; Hms; Date; Complex, I, J"
      "Why; Line-nums, line-Breaks; <, =, > (justify); Plain"
-     "\" (strings); Truncate, [, ]; SPC (refresh), RET"
+     "\" (strings); Truncate, [, ]; SPC (refresh), RET, @"
      "SHIFT + language: Normal, One-line, Big, Unformatted"
      "SHIFT + language: C, Pascal, Fortran; TeX, Eqn"
      "SHIFT + language: Mathematica, W=Maple")
-   "display" ?d)
-)
+   "display" ?d))
 
 
 (defun calc-g-prefix-help ()
@@ -612,8 +610,7 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + Print; Device, Output-file; X-geometry"
      "SHIFT + Num-pts; Command, Kill, View-trail"
      "SHIFT + 3d: Fast, Add; CTRL + z-axis: Range, Title, Log")
-   "graph" ?g)
-)
+   "graph" ?g))
 
 
 (defun calc-k-prefix-help ()
@@ -626,8 +623,7 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + Extended-gcd"
      "SHIFT + dists: Binomial, Chi-square, F, Normal"
      "SHIFT + dists: Poisson, student's-T")
-   "combinatorics" ?k)
-)
+   "combinatorics" ?k))
 
 
 (defun calc-m-prefix-help ()
@@ -637,8 +633,7 @@ C-w  Describe how there is no warranty for Calc."
      "Working; Xtensions; Mode-save"
      "SHIFT + Shifted-prefixes, mode-Filename; Record; reCompute"
      "SHIFT + simplify: Off, Num, Default, Bin, Alg, Ext, Units")
-   "mode" ?m)
-)
+   "mode" ?m))
 
 
 (defun calc-t-prefix-help ()
@@ -650,8 +645,7 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + time: newWeek, newMonth, newYear; Incmonth"
      "SHIFT + time: +, - (business days)"
      "digits 0-9: store-to, same as `s t 0-9'")
-   "trail/time" ?t)
-)
+   "trail/time" ?t))
 
 
 (defun calc-u-prefix-help ()
@@ -663,8 +657,7 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + View-table-other-window"
      "SHIFT + stat: Mean, G-mean, Std-dev, Covar, maX, miN"
      "SHIFT + stat: + (sum), - (asum), * (prod), # (count)")
-   "units/stat" ?u)
-)
+   "units/stat" ?u))
 
 
 (defun calc-v-prefix-help ()
@@ -681,6 +674,7 @@ C-w  Describe how there is no warranty for Calc."
      "SHIFT + sets: : (span), # (card), + (rdup)"
      "<, =, > (justification); , (commas); [, {, ( (brackets)"
      "} (matrix brackets); . (abbreviate); / (multi-lines)")
-   "vec/mat" ?v)
-)
+   "vec/mat" ?v))
 
+;; arch-tag: 2d347593-7591-449e-a64a-93dab5f2f686
+;;; calc-help.el ends here