]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-misc.el
(ido-enable-prefix): Improve previous doc fix.
[gnu-emacs] / lisp / calc / calc-misc.el
index 1e4d376f6439ae3324925b8f2f1cf6906ad1cd89..14bf3908b83e2e4b6cb198dec6234ef704657f51 100644 (file)
@@ -1,6 +1,10 @@
-;; Calculator for GNU Emacs, part I [calc-misc.el]
-;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
-;; Written by Dave Gillespie, daveg@synaptics.com.
+;;; calc-misc.el --- miscellaneous functions for Calc
+
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004
+;;   2005, 2006 Free Software Foundation, Inc.
+
+;; Author: David Gillespie <daveg@synaptics.com>
+;; Maintainer: Jay Belanger <belanger@truman.edu>
 
 ;; This file is part of GNU Emacs.
 
 ;; 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.el.
-(require 'calc)
 
+(require 'calc)
 (require 'calc-macs)
 
-(defun calc-Need-calc-misc () nil)
-
-
 (defun calc-dispatch-help (arg)
-  "M-# is a prefix key; follow it with one of these letters:
+  "C-x* is a prefix key sequence; follow it with one of these letters:
 
 For turning Calc on and off:
   C  calc.  Start the Calculator in a window at the bottom of the screen.
@@ -70,8 +73,9 @@ Miscellaneous:
   M  read-kbd-macro.  Read a region of keystroke names as a keyboard macro.
   0  (zero) calc-reset.  Reset Calc stack and modes to default state.
 
-Press twice (`M-# M-#' or `M-# #') to turn Calc on or off using the same
-Calc user interface as before (either M-# C or M-# K; initially M-# C)."
+Press `*' twice (`C-x * *') to turn Calc on or off using the same
+Calc user interface as before (either C-x * C or C-x * K; initially C-x * C).
+"
   (interactive "P")
   (calc-check-defines)
   (if calc-dispatch-help
@@ -95,8 +99,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
                      (calc-unread-command (cdr key))))))
        (calc-do-dispatch nil))
     (let ((calc-dispatch-help t))
-      (calc-do-dispatch arg)))
-)
+      (calc-do-dispatch arg))))
 
 
 (defun calc-big-or-small (arg)
@@ -108,8 +111,8 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
     (if cwin
        (setq calc-full-mode
              (if kwin
-                 (and twin (eq (window-width twin) (screen-width)))
-               (eq (window-height cwin) (1- (screen-height))))))
+                 (and twin (eq (window-width twin) (frame-width)))
+               (eq (window-height cwin) (1- (frame-height))))))
     (setq calc-full-mode (if arg
                             (> (prefix-numeric-value arg) 0)
                           (not calc-full-mode)))
@@ -122,13 +125,12 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
            (calc-quit)
            (calc nil calc-full-mode nil))))
     (message (if calc-full-mode
-                "Now using full screen for Calc."
-              "Now using partial screen for Calc.")))
-)
+                "Now using full screen for Calc"
+              "Now using partial screen for Calc"))))
 
-(defun calc-other-window ()
+(defun calc-other-window (&optional interactive)
   "Invoke the Calculator in another window."
-  (interactive)
+  (interactive "p")
   (if (memq major-mode '(calc-mode calc-trail-mode))
       (progn
        (other-window 1)
@@ -137,8 +139,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
     (if (get-buffer-window "*Calculator*")
        (calc-quit)
       (let ((win (selected-window)))
-       (calc nil win (interactive-p)))))
-)
+       (calc nil win interactive)))))
 
 (defun another-calc ()
   "Create another, independent Calculator buffer."
@@ -149,118 +150,33 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
                 (set-default v (symbol-value v)))) calc-local-var-list))
   (set-buffer (generate-new-buffer "*Calculator*"))
   (pop-to-buffer (current-buffer))
