From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 15:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 21648@debbugs.gnu.org, jay.p.belanger@gmail.com X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" , jay.p.belanger@gmail.com Received: via spool by submit@debbugs.gnu.org id=B.1444316946854 (code B ref -1); Thu, 08 Oct 2015 15:10:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 Oct 2015 15:09:06 +0000 Received: from localhost ([127.0.0.1]:32775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkCob-0000Dg-T0 for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:09:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47559) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkCoZ-0000DH-8U for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:09:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkCo2-0003oe-Mq for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:09:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_FONT_FACE_BAD,HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkCo2-0003m4-0A for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:08:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkCny-0002oZ-DK for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkCnr-0003B5-4q for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:08:25 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:35562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkCnq-00038g-Dn for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:08:18 -0400 Received: by oigi138 with SMTP id i138so6455007oig.2 for ; Thu, 08 Oct 2015 08:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=hp9X4cWwohMWBr9OVkY24ejGDwdEhcaxYcYc4umPI0A=; b=QxkGOXsBpxEnmRQLeTXMMDe0DmYgReUZqraEbdpNZk8FvQe1xqgH1bVIQgoUIZbAb/ 9J5k2FShrVk13aO0DY37WwQ33Y16f7WGw7e/NV2qeynLlRkQTEqLYmEsAEW+/RyV93xf Lf9Nul4fg+ih/xYeiQG2THDgl8DQzm5MTudXQkfJVEyGgmQRpkJ9R7u+JeeaTNjG2+tr h5kdA9qGULMHls0SbdwetJ0JnyKV7QaraiokTs9Wy2rXv4qXRHuZvsgFrpVviWWnKUpe wWZz3+Co59Hfx83bdrzmTvvOwcjNeBaRyTo3XBcqoLbV/NdWnm6oBhSJmFVLoP1c4e/X GYzQ== X-Received: by 10.202.65.136 with SMTP id o130mr4641784oia.134.1444316897726; Thu, 08 Oct 2015 08:08:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.172.205 with HTTP; Thu, 8 Oct 2015 08:07:38 -0700 (PDT) From: Kaushal Modi Date: Thu, 8 Oct 2015 11:07:38 -0400 Message-ID: Content-Type: multipart/alternative; boundary=001a113cd6d2a1d97b0521993b37 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.7 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.7 (---) --001a113cd6d2a1d97b0521993b37 Content-Type: text/plain; charset=UTF-8 Hi, I read this question of emacs.stackexchange ( http://emacs.stackexchange.com/q/13451/115 ) where the user needed to specify the radix of the number he was pasting in calc. If the calc default radix is decimal and if a user pastes 1000, it will be pasted as decimal 1000. But what if the user meant to paste binary 1000 (decimal 8)? My patch below enables doing that using numeric prefixes. Please advise if merging this patch to calc-yank is a good idea or if needs improvement/bug fixes before the merging. I have used this modified calc-yank function for few weeks and did not mess up anything else in my calc usage. ====================================================== >From fa9c8f6c2cce1c9e69bd6f6c25f036a72e0b799b Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Thu, 8 Oct 2015 10:56:36 -0400 Subject: [PATCH] Prepend radix to yanked numbers using num prefix If 1000 is the last element saved to the kill-ring. Then, C-2 C-y will paste 8 (2#1000), C-8 C-y will paste 512 (8#1000), C-0 C-y will paste 1000 (10#1000), C-6 C-y will paste 4096 (16#1000) .. and C-y will paste 1000 (1000). --- lisp/calc/calc-yank.el | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el index 5694a4e..811b308 100644 --- a/lisp/calc/calc-yank.el +++ b/lisp/calc/calc-yank.el @@ -111,25 +111,40 @@ calc-copy-region-as-kill ;; otherwise it just parses the yanked string. ;; Modified to use Emacs 19 extended concept of kill-ring. -- daveg 12/15/96 ;;;###autoload -(defun calc-yank () - (interactive) +(defun calc-yank (radix) + "Yank a value into the Calculator buffer. + +If RADIX is nil, do not prepend any radix notation. + +If RADIX is 2, prepend \"2#\" (The yanked number will be perceived as binary.) +If RADIX is 8, prepend \"8#\" (The yanked number will be perceived as octal.) +If RADIX is 0, prepend \"10#\" (The yanked number will be perceived as decimal.) +If RADIX is 16, prepend \"16#\" (The yanked number will be perceived as hexadecimal.) " + (interactive "P") (calc-wrapper (calc-pop-push-record-list 0 "yank" - (let ((thing (if (fboundp 'current-kill) - (current-kill 0 t) - (car kill-ring-yank-pointer)))) + (let* ((radix-notation (cl-case radix + (2 "2#") + (8 "8#") + (0 "10#") + (6 "16#") + (t ""))) + (thing (concat radix-notation + (if (fboundp 'current-kill) + (current-kill 0 t) + (car kill-ring-yank-pointer))))) (if (eq (car-safe calc-last-kill) thing) - (cdr calc-last-kill) - (if (stringp thing) - (let ((val (math-read-exprs (calc-clean-newlines thing)))) - (if (eq (car-safe val) 'error) - (progn - (setq val (math-read-exprs thing)) - (if (eq (car-safe val) 'error) - (error "Bad format in yanked data") - val)) - val)))))))) + (cdr calc-last-kill) + (if (stringp thing) + (let ((val (math-read-exprs (calc-clean-newlines thing)))) + (if (eq (car-safe val) 'error) + (progn + (setq val (math-read-exprs thing)) + (if (eq (car-safe val) 'error) + (error "Bad format in yanked data") + val)) + val)))))))) ;;; The Calc set- and get-register commands are modified versions of functions ;;; in register.el -- 2.6.0.rc0.24.gec371ff ====================================================== PS: My copyright paperwork is on file (#1029578) -- Kaushal Modi --001a113cd6d2a1d97b0521993b37 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I read this question of emacs.stackexchange (= =C2=A0http://emacs.s= tackexchange.com/q/13451/115 ) where the user needed to specify the rad= ix of the number he was pasting in calc.

=
If the calc default radix is decimal and if a user pastes 1000, it wil= l be pasted as decimal 1000. But what if the user meant to paste binary 100= 0 (decimal 8)?

My patch below enable= s doing that using numeric prefixes.

Please advise if merging this patch to calc-yank is a good idea or if need= s improvement/bug fixes before the merging. I have used this modified calc-= yank function for few weeks and did not mess up anything else in my calc us= age.



<= /font>

<= font face=3D"trebuchet ms, sans-serif">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

<= /font>
From fa9c8f6c2cce1c9e69bd6f6c25f036a72e0b799b Mon Sep 17 0= 0:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date:= Thu, 8 Oct 2015 10:56:36 -0400
Subject: [PATCH] Prepend r= adix to yanked numbers using num prefix

<= div class=3D"gmail_default" style=3D"">If 1000 is the last element saved to the kill-ring.
Then,

C-2 C-y wi= ll paste 8 (2#1000),
C-8 C-y will paste 512 (8#1000),
C-0 C-y will paste 1000 (10#1000),
C-6 C-y wi= ll paste 4096 (16#1000)
.. and C-y will paste 1000 (1000).=
---
<= font face=3D"trebuchet ms, sans-serif">=C2=A0lisp/calc/calc-yank.el | 45 ++= ++++++++++++++++++++++++++++---------------
=C2=A01 file c= hanged, 30 insertions(+), 15 deletions(-)

diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el
index 5694a4e..811b308 100644
--- a/lisp/calc/cal= c-yank.el
+++ b/lisp/calc/calc-yank.el
@@= -111,25 +111,40 @@ calc-copy-region-as-kill
=C2=A0;; othe= rwise it just parses the yanked string.
=C2=A0;; Modified = to use Emacs 19 extended concept of kill-ring. -- daveg 12/15/96
=C2=A0;;;###autoload
-(defun calc-yank ()
- =C2=A0(interactive)
+(defun calc-yank (radix)
+ =C2=A0"Yank a value into the Calculator buffer.
+
+If RADIX is nil, do not prepend any radix = notation.
+
+If RADIX is 2, prepend \&quo= t;2#\" (The yanked number will be perceived as binary.)
+If RADIX is 8, prepend \"8#\" (The yanked number will be perc= eived as octal.)
+If RADIX is 0, prepend \"10#\"= (The yanked number will be perceived as decimal.)
+If R= ADIX is 16, prepend \"16#\" (The yanked number will be perceived = as hexadecimal.) "
+ =C2=A0(interactive "P"= )
=C2=A0 =C2=A0(calc-wrapper
=C2=A0 =C2= =A0 (calc-pop-push-record-list
=C2=A0 =C2=A0 =C2=A00 "= ;yank"
- =C2=A0 =C2=A0(let ((thing (if (fboundp '= ;current-kill)
- =C2=A0 =C2=A0 (current-kill 0 t)
- =C2=A0 (car kill-ring-yank-pointe= r))))
+ =C2=A0 =C2=A0(let* ((radix-notation (cl-case radix=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (2 "2#")
<= div class=3D"gmail_default" style=3D"">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (8 "8#")
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (0 "10#")
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (6 "16#")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (t &= quot;")))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (thing= (concat radix-notation
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (fboundp = 9;current-kill)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(current-= kill 0 t)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(car kill-ring-yank-poi= nter)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(if (eq (car-safe cal= c-last-kill) thing)
- =C2=A0(cdr calc-last-kill)
- (if (stringp thing)
-<= span class=3D"" style=3D"white-space:pre"> =C2=A0 =C2=A0(let ((val = (math-read-exprs (calc-clean-newlines thing))))
- =C2=A0 =C2=A0 =C2=A0(if (eq (car= -safe val) 'error)
= - =C2=A0(progn
- =C2=A0 =C2=A0(setq val (math-read-exprs thing))=
- =C2= =A0 =C2=A0(if (eq (car-safe val) 'error)
- (error "Bad format in yanked= data")
- = =C2=A0 =C2=A0 =C2=A0val))
- val))))))))
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(cdr calc-last-kill)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0(if (stringp thing)
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(let ((val (math-read-exprs (calc-clean-newlines thing)= )))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if = (eq (car-safe val) 'error)
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(progn
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq val (math-= read-exprs thing))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (eq (car-safe val) 'error)=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0(error "Bad format in yanked data")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0val))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0val))))))))
=C2=A0
= =C2=A0;;; The Calc set- and get-register commands are modified versions of = functions
=C2=A0;;; in register.el
--=C2= =A0
2.6.0.rc0.24.gec371ff

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

PS: My copyright= paperwork is on file (#1029578)

--<= br>Kaushal Modi
--001a113cd6d2a1d97b0521993b37-- From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Jay Belanger Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 16:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Kaushal Modi Cc: jay.p.belanger@gmail.com, 21648@debbugs.gnu.org X-Debbugs-Original-Cc: jay.p.belanger@gmail.com, "bug-gnu-emacs@gnu.org" Reply-To: jay.p.belanger@gmail.com Received: via spool by submit@debbugs.gnu.org id=B.14443207256674 (code B ref -1); Thu, 08 Oct 2015 16:13:02 +0000 Received: (at submit) by debbugs.gnu.org; 8 Oct 2015 16:12:05 +0000 Received: from localhost ([127.0.0.1]:32841 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkDnZ-0001ja-AX for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:12:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39946) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkDnW-0001jS-TZ for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:12:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDnP-0006jh-5u for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:12:02 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:53954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDnP-0006jc-2O for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:11:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDnK-0005rK-Lj for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 12:11:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDme-0006HG-BP for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 12:11:50 -0400 Received: from mail-ig0-x22a.google.com ([2607:f8b0:4001:c05::22a]:36740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDme-0006Gk-4r for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 12:11:08 -0400 Received: by igcrk20 with SMTP id rk20so16486348igc.1 for ; Thu, 08 Oct 2015 09:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:reply-to:cc:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=kKtt/HIx/f6Dh7BhwCnqJvWMhaZwJfqG72sDnHmREz0=; b=p+O3eRaCYVGURf53DP8Fm6BDwALKsr2asFKxO/kjPogCrQ72tMihIBBHGDJxyjYmtZ 8aP9oWutQc5ZufAEr/yM0XpOCBDPWdRJvGHvpl5TumJVzi3Sn53WRwZmvH76J/l6XGwb hnVEFX9N83Sl73Nl4EubuFlCnnTcwLGfEodnkv6qFK50kRRY5sbEyzsFl06MQYxnnUC3 7qZFqgtfuSHfQMlG9rxal0myX7Qz5LVSTnUyqDU8k18jgWZo+aBzvLFlpoy4mrCENygy QH15h24avkwlSul6zSKARdvYrJ8U6TtxBBHNME9vFLdpxAXhBT+rjJjGlbY+xa6quNb2 j/wg== X-Received: by 10.50.30.233 with SMTP id v9mr5201291igh.5.1444320667198; Thu, 08 Oct 2015 09:11:07 -0700 (PDT) Received: from vh213601 (vh213601.truman.edu. [150.243.162.59]) by smtp.gmail.com with ESMTPSA id hh9sm3820262igb.18.2015.10.08.09.11.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 Oct 2015 09:11:06 -0700 (PDT) From: Jay Belanger References: Date: Thu, 08 Oct 2015 11:08:33 -0500 In-Reply-To: (Kaushal Modi's message of "Thu, 8 Oct 2015 11:07:38 -0400") Message-ID: <87oag9fim6.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hi Kaushal, > I read this question of emacs.stackexchange > ( http://emacs.stackexchange.com/q/13451/115) > where the user needed to specify the radix of the number he was > pasting in calc. > > If the calc default radix is decimal and if a user pastes 1000, it > will be pasted as decimal 1000. But what if the user meant to paste > binary 1000 (decimal 8)? > > My patch below enables doing that using numeric prefixes. > > Please advise if merging this patch to calc-yank is a good idea or if > needs improvement/bug fixes before the merging. There's a feature freeze on right now, so it shouldn't be added to Emacs right away. But it looks useful. With the patch, if the yanked number already has the radix prefix, there is an error. It might make more sense to have Calc do an appropriate conversion. Also, the number of radixes in the patch is less than Calc allows. It might make more sense to have calc-yank use the current Calc's current radix rather than a prefix radix. I don't recall the policy on using cl- functions, but cond could easily be used instead of cl-case. But this should be brought up again after the feature freeze. Jay From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 16:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: jay.p.belanger@gmail.com Cc: 21648@debbugs.gnu.org X-Debbugs-Original-Cc: "bug-gnu-emacs@gnu.org" Received: via spool by submit@debbugs.gnu.org id=B.14443212227438 (code B ref -1); Thu, 08 Oct 2015 16:21:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 Oct 2015 16:20:22 +0000 Received: from localhost ([127.0.0.1]:32845 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkDvZ-0001vt-IS for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:20:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38832) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkDvX-0001vk-KT for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDvW-0004ta-5V for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:20:19 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_FONT_FACE_BAD,HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDvW-0004tQ-3B for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:20:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDvU-0001Fg-TG for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 12:20:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDvT-0004sT-Px for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 12:20:16 -0400 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:33444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDvT-0004sG-KX for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 12:20:15 -0400 Received: by oixx17 with SMTP id x17so29805935oix.0 for ; Thu, 08 Oct 2015 09:20:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=VswMNkCWjOj0owT66C50bvkigW195g4rI+CTyqjLMv4=; b=VqsJYEvNZt63ZupnkR6QY/WBlhB5Qo2WwXcne4QTzXFgxgnrdVt7hSZiwJxoKxi6rd oR1Ow/od7CIe0m1VsNv8Fm5y/eewI12HAryw+PdKlWQ6BJyIKSnXYGhtocUy4oDhAo0U HjXIbd1rTiy4q4e+uqkFIkQPDURWA1/aDIWhzkYDY/eyABckdx16knW3mJB1W0Dvwxz8 5wJkCWARJkyKeBkZYH2yFzQDcp2FBUG159zBAxl21yxbiFXKhwijafjVu+hihn34RjLC o8Ohu6r/8lwe/S3jB/1B6GeWId/CoYnEM36zlZf85hGRGMQSPkuWS8mLGdjifT8gp9lN YLEg== X-Received: by 10.202.211.10 with SMTP id k10mr4966319oig.34.1444321214855; Thu, 08 Oct 2015 09:20:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.172.205 with HTTP; Thu, 8 Oct 2015 09:19:35 -0700 (PDT) In-Reply-To: <87oag9fim6.fsf@gmail.com> References: <87oag9fim6.fsf@gmail.com> From: Kaushal Modi Date: Thu, 8 Oct 2015 12:19:35 -0400 Message-ID: Content-Type: multipart/alternative; boundary=001a113d2cd6f4029705219a3c41 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.7 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.7 (---) --001a113d2cd6f4029705219a3c41 Content-Type: text/plain; charset=UTF-8 Thanks for the review! I will work out these kinks by the time we can add in more features. I'll update this thread then. -- Kaushal Modi On Thu, Oct 8, 2015 at 12:08 PM, Jay Belanger wrote: > > Hi Kaushal, > > > I read this question of emacs.stackexchange > > ( http://emacs.stackexchange.com/q/13451/115) > > where the user needed to specify the radix of the number he was > > pasting in calc. > > > > If the calc default radix is decimal and if a user pastes 1000, it > > will be pasted as decimal 1000. But what if the user meant to paste > > binary 1000 (decimal 8)? > > > > My patch below enables doing that using numeric prefixes. > > > > Please advise if merging this patch to calc-yank is a good idea or if > > needs improvement/bug fixes before the merging. > > There's a feature freeze on right now, so it shouldn't be added to Emacs > right away. But it looks useful. > > With the patch, if the yanked number already has the radix prefix, there > is an error. It might make more sense to have Calc do an appropriate > conversion. Also, the number of radixes in the patch is less than Calc > allows. > It might make more sense to have calc-yank use the current Calc's > current radix rather than a prefix radix. > I don't recall the policy on using cl- functions, but cond could > easily be used instead of cl-case. > > But this should be brought up again after the feature freeze. > > Jay > > --001a113d2cd6f4029705219a3c41 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the review!
I will work out these kinks by the time we can = add in more features.
I'll update this thread then= .


= --
Kaushal Modi

On Thu, Oct 8, 2015 at 12:08 PM, Jay Belange= r <jay.p.belanger@gmail.com> wrote:

Hi Kaushal,

> I read this question of emacs.stackexchange
> ( http://emacs.stackexchange.com/q/13451/115)
> where the user needed to specify the radix of the number he was
> pasting in calc.
>
> If the calc default radix is decimal and if a user pastes 1000, it
> will be pasted as decimal 1000. But what if the user meant to paste > binary 1000 (decimal 8)?
>
> My patch below enables doing that using numeric prefixes.
>
> Please advise if merging this patch to calc-yank is a good idea or if<= br> > needs improvement/bug fixes before the merging.

There's a feature freeze on right now, so it shouldn't be ad= ded to Emacs
right away.=C2=A0 But it looks useful.

With the patch, if the yanked number already has the radix prefix, there is an error.=C2=A0 It might make more sense to have Calc do an appropriate<= br> conversion. Also, the number of radixes in the patch is less than Calc allo= ws.
It might make more sense to have calc-yank use the current Calc's
current radix rather than a prefix radix.
I don't recall the policy on using cl- functions, but cond could
easily be used instead of cl-case.

But this should be brought up again after the feature freeze.

Jay


--001a113d2cd6f4029705219a3c41-- From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 16:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: jay.p.belanger@gmail.com Cc: 21648@debbugs.gnu.org, kaushal.modi@gmail.com Reply-To: Eli Zaretskii Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.14443218278417 (code B ref 21648); Thu, 08 Oct 2015 16:31:01 +0000 Received: (at 21648) by debbugs.gnu.org; 8 Oct 2015 16:30:27 +0000 Received: from localhost ([127.0.0.1]:32850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkE5K-0002Be-2R for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:30:26 -0400 Received: from mtaout22.012.net.il ([80.179.55.172]:41952) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkE5F-0002BK-Ql for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 12:30:23 -0400 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NVW00D00TQ5JD00@a-mtaout22.012.net.il> for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 19:30:20 +0300 (IDT) Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NVW00D8ATUJGA40@a-mtaout22.012.net.il>; Thu, 08 Oct 2015 19:30:20 +0300 (IDT) Date: Thu, 08 Oct 2015 19:30:22 +0300 From: Eli Zaretskii In-reply-to: <87oag9fim6.fsf@gmail.com> X-012-Sender: halo1@inter.net.il Message-id: <83r3l5cogx.fsf@gnu.org> References: <87oag9fim6.fsf@gmail.com> X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Jay Belanger > Date: Thu, 08 Oct 2015 11:08:33 -0500 > Cc: 21648@debbugs.gnu.org > > There's a feature freeze on right now No, there was no decision yet to start the feature freeze. From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 17:00:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Jay Belanger , 21648@debbugs.gnu.org Cc: Eli Zaretskii Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.144432359417120 (code B ref 21648); Thu, 08 Oct 2015 17:00:05 +0000 Received: (at 21648) by debbugs.gnu.org; 8 Oct 2015 16:59:54 +0000 Received: from localhost ([127.0.0.1]:32866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkEXp-0004S2-FB for submit@debbugs.gnu.org; Thu, 08 Oct 2015 12:59:54 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:34730) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkEXn-0004Rt-9r for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 12:59:52 -0400 Received: by obbda8 with SMTP id da8so43269626obb.1 for <21648@debbugs.gnu.org>; Thu, 08 Oct 2015 09:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=KfoavZCsGVGV6zUUuapIHKHupki3RvlxnP448TgvDJQ=; b=PNCZdCFq+4pulX7auvVzcDRB6uf2p4S3gzwzh3Nvr8uFSzpAVFz5gD4QrVZyMudqc6 ySrGfIaqKNCaINMGFnEWU00/DqAsMZ9le27aNL1LQz8AxdIsQ5/5UXVZ/CdUkPFuIEso CALKhpDxaZLJiDHX/TouE7Zz86MsaLqegCCaN7vcc7D3bgHohIJVoe9Fp1++b5bOhPM9 7FRAsbeKS08OxLSzuAFnJN6UgoAcV8JiZ1RHzG2tonIzRhIHe+b2LBGP02wpOXPeq8+9 BWroUZ6ZBcCYoPu35t6hG3JALoFWxNgw7HEoUKsnPj53f5widfln7pM9FjR4QiSYaSyB Q5DA== X-Received: by 10.182.60.168 with SMTP id i8mr5249797obr.81.1444323590444; Thu, 08 Oct 2015 09:59:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.172.205 with HTTP; Thu, 8 Oct 2015 09:59:11 -0700 (PDT) In-Reply-To: References: <87oag9fim6.fsf@gmail.com> From: Kaushal Modi Date: Thu, 8 Oct 2015 12:59:11 -0400 Message-ID: Content-Type: multipart/alternative; boundary=089e0153716c8cc04405219aca8b X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) --089e0153716c8cc04405219aca8b Content-Type: text/plain; charset=UTF-8 >>> Eli Zaretskii > No, there was no decision yet to start the feature freeze. In that case, here is my feedback on a quick review. >>> Jay Belanger > With the patch, if the yanked number already has the radix prefix, there > is an error. It might make more sense to have Calc do an appropriate > conversion. I did not try that case as I meant to use the prefix only when the copied number does not have a calc-style prefix. But that's a valid point. If the copied number has calc-style prefix, what should have a higher priority? - The radix translated by the copied number with prefix, or - The radix conveyed by the user specified prefix to calc-yank? I believe that if the user has intentionally used the prefix, the calc-yank prefix should override. Either way, it will be easy with some string manipulation. > Also, the number of radixes in the patch is less than Calc allows. I assumed the use cases of only the common radixes used in programming. How about I display a prompt for the user to enter any radix they like (I believe calc supports up to radix 36) if the prefix is specifically '(4) ( a list prefix created when user uses C-u specifically for prefix). So now, C-2 C-y will prefix the yanked number with "2#". But C-u C-y will show a prompt where the user will enter radix. If the user entered 9, the prefix appended will be "9#". Does this option sound fair? > It might make more sense to have calc-yank use the current Calc's current radix rather than a prefix radix. I need some clarification for this point. Did you mean that if the user has set the calc radix to hex by using "d6" and now if they yank a number "1000" it gets yanked automatically as "16#1000". If yes, I believe it will cause a huge disturbance in the way people might have already got used to yanking in calc. > I don't recall the policy on using cl- functions, but cond could easily be used instead of cl-case. I personally find cl-case syntax very concise and so I used that. In a thread in emacs-devel, there is/was a discussion on if cl-lib should be preloaded automatically. I believe that until that decision is reached, I should use cond instead of cl-case. -- Kaushal Modi On Thu, Oct 8, 2015 at 12:19 PM, Kaushal Modi wrote: > Thanks for the review! > > I will work out these kinks by the time we can add in more features. > I'll update this thread then. > > > -- > Kaushal Modi > > On Thu, Oct 8, 2015 at 12:08 PM, Jay Belanger > wrote: > >> >> Hi Kaushal, >> >> > I read this question of emacs.stackexchange >> > ( http://emacs.stackexchange.com/q/13451/115) >> > where the user needed to specify the radix of the number he was >> > pasting in calc. >> > >> > If the calc default radix is decimal and if a user pastes 1000, it >> > will be pasted as decimal 1000. But what if the user meant to paste >> > binary 1000 (decimal 8)? >> > >> > My patch below enables doing that using numeric prefixes. >> > >> > Please advise if merging this patch to calc-yank is a good idea or if >> > needs improvement/bug fixes before the merging. >> >> There's a feature freeze on right now, so it shouldn't be added to Emacs >> right away. But it looks useful. >> >> With the patch, if the yanked number already has the radix prefix, there >> is an error. It might make more sense to have Calc do an appropriate >> conversion. Also, the number of radixes in the patch is less than Calc >> allows. >> It might make more sense to have calc-yank use the current Calc's >> current radix rather than a prefix radix. >> I don't recall the policy on using cl- functions, but cond could >> easily be used instead of cl-case. >> >> But this should be brought up again after the feature freeze. >> >> Jay >> >> > --089e0153716c8cc04405219aca8b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
>>> Eli Zaretskii
=
> No, there was no decision yet to start the feature freeze= .

<= span style=3D"font-family:arial,sans-serif;font-size:12.8px">In that case, = here is my feedback on a quick review.

=
>>= ;> Jay Belanger
>= ; With the patch, if the yanked number already has the radix prefix, there<= /span>
> is an error.=C2= =A0 It might make more sense to have Calc do an appropriate
> conversion.=C2=A0
I did not try t= hat case as I meant to use the prefix only when the copied number does not = have a calc-style prefix. But that's a valid point. If the copied numbe= r has calc-style prefix, what should have a higher priority?
- The radix tra= nslated by the copied number with prefix, or
- The radix conveyed by the use= r specified prefix to calc-yank?
<= span style=3D"font-size:12.8px">I believe that if the user has intentionall= y used the prefix, the calc-yank prefix should override. Either way, it wil= l be easy with some string manipulation.

> Also, the number of radixes in the patch is= less than Calc allows.
I assumed = the use cases of only the common radixes used in programming. How about I d= isplay a prompt for the user to enter any radix they like (I believe calc s= upports up to radix 36) if the prefix is specifically '(4) ( a list pre= fix created when user uses C-u specifically for prefix).

So now, C-2 C-y will= prefix the yanked number with "2#". But C-u C-y will show a prom= pt where the user will enter radix. If the user entered 9, the prefix appen= ded will be "9#". Does this option sound fair?

> It might make more sense= to have calc-yank use the current Calc's=C2=A0current radix rather than a pr= efix radix.
I need some clarification for this point. Did you = mean that if the user has set the calc radix to hex by using "d6"= and now if they yank a number "1000" it gets yanked automaticall= y as "16#1000". If yes, I believe it will cause a huge disturbanc= e in the way people might have already got used to yanking in calc.=C2=A0

> I don'= t recall the policy on using cl- functions, but cond could=C2=A0easily be used in= stead of cl-case.
I personally find cl-case syntax very concise and so I used that. = In a thread in emacs-devel, there is/was a discussion on if cl-lib should b= e preloaded automatically. I believe that until that decision is reached, I= should use cond instead of cl-case.

--
Kaushal Modi

On Thu, Oct 8, 2015 at 12:19 PM, Kaushal Mod= i <kaushal.modi@gmail.com> wrote:
=
Thanks for the review!

I will work out t= hese kinks by the time we can add in more features.
I'll update this thread then.


--
Kaushal Modi

On Thu, Oct 8, 2015 at 12:08 PM, Jay Belange= r <jay.p.belanger@gmail.com> wrote:

Hi Kaushal,

> I read this question of emacs.stackexchange
> ( http://emacs.stackexchange.com/q/13451/115)
> where the user needed to specify the radix of the number he was
> pasting in calc.
>
> If the calc default radix is decimal and if a user pastes 1000, it
> will be pasted as decimal 1000. But what if the user meant to paste > binary 1000 (decimal 8)?
>
> My patch below enables doing that using numeric prefixes.
>
> Please advise if merging this patch to calc-yank is a good idea or if<= br> > needs improvement/bug fixes before the merging.

There's a feature freeze on right now, so it shouldn't be ad= ded to Emacs
right away.=C2=A0 But it looks useful.

With the patch, if the yanked number already has the radix prefix, there is an error.=C2=A0 It might make more sense to have Calc do an appropriate<= br> conversion. Also, the number of radixes in the patch is less than Calc allo= ws.
It might make more sense to have calc-yank use the current Calc's
current radix rather than a prefix radix.
I don't recall the policy on using cl- functions, but cond could
easily be used instead of cl-case.

But this should be brought up again after the feature freeze.

Jay



--089e0153716c8cc04405219aca8b-- From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Jay Belanger Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 18:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 21648@debbugs.gnu.org, jay.p.belanger@gmail.com, kaushal.modi@gmail.com Reply-To: jay.p.belanger@gmail.com Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.144432802323813 (code B ref 21648); Thu, 08 Oct 2015 18:14:02 +0000 Received: (at 21648) by debbugs.gnu.org; 8 Oct 2015 18:13:43 +0000 Received: from localhost ([127.0.0.1]:32901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkFhG-0006C0-PZ for submit@debbugs.gnu.org; Thu, 08 Oct 2015 14:13:43 -0400 Received: from mail-yk0-f178.google.com ([209.85.160.178]:36645) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkFhD-0006Bs-VL for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 14:13:40 -0400 Received: by ykba192 with SMTP id a192so52793114ykb.3 for <21648@debbugs.gnu.org>; Thu, 08 Oct 2015 11:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:reply-to:cc:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=Ft23ze5cO/5O40Geoi27zJLxgI/J0wXKPACcyWcHxs0=; b=sPvw3NZ3VJSxBnLrU7N/Px/Og+TU/Diy2AHMXwqf/68EAgTH5Md4iY/xPT4n5zpLyl +DtqmsuUogLEFFkgmvIC+EaNu1hBwLsaiNPe9sa5j7pLE9yNQXgVaooe5Ktx6BN3cKpN OB4fL3hKOQq/adueyoNfS9BkfiMnGOryl+aBrHz0CcQjFYePLdLAVsVJAT3L9FyAHmIC 3bTKA97UavHzSQC+XDyMhlJSxplLsA6AaWQiwfbfJoz5qzzQSredAW+c+puce6af7Id6 KgaXkItcs7pph1S3fLJP9osTZQb2YUEIeIJYIL9rW/ddw5iQ1FArEbqxkyf8O4rDqahd nAPQ== X-Received: by 10.129.111.6 with SMTP id k6mr6272882ywc.114.1444328019423; Thu, 08 Oct 2015 11:13:39 -0700 (PDT) Received: from vh213601 (vh213601.truman.edu. [150.243.162.59]) by smtp.gmail.com with ESMTPSA id b186sm30339947ywc.53.2015.10.08.11.13.38 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 Oct 2015 11:13:38 -0700 (PDT) From: Jay Belanger References: <87oag9fim6.fsf@gmail.com> <83r3l5cogx.fsf@gnu.org> Date: Thu, 08 Oct 2015 13:11:11 -0500 In-Reply-To: <83r3l5cogx.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 08 Oct 2015 19:30:22 +0300") Message-ID: <871td59qo0.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) >> There's a feature freeze on right now > > No, there was no decision yet to start the feature freeze. Sorry then; I misremembered. From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Jay Belanger Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 19:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Kaushal Modi Cc: 21648@debbugs.gnu.org, jay.p.belanger@gmail.com, Eli Zaretskii Reply-To: jay.p.belanger@gmail.com Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.14443325204300 (code B ref 21648); Thu, 08 Oct 2015 19:29:02 +0000 Received: (at 21648) by debbugs.gnu.org; 8 Oct 2015 19:28:40 +0000 Received: from localhost ([127.0.0.1]:33041 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkGro-00017H-6x for submit@debbugs.gnu.org; Thu, 08 Oct 2015 15:28:40 -0400 Received: from mail-io0-f171.google.com ([209.85.223.171]:33502) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkGrl-000179-MX for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 15:28:38 -0400 Received: by iofh134 with SMTP id h134so69655610iof.0 for <21648@debbugs.gnu.org>; Thu, 08 Oct 2015 12:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:reply-to:cc:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=kgCYp/sYLYD1VpCaTGRImMbUXBK9BBhuI2oFMfLHTNk=; b=rN+YGokmDDq6O7UVq54zLQ/nwhA/U5XerJxRBqhax1FJcernGCiUFD8UZGvW68tWlM NokK/OrjsvB2cZugXoH4cfy2gXgjwKCuivCFfmt11VyFasiUWrkxjykl0MfpOCHT6SLw /iGS+wTNdWefNj9UynaG4DdvwOwBp6AP38Ri353J9+RsKhaulmWVdKrYMhHDc03duF1j GYb1tjxRVaozU77Pt5YoQ6H0d0L1IYU818dor72/7hPyEe8v5uXhLQIL8M5V+zRdaVmI bc2Egvnfn4BThQd0xLboKOFUNpblraAcex48A5ENV/LYFttFc7lfTVM1SXIbEzIlzco7 NTRQ== X-Received: by 10.107.41.211 with SMTP id p202mr11018984iop.132.1444332517104; Thu, 08 Oct 2015 12:28:37 -0700 (PDT) Received: from vh213601 (vh213601.truman.edu. [150.243.162.59]) by smtp.gmail.com with ESMTPSA id g9sm4237213igg.7.2015.10.08.12.28.35 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 Oct 2015 12:28:36 -0700 (PDT) From: Jay Belanger References: <87oag9fim6.fsf@gmail.com> Date: Thu, 08 Oct 2015 14:26:07 -0500 In-Reply-To: (Kaushal Modi's message of "Thu, 8 Oct 2015 12:59:11 -0400") Message-ID: <87wpux88mo.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) >> With the patch, if the yanked number already has the radix prefix, there >> is an error. It might make more sense to have Calc do an appropriate >> conversion. > I did not try that case as I meant to use the prefix only when the copied number does > not have a calc-style prefix. But that's a valid point. If the copied number has > calc-style prefix, what should have a higher priority? If the copied number has a calc-style prefix, then the number should be interpreted in that base. I can be entered onto the stack in the new base. That's done now; if Calc is using base 5 and 2#111 is yanked, then 5#12 appears on the stack. > Either way, it will be easy with some string manipulation. You'd probably want Calc to do the conversion. >> It might make more sense to have calc-yank use the current Calc's current radix rather >> than a prefix radix. > I need some clarification for this point. Did you mean that if the > user has set the calc radix to hex by using "d6" and now if they yank > a number "1000" it gets yanked automatically as "16#1000". Yes; that's what I meant. > If yes, I believe it will cause a huge disturbance in the way people > might have already got used to yanking in calc. You are probably right. I would prefer the yanking to pay attention to the current Calc setting, but I really don't like changing age-old behavior. Your method is a good approach. >> Also, the number of radixes in the patch is less than Calc allows. > I assumed the use cases of only the common radixes used in programming. How about I > display a prompt for the user to enter any radix they like (I believe calc supports up > to radix 36) if the prefix is specifically '(4) ( a list prefix created when user uses > C-u specifically for prefix). > > So now, C-2 C-y will prefix the yanked number with "2#". But C-u C-y will show a prompt > where the user will enter radix. If the user entered 9, the prefix appended will be > "9#". Does this option sound fair? Yes; it sounds like a nice approach. And perhaps some sort of message if the entered radix isn't a number from 2 to 36 (the allowed radixes). Thanks again, Jay From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 20:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Jay Belanger Cc: 21648@debbugs.gnu.org, Eli Zaretskii Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.144433657110614 (code B ref 21648); Thu, 08 Oct 2015 20:37:01 +0000 Received: (at 21648) by debbugs.gnu.org; 8 Oct 2015 20:36:11 +0000 Received: from localhost ([127.0.0.1]:33078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkHv7-0002l6-Tb for submit@debbugs.gnu.org; Thu, 08 Oct 2015 16:36:11 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:36463) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkHv4-0002kx-TA for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 16:36:08 -0400 Received: by oibi136 with SMTP id i136so33816811oib.3 for <21648@debbugs.gnu.org>; Thu, 08 Oct 2015 13:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=/Rhf6HM45Dm2Q2MwJ7yEpO3ZnUZ3GExfS9vL/20Otfc=; b=waduDh1asQMUUCu3swNTvMBshK4P57meDbbLe4OjLYRplAsXsjWq8/G0mD+QnG/uJy 9jEfKUjTJbM20Nl5+Ub1X3E1lLlSjvRwqxRxUTZQ18r6HMrn1RYOmB22g7a/wxEJg7oL mfIGbb8q7BYkuUNjhR3fkdPnwhFmZ3qzgoel7tut4/5qVuDQRF+Fg0KAjO8Sdz+n2hQE bV+uxpwauvFeOv8LKN9o8Au03gMKtJe0morJ3/iOOxZXarfJbSbye8fBAC/hFGhPufz4 BJyQzAOmRMGDEzTPzVWBqN8Zokbj0OKBJDJbuLudlS9lcmgLHyEVgEu4qSIHfdcK8NTc xukg== X-Received: by 10.202.215.136 with SMTP id o130mr5729589oig.85.1444336566230; Thu, 08 Oct 2015 13:36:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.172.205 with HTTP; Thu, 8 Oct 2015 13:35:26 -0700 (PDT) In-Reply-To: <87wpux88mo.fsf@gmail.com> References: <87oag9fim6.fsf@gmail.com> <87wpux88mo.fsf@gmail.com> From: Kaushal Modi Date: Thu, 8 Oct 2015 16:35:26 -0400 Message-ID: Content-Type: multipart/alternative; boundary=001a113d5d34f7684805219dcfe0 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a113d5d34f7684805219dcfe0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi all, Here the the new implementation of calc-yank. I can submit a PATCH once the new definition is confirmed. > If the copied number has a calc-style prefix, then the number should be > interpreted in that base. I can be entered onto the stack in the new > base. That's done now; if Calc is using base 5 and 2#111 is yanked, > then 5#12 appears on the stack. It does that now =E2=80=8B. I also tested with the 2#111 and few other examples. =E2=80=8B =E2=80=8B> =E2=80=8B You'd probably want Calc to do the conversion. =E2=80=8BCorrect, I am not doing any string manipulation.. I simply don't h= andle the string if it begins with "\\`[0-9]+#".=E2=80=8B =E2=80=8B> =E2=80=8B Your method is a good approach. =E2=80=8BThanks. I have not changed the way =E2=80=8Bit works right now. Us= ing the same example of yanking "1000" in a calc buffer with radix set to hex ("d6"), doing C-y will paste 16#3E8. But with the new calc-yank, C-6 C-y will paste 16#1000. =E2=80=8B> =E2=80=8B Yes; it sounds like a nice approach. =E2=80=8BDone! I have implemented C-u C-y functionality which will prompt u= ser to enter radix between 2 and 36.=E2=80=8B =E2=80=8B> =E2=80=8B And perhaps some sort of message =E2=80=8B> =E2=80=8B if the entered radix isn't a number from 2 to 36 (the allowed radixes). Is that check needed in calc-yank? If I enter an invalid radix like 37, I get the generic error "Bad format in yanked data".=E2=80=8B > =E2=80=8BAlso, you probably want to make sure that calc-yank behaves =E2=80=8B> =E2=80=8B appropriately when a number isn't being yanked. =E2=80=8B> =E2=80=8B (Either applying the new base to all numbers in an expression or =E2=80=8B> =E2=80=8B disregarding the radix when the expression being yanked isn't a pure > number, for example.) Ah! I wasn't aware that yanking non-numbers was possible! Based on the current code, as long as the user does not provide ANY prefix, calc-yank will work exactly as before. So the non-number yanking should also behave the same way. Can you please provide feedback on how to incorporate that based on the below updated code? Or can you provide some valid non-number examples for yanking? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=E2=80=8B (defun calc-yank (radix) "Yank a value into the Calculator buffer. Valid numeric prefixes for RADIX: 0, 2, 6, 8 No radix notation is prepended for any other numeric prefix. If RADIX is 2, prepend \"2#\" - Binary. If RADIX is 8, prepend \"8#\" - Octal. If RADIX is 0, prepend \"10#\" - Decimal. If RADIX is 6, prepend \"16#\" - Hexadecimal. If RADIX is a non-nil list (created using \\[universal-argument]), the user will be prompted to enter the radix in the minibuffer. If RADIX is nil or if the yanked string already has a calc radix prefix, th= e yanked string will be passed on directly to the Calculator buffer without any alteration." (interactive "P") (calc-wrapper (calc-pop-push-record-list 0 "yank" (let* (radix-notation (thing-raw (if (fboundp 'current-kill) (current-kill 0 t) (car kill-ring-yank-pointer))) (thing (if (or (null radix) (string-match-p "\\`[0-9]+#" thing-raw)) thing-raw (progn (setq radix-notation (if (listp radix) (concat (number-to-string (read-number "Set radix for yanked number (2-36): ")) "#") (cond ((eq radix 2) "2#") ((eq radix 8) "8#") ((eq radix 0) "10#") ((eq radix 6) "16#") (t (progn (message (concat "No radix is " "prepended for prefix " "value of %0d. Valid " "numeric prefixes are " "0, 2, 6, 8.") radix) ""))))) (concat radix-notation thing-raw))))) (if (eq (car-safe calc-last-kill) thing) (cdr calc-last-kill) (if (stringp thing) (let ((val (math-read-exprs (calc-clean-newlines thing)))) (if (eq (car-safe val) 'error) (progn (setq val (math-read-exprs thing)) (if (eq (car-safe val) 'error) (error "Bad format in yanked data") val)) val)))))))) -- Kaushal Modi On Thu, Oct 8, 2015 at 3:26 PM, Jay Belanger wrote: > > > >> With the patch, if the yanked number already has the radix prefix, there > >> is an error. It might make more sense to have Calc do an appropriate > >> conversion. > > I did not try that case as I meant to use the prefix only when the copied number does > > not have a calc-style prefix. But that's a valid point. If the copied number has > > calc-style prefix, what should have a higher priority? > > If the copied number has a calc-style prefix, then the number should be > interpreted in that base. I can be entered onto the stack in the new > base. That's done now; if Calc is using base 5 and 2#111 is yanked, > then 5#12 appears on the stack. > > > Either way, it will be easy with some string manipulation. > > You'd probably want Calc to do the conversion. > > >> It might make more sense to have calc-yank use the current Calc's current radix rather > >> than a prefix radix. > > I need some clarification for this point. Did you mean that if the > > user has set the calc radix to hex by using "d6" and now if they yank > > a number "1000" it gets yanked automatically as "16#1000". > > Yes; that's what I meant. > > > If yes, I believe it will cause a huge disturbance in the way people > > might have already got used to yanking in calc. > > You are probably right. I would prefer the yanking to pay attention to > the current Calc setting, but I really don't like changing age-old > behavior. Your method is a good approach. > > >> Also, the number of radixes in the patch is less than Calc allows. > > I assumed the use cases of only the common radixes used in programming. How about I > > display a prompt for the user to enter any radix they like (I believe calc supports up > > to radix 36) if the prefix is specifically '(4) ( a list prefix created when user uses > > C-u specifically for prefix). > > > > So now, C-2 C-y will prefix the yanked number with "2#". But C-u C-y will show a prompt > > where the user will enter radix. If the user entered 9, the prefix appended will be > > "9#". Does this option sound fair? > > Yes; it sounds like a nice approach. And perhaps some sort of message > if the entered radix isn't a number from 2 to 36 (the allowed radixes). > > Thanks again, > Jay > > --001a113d5d34f7684805219dcfe0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all,

Here the the new implementation of calc-yan= k. I can submit a PATCH once the new definition is confirmed.

> I= f the copied number has a calc-style prefix, then the number should be
&= gt; interpreted in that base.=C2=A0 I can be entered onto the stack in the = new
> base.=C2=A0 That's done now; if Calc is using base 5 and 2#= 111 is yanked,
> then 5#12 appears on the stack.

It does that = now
=E2=80=8B. I also tested with t= he 2#111 and few other examples.

=E2= =80=8B

=E2=80=8B> =E2= =80=8B
You'd probably want Calc to do the conversion.

=E2=80=8BCorrect, I am not doing any string manipulati= on.. I simply don't handle the string if it begins with "\\`[0-9]+= #".=E2=80=8B

=E2=80= =8B> =E2=80=8B
Your method is a good approach.

=E2=80=8BThanks. I have not changed the way =E2=80=8Bit works = right now. Using the same example of yanking "1000" in a calc buf= fer with radix set to hex ("d6"), doing C-y will paste 16#3E8. Bu= t with the new calc-yank, C-6 C-y will paste 16#1000.

=E2=80=8B> =E2=80=8B
Yes; it sounds = like a nice approach. =C2=A0

=E2=80=8BDone! I have implemented C-u C-y functionality which will pro= mpt user to enter radix between 2 and 36.=E2=80=8B

=E2=80=8B> =E2=80=8B
And perha= ps some sort of message
=E2=80= =8B> =E2=80=8B
if the entered radix isn't a number from 2 to 36= (the allowed radixes).

Is that check need= ed in calc-yank? If I enter an invalid radix like 37, I get the generic err= or "Bad format in yanked data".=E2=80=8B

> =E2=80=8BAlso, you probably want to make sure that calc-yank behaves
=E2=80=8B> =E2=80=8B
appropriately when a number isn't = being yanked.

=E2=80=8B> =E2=80=8B(Either applying the new base to all numbers in an expression or=
=E2=80=8B> =E2=80=8B
disregarding th= e radix when the expression being yanked isn't a pure

> number, for example.)
<= div class=3D"gmail_default" style=3D"font-family:'trebuchet ms',san= s-serif;font-size:small">
Ah! I wasn'= ;t aware that yanking non-numbers was possible!
Based on the current code, as long as the = user does not provide ANY prefix, calc-yank will work exactly as before. So= the non-number yanking should also behave the same way.

Can you please provide feedback on how to= incorporate that based on the below updated code?
Or can you provide some valid non-number examples for yanking?
=



=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=E2=80=8B

(defun calc-yank (radix)
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Yank a value into the Calculator buffer.<= br>
Valid numeric prefixes for RADIX: 0, 2, 6, 8
No radix notation is= prepended for any other numeric prefix.

If RADIX is 2, prepend \&qu= ot;2#\" =C2=A0- Binary.
If RADIX is 8, prepend \"8#\" =C2= =A0- Octal.
If RADIX is 0, prepend \"10#\" - Decimal.
If RA= DIX is 6, prepend \"16#\" - Hexadecimal.

If RADIX is a non= -nil list (created using \\[universal-argument]), the user
will be promp= ted to enter the radix in the minibuffer.

If RADIX is nil or if the = yanked string already has a calc radix prefix, the
yanked string will be= passed on directly to the Calculator buffer without any
alteration.&quo= t;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (interactive "P")
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (calc-wrapper
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(calc-pop-push-record-list
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 0 "yank"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (let* (radix-notation
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(thing-raw (if (fboundp 'current-kill)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=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=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (concat radix-notation thi= ng-raw)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (eq (ca= r-safe calc-last-kill) thing)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (cdr calc-last-kill)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (stringp thing)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((val (math-read-exprs (= calc-clean-newlines thing))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (eq (car-safe val) 'error)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (progn
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq val (math-read-e= xprs thing))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (eq (car-safe val) 'error)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Bad format in yanked da= ta")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 val))
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 val))))))))<= br>

--
Kaushal Modi

On Thu, Oct 8, 2015 at 3:26 PM, Jay Be= langer <jay.p.belanger@gmail= .com> wrote:
>
>
> >> With the patch, if the= yanked number already has the radix prefix, there
> >> is an e= rror. It might make more sense to have Calc do an appropriate
> >&= gt; conversion.
> > I did not try that case as I meant to use the = prefix only when the copied number does
> > not have a calc-style = prefix. But that's a valid point. If the copied number has
> >= calc-style prefix, what should have a higher priority?
>
> If = the copied number has a calc-style prefix, then the number should be
>= ; interpreted in that base.=C2=A0 I can be entered onto the stack in the ne= w
> base.=C2=A0 That's done now; if Calc is using base 5 and 2#11= 1 is yanked,
> then 5#12 appears on the stack.
>
> > E= ither way, it will be easy with some string manipulation.
>
> Y= ou'd probably want Calc to do the conversion.
>
> >> = It might make more sense to have calc-yank use the current Calc's curre= nt radix rather
> >> than a prefix radix.
> > I need s= ome clarification for this point. Did you mean that if the
> > use= r has set the calc radix to hex by using "d6" and now if they yan= k
> > a number "1000" it gets yanked automatically as &q= uot;16#1000".
>
> Yes; that's what I meant.
>> > If yes, I believe it will cause a huge disturbance in the way pe= ople
> > might have already got used to yanking in calc.
>> You are probably right.=C2=A0 I would prefer the yanking to pay atte= ntion to
> the current Calc setting, but I really don't like chan= ging age-old
> behavior.=C2=A0 Your method is a good approach.
>= ;
> >> Also, the number of radixes in the patch is less than Ca= lc allows.
> > I assumed the use cases of only the common radixes = used in programming. How about I
> > display a prompt for the user= to enter any radix they like (I believe calc supports up
> > to r= adix 36) if the prefix is specifically '(4) ( a list prefix created whe= n user uses
> > C-u specifically for prefix).
> >
>= > So now, C-2 C-y will prefix the yanked number with "2#". Bu= t C-u C-y will show a prompt
> > where the user will enter radix. = If the user entered 9, the prefix appended will be
> > "9#&qu= ot;. Does this option sound fair?
>
> Yes; it sounds like a nic= e approach.=C2=A0 And perhaps some sort of message
> if the entered r= adix isn't a number from 2 to 36 (the allowed radixes).
>
>= Thanks again,
> Jay
>
>
--001a113d5d34f7684805219dcfe0-- From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank In-Reply-To: Resent-From: Jay Belanger Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Oct 2015 01:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Kaushal Modi Cc: 21648@debbugs.gnu.org, jay.p.belanger@gmail.com Reply-To: jay.p.belanger@gmail.com Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.14443526918612 (code B ref 21648); Fri, 09 Oct 2015 01:05:01 +0000 Received: (at 21648) by debbugs.gnu.org; 9 Oct 2015 01:04:51 +0000 Received: from localhost ([127.0.0.1]:33235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkM78-0002Ep-Ou for submit@debbugs.gnu.org; Thu, 08 Oct 2015 21:04:51 -0400 Received: from mail-ob0-f169.google.com ([209.85.214.169]:36112) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkM76-0002Eh-9G for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 21:04:48 -0400 Received: by obcgx8 with SMTP id gx8so51815585obc.3 for <21648@debbugs.gnu.org>; Thu, 08 Oct 2015 18:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:reply-to:cc:date:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=cdguX0UnQh5MqMpeKGp8+V0WZf4/2JOL2LXsMDNqx4w=; b=PUwNDqAYU+ZspNBYWF/zzT04jFN5FOmSovCGpC0TqGqaazEzAqw4Zi34kS0gDYMW4p 0Y4fOEwFiN+OR+jZYDE0DzFVnALlwUMgJ6TYI+4Wi23yXL+LKN7nIW//123MfupCpXFM WViHCIYHePaSSI1KUHgU6Rr8WR8oxKBIH6fEyaWS7k0syqdiZRVdrD49AvacaSuOiE+E gcteEy2l4FGQGCgN/4lbeOL3lHjRGIpkeklqFpLmVht0xGFDm6EUknhMic5GPuK8knN5 gTupjHG2GMLwaXkd3us3ktr9nu3ZExON2P8HX7gMPCV4zkkc/c0JkGokaIpuMvZsorO6 zyuQ== X-Received: by 10.182.16.135 with SMTP id g7mr6420957obd.67.1444352687724; Thu, 08 Oct 2015 18:04:47 -0700 (PDT) Received: from belanger-home (67-60-185-108.cpe.cableone.net. [67.60.185.108]) by smtp.gmail.com with ESMTPSA id s127sm20690557oia.21.2015.10.08.18.04.46 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 Oct 2015 18:04:46 -0700 (PDT) From: Jay Belanger References: <87oag9fim6.fsf@gmail.com> <87wpux88mo.fsf@gmail.com> Date: Thu, 08 Oct 2015 20:04:06 -0500 Message-ID: <87fv1k3la1.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hi! > =E2=80=8BDone! I have implemented C-u C-y functionality which will prompt= user to enter radix between 2 and 36.=E2=80=8B > >> And perhaps some sort of message >> if the entered radix isn't a number from 2 to 36 (the allowed radixes). > > Is that check needed in calc-yank? If I enter an invalid radix like > 37, I get the generic error "Bad format in yanked data".=E2=80=8B But the data might be fine; the problem is with the radix. >> =E2=80=8BAlso, you probably want to make sure that calc-yank behaves >> appropriately when a number isn't being yanked. > > Can you please provide feedback on how to incorporate that based on the b= elow updated code? To determine whether or not a string represents a number, you could have Calc parse it, I suppose. But that would be wasteful. It might be better to add a function, maybe called `math-numberstring-p', which returns t is the argument is a string which represents a Calc number. Then along with (or ((null radix) (string-match-p "\\`[0-9]+#" thing-raw) ... you could add (not (math-numberstring-p thing-raw)) Oh, also, calc-yank can yank more than one line. Currently, if 111 1111 is killed and yanked with C-8 C-y, the result is 2: 73 1: 1111 and you'd probably want 2: 73 1: 585 Also, the message (message (concat "No radix is " "prepended for prefix " "value of %0d. Valid " "numeric prefixes are " "0, 2, 6, 8.") radix) is a bit long. > I can submit a PATCH once the new definition is confirmed. I can commit this for you without a patch. Jay From unknown Fri Jun 20 07:22:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Oct 2015 02:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21648 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Jay Belanger Cc: 21648@debbugs.gnu.org Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.144435943418984 (code B ref 21648); Fri, 09 Oct 2015 02:58:01 +0000 Received: (at 21648) by debbugs.gnu.org; 9 Oct 2015 02:57:14 +0000 Received: from localhost ([127.0.0.1]:33252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkNrt-0004w7-Br for submit@debbugs.gnu.org; Thu, 08 Oct 2015 22:57:14 -0400 Received: from mail-oi0-f52.google.com ([209.85.218.52]:34673) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkNrq-0004vz-T0 for 21648@debbugs.gnu.org; Thu, 08 Oct 2015 22:57:11 -0400 Received: by oiak8 with SMTP id k8so23449050oia.1 for <21648@debbugs.gnu.org>; Thu, 08 Oct 2015 19:57:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=gyRoFdjAM2mjr19aIrNVx9TSbywvtbRiV2uUTWpT0Oo=; b=ZYLKVNRz6ozoiJYWPDVACGk1ZEGp5u8LBNbB0SaglXD+bGQ7o+G1aOzh2zbbFy2MM6 j11rRcPnj/jEIMji1Y/84Egz/CwNMMA3MtG8ft6RjbPTQoRtz7CxCciVycgwi8V6pMR8 6P9Lb8L40ZZkB8kb9ubKRnQEWO1FW/i2/pMM7e+yldoVRNODrjyiFDL6Jh3iipc5LvHI pkaAotXpbsa94OTKhl3ehi4DQhT5MdY84WfVt5Wq1OLZMYfl+2X8ysFyRtkVx3b5c1Du FXV0n8BpPHj1ZehevC9tci+8Ch89mJpohAWE0PJ9Ofq9v2tn3TC1XTwqfZqf/AEH/2sA ABrw== X-Received: by 10.202.211.10 with SMTP id k10mr6501556oig.34.1444359430007; Thu, 08 Oct 2015 19:57:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.172.205 with HTTP; Thu, 8 Oct 2015 19:56:30 -0700 (PDT) In-Reply-To: <87fv1k3la1.fsf@gmail.com> References: <87oag9fim6.fsf@gmail.com> <87wpux88mo.fsf@gmail.com> <87fv1k3la1.fsf@gmail.com> From: Kaushal Modi Date: Thu, 8 Oct 2015 22:56:30 -0400 Message-ID: Content-Type: multipart/alternative; boundary=001a113d2cd6c10c4a0521a32286 X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) --001a113d2cd6c10c4a0521a32286 Content-Type: text/plain; charset=UTF-8 Thanks for the feedback. The below code has every suggestion implemented except for the `math-numberstring-p`. I will need to thing more about how to implement that. Also the below condition might not be enough (even before we start thinking about math-numberstring-p): (or (null radix) (string-match-p "\\`[0-9]+#" thing-raw)) What if the user yanks the below string? 111 2#1111 In that case, the below code will generate the below if called using C-2 C-y 2#111 2#2#1111 The above case seems impractical. Or is it? Should we need to make the code foolproof against such unusual cases? If yes, then we need to ensure that either the radix prepending happens only if all yanked lines are pristine The below code has the following updated: - Support for negative numbers! - Error when user enters a non-integer or an integer <2 or >36 - Support for prepending the radix-notation to multiline yanks (assuming the yanks do not fit in the above mentioned strange case) - Made the referenced long message a bit concise. ====== (defun calc-yank (radix) "Yank a value into the Calculator buffer. Valid numeric prefixes for RADIX: 0, 2, 6, 8 No radix notation is prepended for any other numeric prefix. If RADIX is 2, prepend \"2#\" - Binary. If RADIX is 8, prepend \"8#\" - Octal. If RADIX is 0, prepend \"10#\" - Decimal. If RADIX is 6, prepend \"16#\" - Hexadecimal. If RADIX is a non-nil list (created using \\[universal-argument]), the user will be prompted to enter the radix in the minibuffer. If RADIX is nil or if the yanked string already has a calc radix prefix, the yanked string will be passed on directly to the Calculator buffer without any alteration." (interactive "P") (calc-wrapper (calc-pop-push-record-list 0 "yank" (let* (radix-num radix-notation (thing-raw (if (fboundp 'current-kill) (current-kill 0 t) (car kill-ring-yank-pointer))) (thing (if (or (null radix) (string-match-p "\\`\\-*[0-9]+#" thing-raw)) thing-raw (progn (setq radix-notation (if (listp radix) (progn (setq radix-num (read-number "Set radix for yanked number (2-36): ")) (if (and (integerp radix-num) (<= 2 radix-num) (>= 36 radix-num)) (concat (number-to-string radix-num) "#") (error (concat "The radix has to be an " "integer between 2 and 36.")))) (cond ((eq radix 2) "2#") ((eq radix 8) "8#") ((eq radix 0) "10#") ((eq radix 6) "16#") (t (progn (message (concat "No radix prepended " "for invalid numeric " "prefix %0d.") radix) ""))))) ;; Ensure that the radix-notation is prefixed ;; correctly even for multi-line yanks like ;; 111 ;; 1111 (replace-regexp-in-string "^\\(\\-*\\)\\(.*\\)" (concat "\\1" radix-notation "\\2") thing-raw))))) (if (eq (car-safe calc-last-kill) thing) (cdr calc-last-kill) (if (stringp thing) (let ((val (math-read-exprs (calc-clean-newlines thing)))) (if (eq (car-safe val) 'error) (progn (setq val (math-read-exprs thing)) (if (eq (car-safe val) 'error) (error "Bad format in yanked data") val)) val)))))))) -- Kaushal Modi --001a113d2cd6c10c4a0521a32286 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the feedback.

The below code = has every suggestion implemented except for the `math-numberstring-p`.
I will need to thing more about how to implement= that.

A= lso the below condition might not be enough (even before we start thinking = about math-numberstring-p):

(or (null radix)
= =C2=A0 =C2=A0 =C2=A0(string-match-p= "\\`[0-9]+#" thing-raw))


<= br>
111
2#111= 1

In tha= t case, the below code will generate the below if called using C-2 C-y

2#111
2#2#1111

The above case seems impractical. Or is it? Should we nee= d to make the code foolproof against such unusual cases?
If yes, = then we need to ensure that either the radix prepending happens only if all= yanked lines are pristine=C2=A0

The below code ha= s the following updated:
- Support for negative numbers!
- Error when user enters a non-integer or an integer <2 or >36
- Support for prepending the radix-notation to multiline yanks (assum= ing the yanks do not fit in the above mentioned strange case)
- M= ade the referenced long message a bit concise.

=3D= =3D=3D=3D=3D=3D

(defun calc-yank (radix)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 "Yank a value into the Calculator buffer.

Valid numeric prefixes for RADIX: 0, 2, 6, 8
No radix notation is prepended for any other numeric prefix.

If RADIX is 2, prepend \"2#\"= ; =C2=A0- Binary.
If RADIX is 8, prepend \"8#\" = =C2=A0- Octal.
If RADIX is 0, prepend \"10#\" - = Decimal.
If RADIX is 6, prepend \"16#\" - Hexade= cimal.

If RADIX is a non-nil list (c= reated using \\[universal-argument]), the user
will be pro= mpted to enter the radix in the minibuffer.

If RADIX is nil or if the yanked string already has a calc radix pr= efix, the
yanked string will be passed on directly to the = Calculator buffer without any
alteration."
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (interactive "P")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (calc-wrapper
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(calc-pop-push-record-list
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0 "yank"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let* (radix-num<= /font>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0radix-notation
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(thing-raw (if (fboundp 'curre= nt-kill)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (curr= ent-kill 0 t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (car = kill-ring-yank-pointer)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(thing (if (or (null radix)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (string-match-p "= \\`\\-*[0-9]+#" thing-raw))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0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C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Set rad= ix for yanked number (2-36): "))
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (and (integerp rad= ix-num)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(<=3D 2 radix= -num)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(>=3D 36 radix-nu= m))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (concat (number-to-string radix-num) &qu= ot;#")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error (concat "The radix has to be= an "
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0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C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0thing-raw)))))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (eq (car-safe calc-last-kill) thing)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (cdr calc-last-kill)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (stringp thing)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((val (mat= h-read-exprs (calc-clean-newlines thing))))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (eq (car= -safe val) 'error)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq val (math-read-exprs thing))
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (eq (car-safe val) 'error)
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Bad format in yanked= data")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 val))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 val))))))))

--
Kaushal Modi

--001a113d2cd6c10c4a0521a32286-- From unknown Fri Jun 20 07:22:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Kaushal Modi Subject: bug#21648: closed (Re: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank) Message-ID: References: X-Gnu-PR-Message: they-closed 21648 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 21648@debbugs.gnu.org Date: Mon, 12 Oct 2015 13:17:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1444655823-3584-1" This is a multi-part message in MIME format... ------------=_1444655823-3584-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number= in calc-yank which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 21648@debbugs.gnu.org. --=20 21648: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21648 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1444655823-3584-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 21648-done) by debbugs.gnu.org; 12 Oct 2015 13:16:21 +0000 Received: from localhost ([127.0.0.1]:36950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zlcxg-0000up-Ie for submit@debbugs.gnu.org; Mon, 12 Oct 2015 09:16:20 -0400 Received: from mail-oi0-f52.google.com ([209.85.218.52]:32902) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zlcxe-0000uh-2w for 21648-done@debbugs.gnu.org; Mon, 12 Oct 2015 09:16:18 -0400 Received: by oiar126 with SMTP id r126so35481520oia.0 for <21648-done@debbugs.gnu.org>; Mon, 12 Oct 2015 06:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=Z14BMsru0iJoMEWphclyrWKwux/IefZ7RCVA7qIeV98=; b=WazMo1mjuL40jY128eciiUn3+nWGArasoPjx788mHMDk4W8eXc3KrHsAPYQ0fUkAyj AD43waazSOHcEPJ/bBc0TRoXi3HwEEffZ9lRS0RXaGugoed3mSTIZcWIZlR3x1B1g6L4 4W4o6px5KW1+KU95alDnAKwqufkJ66vmYpCU13MblrLwauKKamKDLADS8gRoLbH0/xmr 3Mb9WvkzCZg9Egu9l2jRqEcoaVmIlAUVxDG8iNoqcVM+fi4HBQZ/ZBE6nrxWMdyNjEDR 4OjOdOZLAXuIiAnrSO6e2YmGpeWMXsNQLd0tJuxyP5PKjqS7J6b8g5QR/qbf7yFCbmQw SPCA== X-Received: by 10.202.104.35 with SMTP id d35mr12035729oic.57.1444655777389; Mon, 12 Oct 2015 06:16:17 -0700 (PDT) MIME-Version: 1.0 References: <87oag9fim6.fsf@gmail.com> <87wpux88mo.fsf@gmail.com> <87fv1k3la1.fsf@gmail.com> <8737xk7nge.fsf@gmail.com> <87twq0dkqd.fsf@gmail.com> <87vbael6ph.fsf@gmail.com> <87twpyuz1q.fsf@gmail.com> <87vbaeib5o.fsf@gmail.com> In-Reply-To: <87vbaeib5o.fsf@gmail.com> From: Kaushal Modi Date: Mon, 12 Oct 2015 13:16:07 +0000 Message-ID: Subject: Re: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank To: jay.p.belanger@gmail.com, 21648-done@debbugs.gnu.org Content-Type: multipart/alternative; boundary=001a1140b4826f22110521e82224 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 21648-done Cc: Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a1140b4826f22110521e82224 Content-Type: text/plain; charset=UTF-8 Closing this debbugs as the patch is now commited to the trunk: http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ec0d4d24fd11b5040de9f7657b486c3b1e743071 Many thanks to Jay for a very active feedback session, helping make the final patch much more robust than the initial version. --001a1140b4826f22110521e82224 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Closing this debbugs as the patch is now commited to the t= runk:=C2=A0http://git.savannah.gnu.org/cg= it/emacs.git/commit/?id=3Dec0d4d24fd11b5040de9f7657b486c3b1e743071
=
Many thanks to Jay for a very active feedback session, helpi= ng make the final patch much more robust than the initial version.
--001a1140b4826f22110521e82224-- ------------=_1444655823-3584-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 Oct 2015 15:09:06 +0000 Received: from localhost ([127.0.0.1]:32775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkCob-0000Dg-T0 for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:09:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47559) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkCoZ-0000DH-8U for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:09:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkCo2-0003oe-Mq for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:09:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_FONT_FACE_BAD,HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkCo2-0003m4-0A for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:08:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkCny-0002oZ-DK for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkCnr-0003B5-4q for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:08:25 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:35562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkCnq-00038g-Dn for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:08:18 -0400 Received: by oigi138 with SMTP id i138so6455007oig.2 for ; Thu, 08 Oct 2015 08:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=hp9X4cWwohMWBr9OVkY24ejGDwdEhcaxYcYc4umPI0A=; b=QxkGOXsBpxEnmRQLeTXMMDe0DmYgReUZqraEbdpNZk8FvQe1xqgH1bVIQgoUIZbAb/ 9J5k2FShrVk13aO0DY37WwQ33Y16f7WGw7e/NV2qeynLlRkQTEqLYmEsAEW+/RyV93xf Lf9Nul4fg+ih/xYeiQG2THDgl8DQzm5MTudXQkfJVEyGgmQRpkJ9R7u+JeeaTNjG2+tr h5kdA9qGULMHls0SbdwetJ0JnyKV7QaraiokTs9Wy2rXv4qXRHuZvsgFrpVviWWnKUpe wWZz3+Co59Hfx83bdrzmTvvOwcjNeBaRyTo3XBcqoLbV/NdWnm6oBhSJmFVLoP1c4e/X GYzQ== X-Received: by 10.202.65.136 with SMTP id o130mr4641784oia.134.1444316897726; Thu, 08 Oct 2015 08:08:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.172.205 with HTTP; Thu, 8 Oct 2015 08:07:38 -0700 (PDT) From: Kaushal Modi Date: Thu, 8 Oct 2015 11:07:38 -0400 Message-ID: Subject: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank To: "bug-gnu-emacs@gnu.org" , jay.p.belanger@gmail.com Content-Type: multipart/alternative; boundary=001a113cd6d2a1d97b0521993b37 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.7 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.7 (---) --001a113cd6d2a1d97b0521993b37 Content-Type: text/plain; charset=UTF-8 Hi, I read this question of emacs.stackexchange ( http://emacs.stackexchange.com/q/13451/115 ) where the user needed to specify the radix of the number he was pasting in calc. If the calc default radix is decimal and if a user pastes 1000, it will be pasted as decimal 1000. But what if the user meant to paste binary 1000 (decimal 8)? My patch below enables doing that using numeric prefixes. Please advise if merging this patch to calc-yank is a good idea or if needs improvement/bug fixes before the merging. I have used this modified calc-yank function for few weeks and did not mess up anything else in my calc usage. ====================================================== >From fa9c8f6c2cce1c9e69bd6f6c25f036a72e0b799b Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Thu, 8 Oct 2015 10:56:36 -0400 Subject: [PATCH] Prepend radix to yanked numbers using num prefix If 1000 is the last element saved to the kill-ring. Then, C-2 C-y will paste 8 (2#1000), C-8 C-y will paste 512 (8#1000), C-0 C-y will paste 1000 (10#1000), C-6 C-y will paste 4096 (16#1000) .. and C-y will paste 1000 (1000). --- lisp/calc/calc-yank.el | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el index 5694a4e..811b308 100644 --- a/lisp/calc/calc-yank.el +++ b/lisp/calc/calc-yank.el @@ -111,25 +111,40 @@ calc-copy-region-as-kill ;; otherwise it just parses the yanked string. ;; Modified to use Emacs 19 extended concept of kill-ring. -- daveg 12/15/96 ;;;###autoload -(defun calc-yank () - (interactive) +(defun calc-yank (radix) + "Yank a value into the Calculator buffer. + +If RADIX is nil, do not prepend any radix notation. + +If RADIX is 2, prepend \"2#\" (The yanked number will be perceived as binary.) +If RADIX is 8, prepend \"8#\" (The yanked number will be perceived as octal.) +If RADIX is 0, prepend \"10#\" (The yanked number will be perceived as decimal.) +If RADIX is 16, prepend \"16#\" (The yanked number will be perceived as hexadecimal.) " + (interactive "P") (calc-wrapper (calc-pop-push-record-list 0 "yank" - (let ((thing (if (fboundp 'current-kill) - (current-kill 0 t) - (car kill-ring-yank-pointer)))) + (let* ((radix-notation (cl-case radix + (2 "2#") + (8 "8#") + (0 "10#") + (6 "16#") + (t ""))) + (thing (concat radix-notation + (if (fboundp 'current-kill) + (current-kill 0 t) + (car kill-ring-yank-pointer))))) (if (eq (car-safe calc-last-kill) thing) - (cdr calc-last-kill) - (if (stringp thing) - (let ((val (math-read-exprs (calc-clean-newlines thing)))) - (if (eq (car-safe val) 'error) - (progn - (setq val (math-read-exprs thing)) - (if (eq (car-safe val) 'error) - (error "Bad format in yanked data") - val)) - val)))))))) + (cdr calc-last-kill) + (if (stringp thing) + (let ((val (math-read-exprs (calc-clean-newlines thing)))) + (if (eq (car-safe val) 'error) + (progn + (setq val (math-read-exprs thing)) + (if (eq (car-safe val) 'error) + (error "Bad format in yanked data") + val)) + val)))))))) ;;; The Calc set- and get-register commands are modified versions of functions ;;; in register.el -- 2.6.0.rc0.24.gec371ff ====================================================== PS: My copyright paperwork is on file (#1029578) -- Kaushal Modi --001a113cd6d2a1d97b0521993b37 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I read this question of emacs.stackexchange (= =C2=A0http://emacs.s= tackexchange.com/q/13451/115 ) where the user needed to specify the rad= ix of the number he was pasting in calc.

=
If the calc default radix is decimal and if a user pastes 1000, it wil= l be pasted as decimal 1000. But what if the user meant to paste binary 100= 0 (decimal 8)?

My patch below enable= s doing that using numeric prefixes.

Please advise if merging this patch to calc-yank is a good idea or if need= s improvement/bug fixes before the merging. I have used this modified calc-= yank function for few weeks and did not mess up anything else in my calc us= age.



<= /font>

<= font face=3D"trebuchet ms, sans-serif">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

<= /font>
From fa9c8f6c2cce1c9e69bd6f6c25f036a72e0b799b Mon Sep 17 0= 0:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date:= Thu, 8 Oct 2015 10:56:36 -0400
Subject: [PATCH] Prepend r= adix to yanked numbers using num prefix

<= div class=3D"gmail_default" style=3D"">If 1000 is the last element saved to the kill-ring.
Then,

C-2 C-y wi= ll paste 8 (2#1000),
C-8 C-y will paste 512 (8#1000),
C-0 C-y will paste 1000 (10#1000),
C-6 C-y wi= ll paste 4096 (16#1000)
.. and C-y will paste 1000 (1000).=
---
<= font face=3D"trebuchet ms, sans-serif">=C2=A0lisp/calc/calc-yank.el | 45 ++= ++++++++++++++++++++++++++++---------------
=C2=A01 file c= hanged, 30 insertions(+), 15 deletions(-)

diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el
index 5694a4e..811b308 100644
--- a/lisp/calc/cal= c-yank.el
+++ b/lisp/calc/calc-yank.el
@@= -111,25 +111,40 @@ calc-copy-region-as-kill
=C2=A0;; othe= rwise it just parses the yanked string.
=C2=A0;; Modified = to use Emacs 19 extended concept of kill-ring. -- daveg 12/15/96
=C2=A0;;;###autoload
-(defun calc-yank ()
- =C2=A0(interactive)
+(defun calc-yank (radix)
+ =C2=A0"Yank a value into the Calculator buffer.
+
+If RADIX is nil, do not prepend any radix = notation.
+
+If RADIX is 2, prepend \&quo= t;2#\" (The yanked number will be perceived as binary.)
+If RADIX is 8, prepend \"8#\" (The yanked number will be perc= eived as octal.)
+If RADIX is 0, prepend \"10#\"= (The yanked number will be perceived as decimal.)
+If R= ADIX is 16, prepend \"16#\" (The yanked number will be perceived = as hexadecimal.) "
+ =C2=A0(interactive "P"= )
=C2=A0 =C2=A0(calc-wrapper
=C2=A0 =C2= =A0 (calc-pop-push-record-list
=C2=A0 =C2=A0 =C2=A00 "= ;yank"
- =C2=A0 =C2=A0(let ((thing (if (fboundp '= ;current-kill)
- =C2=A0 =C2=A0 (current-kill 0 t)
- =C2=A0 (car kill-ring-yank-pointe= r))))
+ =C2=A0 =C2=A0(let* ((radix-notation (cl-case radix=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (2 "2#")
<= div class=3D"gmail_default" style=3D"">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (8 "8#")
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (0 "10#")
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (6 "16#")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (t &= quot;")))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (thing= (concat radix-notation
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (fboundp = 9;current-kill)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(current-= kill 0 t)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(car kill-ring-yank-poi= nter)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(if (eq (car-safe cal= c-last-kill) thing)
- =C2=A0(cdr calc-last-kill)
- (if (stringp thing)
-<= span class=3D"" style=3D"white-space:pre"> =C2=A0 =C2=A0(let ((val = (math-read-exprs (calc-clean-newlines thing))))
- =C2=A0 =C2=A0 =C2=A0(if (eq (car= -safe val) 'error)
= - =C2=A0(progn
- =C2=A0 =C2=A0(setq val (math-read-exprs thing))=
- =C2= =A0 =C2=A0(if (eq (car-safe val) 'error)
- (error "Bad format in yanked= data")
- = =C2=A0 =C2=A0 =C2=A0val))
- val))))))))
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(cdr calc-last-kill)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0(if (stringp thing)
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(let ((val (math-read-exprs (calc-clean-newlines thing)= )))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if = (eq (car-safe val) 'error)
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(progn
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq val (math-= read-exprs thing))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (eq (car-safe val) 'error)=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0(error "Bad format in yanked data")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0val))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0val))))))))
=C2=A0
= =C2=A0;;; The Calc set- and get-register commands are modified versions of = functions
=C2=A0;;; in register.el
--=C2= =A0
2.6.0.rc0.24.gec371ff

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

PS: My copyright= paperwork is on file (#1029578)

--<= br>Kaushal Modi
--001a113cd6d2a1d97b0521993b37-- ------------=_1444655823-3584-1--