GNU bug report logs - #21648
25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank

Previous Next

Package: emacs;

Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>

Date: Thu, 8 Oct 2015 15:10:01 UTC

Severity: wishlist

Tags: patch

Found in version 25.0.50

Done: Kaushal Modi <kaushal.modi <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jay Belanger <jay.p.belanger <at> gmail.com>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 21648 <at> debbugs.gnu.org, jay.p.belanger <at> gmail.com, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#21648: 25.0.50; [PATCH] Add ability to specify radix for the yanked number in calc-yank
Date: Thu, 08 Oct 2015 14:26:07 -0500
>> 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






This bug report was last modified 9 years and 224 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.