-  (calc-mode)
-)
-
-
-;;; Make an attempt to preserve the window configuration, while deleting
-;;; windows on "bufs".  Emacs 19's delete-window function will probably
-;;; make this kludgery unnecessary, but Emacs 18's tendency to grow all
-;;; windows on the screen to take up the slack from the deleted windows
-;;; can be annoying when Calc was called during another multi-window
-;;; application, such as GNUS.
-
-(defun calc-delete-windows-keep (&rest bufs)
-  (if (one-window-p)
-      (mapcar 'delete-windows-on bufs)
-    (let* ((w (car calc-was-split))
-          (e (window-edges w))
-          (wins nil)
-          w2 e2)
-      (while (progn
-              (setq w2 (previous-window w)
-                    e2 (window-edges w2))
-              (and (= (car e2) (car e))
-                   (= (nth 2 e2) (nth 2 e))
-                   (< (nth 1 e2) (nth 1 e))))
-       (setq w w2 e e2))
-      (setq w2 w e2 e)
-      (while (progn
-              (setq wins (cons (list w (nth 1 e) (window-buffer w)
-                                     (window-point w) (window-start w))
-                               wins)
-                    w (next-window w)
-                    e (window-edges w))
-              (and (not (eq w w2))
-                   (= (car e2) (car e))
-                   (= (nth 2 e2) (nth 2 e)))))
-      (setq wins (nreverse wins))
-      (mapcar 'delete-windows-on bufs)
-      (or (one-window-p)
-         (let ((w wins)
-               (main nil)
-               (mainpos 0)
-               (sel (if (window-point (nth 2 calc-was-split))
-                        (nth 2 calc-was-split)
-                      (selected-window))))
-           (while w
-             (if (window-point (car (car w)))
-                 (if main
-                     (delete-window (car (car w)))
-                   (setq main (car (car w))
-                         mainpos (nth 1 (car w))
-                         wins (cdr wins)))
-               (setq wins (delq (car w) wins)))
-             (setq w (cdr w)))
-           (while wins
-             (setq w (split-window main
-                                   (if (eq main (car calc-was-split))
-                                       (nth 1 calc-was-split)
-                                     (- (nth 1 (car wins)) mainpos))))
-             (set-window-buffer w (nth 2 (car wins)))
-             (set-window-point w (nth 3 (car wins)))
-             (set-window-start w (nth 4 (car wins)))
-             (if (eq sel (car (car wins)))
-                 (select-window w))
-             (setq main w
-                   mainpos (nth 1 (car wins))
-                   wins (cdr wins)))
-           (if (window-point sel)
-               (select-window sel))))))
-)
-
+  (calc-mode))
 
 (defun calc-info ()
   "Run the Emacs Info system on the Calculator documentation."
   (interactive)
-  (require 'info)
   (select-window (get-largest-window))
-  (or (file-name-absolute-p calc-info-filename)
-       (let ((p load-path)
-            name)
-        (if (boundp 'Info-directory)
-            (setq p (cons Info-directory p)))
-        (while (and p (not (file-exists-p
-                            (setq name (expand-file-name calc-info-filename
-                                                         (car p))))))
-          (setq p (cdr p)))
-        (if p (setq calc-info-filename name))))
-  (condition-case err
-      (info)
-    (error nil))
-  (or (and (boundp 'Info-current-file)
-          (stringp Info-current-file)
-          (string-match "calc" Info-current-file))
-      (Info-find-node calc-info-filename "Top"))
-)
+  (info "Calc"))
+
+(defun calc-info-goto-node (node)
+  "Go to a node in the Calculator info documentation."
+  (interactive)
+  (select-window (get-largest-window))
+  (info (concat "(Calc)" node)))
 
 (defun calc-tutorial ()
   "Run the Emacs Info system on the Calculator Tutorial."
   (interactive)
   (if (get-buffer-window "*Calculator*")
       (calc-quit))
-  (calc-info)
-  (Info-goto-node "Interactive Tutorial")
+  (calc-info-goto-node "Interactive Tutorial")
   (calc-other-window)
-  (message "Welcome to the Calc Tutorial!")
-)
+  (message "Welcome to the Calc Tutorial!"))
 
 (defun calc-info-summary ()
   "Run the Emacs Info system on the Calculator Summary."
   (interactive)
-  (calc-info)
-  (Info-goto-node "Summary")
-)
+  (calc-info-goto-node "Summary"))
 
 (defun calc-help ()
   (interactive)
@@ -307,14 +223,16 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
                                                                   msgs))
                                                    (length msg)) 32)
                                    "  [?=MORE]")
