February 2, 2025
Here is a nice little improvement to calc-mode
that adds up all the numbers on the stack. It’s equivalent to hitting the + key until the stack is exhausted, and it’s more handy than I would have expected.
(defun my/calc-sum-stack () (interactive) (when-let* ((stack calc-stack) (additions (- (length stack) 2)) (_ (> additions 0))) (dotimes (i additions) (call-interactively 'calc-plus))))
I’ve bound it to Ctrl + like this:
(define-key calc-mode-map (kbd "C-+") #'my/calc-sum-stack)