Function: calculator-update-display

calculator-update-display is a byte-compiled function defined in calculator.el.gz.

Signature

(calculator-update-display &optional FORCE)

Documentation

Update the display.

If optional argument FORCE is non-nil, don't use the cached string.

Source Code

;; Defined in /usr/src/emacs/lisp/calculator.el.gz
(defun calculator-update-display (&optional force)
  "Update the display.
If optional argument FORCE is non-nil, don't use the cached string."
  (when (buffer-live-p calculator-buffer)
    (set-buffer calculator-buffer)
    ;; update calculator-stack-display
    (when (or force (not (eq (car calculator-stack-display)
                             calculator-stack)))
      (setq calculator-stack-display
            (cons calculator-stack
                  (if calculator-stack
                      (concat
                       (let ((calculator-displayer
                              (if (and calculator-displayers
                                       (= 1 (length calculator-stack)))
				  ;; customizable display for a single value
				  (caar calculator-displayers)
				calculator-displayer)))
			 (mapconcat 'calculator-number-to-string
                                    (reverse calculator-stack)
                                    " "))
                       " "
                       (and calculator-display-fragile
                            calculator-saved-list
                            ;; Hack: use `eq' to compare the number: it's a
                            ;; flonum, so `eq' means that its the actual
                            ;; number rather than a computation that had an
                            ;; equal result (eg, enter 1,3,2, use "v" to see
                            ;; the average -- it now shows "2" instead of
                            ;; "2 [3]").
                            (eq (car calculator-stack)
				(nth calculator-saved-ptr
                                     calculator-saved-list))
                            (if (= 0 calculator-saved-ptr)
				(format "[%s]" (length calculator-saved-list))
                              (format "[%s/%s]"
                                      (- (length calculator-saved-list)
					 calculator-saved-ptr)
                                      (length calculator-saved-list)))))
                    ""))))
    (let ((inhibit-read-only t))
      (erase-buffer)
      (insert (calculator-get-display)))
    (set-buffer-modified-p nil)
    (goto-char (if calculator-display-fragile
		   (1+ (length calculator-prompt))
		 (1- (point))))))