-                         ""))))))
-)
+                         "")))))))
 
 
 
 
 ;;;; Stack and buffer management.
 
+;; The variable calc-last-why-command is set in calc-do-handly-whys
+;; and used in calc-why (in calc-stuff.el).
+(defvar calc-last-why-command)
 
 (defun calc-do-handle-whys ()
   (setq calc-why (sort calc-next-why
@@ -326,15 +244,14 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
                        (and (eq (car (car calc-why)) '*)
                             calc-auto-why)))
       (progn
-       (calc-extensions)
+       (require 'calc-ext)
        (calc-explain-why (car calc-why)
                          (if (eq calc-auto-why t)
                              (cdr calc-why)
                            (if calc-auto-why
                                (eq (car (nth 1 calc-why)) '*))))
        (setq calc-last-why-command this-command)
-       (calc-clear-command-flag 'clear-message)))
-)
+       (calc-clear-command-flag 'clear-message))))
 
 (defun calc-record-why (&rest stuff)
   (if (eq (car stuff) 'quiet)
@@ -351,8 +268,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
          (setq stuff (cons '* (cons (substring (car stuff) 1)
                                     (cdr stuff)))))))
   (setq calc-next-why (cons stuff calc-next-why))
-  nil
-)
+  nil)
 
 ;;; True if A is a constant or vector of constants.  [P x] [Public]
 (defun math-constp (a)
@@ -362,8 +278,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
             (while (and (setq a (cdr a))
                         (or (Math-scalarp (car a))  ; optimization
                             (math-constp (car a)))))
-            (null a))))
-)
+            (null a)))))
 
 
 (defun calc-roll-down-stack (n &optional m)
@@ -378,8 +293,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
             (calc-roll-down-with-selections n m)
           (calc-pop-push-list n
                               (append (calc-top-list m 1)
-                                      (calc-top-list (- n m) (1+ m)))))))
-)
+                                      (calc-top-list (- n m) (1+ m))))))))
 
 (defun calc-roll-up-stack (n &optional m)
   (if (< n 0)
@@ -393,8 +307,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
             (calc-roll-up-with-selections n m)
           (calc-pop-push-list n
                               (append (calc-top-list (- n m) 1)
-                                      (calc-top-list m (- n m -1)))))))
-)
+                                      (calc-top-list m (- n m -1))))))))
 
 
 (defun calc-do-refresh ()
@@ -403,8 +316,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
        (setq calc-display-dirty t)
        nil)
     (calc-refresh)
-    t)
-)
+    t))
 
 
 (defun calc-record-list (vals &optional prefix)
@@ -413,60 +325,52 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
        (progn
          (calc-record (car vals) prefix)
          (setq prefix "...")))
