]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-prog.el
Add 2010 to copyright years.
[gnu-emacs] / lisp / calc / calc-prog.el
index 9893bfa636b835c5f9aff1f5902c35b7fa2f51e1..5e4adace91efd7306c78f07f29b6720a9bd14643 100644 (file)
@@ -1,17 +1,17 @@
 ;;; calc-prog.el --- user programmability functions for Calc
 
 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
      (while
         (progn
           (setq cmd-base-default (concat "User-" keyname))
-           (setq cmd (completing-read 
+           (setq cmd (completing-read
                       (concat "Define M-x command name (default calc-"
                               cmd-base-default
                               "): ")
                    "That name conflicts with a built-in Emacs function.  Replace this function? "))))))
      (while
         (progn
-           (setq cmd-base-default     
+           (setq cmd-base-default
                  (if cmd-base
                      (if (string-match
                           "\\`User-.+" cmd-base)
                           (substring cmd-base 5))
                        cmd-base)
                    (concat "User" keyname)))
-          (setq func 
+          (setq func
                  (concat "calcFunc-"
-                         (completing-read 
+                         (completing-read
                           (concat "Define algebraic function name (default "
                                   cmd-base-default "): ")
                           (mapcar (lambda (x) (substring x 9))
                                   (all-completions "calcFunc-"
                                                    obarray))
-                          (lambda (x) 
-                            (fboundp 
+                          (lambda (x)
+                            (fboundp
                              (intern (concat "calcFunc-" x))))
                           nil)))
            (setq func
         (setq calc-user-formula-alist arglist)
        (while
           (progn
-            (setq calc-user-formula-alist 
+            (setq calc-user-formula-alist
                    (read-from-minibuffer "Function argument list: "
                                          (if arglist
                                              (prin1-to-string arglist)
                        func
                        (y-or-n-p
                         "Leave it symbolic for non-constant arguments? ")))
-     (setq calc-user-formula-alist 
+     (setq calc-user-formula-alist
            (mapcar (function (lambda (x)
                                (or (cdr (assq x '((nil . arg-nil)
                                                   (t . arg-t))))
             (setcdr kmap (cons (cons key cmd) (cdr kmap)))))))
    (message "")))
 
+(defvar arglist)                   ; dynamically bound in all callers
 (defun calc-default-formula-arglist (form)
   (if (consp form)
       (if (eq (car form) 'var)
    (if (eq calc-language 'unform)
        (error "Can't define formats for unformatted mode"))
    (let* ((comp (calc-top 1))
-         (func (intern 
+         (func (intern
                  (concat "calcFunc-"
                          (completing-read "Define format for which function: "
                                           (mapcar (lambda (x) (substring x 9))
                                                   (all-completions "calcFunc-"
                                                                    obarray))
-                                          (lambda (x) 
-                                            (fboundp 
+                                          (lambda (x)
+                                            (fboundp
                                              (intern (concat "calcFunc-" x))))))))
          (comps (get func 'math-compose-forms))
          entry entry2
        (setq arglist (sort arglist 'string-lessp))
        (while
           (progn
-            (setq calc-user-formula-alist 
+            (setq calc-user-formula-alist
                    (read-from-minibuffer "Composition argument list: "
                                          (if arglist
                                              (prin1-to-string arglist)
                (cons (setq entry (list calc-language)) comps)))
        (or (setq entry2 (assq (length calc-user-formula-alist) (cdr entry)))
           (setcdr entry
-                  (cons (setq entry2 
+                  (cons (setq entry2
                                (list (length calc-user-formula-alist))) (cdr entry))))
-       (setcdr entry2 
+       (setcdr entry2
                (list 'lambda calc-user-formula-alist (calc-fix-user-formula comp))))
      (calc-pop-stack 1)
      (calc-do-refresh))))
   (switch-to-buffer calc-original-buffer))
 
 ;; The variable calc-lang is local to calc-write-parse-table, but is
-;; used by calc-write-parse-table-part which is called by 
-;; calc-write-parse-table.  The variable is also local to 
+;; used by calc-write-parse-table-part which is called by
+;; calc-write-parse-table.  The variable is also local to
 ;; calc-read-parse-table, but is used by calc-fix-token-name which
 ;; is called (indirectly) by calc-read-parse-table.
 (defvar calc-lang)
          (let ((pos (point)))
            (end-of-line)
            (let* ((str (buffer-substring pos (point)))
-                  (exp (save-excursion
-                         (set-buffer calc-buf)
+                  (exp (with-current-buffer calc-buf
                          (let ((calc-user-parse-tables nil)
                                (calc-language nil)
                                (math-expr-opers (math-standard-ops))
            (let* ((mac (elt (nth 1 (nth 3 cmd)) 1))
                   (str (edmacro-format-keys mac t))
                   (kys (nth 3 (nth 3 cmd))))
-             (calc-edit-mode 
+             (calc-edit-mode
               (list 'calc-edit-macro-finish-edit cmdname kys)
-              t (format (concat 
-                         "Editing keyboard macro (%s, bound to %s).\n" 
+              t (format (concat
+                         "Editing keyboard macro (%s, bound to %s).\n"
                          "Original keys: %s \n")
                         cmdname kys (elt (nth 1 (nth 3 cmd)) 0)))
              (insert str "\n")
               (if (and defn (calc-valid-formula-func func))
                   (let ((niceexpr (math-format-nice-expr defn (frame-width))))
                     (calc-wrapper
-                     (calc-edit-mode 
+                     (calc-edit-mode
                        (list 'calc-finish-formula-edit (list 'quote func))
                        nil
                        (format (concat
     (when match
       (kill-line 1)
       (setq line (concat line (substring curline 0 match))))
-    (setq line (replace-regexp-in-string "SPC" " SPC " 
+    (setq line (replace-regexp-in-string "SPC" " SPC "
                   (replace-regexp-in-string " " "" line)))
     (insert line "\t\t\t")
     (if (> (current-column) 24)
       (setq line (concat line curline))
       (kill-line 1)
       (setq curline (calc-edit-macro-command)))
-    (when match 
+    (when match
       (kill-line 1)
       (setq line (concat line (substring curline 0 match))))
     (setq line (replace-regexp-in-string " " "" line))
         (setq line (concat line curline))
         (kill-line 1)
         (setq curline (calc-edit-macro-command)))
-      (when match 
+      (when match
         (kill-line 1)
         (setq line (concat line (substring curline 0 match))))
       (setq line (replace-regexp-in-string " " "" line))
@@ -1021,8 +1019,8 @@ Redefine the corresponding command."
                                         (mapcar (lambda (x) (substring x 9))
                                                 (all-completions "calcFunc-"
                                                                  obarray))
-                                        (lambda (x) 
-                                          (fboundp 
+                                        (lambda (x)
+                                          (fboundp
                                            (intern (concat "calcFunc-" x))))
                                         t)))))
                    (and (eq key ?\M-x)
@@ -1210,7 +1208,7 @@ Redefine the corresponding command."
      (calc-pop-stack 1)
      (if (math-is-true cond)
         (if defining-kbd-macro
-            (message "If true.."))
+            (message "If true..."))
        (if defining-kbd-macro
           (message "Condition is false; skipping to Z: or Z] ..."))
        (calc-kbd-skip-to-else-if t)))))
@@ -1287,7 +1285,7 @@ Redefine the corresponding command."
   (let* ((count 0)
         (parts nil)
         (body "")
-        (open last-command-char)
+        (open last-command-event)
         (counter initial)
         ch)
     (or executing-kbd-macro
@@ -2366,5 +2364,5 @@ Redefine the corresponding command."
 
 (provide 'calc-prog)
 
-;;; arch-tag: 4c5a183b-c9e5-4632-bb3f-e41a764518b0
+;; arch-tag: 4c5a183b-c9e5-4632-bb3f-e41a764518b0
 ;;; calc-prog.el ends here