]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-yank.el
(rmail-current-message, rmail-inbox-list): Add defvars.
[gnu-emacs] / lisp / calc / calc-yank.el
index 2fdfab6c6f432f4e42812046f05c7acaf03c6916..628b1fef1c0e9d43f92590cae2c8da96238400dc 100644 (file)
@@ -1,6 +1,7 @@
 ;;; calc-yank.el --- kill-ring functionality for Calc
 
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
+;;   2005 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger <belanger@truman.edu>
                        pos j)))))
        (if (string-match "\\` *-?[0-9][0-9]?[0-9]?[0-9]?[0-9]?[0-9]? *\\'"
                          (car data))
-           (setq vals (list 'vec (string-to-int (car data))))
+           (setq vals (list 'vec (string-to-number (car data))))
          (if (and (null arg)
                   (string-match "[[{][^][{}]*[]}]" (car data)))
              (setq pos (match-beginning 0)
 (defvar calc-edit-handler)
 (defvar calc-restore-trail)
 (defvar calc-allow-ret)
+(defvar calc-edit-top)
 
 (defun calc-edit-mode (&optional handler allow-ret title)
   "Calculator editing mode.  Press RET, LFD, or C-c C-c to finish.
@@ -446,7 +448,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
     (setq truncate-lines nil)
     (setq major-mode 'calc-edit-mode)
     (setq mode-name "Calc Edit")
-    (run-hooks 'calc-edit-mode-hook)
+    (run-mode-hooks 'calc-edit-mode-hook)
     (make-local-variable 'calc-original-buffer)
     (setq calc-original-buffer oldbuf)
     (make-local-variable 'calc-return-buffer)
@@ -459,15 +461,21 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
     (setq calc-restore-trail (get-buffer-window (calc-trail-buffer)))
     (make-local-variable 'calc-allow-ret)
     (setq calc-allow-ret allow-ret)
-    (erase-buffer)
+    (let ((inhibit-read-only t))
+      (erase-buffer))
     (add-hook 'kill-buffer-hook (lambda () 
                                   (let ((calc-edit-handler nil))
                                     (calc-edit-finish t))
                                   (message "(Cancelled)")) t t)
-    (insert (or title title "Calc Edit Mode")
-           ".  Press `C-c C-c'"
-            (if allow-ret "" " or RET")
-           " to finish, `C-x k RET' to cancel.\n")))
+    (insert (propertize
+             (concat 
+              (or title title "Calc Edit Mode. ")
+              "Press `C-c C-c'"
+              (if allow-ret "" " or RET")
+              " to finish, `C-x k RET' to cancel.\n\n")
+             'font-lock-face 'italic 'read-only t 'rear-nonsticky t 'front-sticky t))
+    (make-local-variable 'calc-edit-top)
+    (setq calc-edit-top (point))))
 (put 'calc-edit-mode 'mode-class 'special)
 
 (defun calc-show-edit-buffer ()
@@ -484,8 +492,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
          (if win
              (delete-window win))))
     (set-buffer-modified-p nil)
-    (goto-char (point-min))
-    (forward-line 1)))
+    (goto-char calc-edit-top)))
 
 (defun calc-edit-return ()
   (interactive)
@@ -519,12 +526,10 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
                  (set-buffer original)
                  (not (eq major-mode 'calc-mode))))
        (error "Original calculator buffer has been corrupted")))
-    (goto-char (point-min))
-    (when (looking-at "Calc Edit\\|Editing ")
-      (forward-line 1))
+    (goto-char calc-edit-top)
     (if (buffer-modified-p)
        (eval calc-edit-handler))
-    (if one-window
+    (if (and one-window (not (one-window-p t)))
        (delete-window))
     (if (get-buffer-window return)
        (select-window (get-buffer-window return))
@@ -546,7 +551,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
 
 (defun calc-finish-stack-edit (num)
   (let ((buf (current-buffer))
-       (str (buffer-substring (point) (point-max)))
+       (str (buffer-substring calc-edit-top (point-max)))
        (start (point))
        pos)
     (if (and (integerp num) (> num 1))