-    (setq vals (cdr vals)))
-)
+    (setq vals (cdr vals))))
 
 
 (defun calc-last-args-stub (arg)
   (interactive "p")
-  (calc-extensions)
-  (calc-last-args arg)
-)
+  (require 'calc-ext)
+  (calc-last-args arg))
 
 
 (defun calc-power (arg)
   (interactive "P")
   (calc-slow-wrapper
-   (if (and calc-extensions-loaded
+   (if (and (featurep 'calc-ext)
            (calc-is-inverse))
        (calc-binary-op "root" 'calcFunc-nroot arg nil nil)
-     (calc-binary-op "^" 'calcFunc-pow arg nil nil '^)))
-)
+     (calc-binary-op "^" 'calcFunc-pow arg nil nil '^))))
 
 (defun calc-mod (arg)
   (interactive "P")
   (calc-slow-wrapper
-   (calc-binary-op "%" 'calcFunc-mod arg nil nil '%))
-)
+   (calc-binary-op "%" 'calcFunc-mod arg nil nil '%)))
 
 (defun calc-inv (arg)
   (interactive "P")
   (calc-slow-wrapper
-   (calc-unary-op "inv" 'calcFunc-inv arg))
-)
+   (calc-unary-op "inv" 'calcFunc-inv arg)))
 
 (defun calc-percent ()
   (interactive)
   (calc-slow-wrapper
    (calc-pop-push-record-list
-    1 "%" (list (list 'calcFunc-percent (calc-top-n 1)))))
-)
+    1 "%" (list (list 'calcFunc-percent (calc-top-n 1))))))
 
 
 (defun calc-over (n)
   (interactive "P")
   (if n
       (calc-enter (- (prefix-numeric-value n)))
-    (calc-enter -2))
-)
+    (calc-enter -2)))
 
 
 (defun calc-pop-above (n)
   (interactive "P")
   (if n
       (calc-pop (- (prefix-numeric-value n)))
-    (calc-pop -2))
-)
+    (calc-pop -2)))
 
 (defun calc-roll-down (n)
   (interactive "P")
@@ -481,8 +385,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
                                (reverse
                                 (calc-top-list (calc-stack-size)))))
           (t
-           (calc-roll-down-stack (calc-stack-size) (- nn))))))
-)
+           (calc-roll-down-stack (calc-stack-size) (- nn)))))))
 
 (defun calc-roll-up (n)
   (interactive "P")
@@ -497,8 +400,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
                                (reverse
                                 (calc-top-list (calc-stack-size)))))
           (t
-           (calc-roll-up-stack (calc-stack-size) (- nn))))))
-)
+           (calc-roll-up-stack (calc-stack-size) (- nn)))))))
 
 
 
@@ -510,26 +412,23 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
        ((equal n '(4)) "C-u ")
        ((consp n) (format "%d " (car n)))
        ((integerp n) (format "%d " n))
-       (t ""))
-)
+       (t "")))
 
 (defun calc-missing-key (n)
   "This is a placeholder for a command which needs to be loaded from calc-ext.
 When this key is used, calc-ext (the Calculator extensions module) will be
 loaded and the keystroke automatically re-typed."
   (interactive "P")
-  (calc-extensions)
+  (require 'calc-ext)
   (if (keymapp (key-binding (char-to-string last-command-char)))
       (message "%s%c-" (calc-num-prefix-name n) last-command-char))
   (calc-unread-command)
-  (setq prefix-arg n)
-)
+  (setq prefix-arg n))
 
 (defun calc-shift-Y-prefix-help ()
   (interactive)
-  (calc-extensions)
-  (calc-do-prefix-help calc-Y-help-msgs "other" ?Y)
-)
+  (require 'calc-ext)
+  (calc-do-prefix-help calc-Y-help-msgs "other" ?Y))
 
 
 
@@ -540,8 +439,7 @@ loaded and the keystroke automatically re-typed."
       (progn
        (setq last-command-char (upcase last-command-char))
        (calcDigit-key))
-    (calcDigit-nondigit))
-)
+    (calcDigit-nondigit)))
 
 
 ;; A Lisp version of temp_minibuffer_message from minibuf.c.
@@ -558,8 +456,7 @@ loaded and the keystroke automatically re-typed."
            (setq okay t))
        (progn
          (delete-region savemax (point-max))
-         (or okay (abort-recursive-edit))))))
-)
+         (or okay (abort-recursive-edit)))))))
 
 
 (put 'math-with-extra-prec 'lisp-indent-hook 1)
