aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Barzilay2014-06-23 01:14:23 -0400
committerEli Barzilay2014-06-23 01:14:23 -0400
commitcc43334a3e3dd1937a9f43ebbdaa89297fc34a1c (patch)
tree78f0058c75d676b3f7b163d46c077452019c22db
parent200fc9496f7e2d53610e31634fdcd750d1870279 (diff)
downloademacs-cc43334a3e3dd1937a9f43ebbdaa89297fc34a1c.tar.gz
emacs-cc43334a3e3dd1937a9f43ebbdaa89297fc34a1c.zip
* 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 @@
12014-06-23 Eli Barzilay <eli@barzilay.org>
2
3 * calculator.el (calculator-standard-displayer): Fix bug in use of
4 `calculator-groupize-number'.
5 (calculator-funcall): Fix broken `cl-flet' use by moving it into the
6 `eval' code, so it works in v24.3.1 too.
7 (calculator-last-input): Comment to clarify purpose.
8
12014-06-22 Mario Lang <mlang@delysid.org> 92014-06-22 Mario Lang <mlang@delysid.org>
2 10
3 * textmodes/rst.el (rst-comment-region): From from -> from. 11 * textmodes/rst.el (rst-comment-region): From from -> from.
@@ -194,6 +202,48 @@
194 rlogin is anymore. 202 rlogin is anymore.
195 (dun-help): Bump version number; update contact info. 203 (dun-help): Bump version number; update contact info.
196 204
2052014-06-15 Eli Barzilay <eli@barzilay.org>
206
207 * calculator.el (calculator-prompt, calculator-remove-zeros)
208 (calculator-mode-hook, calculator-operators, calculator-stack)
209 (calculator-mode): Tweak docstring.
210 (calculator-user-operators): Tweak docstring, fix a bug in the last
211 example.
212 (calculator-displayer): `std' case has an optional boolean.
213 (calculator-displayers): Use the new boolean to group in decimal mode.
214 (calculator-mode-map, calculator, calculator-message)
215 (calculator-op-arity, calculator-add-operators)
216 (calculator-string-to-number, calculator-displayer-prev)
217 (calculator-displayer-next, calculator-remove-zeros)
218 (calculator-eng-display, calculator-number-to-string)
219 (calculator-update-display, calculator-last-input)
220 (calculator-clear-fragile, calculator-digit, calculator-decimal)
221 (calculator-exp, calculator-saved-move, calculator-clear)
222 (calculator-copy, calculator-put-value, calculator-help)
223 (calculator-expt, calculator-truncate): Minor code improvements.
224 (calculator-need-3-lines): New function pulling out code from
225 `calculator'.
226 (calculator-get-display): Renamed from `calculator-get-prompt', and
227 improved.
228 (calculator-push-curnum): Renamed from `calculator-curnum-value', and
229 extended for all uses of it. All callers changed.
230 (calculator-groupize-number): New utility for splitting a number into
231 groups.
232 (calculator-standard-displayer): Improve code, new optional argument to
233 use comma-split groups, make second argument optional too to use with
234 'left/'right inputs. All callers changed.
235 (calculator-reduce-stack-once): New utility, doing the meat of what
236 `calculator-reduce-stack' used to do, much improved (mostly using
237 `pcase' for conciseness and clarity).
238 (calculator-reduce-stack): Now doing just the reduction loop using
239 `calculator-reduce-stack-once'.
240 (calculator-funcall): Improved code, make it work in v24.3.1 too.
241 (calculator-last-input): Improved code, remove some old cruft.
242 (calculator-quit): Kill `calculator-buffer' in electric mode too.
243 (calculator-integer-p): Removed.
244 (calculator-fact): Improved code, make it work on non-integer values
245 too (using truncated numbers).
246
1972014-06-15 Michael Albinus <michael.albinus@gmx.de> 2472014-06-15 Michael Albinus <michael.albinus@gmx.de>
198 248
199 Sync with Tramp 2.2.10. 249 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')."
1019 (s (calculator-remove-zeros (format s num))) 1019 (s (calculator-remove-zeros (format s num)))
1020 (s (if (or (not group-p) (string-match-p "[eE]" s)) s 1020 (s (if (or (not group-p) (string-match-p "[eE]" s)) s
1021 (replace-regexp-in-string 1021 (replace-regexp-in-string
1022 "\\([0-9]+\\)\\(?:\\.\\|$\\)" 1022 "\\([0-9]+\\)\\(?:\\..*\\|$\\)"
1023 (lambda (s) (calculator-groupize-number s 3 ",")) 1023 (lambda (_) (calculator-groupize-number
1024 (match-string 1 s) 3 ","))
1024 s nil nil 1)))) 1025 s nil nil 1))))
1025 s))) 1026 s)))
1026 1027
@@ -1197,12 +1198,13 @@ arguments."
1197 (let ((TX (and X (calculator-truncate X))) 1198 (let ((TX (and X (calculator-truncate X)))
1198 (TY (and Y (calculator-truncate Y))) 1199 (TY (and Y (calculator-truncate Y)))
1199 (DX (if (and X calculator-deg) (/ (* X pi) 180) X)) 1200 (DX (if (and X calculator-deg) (/ (* X pi) 180) X))
1200 (L calculator-saved-list)) 1201 (L calculator-saved-list)
1201 (cl-flet ((F (&optional x y) (calculator-funcall f x y)) 1202 (fF `(calculator-funcall ',f x y))
1202 (D (x) (if calculator-deg (/ (* x 180) float-pi) x))) 1203 (fD `(if calculator-deg (/ (* x 180) float-pi) x)))
1203 (eval `(let ((X ,X) (Y ,Y) (DX ,DX) (TX ,TX) (TY ,TY) (L ',L)) 1204 (eval `(cl-flet ((F (&optional x y) ,fF) (D (x) ,fD))
1204 ,f) 1205 (let ((X ,X) (Y ,Y) (DX ,DX) (TX ,TX) (TY ,TY) (L ',L))
1205 t))))) 1206 ,f))
1207 t))))
1206 1208
1207;;;--------------------------------------------------------------------- 1209;;;---------------------------------------------------------------------
1208;;; Input interaction 1210;;; Input interaction
@@ -1213,9 +1215,12 @@ Use KEYS if given, otherwise use `this-command-keys'."
1213 (let ((inp (or keys (this-command-keys)))) 1215 (let ((inp (or keys (this-command-keys))))
1214 (if (or (stringp inp) (not (arrayp inp))) 1216 (if (or (stringp inp) (not (arrayp inp)))
1215 inp 1217 inp
1216 ;; translates kp-x to x and [tries to] create a string to lookup 1218 ;; Translates kp-x to x and [tries to] create a string to lookup
1217 ;; operators; assume all symbols are translatable via 1219 ;; operators; assume all symbols are translatable via
1218 ;; `function-key-map' or with an 'ascii-character property 1220 ;; `function-key-map' or with an 'ascii-character property. This
1221 ;; is needed because we have key bindings for kp-* (which might be
1222 ;; the wrong thing to do) so they don't get translated in
1223 ;; `this-command-keys'.
1219 (concat (mapcar (lambda (k) 1224 (concat (mapcar (lambda (k)
1220 (if (numberp k) k (or (get k 'ascii-character) 1225 (if (numberp k) k (or (get k 'ascii-character)
1221 (error "??bad key??")))) 1226 (error "??bad key??"))))