GNU bug report logs - #64344
[PATCH] Make calculator work with customized mode-line

Previous Next

Package: emacs;

Reported by: john muhl <jm <at> pub.pink>

Date: Thu, 29 Jun 2023 06:44:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 64344 in the body.
You can then email your comments to 64344 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 06:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to john muhl <jm <at> pub.pink>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 29 Jun 2023 06:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: john muhl <jm <at> pub.pink>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Make calculator work with customized mode-line
Date: Wed, 28 Jun 2023 13:23:45 -0500
[Message part 1 (text/plain, inline)]
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

[0001-lisp-calculator-el--calculator-need-3-lines---Ch.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]

[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 07:50:01 GMT) Full text and rfc822 format available.

Message #8 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: john muhl <jm <at> pub.pink>
Cc: 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 10:49:38 +0300
> Date: Wed, 28 Jun 2023 13:23:45 -0500
> From:  john muhl via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> 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)

Thanks.

> 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))))
                                               ^^^^^
Shouldn't that be 'consp' instead?  'listp' returns non-nil for nil
argument.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 08:23:02 GMT) Full text and rfc822 format available.

Message #11 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: john muhl <jm <at> pub.pink>, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 10:22:02 +0200
On Jun 29 2023, Eli Zaretskii wrote:

>> 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))))
>                                                ^^^^^
> Shouldn't that be 'consp' instead?  'listp' returns non-nil for nil
> argument.

lh cannot be nil here, but it wouldn't make a difference anyway, since
(cdr nil) returns nil.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 08:47:02 GMT) Full text and rfc822 format available.

Message #14 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: john muhl <jm <at> pub.pink>, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 10:46:11 +0200
On Thu, 29 Jun 2023 10:49:38 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:

>> Date: Wed, 28 Jun 2023 13:23:45 -0500
>> From:  john muhl via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> 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)
>
> Thanks.
>
>> 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))))

Why is the state of the mode-line face shown as "EDITED, shown value
does not take effect until you set or save it." before setting it in the
above recipe?  In fact, I see nine such faces in the buffer *Customize
Faces* with -Q (the state of all other faces is shown as "STANDARD").

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 09:27:01 GMT) Full text and rfc822 format available.

Message #17 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: jm <at> pub.pink, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 12:26:00 +0300
> From: Stephen Berman <stephen.berman <at> gmx.net>
> Cc: john muhl <jm <at> pub.pink>,  64344 <at> debbugs.gnu.org
> Date: Thu, 29 Jun 2023 10:46:11 +0200
> 
> Why is the state of the mode-line face shown as "EDITED, shown value
> does not take effect until you set or save it." before setting it in the
> above recipe?  In fact, I see nine such faces in the buffer *Customize
> Faces* with -Q (the state of all other faces is shown as "STANDARD").

Please submit a separate bug report about this, as it's unrelated to
the issue at hand here.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 09:29:01 GMT) Full text and rfc822 format available.

Message #20 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andreas Schwab <schwab <at> suse.de>
Cc: jm <at> pub.pink, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 12:28:28 +0300
> From: Andreas Schwab <schwab <at> suse.de>
> Cc: john muhl <jm <at> pub.pink>,  64344 <at> debbugs.gnu.org
> Date: Thu, 29 Jun 2023 10:22:02 +0200
> 
> On Jun 29 2023, Eli Zaretskii wrote:
> 
> >> -               (and bx (or (not lh) (> lh 0))))
> >> +               (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.
> 
> lh cannot be nil here, but it wouldn't make a difference anyway, since
> (cdr nil) returns nil.

I prefer not to have, nor force others, to analyze code in order to
ensure it's correct.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 09:32:01 GMT) Full text and rfc822 format available.

Message #23 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: jm <at> pub.pink, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 11:31:06 +0200
On Jun 29 2023, Eli Zaretskii wrote:

>> From: Andreas Schwab <schwab <at> suse.de>
>> Cc: john muhl <jm <at> pub.pink>,  64344 <at> debbugs.gnu.org
>> Date: Thu, 29 Jun 2023 10:22:02 +0200
>> 
>> On Jun 29 2023, Eli Zaretskii wrote:
>> 
>> >> -               (and bx (or (not lh) (> lh 0))))
>> >> +               (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.
>> 
>> lh cannot be nil here, but it wouldn't make a difference anyway, since
>> (cdr nil) returns nil.
>
> I prefer not to have, nor force others, to analyze code in order to
> ensure it's correct.

Then you need to add a comment, not change correct code.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 09:39:01 GMT) Full text and rfc822 format available.

