unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Kuba Orlik <kontakt@kuba-orlik.name>, 55943@debbugs.gnu.org
Subject: bug#55943: Cannot insert registers in calc
Date: Tue, 14 Jun 2022 13:29:58 +0200	[thread overview]
Message-ID: <87fsk71o09.fsf@web.de> (raw)
In-Reply-To: <87mtef1p5m.fsf@web.de> (Michael Heerdegen's message of "Tue, 14 Jun 2022 13:05:09 +0200")

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-Allow-number-register-value-insertion-in-Calc.patch --]
[-- Type: text/x-diff, Size: 1419 bytes --]

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


[-- Attachment #3: Type: text/plain, Size: 90 bytes --]


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

Michael.

  reply	other threads:[~2022-06-14 11:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 10:33 bug#55943: Cannot insert registers in calc Kuba Orlik
2022-06-13 15:14 ` Lars Ingebrigtsen
2022-06-13 15:31   ` Kuba Orlik
2022-06-13 15:32     ` Lars Ingebrigtsen
2022-06-14  7:21       ` Kuba Orlik
2022-06-14 11:57         ` Lars Ingebrigtsen
2022-06-14 11:07       ` Michael Heerdegen
2022-06-14 11:05   ` Michael Heerdegen
2022-06-14 11:29     ` Michael Heerdegen [this message]
2022-06-14 11:57       ` Lars Ingebrigtsen
2022-06-16 17:17         ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsk71o09.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=55943@debbugs.gnu.org \
    --cc=kontakt@kuba-orlik.name \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).