From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.bugs Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank Date: Thu, 8 Oct 2015 16:35:26 -0400 Message-ID: References: <87oag9fim6.fsf@gmail.com> <87wpux88mo.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113d5d34f7684805219dcfe0 X-Trace: ger.gmane.org 1444336798 22957 80.91.229.3 (8 Oct 2015 20:39:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Oct 2015 20:39:58 +0000 (UTC) Cc: 21648@debbugs.gnu.org To: Jay Belanger Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 08 22:39:47 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from eggs.gnu.org ([208.118.235.92]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZkHyc-0000pG-Dc for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 22:39:46 +0200 Original-Received: from lists.gnu.org ([208.118.235.17]:52421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkHyb-0008Re-Cq for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 16:39:45 -0400 Original-Received: from localhost ([::1]:36950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkHyb-0002YW-Ay for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 16:39:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkHw3-0002Qk-W3 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 16:37:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkHvy-0007rR-Hb for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 16:37:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkHvy-0007rE-F5 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 16:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZkHvx-0002mM-VL for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 16:37:02 -0400 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 21648-submit@debbugs.gnu.org id=B21648.144433657110614 (code B ref 21648); Thu, 08 Oct 2015 20:37:01 +0000 Original-Received: (at 21648) by debbugs.gnu.org; 8 Oct 2015 20:36:11 +0000 Original-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 Original-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 Original-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) Original-Received: by 10.202.172.205 with HTTP; Thu, 8 Oct 2015 13:35:26 -0700 (PDT) In-Reply-To: <87wpux88mo.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x Xref: news.gmane.org gmane.emacs.bugs:107463 Archived-At: --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=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 =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 (nul= l 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 &qu= ot;\\`[0-9]+#" thing-raw))
=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 thing-ra= w
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 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 "0, 2, 6, 8.&q= uot;)
=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 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 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&q= uot;")))))
=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 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--