GNU bug report logs - #43295
26.1: calc-mode header line [UPDATED PATCH]

Previous Next

Package: emacs;

Reported by: Boruch Baum <boruch_baum <at> gmx.com>

Date: Wed, 9 Sep 2020 18:32:01 UTC

Severity: normal

Tags: fixed, patch

Found in version 26.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Boruch Baum <boruch_baum <at> gmx.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 43295 <at> debbugs.gnu.org
Subject: bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
Date: Sun, 13 Sep 2020 15:15:27 +0200
[Message part 1 (text/plain, inline)]
Boruch Baum <boruch_baum <at> gmx.com> writes:

> In the attached patch:
>
> 1) the hunk @1421 restores the behavior that Eli wants
>
> 2) the hunk @2010 corrects the width calculation in that case
>
> 3) the hunk @2133 better handles the header line for the trail display

This results in a trail buffer that looks like:

[Message part 2 (image/png, inline)]
[Message part 3 (text/plain, inline)]
Which surely can't be optimal?  If modified as follows, the duplicated
text disappears:

diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index bf8b006d7c..62c0bea6d4 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -1396,8 +1396,6 @@ calc--header-line
         (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   (max (/ (- width factor) 2) 0))
                (fill (make-string size ?-))
@@ -1428,6 +1426,12 @@ calc-create-buffer
   (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))
@@ -2009,8 +2013,8 @@ calc-refresh
 	 (setq calc-any-selections nil)
 	 (erase-buffer)
          (when calc-show-banner
-           (calc--header-line  "Emacs Calculator Mode" "Emacs Calc"
-                       (* 2 (/ (window-width) 3)) -3))
+           (calc--header-line "Emacs Calculator Mode" "Emacs Calc"
+                              (window-width) 1))
 	 (while thing
 	   (goto-char (point-min))
 	   (insert (math-format-stack-value (car thing)) "\n")
@@ -2133,29 +2137,32 @@ calc-record
 (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
-	      (not (if flag (memq flag '(nil 0)) win)))
-	(if (null win)
-	    (progn
-              (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)))
-              (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
-	    (delete-window win)
-	    (calc-wrapper
-	     (or no-refresh
-		 (if interactive
-		     (calc-do-refresh)
-		   (calc-refresh))))))))
+    (cond
+     ((setq calc-display-trail
+	    (not (if flag (memq flag '(nil 0)) win)))
+      (when (null win)
+        (if calc-trail-window-hook
+            (run-hooks 'calc-trail-window-hook)
+          (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)))))
+      (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-trail-buffer)
 
 (defun calc-trail-here ()


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

This bug report was last modified 4 years and 333 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.