unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
@ 2020-09-09 18:31 Boruch Baum
  2020-09-10 21:45 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Boruch Baum @ 2020-09-09 18:31 UTC (permalink / raw)
  To: 43295, larsi

[-- Attachment #1: Type: text/plain, Size: 1905 bytes --]

This is summary of related mail on emacs-devel (an updated patch is attached):

On 2020-08-31 14:44, Boruch Baum wrote:
> Back in version 21, emacs introduced a static 'header-line' that could
> be inserted at the top of any buffer. Calc mode is one emacs package
> that does not use it and could benefit from it, so the attached patch
> offers that feature. The main benefit is that the 'calc trail' buffer
> (what some greybeards from the mechanical age would remember as the
> 'tape reel') no longer has its title line scroll off the visible
> window. The patch also includes:
>
> 1) Width-sensitive text for the header line, so that it is readable for
>    very narrow windows, and scales to very wide windows.
>
> 2) Display of the 'calc trail' buffer when invoking calc from a frame
>    that is split vertically (C-x 3, M-x split-window-right).
>
> 3) My version of emacs includes a unicode character at 'C-x 8 <return>
>    POCKET CALCULATOR', that I did not include in the header line as the
>    mode's icon, but that could be done.
>
> The patch was diff'ed against the version of emacs that I have: the
> latest-and-greatest that debian is distributing ... v26.1


On 2020-09-07 14:01, Boruch Baum wrote:
> First, congratulations on assuming your new responsibilities.
>
> On 2020-09-07 17:00, Lars Ingebrigtsen wrote:
> > The patch doesn't apply to Emacs 28, so I've respun it (included below).
>
> Oops. I didn't think there would be a difference. I'm using emacs 26.1
> in debian and I didn't download the v28 calc.el
>
> > This is somewhat inscrutable, and is repeated twice (once for the calc
> > buffer and once for the trail buffer).
> >
> > It just centres whatever the string like "--- this ---", so it seems
> > like it should land in a single function for reuse.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: calc.patch --]
[-- Type: text/x-diff, Size: 4576 bytes --]

--- calc.el	2020-08-30 15:03:07.563840474 -0400
+++ calc-new.el	2020-09-09 14:12:01.949816446 -0400
@@ -1396,6 +1396,31 @@
     (set-keymap-parent map calc-mode-map)
     map))