Message #26 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andreas Schwab <schwab <at> suse.de>
Cc: jm <at> pub.pink, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 12:38:36 +0300
> From: Andreas Schwab <schwab <at> suse.de>
> Cc: jm <at> pub.pink,  64344 <at> debbugs.gnu.org
> Date: Thu, 29 Jun 2023 11:31:06 +0200
> 
> On Jun 29 2023, Eli Zaretskii wrote:
> 
> >> From: Andreas Schwab <schwab <at> suse.de>
> >> Cc: john muhl <jm <at> pub.pink>,  64344 <at> debbugs.gnu.org
> >> Date: Thu, 29 Jun 2023 10:22:02 +0200
> >> 
> >> On Jun 29 2023, Eli Zaretskii wrote:
> >> 
> >> >> -               (and bx (or (not lh) (> lh 0))))
> >> >> +               (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.
> >> 
> >> lh cannot be nil here, but it wouldn't make a difference anyway, since
> >> (cdr nil) returns nil.
> >
> > I prefer not to have, nor force others, to analyze code in order to
> > ensure it's correct.
> 
> Then you need to add a comment, not change correct code.

There's no reason whatsoever to comment correct code.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 09:45:02 GMT) Full text and rfc822 format available.

Message #29 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: jm <at> pub.pink, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 11:43:59 +0200
On Jun 29 2023, Eli Zaretskii wrote:

>> From: Andreas Schwab <schwab <at> suse.de>
>> Cc: jm <at> pub.pink,  64344 <at> debbugs.gnu.org
>> Date: Thu, 29 Jun 2023 11:31:06 +0200
>> 
>> On Jun 29 2023, Eli Zaretskii wrote:
>> 
>> >> From: Andreas Schwab <schwab <at> suse.de>
>> >> Cc: john muhl <jm <at> pub.pink>,  64344 <at> debbugs.gnu.org
>> >> Date: Thu, 29 Jun 2023 10:22:02 +0200
>> >> 
>> >> On Jun 29 2023, Eli Zaretskii wrote:
>> >> 
>> >> >> -               (and bx (or (not lh) (> lh 0))))
>> >> >> +               (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.
>> >> 
>> >> lh cannot be nil here, but it wouldn't make a difference anyway, since
>> >> (cdr nil) returns nil.
>> >
>> > I prefer not to have, nor force others, to analyze code in order to
>> > ensure it's correct.
>> 
>> Then you need to add a comment, not change correct code.
>
> There's no reason whatsoever to comment correct code.

Ok, so nothing needs to change.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 10:18:02 GMT) Full text and rfc822 format available.

Message #32 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: jm <at> pub.pink, 64344 <at> debbugs.gnu.org
Subject: Re: bug#64344: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 12:17:48 +0200
On Thu, 29 Jun 2023 12:26:00 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:

>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> Cc: john muhl <jm <at> pub.pink>,  64344 <at> debbugs.gnu.org
>> Date: Thu, 29 Jun 2023 10:46:11 +0200
>>
>> Why is the state of the mode-line face shown as "EDITED, shown value
>> does not take effect until you set or save it." before setting it in the
>> above recipe?  In fact, I see nine such faces in the buffer *Customize
>> Faces* with -Q (the state of all other faces is shown as "STANDARD").
>
> Please submit a separate bug report about this, as it's unrelated to
> the issue at hand here.
>
> Thanks.

Done, bug#64347.

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64344; Package emacs. (Thu, 29 Jun 2023 16:45:02 GMT) Full text and rfc822 format available.

Message #35 received at 64344 <at> debbugs.gnu.org (full text, mbox):

From: john muhl <jm <at> pub.pink>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64344 <at> debbugs.gnu.org
Subject: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 10:12:06 -0500
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> 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.

[0001-lisp-calculator-el--calculator-need-3-lines---Ch.patch (text/x-patch, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 29 Jun 2023 18:23:01 GMT) Full text and rfc822 format available.

Notification sent to john muhl <jm <at> pub.pink>:
bug acknowledged by developer. (Thu, 29 Jun 2023 18:23:02 GMT) Full text and rfc822 format available.

Message #40 received at 64344-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: john muhl <jm <at> pub.pink>
Cc: 64344-done <at> debbugs.gnu.org
Subject: Re: [PATCH] Make calculator work with customized mode-line
Date: Thu, 29 Jun 2023 21:22:45 +0300
> From: john muhl <jm <at> pub.pink>
> Cc: 64344 <at> debbugs.gnu.org
> Date: Thu, 29 Jun 2023 10:12:06 -0500
> 
> > 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.

Thanks.  That still uses 'listp', so I fixed that manually.

This is now installed on the emacs-29 branch; closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 28 Jul 2023 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 331 days ago.

Previous Next


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