Subject: [PATCH] Make calculator work with customized mode-line
From: john muhl <[email-masked]>
To: [email-masked]
Date: Wed, 28 Jun 2023 13:23:45 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

calculator.el doesn’t work after customizing the mode-line. It assumes
the line-width is always an integer but after using customize it is a
dotted list.

  - emacs -Q
  - M-x customize-apropos-faces RET mode-line RET
  - Ensure ‘mode-line-face’ has a box property with vertical and
    horizontal widths. The default config includes these already.
  - Set for current session
  - M-x calculator RET
  => calculator: Wrong type argument: number-or-marker-p, (1 . -1)

In GNU Emacs 30.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2023-06-28 built on localhost
Repository revision: c5d6102313076b83526dc79bfb563621671fb70b
Repository branch: master
System Description: Fedora Linux 38 (Workstation Edition)

Configured using:
 'configure --with-native-compilation --with-pgtk'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB

From 54cd9fe40d954231a6be822d9ea448902e12c60c Mon Sep 17 00:00:00 2001
From: john muhl <[email-masked]>
Date: Wed, 28 Jun 2023 12:58:27 -0500
Subject: [PATCH] * lisp/calculator.el (calculator-need-3-lines): Check type

Copyright-paperwork-exempt: yes
---
 lisp/calculator.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/calculator.el b/lisp/calculator.el
index bf2ac9b6215..6af6464d2f4 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -746,7 +746,7 @@ calculator-need-3-lines
              ;; use 3 lines
              (let* ((bx (face-attribute 'mode-line :box))
                     (lh (plist-get bx :line-width)))
-               (and bx (or (not lh) (> lh 0))))
+               (and bx (or (not lh) (> (if (listp lh) (cdr lh) lh) 0))))
              ;; if the mode line has an overline, use 3 lines
              (not (memq (face-attribute 'mode-line :overline)
                         '(nil unspecified)))))))
-- 
2.41.0