@@ -569,7 +466,7 @@ loaded and the keystroke automatically re-typed."
 (defun math-concat (v1 v2)
   (if (stringp v1)
       (concat v1 v2)
-    (calc-extensions)
+    (require 'calc-ext)
     (if (and (or (math-objvecp v1) (math-known-scalarp v1))
             (or (math-objvecp v2) (math-known-scalarp v2)))
        (append (if (and (math-vectorp v1)
@@ -582,8 +479,7 @@ loaded and the keystroke automatically re-typed."
                             (not (math-matrixp v1))))
                    (cdr v2)
                  (list v2)))
-      (list '| v1 v2)))
-)
+      (list '| v1 v2))))
 
 
 ;;; True if A is zero.  Works for un-normalized values.  [P n] [Public]
@@ -600,8 +496,7 @@ loaded and the keystroke automatically re-typed."
             (and (math-zerop (nth 1 a))
                  (math-zerop (nth 2 a))
                  (math-zerop (nth 3 a)))))
-    (eq a 0))
-)
+    (eq a 0)))
 
 
 ;;; True if A is real and negative.  [P n] [Public]
@@ -625,8 +520,7 @@ loaded and the keystroke automatically re-typed."
                 (and (math-zerop (nth 3 a))
                      (memq (nth 1 a) '(0 2)))))
            ((equal a '(neg (var inf var-inf))) t))
-    (< a 0))
-)
+    (< a 0)))
 
 ;;; True if A is a negative number or an expression the starts with '-'.
 (defun math-looks-negp (a)   ; [P x] [Public]
@@ -636,8 +530,7 @@ loaded and the keystroke automatically re-typed."
           (or (math-looks-negp (nth 1 a))
               (math-looks-negp (nth 2 a))))
       (and (eq (car-safe a) '-)
-          (math-looks-negp (nth 1 a))))
-)
+          (math-looks-negp (nth 1 a)))))
 
 
 ;;; True if A is real and positive.  [P n] [Public]
@@ -662,11 +555,10 @@ loaded and the keystroke automatically re-typed."
                 (and (math-zerop (nth 2 a))
                      (memq (nth 1 a) '(0 1)))))
            ((equal a '(var inf var-inf)) t))
-    (> a 0))
-)
+    (> a 0)))
 
-(fset 'math-fixnump (symbol-function 'integerp))
-(fset 'math-fixnatnump (symbol-function 'natnump))
+(defalias 'math-fixnump 'integerp)
+(defalias 'math-fixnatnump 'natnump)
 
 
 ;;; True if A is an even integer.  [P R R] [Public]
@@ -674,8 +566,7 @@ loaded and the keystroke automatically re-typed."
   (if (consp a)
       (and (memq (car a) '(bigpos bigneg))
           (= (% (nth 1 a) 2) 0))
-    (= (% a 2) 0))
-)
+    (= (% a 2) 0)))
 
 ;;; Compute A / 2, for small or big integer A.  [I i]
 ;;; If A is negative, type of truncation is undefined.
@@ -684,15 +575,13 @@ loaded and the keystroke automatically re-typed."
       (if (cdr a)
          (math-normalize (cons (car a) (math-div2-bignum (cdr a))))
        0)
-    (/ a 2))
-)
+    (/ a 2)))
 
 (defun math-div2-bignum (a)   ; [l l]
   (if (cdr a)
       (cons (+ (/ (car a) 2) (* (% (nth 1 a) 2) 500))
            (math-div2-bignum (cdr a)))
-    (list (/ (car a) 2)))
-)
+    (list (/ (car a) 2))))
 
 
 ;;; Reject an argument to a calculator function.  [Public]
@@ -701,40 +590,45 @@ loaded and the keystroke automatically re-typed."
       (calc-record-why option p a)
     (if p
        (calc-record-why p a)))
