]> git.eshelyaron.com Git - emacs.git/commitdiff
* calculator.el (calculator-standard-displayer): Fix bug in use of
authorEli Barzilay <eli@barzilay.org>
Mon, 23 Jun 2014 05:14:23 +0000 (01:14 -0400)
committerEli Barzilay <eli@barzilay.org>
Mon, 23 Jun 2014 05:14:23 +0000 (01:14 -0400)
`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.

lisp/ChangeLog
lisp/calculator.el

index 676635b0db8ed200ad7292fa0a6a743d143f3b28..c3f74d849986a45daa4526d5c04aeaf670ad2f79 100644 (file)
@@ -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.
        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.
index 52dc8c53661c6e26cc0b756aa7a363582e2d6fc3..9ffa6b1a64bf7535ead83bedf5a6625a824251bf 100644 (file)
@@ -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??"))))