all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Boruch Baum <boruch_baum@gmx.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: 26.1: calc-mode header line [PATCH]
Date: Sun, 6 Sep 2020 14:45:30 -0400	[thread overview]
Message-ID: <20200906184529.srcmx42ircaeueqv@E15-2016.optimum.net> (raw)
In-Reply-To: <83sgbvng5l.fsf@gnu.org>

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

New patches attached.

On 2020-09-06 17:17, Eli Zaretskii wrote:
> ...

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

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

--- calc.el	2020-08-30 15:03:07.563840474 -0400
+++ calc-new.el	2020-09-06 14:42:10.768154045 -0400
@@ -1410,15 +1410,33 @@
   (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)))
+   (setq header-line-format
+     (let* ((fract  (/ (window-width) 3))
+            (factor (if (> fract 19) 22 10))
+            (size   (/ (- fract factor) 2))
+            (fill (make-string size ?-))
+            (pre  (replace-regexp-in-string ".$" " " fill))
+            (post (replace-regexp-in-string "^." " " fill)))
+       (concat pre (if (= factor 22) "Emacs Calculator Trail" "Calc Trail") post)))))

 (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
+    (setq header-line-format
+      (let* ((fract  (/ (* (window-width) 2) 3))
+             (factor (if (> fract 22) 21 10))
+             (size   (/ (- fract factor) 2))
+             (fill (make-string size ?-))
+             (pre  (replace-regexp-in-string ".$" " " fill))
+             (post (replace-regexp-in-string "^." " " fill)))
+        (concat pre (if (= factor 21) "Emacs Calculator Mode" "Emacs Calc") post))))
   (setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
   (when calc-always-load-extensions
     (require 'calc-ext))
@@ -1465,7 +1483,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 +2017,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 +2103,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 +2170,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 +2185,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

 ---

  reply	other threads:[~2020-09-06 18:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 18:44 26.1: calc-mode header line [PATCH] Boruch Baum
2020-09-05  6:57 ` Eli Zaretskii
2020-09-06  2:35   ` Boruch Baum
2020-09-06 14:17     ` Eli Zaretskii
2020-09-06 18:45       ` Boruch Baum [this message]
2020-09-07 15:00         ` Lars Ingebrigtsen
2020-09-07 18:01           ` Boruch Baum
2020-09-07 20:24             ` Lars Ingebrigtsen
2020-09-07 21:11               ` Boruch Baum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200906184529.srcmx42ircaeueqv@E15-2016.optimum.net \
    --to=boruch_baum@gmx.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.