unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55943: Cannot insert registers in calc
@ 2022-06-13 10:33 Kuba Orlik
  2022-06-13 15:14 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Kuba Orlik @ 2022-06-13 10:33 UTC (permalink / raw)
  To: 55943

1. Run emacs -Q
2. Type the number 20 into the buffer
3. Move the point to the "2" in the "20"
4. Run M-x number-to-register
5. Pick a letter for the register (I picked "a")
6. Run M-x calc
7. Type "r i" and pick the same register
8. It rings a bell and shows "Bad format in register data"


In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2021-03-28, modified by Debian built on x86-conova-01
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
You can run the command ‘number-to-register’ with C-x r n
Welcome to the GNU Emacs Calculator!  Press ‘?’ or ‘h’ for help, ‘q’ to quit
r-
calc-do: Bad format in register data
Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-cairo
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2
 -ffile-prefix-map=/build/emacs-LlFm6W/emacs-27.1+1=. -fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Calculator

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq
byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils calc-yank calc-ext
calc-misc cl-loaddefs cl-lib calc-menu easymenu calc calc-loaddefs
calc-macs tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 73649 8293)
 (symbols 48 8721 1)
 (strings 32 20611 2050)
 (string-bytes 1 604578)
 (vectors 16 12708)
 (vector-slots 8 154643 9372)
 (floats 8 29 41)
 (intervals 56 257 0)
 (buffers 1000 13))

-- 
Kuba Orlik





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  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-14 11:05   ` Michael Heerdegen
  0 siblings, 2 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-13 15:14 UTC (permalink / raw)
  To: Kuba Orlik; +Cc: 55943

Kuba Orlik <kontakt@kuba-orlik.name> writes:

> 1. Run emacs -Q
> 2. Type the number 20 into the buffer
> 3. Move the point to the "2" in the "20"
> 4. Run M-x number-to-register
> 5. Pick a letter for the register (I picked "a")
> 6. Run M-x calc
> 7. Type "r i" and pick the same register
> 8. It rings a bell and shows "Bad format in register data"

Registers in Calc have nothing to do with the normal Emacs-wide
registers -- you can only insert with `r i' in Calc stuff you've save
with `r s' in Calc.  But I see that the doc strings here don't actually
say this, so I've fixed this for Emacs 28.2.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  2022-06-13 15:14 ` Lars Ingebrigtsen
@ 2022-06-13 15:31   ` Kuba Orlik
  2022-06-13 15:32     ` Lars Ingebrigtsen
  2022-06-14 11:05   ` Michael Heerdegen
  1 sibling, 1 reply; 11+ messages in thread
From: Kuba Orlik @ 2022-06-13 15:31 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55943

> Registers in Calc have nothing to do with the normal Emacs-wide
registers

Is it then also a bug that when I press "r i" in Calc and wait for a
second then it suggests me the registers (along with their values) that
I created outside of Calc?

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Kuba Orlik <kontakt@kuba-orlik.name> writes:
>
>> 1. Run emacs -Q
>> 2. Type the number 20 into the buffer
>> 3. Move the point to the "2" in the "20"
>> 4. Run M-x number-to-register
>> 5. Pick a letter for the register (I picked "a")
>> 6. Run M-x calc
>> 7. Type "r i" and pick the same register
>> 8. It rings a bell and shows "Bad format in register data"
>
> Registers in Calc have nothing to do with the normal Emacs-wide
> registers -- you can only insert with `r i' in Calc stuff you've save
> with `r s' in Calc.  But I see that the doc strings here don't actually
> say this, so I've fixed this for Emacs 28.2.


-- 
Kuba Orlik





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  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:07       ` Michael Heerdegen
  0 siblings, 2 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-13 15:32 UTC (permalink / raw)
  To: Kuba Orlik; +Cc: 55943

Kuba Orlik <kontakt@kuba-orlik.name> writes:

> Is it then also a bug that when I press "r i" in Calc and wait for a
> second then it suggests me the registers (along with their values) that
> I created outside of Calc?

Yes, that looks like a bug.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  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
  1 sibling, 1 reply; 11+ messages in thread