-  (signal 'wrong-type-argument (and a (if p (list p a) (list a))))
-)
+  (signal 'wrong-type-argument (and a (if p (list p a) (list a)))))
 
 
 ;;; Coerce A to be an integer (by truncation toward zero).  [I N] [Public]
-(defun math-trunc (a &optional prec)
-  (cond (prec
-        (calc-extensions)
-        (math-trunc-special a prec))
+
+;; The variable math-trunc-prec is local to math-trunc, but used by
+;; math-trunc-fancy in calc-arith.el, which is called by math-trunc.
+
+(defun math-trunc (a &optional math-trunc-prec)
+  (cond (math-trunc-prec
+        (require 'calc-ext)
+        (math-trunc-special a math-trunc-prec))
        ((Math-integerp a) a)
        ((Math-looks-negp a)
         (math-neg (math-trunc (math-neg a))))
        ((eq (car a) 'float)
         (math-scale-int (nth 1 a) (nth 2 a)))
-       (t (calc-extensions)
-          (math-trunc-fancy a)))
-)
-(fset 'calcFunc-trunc (symbol-function 'math-trunc))
+       (t (require 'calc-ext)
+          (math-trunc-fancy a))))
+(defalias 'calcFunc-trunc 'math-trunc)
 
 ;;; Coerce A to be an integer (by truncation toward minus infinity).  [I N]
-(defun math-floor (a &optional prec)    ;  [Public]
-  (cond (prec
-        (calc-extensions)
-        (math-floor-special a prec))
+
+;; The variable math-floor-prec is local to math-floor, but used by
+;; math-floor-fancy in calc-arith.el, which is called by math-floor.
+
+(defun math-floor (a &optional math-floor-prec)    ;  [Public]
+  (cond (math-floor-prec
+        (require 'calc-ext)
+        (math-floor-special a math-floor-prec))
        ((Math-integerp a) a)
        ((Math-messy-integerp a) (math-trunc a))
        ((Math-realp a)
         (if (Math-negp a)
             (math-add (math-trunc a) -1)
           (math-trunc a)))
-       (t (calc-extensions)
-          (math-floor-fancy a)))
-)
-(fset 'calcFunc-floor (symbol-function 'math-floor))
+       (t (require 'calc-ext)
+          (math-floor-fancy a))))
+(defalias 'calcFunc-floor 'math-floor)
 
 
 (defun math-imod (a b)   ; [I I I] [Public]
@@ -742,24 +636,25 @@ loaded and the keystroke automatically re-typed."
       (if (= b 0)
          (math-reject-arg a "*Division by zero")
        (% a b))
-    (cdr (math-idivmod a b)))
-)
+    (cdr (math-idivmod a b))))
 
 
 (defun calcFunc-inv (m)
   (if (Math-vectorp m)
       (progn
-       (calc-extensions)
+       (require 'calc-ext)
        (if (math-square-matrixp m)
            (or (math-with-extra-prec 2 (math-matrix-inv-raw m))
                (math-reject-arg m "*Singular matrix"))
          (math-reject-arg m 'square-matrixp)))
-    (math-div 1 m))
-)
-
+    (if (and
+         (require 'calc-arith)
+         (math-known-matrixp m))
+        (math-pow m -1)
+      (math-div 1 m))))
 
 (defun math-do-working (msg arg)
-  (or executing-macro
+  (or executing-kbd-macro
       (progn
        (calc-set-command-flag 'clear-message)
        (if math-working-step
@@ -768,8 +663,7 @@ loaded and the keystroke automatically re-typed."
                                  math-working-step math-working-step-2 msg))
              (setq msg (format "[%d] %s" math-working-step msg))))
        (message "Working... %s = %s" msg
-                (math-showing-full-precision (math-format-number arg)))))
-)
+                (math-showing-full-precision (math-format-number arg))))))
 
 
 ;;; Compute A modulo B, defined in terms of truncation toward minus infinity.
@@ -781,9 +675,8 @@ loaded and the keystroke automatically re-typed."
         (math-imod a b))
        ((and (Math-anglep a) (Math-anglep b))
         (math-sub a (math-mul (math-floor (math-div a b)) b)))
-       (t (calc-extensions)
-          (math-mod-fancy a b)))
-)
+       (t (require 'calc-ext)
+          (math-mod-fancy a b))))
 
 
 