+(defun calc--header-line (long short width &optional fudge)
+  "Return a Calc header line appropriate for the buffer width.
+
+This is an internal function for `calc-mode'.
+
+LONG is a desired text for a wide window, SHORT is a desired
+abbreviated text, and width is the buffer width, which will be
+some fraction of the 'parent' window width (At the time of
+writing, 2/3 for calc, 1/3 for trail). The optional FUDGE is a
+trial-and-error adjustment number for the edge-cases at the
+border of the two cases."
+;; TODO: This could be called as part of a 'wiindow-resize' hook.
+  (setq header-line-format
+    (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 ?-))
+           (pre  (replace-regexp-in-string ".$" " " fill))
+           (post (replace-regexp-in-string "^." " " fill)))
+      (concat pre (if (= factor len-long) long short) post))))
+
 (define-derived-mode calc-trail-mode fundamental-mode "Calc Trail"
   "Calc Trail mode.
 This mode is used by the *Calc Trail* buffer, which records all results
@@ -1410,21 +1435,27 @@
   (setq buffer-read-only t)
   (make-local-variable 'overlay-arrow-position)
   (make-local-variable 'overlay-arrow-string)
-  (when (= (buffer-size) 0)
+  (if (and (not calc-show-banner)
+           (= (buffer-size) 0))
     (let ((buffer-read-only nil))
-      (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))))
+      (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))
+  (calc--header-line "Emacs Calculator Trail" "Calc Trail"
+                     (/ (window-width) 3) -3)))

 (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"
+                       (/ (* (window-width) 2) 3) 1)
   (setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
   (when calc-always-load-extensions
     (require 'calc-ext))
   (when calc-language
     (require 'calc-ext)
-    (calc-set-language calc-language calc-language-option t)))
+    (calc-set-language calc-language calc-language-option t))))

 ;;;###autoload
 (defun calc (&optional arg full-display interactive)
@@ -1465,7 +1496,6 @@
                 (pop-to-buffer (current-buffer)))))))
       (with-current-buffer (calc-trail-buffer)
         (and calc-display-trail
-             (= (window-width) (frame-width))
              (calc-trail-display 1 t)))
       (message "Welcome to the GNU Emacs Calculator!  Press `?' or `h' for help, `q' to quit")
       (run-hooks 'calc-start-hook)
@@ -2000,13 +2030,8 @@
 	      (calc-any-evaltos nil))
 	 (setq calc-any-selections nil)
 	 (erase-buffer)
-	 (when calc-show-banner
-	   (insert (propertize "--- Emacs Calculator Mode ---\n"
-			       'face 'italic)))
 	 (while thing
 	   (goto-char (point-min))
-	   (when calc-show-banner
-	     (forward-line 1))
 	   (insert (math-format-stack-value (car thing)) "\n")
 	   (setq thing (cdr thing)))
 	 (calc-renumber-stack)
@@ -2091,7 +2116,6 @@
 	   (eq (marker-buffer calc-trail-pointer) calc-trail-buffer))
       (with-current-buffer calc-trail-buffer
 	(goto-char (point-min))
-	(forward-line 1)
 	(setq calc-trail-pointer (point-marker))))
   calc-trail-buffer)

@@ -2159,10 +2183,8 @@
   (if (derived-mode-p 'calc-trail-mode)
       (progn
 	(beginning-of-line)
-	(if (bobp)
-	    (forward-line 1)
 	  (if (eobp)
-	      (forward-line -1)))
+          (forward-line -1))
 	(if (or (bobp) (eobp))
 	    (setq overlay-arrow-position nil)   ; trail is empty
 	  (set-marker calc-trail-pointer (point) (current-buffer))
@@ -2176,7 +2198,7 @@
 	    (if win
 		(save-excursion
 		  (forward-line (/ (window-height win) 2))
-		  (forward-line (- 1 (window-height win)))
+		  (forward-line (- 2 (window-height win)))
 		  (set-window-start win (point))
 		  (set-window-point win (+ calc-trail-pointer 4))
 		  (set-buffer calc-main-buffer)

[-- Attachment #3: NEWS.patch --]
[-- Type: text/x-diff, Size: 626 bytes --]

--- NEWS	2020-09-05 22:28:48.607653342 -0400
+++ NEWS.new	2020-09-06 14:37:38.286349012 -0400
@@ -921,6 +921,14 @@
 Likewise, point isn't moved to the end of the string before inserting
 digits.

+---
+*** Buffer headings have been changed.
+The *Calc* and *Calc Trail* buffers now use 'header-line-format' to
+present a persistent buffer header line, and they are sized based upon
+the window width upon launch. The header-line for the *Calc Trail*
+buffer is no longer part of the buffer's text and no longer scrolls
+off the visible display, unless on sets 'calc-show-banner' to NIL.
+
 ** term-mode

 ---

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-09 18:31 bug#43295: 26.1: calc-mode header line [UPDATED PATCH] Boruch Baum
@ 2020-09-10 21:45 ` Lars Ingebrigtsen
  2020-09-10 23:40   ` Boruch Baum
  0 siblings, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-10 21:45 UTC (permalink / raw)
  To: Boruch Baum; +Cc: 43295

Boruch Baum <boruch_baum@gmx.com> writes:

> This is summary of related mail on emacs-devel (an updated patch is
> attached):

Thanks; I applied it to Emacs 28, but it needed some changes because it
didn't apply cleanly (and it didn't set the header in the main calc
buffer?)  But it looks like it works now, at least, but you should
perhaps take a look at the result and see whether it looks like you
imagined...

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-10 21:45 ` Lars Ingebrigtsen
@ 2020-09-10 23:40   ` Boruch Baum
  2020-09-11 12:15     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Boruch Baum @ 2020-09-10 23:40 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43295

[-- Attachment #1: Type: text/plain, Size: 2289 bytes --]

On 2020-09-10 23:45, Lars Ingebrigtsen wrote:
> Thanks; I applied it to Emacs 28, but it needed some changes because it
> didn't apply cleanly (and it didn't set the header in the main calc
> buffer?)  But it looks like it works now, at least, but you should
> perhaps take a look at the result and see whether it looks like you
> imagined...

I see a few things. Here are some comments, with reference to a new
patch, attached, which is a diff based upon the savannah-git (my
calc28.el).

1) I notice that I had forgotten to remove two lines of coding notes to
   myself @lines ~1395. They can be removed.

2) You removed two lines I had @lines ~1428, and copied a modified
   version of them to @lines ~2008. I think the absence of the two lines
   ~1428 may be cause the problem that you mentioned.

3) I see an additional problem with your modification to the patch that
   you'll notice upon starting calc with a very narrow window. Your line
   ~2009 reads

                        (* 2 (/ (window-width) 3)) -3))

   which is code for the trail buffer, but it should be for the main
   buffer, like in my line ~1429

+                       (/ (* (window-width) 2) 3) 1)

3) If you modify ~2009, then that snippet might be redundant together
   with my snippet ~1428, but it shouldn't do any harm (but remove the
   comment line 'Added by Lars?').

4) You also did something that I welcome, but that was done at Eli
   Zaretskii's insistence, so you may want to co-ordinate with him about
   it. My very original patch looked like your final result @line ~1419,
   but Eli on-list insisted that was wrong on the basis of 'breaking backward
   compatibility', because in the old behavior, the trail buffer always
   had a title line inside the buffer even when calc-show-banner was
   NIL. My position was that's a bug. That part should really read (modifed
   from my original):

  (if calc-show-banner
    (calc--header-line "Emacs Calculator Trail" "Calc Trail"
                       (/ (window-width) 3) -3)
   (when (zerop (buffer-size))
     (let ((buffer-read-only nil))
       (insert (propertize "Emacs Calculator Trail\n" 'face 'italic))))))


--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: calc28.patch --]
[-- Type: text/x-diff, Size: 1224 bytes --]

--- /home/optimum/calc28.el	2020-09-10 18:57:51.000000000 -0400
+++ /home/optimum/calc28-new.el	2020-09-10 18:55:01.360827855 -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 ?-))
@@ -1428,6 +1426,9 @@
   (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"
+                       (/ (* (window-width) 2) 3) 1))
   (setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
   (when calc-always-load-extensions
     (require 'calc-ext))
@@ -2008,6 +2009,7 @@
 	      (calc-any-evaltos nil))
 	 (setq calc-any-selections nil)
 	 (erase-buffer)
+;; Added by Lars?
          (when calc-show-banner
            (calc--header-line  "Emacs Calculator Mode" "Emacs Calc"
                        (* 2 (/ (window-width) 3)) -3))

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-10 23:40   ` Boruch Baum
@ 2020-09-11 12:15     ` Lars Ingebrigtsen
  2020-09-11 13:37       ` Boruch Baum
  2020-09-13  0:43       ` Boruch Baum
  0 siblings, 2 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-11 12:15 UTC (permalink / raw)
  To: Boruch Baum; +Cc: 43295

Boruch Baum <boruch_baum@gmx.com> writes:

> I see a few things. Here are some comments, with reference to a new
> patch, attached, which is a diff based upon the savannah-git (my
> calc28.el).
>
> 1) I notice that I had forgotten to remove two lines of coding notes to
>    myself @lines ~1395. They can be removed.

[...]

> 3) If you modify ~2009, then that snippet might be redundant together
>    with my snippet ~1428, but it shouldn't do any harm (but remove the
>    comment line 'Added by Lars?').

Could you send a new patch that has all the changes that you want that I
can just apply?  Adding discussion into the patch itself isn't very
helpful.  :-)

And please submit the patch in a way that it can just be applied.  This
patch can't be applied either, since you've changed the name of the file
to "calc28.el".

Thanks.

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-11 12:15     ` Lars Ingebrigtsen
@ 2020-09-11 13:37       ` Boruch Baum
  2020-09-11 13:55         ` Eli Zaretskii
  2020-09-13  0:43       ` Boruch Baum
  1 sibling, 1 reply; 11+ messages in thread
From: Boruch Baum @ 2020-09-11 13:37 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43295

On 2020-09-11 14:15, Lars Ingebrigtsen wrote:
> Boruch Baum <boruch_baum@gmx.com> writes:
>
> Could you send a new patch that has all the changes that you want that I
> can just apply?  Adding discussion into the patch itself isn't very
> helpful.  :-)
>
> And please submit the patch in a way that it can just be applied.  This
> patch can't be applied either, since you've changed the name of the file
> to "calc28.el".

I can't know everything to include in the patch until you tell me what
your decisions are about the comments I made, most importantly whether
Eli's decision stands about the old trail buffer behavior, and whether
to include your addition @line ~2000 something.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-11 13:37       ` Boruch Baum
@ 2020-09-11 13:55         ` Eli Zaretskii
  0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2020-09-11 13:55 UTC (permalink / raw)
  To: Boruch Baum; +Cc: larsi, 43295

> Date: Fri, 11 Sep 2020 09:37:44 -0400
> From: Boruch Baum <boruch_baum@gmx.com>
> Cc: 43295@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
> 
> I can't know everything to include in the patch until you tell me what
> your decisions are about the comments I made, most importantly whether
> Eli's decision stands about the old trail buffer behavior, and whether
> to include your addition @line ~2000 something.

I'd prefer to keep the old behavior, at least as an option, yes.

Thanks.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-11 12:15     ` Lars Ingebrigtsen
  2020-09-11 13:37       ` Boruch Baum
@ 2020-09-13  0:43       ` Boruch Baum
  2020-09-13 13:15         ` Lars Ingebrigtsen
  1 sibling, 1 reply; 11+ messages in thread
From: Boruch Baum @ 2020-09-13  0:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43295

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]

On 2020-09-11 14:15, Lars Ingebrigtsen wrote:
> Could you send a new patch that has all the changes that you want that I
> can just apply?  Adding discussion into the patch itself isn't very
> helpful.  :-)

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
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: calc-003.patch --]
[-- Type: text/x-diff, Size: 3495 bytes --]

--- /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 ()

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-13  0:43       ` Boruch Baum
@ 2020-09-13 13:15         ` Lars Ingebrigtsen
  2020-09-13 14:54           ` Boruch Baum
  0 siblings, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-13 13:15 UTC (permalink / raw)
  To: Boruch Baum; +Cc: 43295

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

Boruch Baum <boruch_baum@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:


[-- Attachment #2: Type: image/png, Size: 15104 bytes --]

[-- Attachment #3: Type: text/plain, Size: 3837 bytes --]


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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-13 13:15         ` Lars Ingebrigtsen
@ 2020-09-13 14:54           ` Boruch Baum
  2020-09-13 14:56             ` Lars Ingebrigtsen
  2020-09-13 15:03             ` Eli Zaretskii
  0 siblings, 2 replies; 11+ messages in thread
From: Boruch Baum @ 2020-09-13 14:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43295

On 2020-09-13 15:15, Lars Ingebrigtsen wrote:
> Boruch Baum <boruch_baum@gmx.com> writes:
>
> This results in a trail buffer that looks like:

Which is intentional. This is the 'prior behavior' that I mentioned Eli
didn't want to change so as not to 'break backward compatability'. It's
all in the message history on emacs-devel.

> Which surely can't be optimal?  If modified as follows, the duplicated
> text disappears:

I don't mind. My original submission had no duplicate text. Eli might
mind.

One possible benefit of Eli's position is that someone might want to
save the trail buffer to a file and expect the title string. Another
benefit would be if there exists third-party code written to parse the
buffer expecting to delete the first two lines.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-13 14:54           ` Boruch Baum
@ 2020-09-13 14:56             ` Lars Ingebrigtsen
  2020-09-13 15:03             ` Eli Zaretskii
  1 sibling, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-13 14:56 UTC (permalink / raw)
  To: Boruch Baum; +Cc: 43295

Boruch Baum <boruch_baum@gmx.com> writes:

> Which is intentional. This is the 'prior behavior' that I mentioned Eli
> didn't want to change so as not to 'break backward compatability'. It's
> all in the message history on emacs-devel.

I kinda doubt that that's the prior behaviour Eli had in mind.  My
powerful mind reading powers says that he probably meant that in the
"backward compatibility mode", there should be no headers, only text in
the buffer (like before).

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43295: 26.1: calc-mode header line [UPDATED PATCH]
  2020-09-13 14:54           ` Boruch Baum
  2020-09-13 14:56             ` Lars Ingebrigtsen
@ 2020-09-13 15:03             ` Eli Zaretskii
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2020-09-13 15:03 UTC (permalink / raw)
  To: Boruch Baum; +Cc: larsi, 43295

> Date: Sun, 13 Sep 2020 10:54:11 -0400
> From: Boruch Baum <boruch_baum@gmx.com>
> Cc: 43295@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
> 
> On 2020-09-13 15:15, Lars Ingebrigtsen wrote:
> > Boruch Baum <boruch_baum@gmx.com> writes:
> >
> > This results in a trail buffer that looks like:
> 
> Which is intentional. This is the 'prior behavior' that I mentioned Eli
> didn't want to change so as not to 'break backward compatability'. It's
> all in the message history on emacs-devel.

To clarify, I think I wanted the prior behavior when the new one is
disabled.





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-09-13 15:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 18:31 bug#43295: 26.1: calc-mode header line [UPDATED PATCH] Boruch Baum
2020-09-10 21:45 ` Lars Ingebrigtsen
2020-09-10 23:40   ` Boruch Baum
2020-09-11 12:15     ` Lars Ingebrigtsen
2020-09-11 13:37       ` Boruch Baum
2020-09-11 13:55         ` Eli Zaretskii
2020-09-13  0:43       ` Boruch Baum
2020-09-13 13:15         ` Lars Ingebrigtsen
2020-09-13 14:54           ` Boruch Baum
2020-09-13 14:56             ` Lars Ingebrigtsen
2020-09-13 15:03             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).