From: Kuba Orlik @ 2022-06-14  7:21 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55943

Should I report it separately?

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Kuba Orlik <kontakt@kuba-orlik.name> writes:
>
>> Is it then also a bug that when I press "r i" in Calc and wait for a
>> second then it suggests me the registers (along with their values) that
>> I created outside of Calc?
>
> Yes, that looks like a bug.


-- 
Kuba Orlik





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  2022-06-13 15:14 ` Lars Ingebrigtsen
  2022-06-13 15:31   ` Kuba Orlik
@ 2022-06-14 11:05   ` Michael Heerdegen
  2022-06-14 11:29     ` Michael Heerdegen
  1 sibling, 1 reply; 11+ messages in thread
From: Michael Heerdegen @ 2022-06-14 11:05 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55943, Kuba Orlik

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Registers in Calc have nothing to do with the normal Emacs-wide
> registers -- you can only insert with `r i' in Calc stuff you've save
> with `r s' in Calc.  But I see that the doc strings here don't actually
> say this, so I've fixed this for Emacs 28.2.

Hmm - I think I don't agree - see what

  (info "(calc) Inserting From Registers")

tells.  String valued registers work fine.  So this change:

+Note that this command only works with Calc registers, and they
+have nothing to do with the Emacs-wide register mechanism.

is not justified in my opinion.  Calc uses the normal register
mechanism, but enhances registers that save regions from Calc by saving
additional data in a separate variable.

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

Michael.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  2022-06-13 15:32     ` Lars Ingebrigtsen
  2022-06-14  7:21       ` Kuba Orlik
@ 2022-06-14 11:07       ` Michael Heerdegen
  1 sibling, 0 replies; 11+ messages in thread
From: Michael Heerdegen @ 2022-06-14 11:07 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55943, Kuba Orlik

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Kuba Orlik <kontakt@kuba-orlik.name> writes:
>
> > Is it then also a bug that when I press "r i" in Calc and wait for a
> > second then it suggests me the registers (along with their values) that
> > I created outside of Calc?
>
> Yes, that looks like a bug.

It's normal that not all register value types support insertion.  Calc
changes a bit which value types can be - but I don't see a bug here.

Michael.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  2022-06-14 11:05   ` Michael Heerdegen
@ 2022-06-14 11:29     ` Michael Heerdegen
  2022-06-14 11:57       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Heerdegen @ 2022-06-14 11:29 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Kuba Orlik, 55943

[-- 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.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  2022-06-14 11:29     ` Michael Heerdegen
@ 2022-06-14 11:57       ` Lars Ingebrigtsen
  2022-06-16 17:17         ` Michael Heerdegen
  0 siblings, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-14 11:57 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Kuba Orlik, 55943

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Subject: [PATCH] WIP: Allow number register value insertion in Calc

Makes sense to me.  I've now reverted the doc change in Emacs 28 about
this.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  2022-06-14  7:21       ` Kuba Orlik
@ 2022-06-14 11:57         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-14 11:57 UTC (permalink / raw)
  To: Kuba Orlik; +Cc: 55943

Kuba Orlik <kontakt@kuba-orlik.name> writes:

> Should I report it separately?

No, I reopened this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#55943: Cannot insert registers in calc
  2022-06-14 11:57       ` Lars Ingebrigtsen
@ 2022-06-16 17:17         ` Michael Heerdegen
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Heerdegen @ 2022-06-16 17:17 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55943-done, Kuba Orlik

Lars Ingebrigtsen <larsi@gnus.org> writes:

> > Subject: [PATCH] WIP: Allow number register value insertion in Calc
>
> Makes sense to me.  I've now reverted the doc change in Emacs 28 about
> this.

Thanks.  I've now committed my suggested patch (which fixes this
problem) to master and am closing this report.

Side note: AFAIK number registers can only be initialized with integer
values, so the use of this change is limited.


Thanks,

Michael.





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-06-16 17:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-06-14 11:57       ` Lars Ingebrigtsen
2022-06-16 17:17         ` Michael Heerdegen

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).