@@ -795,7 +688,7 @@ loaded and the keystroke automatically re-typed."
        ((Math-zerop a)
         (if (and (Math-scalarp b) (Math-posp b))
             (if (math-floatp b) (math-float a) a)
-          (calc-extensions)
+          (require 'calc-ext)
           (math-pow-of-zero a b)))
        ((or (eq a 1) (eq b 1)) a)
        ((or (equal a '(float 1 0)) (equal b '(float 1 0))) a)
@@ -803,7 +696,7 @@ loaded and the keystroke automatically re-typed."
         (if (Math-scalarp a)
             (if (or (math-floatp a) (math-floatp b))
                 '(float 1 0) 1)
-          (calc-extensions)
+          (require 'calc-ext)
           (math-pow-zero a b)))
        ((and (Math-integerp b) (or (Math-numberp a) (Math-vectorp a)))
         (if (and (equal a '(float 1 1)) (integerp b))
@@ -811,9 +704,8 @@ loaded and the keystroke automatically re-typed."
           (math-with-extra-prec 2
             (math-ipow a b))))
        (t
-        (calc-extensions)
-        (math-pow-fancy a b)))
-)
+        (require 'calc-ext)
+        (math-pow-fancy a b))))
 
 (defun math-ipow (a n)   ; [O O I] [Public]
   (cond ((Math-integer-negp n)
@@ -826,15 +718,13 @@ loaded and the keystroke automatically re-typed."
         (math-ipow (math-mul a a) (math-div2 n)))
        (t
         (math-mul a (math-ipow (math-mul a a)
-                               (math-div2 (math-add n -1))))))
-)
+                               (math-div2 (math-add n -1)))))))
 
 (defun math-iipow (a n)   ; [O O S]
   (cond ((= n 0) 1)
        ((= n 1) a)
        ((= (% n 2) 0) (math-iipow (math-mul a a) (/ n 2)))
-       (t (math-mul a (math-iipow (math-mul a a) (/ n 2)))))
-)
+       (t (math-mul a (math-iipow (math-mul a a) (/ n 2))))))
 
 (defun math-iipow-show (a n)   ; [O O S]
   (math-working "pow" a)
@@ -844,8 +734,7 @@ loaded and the keystroke automatically re-typed."
              ((= (% n 2) 0) (math-iipow-show (math-mul a a) (/ n 2)))
              (t (math-mul a (math-iipow-show (math-mul a a) (/ n 2)))))))
     (math-working "pow" val)
-    val)
-)
+    val))
 
 
 (defun math-read-radix-digit (dig)   ; [D S; Z S]
@@ -855,23 +744,25 @@ loaded and the keystroke automatically re-typed."
        (- dig 55))
     (if (>= dig ?0)
        (- dig ?0)
-      nil))
-)
-
-
-
+      nil)))
 
 
 ;;; Bug reporting
 
-(defun report-calc-bug (topic)
+(defun report-calc-bug ()
   "Report a bug in Calc, the GNU Emacs calculator.
 Prompts for bug subject.  Leaves you in a mail buffer."
-  (interactive "sBug Subject: ")
-  (mail nil calc-bug-address topic)
-  (goto-char (point-max))
-  (insert "\nIn Calc " calc-version ", Emacs " (emacs-version) "\n\n")
-  (message (substitute-command-keys "Type \\[mail-send] to send bug report."))
-)
-(fset 'calc-report-bug (symbol-function 'report-calc-bug))
-
+  (interactive)
+  (let ((reporter-prompt-for-summary-p t))
+    (reporter-submit-bug-report calc-bug-address "Calc" '(calc-version)
+                               nil nil
+                               "Please describe exactly what actions triggered the bug and the
+precise symptoms of the bug.  If possible, include a backtrace by
+doing 'M-x toggle-debug-on-error', then reproducing the bug.
+" )))
+(defalias 'calc-report-bug 'report-calc-bug)
+
+(provide 'calc-misc)
+
+;;; arch-tag: 7984d9d0-62e5-41dc-afb8-e904b975f250
+;;; calc-misc.el ends here