]> code.delx.au - gnu-emacs/commitdiff
(calc-help-function-list, calc-help-variable-list): New variables.
authorJay Belanger <jay.p.belanger@gmail.com>
Tue, 12 Oct 2004 15:47:32 +0000 (15:47 +0000)
committerJay Belanger <jay.p.belanger@gmail.com>
Tue, 12 Oct 2004 15:47:32 +0000 (15:47 +0000)
(calc-help-index-entries): New function.

(calc-describe-function):  Use calc-help-function-list instead of
obarray for completion.

(calc-describe-variable):  Use calc-help-variable-list instead of
obarray for completion.

lisp/calc/calc-help.el

index 32f86d6f750fca1b308b0319951add2ece4b3e82..c24a13b91d7951b8959d511f7c58eeebb9ce941c 100644 (file)
@@ -296,29 +296,57 @@ C-w  Describe how there is no warranty for Calc."
        (calc-describe-thing desc "Key Index" nil
                             (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)