summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Barzilay <eli@barzilay.org>2014-06-23 01:14:23 -0400
committerEli Barzilay <eli@barzilay.org>2014-06-23 01:14:23 -0400
commitcc43334a3e3dd1937a9f43ebbdaa89297fc34a1c (patch)
tree78f0058c75d676b3f7b163d46c077452019c22db
parent200fc9496f7e2d53610e31634fdcd750d1870279 (diff)
downloademacs-cc43334a3e3dd1937a9f43ebbdaa89297fc34a1c.tar.gz
* calculator.el (calculator-standard-displayer): Fix bug in use of
`calculator-groupize-number'. (calculator-funcall): Fix broken `cl-flet' use by moving it into the `eval' code, so it works in v24.3.1 too. (calculator-last-input): Comment to clarify purpose. Also add back a ChangeLog blurb for previous commit 2014-06-15T04:52:34Z!eli@barzilay.org.
-rw-r--r--lisp/ChangeLog50
-rw-r--r--lisp/calculator.el25
2 files changed, 65 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 676635b0db8..c3f74d84998 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2014-06-23 Eli Barzilay <eli@barzilay.org>
+
+ * calculator.el (calculator-standard-displayer): Fix bug in use of
+ `calculator-groupize-number'.
+ (calculator-funcall): Fix broken `cl-flet' use by moving it into the
+ `eval' code, so it works in v24.3.1 too.
+ (calculator-last-input): Comment to clarify purpose.
+
2014-06-22 Mario Lang <mlang@delysid.org>
* textmodes/rst.el (rst-comment-region): From from -> from.
@@ -194,6 +202,48 @@
rlogin is anymore.
(dun-help): Bump version number; update contact info.
+2014-06-15 Eli Barzilay <eli@barzilay.org>
+
+ * calculator.el (calculator-prompt, calculator-remove-zeros)
+ (calculator-mode-hook, calculator-operators, calculator-stack)
+ (calculator-mode): Tweak docstring.
+ (calculator-user-operators): Tweak docstring, fix a bug in the last
+ example.
+ (calculator-displayer): `std' case has an optional boolean.
+ (calculator-displayers): Use the new boolean to group in decimal mode.
+ (calculator-mode-map, calculator, calculator-message)
+ (calculator-op-arity, calculator-add-operators)
+ (calculator-string-to-number, calculator-displayer-prev)
+ (calculator-displayer-next, calculator-remove-zeros)
+ (calculator-eng-display, calculator-number-to-string)
+ (calculator-update-display, calculator-last-input)
+ (calculator-clear-fragile, calculator-digit, calculator-decimal)
+ (calculator-exp, calculator-saved-move, calculator-clear)
+ (calculator-copy, calculator-put-value, calculator-help)
+ (calculator-expt, calculator-truncate): Minor code improvements.
+ (calculator-need-3-lines): New function pulling out code from
+ `calculator'.
+ (calculator-get-display): Renamed from `calculator-get-prompt', and
+ improved.
+ (calculator-push-curnum): Renamed from `calculator-curnum-value', and
+ extended for all uses of it. All callers changed.
+ (calculator-groupize-number): New utility for splitting a number into
+ groups.
+ (calculator-standard-displayer): Improve code, new optional argument to
+ use comma-split groups, make second argument optional too to use with
+ 'left/'right inputs. All callers changed.
+ (calculator-reduce-stack-once): New utility, doing the meat of what
+ `calculator-reduce-stack' used to do, much improved (mostly using
+ `pcase' for conciseness and clarity).
+ (calculator-reduce-stack): Now doing just the reduction loop using
+ `calculator-reduce-stack-once'.
+ (calculator-funcall): Improved code, make it work in v24.3.1 too.
+ (calculator-last-input): Improved code, remove some old cruft.
+ (calculator-quit): Kill `calculator-buffer' in electric mode too.
+ (calculator-integer-p): Removed.
+ (calculator-fact): Improved code, make it work on non-integer values
+ too (using truncated numbers).
+
2014-06-15 Michael Albinus <michael.albinus@gmx.de>
Sync with Tramp 2.2.10.
diff --git a/lisp/calculator.el b/lisp/calculator.el
index 52dc8c53661..9ffa6b1a64b 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -1019,8 +1019,9 @@ number of digits displayed (`calculator-number-digits')."
(s (calculator-remove-zeros (format s num)))
(s (if (or (not group-p) (string-match-p "[eE]" s)) s
(replace-regexp-in-string
- "\\([0-9]+\\)\\(?:\\.\\|$\\)"
- (lambda (s) (calculator-groupize-number s 3 ","))
+ "\\([0-9]+\\)\\(?:\\..*\\|$\\)"
+ (lambda (_) (calculator-groupize-number
+ (match-string 1 s) 3 ","))
s nil nil 1))))
s)))
@@ -1197,12 +1198,13 @@ arguments."
(let ((TX (and X (calculator-truncate X)))
(TY (and Y (calculator-truncate Y)))
(DX (if (and X calculator-deg) (/ (* X pi) 180) X))
- (L calculator-saved-list))
- (cl-flet ((F (&optional x y) (calculator-funcall f x y))
- (D (x) (if calculator-deg (/ (* x 180) float-pi) x)))
- (eval `(let ((X ,X) (Y ,Y) (DX ,DX) (TX ,TX) (TY ,TY) (L ',L))
- ,f)
- t)))))
+ (L calculator-saved-list)
+ (fF `(calculator-funcall ',f x y))
+ (fD `(if calculator-deg (/ (* x 180) float-pi) x)))
+ (eval `(cl-flet ((F (&optional x y) ,fF) (D (x) ,fD))
+ (let ((X ,X) (Y ,Y) (DX ,DX) (TX ,TX) (TY ,TY) (L ',L))
+ ,f))
+ t))))
;;;---------------------------------------------------------------------
;;; Input interaction
@@ -1213,9 +1215,12 @@ Use KEYS if given, otherwise use `this-command-keys'."
(let ((inp (or keys (this-command-keys))))
(if (or (stringp inp) (not (arrayp inp)))
inp
- ;; translates kp-x to x and [tries to] create a string to lookup
+ ;; Translates kp-x to x and [tries to] create a string to lookup
;; operators; assume all symbols are translatable via
- ;; `function-key-map' or with an 'ascii-character property
+ ;; `function-key-map' or with an 'ascii-character property. This
+ ;; is needed because we have key bindings for kp-* (which might be
+ ;; the wrong thing to do) so they don't get translated in
+ ;; `this-command-keys'.
(concat (mapcar (lambda (k)
(if (numberp k) k (or (get k 'ascii-character)
(error "??bad key??"))))