bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55943: Cannot insert registers in calc


From: Michael Heerdegen
Subject: bug#55943: Cannot insert registers in calc
Date: Tue, 14 Jun 2022 13:29:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Wouldn't it make sense to make "calc-insert-register" work with number
> valued registers?

This seems to work:

From 3368ead9b62e822e7e3927149c67c09caf17d55f Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Tue, 14 Jun 2022 13:26:06 +0200
Subject: [PATCH] WIP: Allow number register value insertion in Calc

---
 lisp/calc/calc-yank.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el
index e0ed098b70..8346061239 100644
--- a/lisp/calc/calc-yank.el
+++ b/lisp/calc/calc-yank.el
@@ -266,14 +266,16 @@ calc-get-register
   "Return the CALCVAL portion of the contents of the Calc register REG,
 unless the TEXT portion doesn't match the contents of the Emacs register REG,
 in which case either return the contents of the Emacs register (if it is
-text) or nil."
+text or a number) or nil."
   (let ((cval (cdr (assq reg calc-register-alist)))
         (val (cdr (assq reg register-alist))))
-    (if (stringp val)
-        (if (and (stringp (car cval))
-                 (string= (car cval) val))
-            (cdr cval)
-          val))))
+    (cond
+     ((stringp val)
+      (if (and (stringp (car cval))
+               (string= (car cval) val))
+          (cdr cval)
+        val))
+     ((numberp val) (number-to-string val)))))

 (defun calc-copy-to-register (register start end &optional delete-flag)
   "Copy the lines in the region into register REGISTER.
--
2.30.2

Would this make sense?  Are there any number values that could cause
problems?

Michael.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]