Subject: [PATCH] Make calculator work with customized mode-line

From: john muhl <[email-masked]>
Date: Thu, 29 Jun 2023 10:12:06 -0500

Eli Zaretskii <[email-masked]> writes:

>> +               (and bx (or (not lh) (> (if (listp lh) (cdr lh) lh) 0))))
>                                                ^^^^^
> Shouldn't that be 'consp' instead?  'listp' returns non-nil for nil
> argument.

I’m not expert enough to say more than that either way works to fix the
issue. Originally I did the ‘(cdr lh)’ unconditionally and got an error
mentioning ‘listp’ so I just used that when I added the condition; if it
had said ‘conps’ I would have used that.

Here is the patch with ‘consp’ instead.

>From 36ea9a67c9e559c490f2c5787a75b229772a97e4 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