diff lisp/calc/calc-help.el @ 90016:ff0e824afa37

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-57 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-594 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-598 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-599 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-600 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-602 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-603 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-604 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-609 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-611 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-614 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-615 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-42 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-43 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-44 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-46 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-47 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-48 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-49 Add {arch}/=commit-merge-make-log * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-50 {arch}/=commit-merge-make-log: Don't die if there are no ChangeLog changes
author Miles Bader <miles@gnu.org>
date Thu, 14 Oct 2004 08:50:09 +0000
parents 68c22ea6027c cadf61c7f4eb
children f3ec05478165
line wrap: on
line diff
--- a/lisp/calc/calc-help.el	Wed Oct 13 02:40:50 2004 +0000
+++ b/lisp/calc/calc-help.el	Thu Oct 14 08:50:09 2004 +0000
@@ -93,18 +93,15 @@
 
 (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)
@@ -190,13 +187,13 @@
 			     (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
@@ -299,35 +296,62 @@
 	(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)
   (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))
@@ -338,7 +362,8 @@
 				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)