evaluation time changes
[bpt/emacs.git] / lisp / calc / calc-yank.el
index e1e83ab..8d18237 100644 (file)
@@ -1,7 +1,6 @@
 ;;; calc-yank.el --- kill-ring functionality for Calc
 
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2014 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
                      val))
                val))))))))
 
-;;; The Calc set- and get-register commands are modified versions of functions 
+;;; The Calc set- and get-register commands are modified versions of functions
 ;;; in register.el
 
 (defvar calc-register-alist nil
@@ -156,16 +155,20 @@ in which case either return the contents of the Emacs register (if it is
 text) or `nil'."
   (let ((cval (cdr (assq reg calc-register-alist)))
         (val (cdr (assq reg register-alist))))
-    (if (and (stringp (car cval))
-             (stringp val))
-        (if (string= (car cval) val)
+    (if (stringp val)
+        (if (and (stringp (car cval))
+                 (string= (car cval) val))
             (cdr cval)
           val))))
 
 (defun calc-copy-to-register (register start end &optional delete-flag)
   "Copy the lines in the region into register REGISTER.
-With prefix arg, delete as well."
-  (interactive "cCopy to register: \nr\nP")
+With prefix arg, delete as well.
+
+Interactively, reads the register using `register-read-with-preview'."
+  (interactive (list (register-read-with-preview "Copy to register: ")
+                    (region-beginning) (region-end)
+                    current-prefix-arg))
   (if (eq major-mode 'calc-mode)
       (let* ((top-num (calc-locate-cursor-element start))
              (top-pos (save-excursion
@@ -184,8 +187,10 @@ With prefix arg, delete as well."
     (copy-to-register register start end delete-flag)))
 
 (defun calc-insert-register (register)
-  "Insert the contents of register REGISTER."
-  (interactive "cInsert register: ")
+  "Insert the contents of register REGISTER.
+
+Interactively, reads the register using `register-read-with-preview'."
+  (interactive (list (register-read-with-preview "Insert register: ")))
   (if (eq major-mode 'calc-mode)
       (let ((val (calc-get-register register)))
         (calc-wrapper
@@ -207,7 +212,7 @@ With prefix arg, delete as well."
 
 (defun calc-add-to-register (register start end prepend delete-flag)
   "Add the lines in the region to register REGISTER.
-If PREPEND is non-nil, add them to the beginning of the register, 
+If PREPEND is non-nil, add them to the beginning of the register,
 otherwise the end.  If DELETE-FLAG is non-nil, also delete the region."
   (let* ((top-num (calc-locate-cursor-element start))
          (top-pos (save-excursion
@@ -238,20 +243,28 @@ otherwise the end.  If DELETE-FLAG is non-nil, also delete the region."
 
 (defun calc-append-to-register (register start end &optional delete-flag)
   "Copy the lines in the region to the end of register REGISTER.
-With prefix arg, also delete the region."
-  (interactive "cAppend to register: \nr\nP")
+With prefix arg, also delete the region.
+
+Interactively, reads the register using `register-read-with-preview'."
+  (interactive (list (register-read-with-preview "Append to register: ")
+                    (region-beginning) (region-end)
+                    current-prefix-arg))
   (if (eq major-mode 'calc-mode)
       (calc-add-to-register register start end nil delete-flag)
     (append-to-register register start end delete-flag)))
-  
+
 (defun calc-prepend-to-register (register start end &optional delete-flag)
   "Copy the lines in the region to the beginning of register REGISTER.
-With prefix arg, also delete the region."
-  (interactive "cPrepend to register: \nr\nP")
+With prefix arg, also delete the region.
+
+Interactively, reads the register using `register-read-with-preview'."
+  (interactive (list (register-read-with-preview "Prepend to register: ")
+                    (region-beginning) (region-end)
+                    current-prefix-arg))
   (if (eq major-mode 'calc-mode)
       (calc-add-to-register register start end t delete-flag)
     (prepend-to-register register start end delete-flag)))
-  
+
 
 
 (defun calc-clean-newlines (s)
@@ -282,11 +295,8 @@ With prefix arg, also delete the region."
            (setq single t)
          (setq arg (prefix-numeric-value arg))
          (if (= arg 0)
-             (save-excursion
-               (beginning-of-line)
-               (setq top (point))
-               (end-of-line)
-               (setq bot (point)))
+             (setq top (point-at-bol)
+                   bot (point-at-eol))
            (save-excursion
              (setq top (point))
              (forward-line arg)
@@ -444,14 +454,12 @@ With prefix arg, also delete the region."
                (setq top (point))
                (calc-cursor-stack-index 0)
                (setq bot (point))))
-        (save-excursion
-          (set-buffer newbuf)
+        (with-current-buffer newbuf
           (if (consp nn)
               (kill-region (region-beginning) (region-end)))
           (push-mark (point) t)
           (if (and overwrite-mode (not (consp nn)))
-              (calc-overwrite-string (save-excursion
-                                       (set-buffer oldbuf)
+              (calc-overwrite-string (with-current-buffer oldbuf
                                        (buffer-substring top bot))
                                      eat-lnums)
             (or (bolp) (setq eat-lnums nil))
@@ -489,7 +497,7 @@ With prefix arg, also delete the region."
        (insert str))
     (let ((i 0))
       (while (< i (length str))
-       (if (= (setq last-command-char (aref str i)) ?\n)
+       (if (= (setq last-command-event (aref str i)) ?\n)
            (or (= i (1- (length str)))
                (let ((pt (point)))
                  (end-of-line)
@@ -591,12 +599,12 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
     (setq calc-allow-ret allow-ret)
     (let ((inhibit-read-only t))
       (erase-buffer))
-    (add-hook 'kill-buffer-hook (lambda () 
+    (add-hook 'kill-buffer-hook (lambda ()
                                   (let ((calc-edit-handler nil))
                                     (calc-edit-finish t))
-                                  (message "(Cancelled)")) t t)
+                                  (message "(Canceled)")) t t)
     (insert (propertize
-             (concat 
+             (concat
               (or title title "Calc Edit Mode. ")
               "Press `C-c C-c'"
               (if allow-ret "" " or RET")
@@ -675,7 +683,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
   (interactive)
   (let ((calc-edit-handler nil))
     (calc-edit-finish))
-  (message "(Cancelled)"))
+  (message "(Canceled)"))
 
 (defun calc-finish-stack-edit (num)
   (let ((buf (current-buffer))
@@ -702,7 +710,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
         (if calc-edit-disp-trail
             (calc-trail-display 1 t))
         (and vals
-             (let ((calc-simplify-mode (if (eq last-command-char ?\C-j)
+             (let ((calc-simplify-mode (if (eq last-command-event ?\C-j)
                                            'none
                                          calc-simplify-mode)))
                (if (>= num 0)
@@ -715,5 +723,4 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
 ;; generated-autoload-file: "calc-loaddefs.el"
 ;; End:
 
-;; arch-tag: ca61019e-caca-4daa-b32c-b6afe372d5b5
 ;;; calc-yank.el ends here