[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20764: 25.0.50; Minor improvements for calculator.el
From: |
N. Jackson |
Subject: |
bug#20764: 25.0.50; Minor improvements for calculator.el |
Date: |
Wed, 17 Jun 2015 10:43:40 -0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
At 15:39 -0300 on Sunday 2015-06-07, Chris Zheng wrote:
> Hello, Emacs.
>
> I find the calculator.el in Emacs is handy. However, there are two
> things I'd like to see changed.
>
> 1. Press F1 results in `??bad key?? (f1)'.
> 2. Can't enter exponent by `E'.
>
> Both of them can be reproduced by: (1) emacs -Q; (2) M-x calculator; (3)
> Press `F1' or `E'. I have the following patch trying to fix the above
> two things. Please let me know if I'm doing things wrong.
>
> * calculator.el (calculator-mode-map): Bind `E' for `calculator-exp'.
> (calculator-last-input): Fix a bug that press F1 results in
> `??bad key?? (f1)'.
> ---
> lisp/calculator.el | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/calculator.el b/lisp/calculator.el
> index 4027887..d20faa3 100644
> --- a/lisp/calculator.el
> +++ b/lisp/calculator.el
> @@ -394,7 +394,7 @@ Used for repeating operations in calculator-repR/L.")
> [kp-5] [kp-6] [kp-7] [kp-8] [kp-9])
> (calculator-op [kp-divide] [kp-multiply])
> (calculator-decimal "." [kp-decimal])
> - (calculator-exp "e")
> + (calculator-exp "e" "E")
> (calculator-dec/deg-mode "D")
> (calculator-set-register "s")
> (calculator-get-register "g")
> @@ -1219,7 +1219,7 @@ arguments."
> "Last char (or event or event sequence) that was read.
> Use KEYS if given, otherwise use `this-command-keys'."
> (let ((inp (or keys (this-command-keys))))
> - (if (or (stringp inp) (not (arrayp inp)))
> + (if (or (stringp inp) (not (arrayp inp)) (member inp '([f1] [help])))
> inp
> ;; Translates kp-x to x and [tries to] create a string to lookup
> ;; operators; assume all symbols are translatable via
Two cents from another calc user:
`E' is already bound. It is bound to calc-exp, the exponential function
e^x. For example (where "Calc: " is the calculator prompt and the stack
is shown above it):
--- Emacs Calculator Mode ---
.
Calc: 1 <RET>
--- Emacs Calculator Mode ---
1: 1
.
Calc: E
--- Emacs Calculator Mode ---
1: 2.71828182846
.
This is not to be confused with `e' which introduces the exponent
when entering a number in scientific notation:
--- Emacs Calculator Mode ---
.
Calc: 1e3
--- Emacs Calculator Mode ---
1: 1000
.
It would be a disaster if the exponential function were no longer
available!
As far as F1 for help goes, it is incongruent with the calculator
interface. For different types of help, `?', `h i', `C-h m' etc. are
available.
However, F1 is familiar for users from other platforms, so I think it
might be a good addition for the benefit of new or infrequent users.