--- /home/optimum/calc.el 2020-09-11 15:58:55.263774535 -0400 +++ ./calc.el 2020-09-11 13:21:07.485259155 -0400 @@ -1396,8 +1396,6 @@ (let* ((len-long (length long)) (len-short (length short)) (fudge (or fudge 0)) - ;; fudge for trail is: -3 (added to len-long) - ;; (width ) for trail (factor (if (> width (+ len-long fudge)) len-long len-short)) (size (/ (- width factor) 2)) (fill (make-string size ?-)) @@ -1421,13 +1419,22 @@ (make-local-variable 'overlay-arrow-string) (when calc-show-banner (calc--header-line "Emacs Calculator Trail" "Calc Trail" - (/ (window-width) 3) -3))) + (/ (window-width) 3) -3)) + (when (zerop (buffer-size)) + (let ((buffer-read-only nil)) + (insert (propertize "Emacs Calculator Trail\n" 'face 'italic))))) (defun calc-create-buffer () "Create and initialize a buffer for the Calculator." (set-buffer (get-buffer-create "*Calculator*")) (or (derived-mode-p 'calc-mode) (calc-mode)) + (when calc-show-banner + (calc--header-line "Emacs Calculator Mode" "Emacs Calc" + (if calc-display-trail + (/ (* (window-width) 2) 3) + (window-width)) + 1)) (setq max-lisp-eval-depth (max max-lisp-eval-depth 1000)) (when calc-always-load-extensions (require 'calc-ext)) @@ -2010,7 +2017,7 @@ (erase-buffer) (when calc-show-banner (calc--header-line "Emacs Calculator Mode" "Emacs Calc" - (* 2 (/ (window-width) 3)) -3)) + (window-width) 1)) (while thing (goto-char (point-min)) (insert (math-format-stack-value (car thing)) "\n") @@ -2133,29 +2140,32 @@ (defun calc-trail-display (flag &optional no-refresh interactive) (interactive "P\ni\np") (let ((win (get-buffer-window (calc-trail-buffer)))) - (if (setq calc-display-trail + (cond + ((setq calc-display-trail (not (if flag (memq flag '(nil 0)) win))) - (if (null win) - (progn + (when (null win) (if calc-trail-window-hook (run-hooks 'calc-trail-window-hook) - (let ((w (split-window nil (/ (* (window-width) 2) 3) t))) - (set-window-buffer w calc-trail-buffer))) + (setq win (split-window nil (/ (* (window-width) 2) 3) t)) + (set-window-buffer win calc-trail-buffer)) (calc-wrapper (setq overlay-arrow-string calc-trail-overlay overlay-arrow-position calc-trail-pointer) (or no-refresh (if interactive (calc-do-refresh) - (calc-refresh)))))) - (if win - (progn + (calc-refresh))))) + (with-current-buffer calc-trail-buffer + (when calc-show-banner + (calc--header-line "Emacs Calculator Trail" "Calc Trail" + (window-width win) -3)))) + (win ; not calc-display-trail (delete-window win) (calc-wrapper (or no-refresh (if interactive (calc-do-refresh) - (calc-refresh)))))))) + (calc-refresh))))))) calc-trail-buffer) (defun calc-trail-here ()