GNU bug report logs - #75557
gnus-highlight-selected-tree is broken (fix)

Previous Next

Package: emacs;

Reported by: Pranshu Sharma <pranshu <at> bauherren.ovh>

Date: Tue, 14 Jan 2025 14:05:01 UTC

Severity: normal

Fixed in version 31.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

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 75557 in the body.
You can then email your comments to 75557 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#75557; Package emacs. (Tue, 14 Jan 2025 14:05:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Pranshu Sharma <pranshu <at> bauherren.ovh>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 14 Jan 2025 14:05:02 GMT) Full text and rfc822 format available.

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

From: Pranshu Sharma <pranshu <at> bauherren.ovh>
To: bug-gnu-emacs <at> gnu.org
Subject: gnus-highlight-selected-tree is broken (fix)
Date: Wed, 15 Jan 2025 00:03:40 +1000
[Message part 1 (text/plain, inline)]
seems like buffer-live-p does not accept string buffer names anymore

[Message part 2 (text/x-diff, inline)]
diff --git a/lisp/gnus/gnus-salt.el b/lisp/gnus/gnus-salt.el
index 6514d8d4174..75daf7e7cfa 100644
--- a/lisp/gnus/gnus-salt.el
+++ b/lisp/gnus/gnus-salt.el
@@ -808,7 +808,7 @@ gnus-tree-perhaps-minimize
 
 (defun gnus-highlight-selected-tree (article)
   "Highlight the selected article in the tree."
-  (when (buffer-live-p gnus-tree-buffer)
+  (when (buffer-live-p (get-buffer gnus-tree-buffer))
     (let ((buf (current-buffer))
 	  region)
       (set-buffer gnus-tree-buffer)
[Message part 3 (text/plain, inline)]
-- 
Pranshu Sharma <https://p.bauherren.ovh>

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75557; Package emacs. (Sun, 02 Mar 2025 04:05:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Pranshu Sharma <pranshu <at> bauherren.ovh>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 75557 <at> debbugs.gnu.org
Subject: Re: bug#75557: gnus-highlight-selected-tree is broken (fix)
Date: Sat, 1 Mar 2025 20:04:45 -0800
fixed 75557 31.1
thanks

Pranshu Sharma <pranshu <at> bauherren.ovh> writes:

> seems like buffer-live-p does not accept string buffer names anymore

It actually never did.

I installed the below change on master (in your name), thanks.

>
> diff --git a/lisp/gnus/gnus-salt.el b/lisp/gnus/gnus-salt.el
> index 6514d8d4174..75daf7e7cfa 100644
> --- a/lisp/gnus/gnus-salt.el
> +++ b/lisp/gnus/gnus-salt.el
> @@ -808,7 +808,7 @@ gnus-tree-perhaps-minimize
>
>  (defun gnus-highlight-selected-tree (article)
>    "Highlight the selected article in the tree."
> -  (when (buffer-live-p gnus-tree-buffer)
> +  (when (buffer-live-p (get-buffer gnus-tree-buffer))
>      (let ((buf (current-buffer))
>  	  region)
>        (set-buffer gnus-tree-buffer)

My only question is if we should perhaps make `buffer-live-p` throw an
error in case it is passed something of the wrong type.  Yes, it is a
backwards-incompatible change, but OTOH it would catch real bugs like
the above, instead of silently returning nil.

For example, we can currently do all of this nonsense:

    (buffer-live-p 123)                          => nil
    (buffer-live-p [foo])                        => nil
    (buffer-live-p (make-symbol "foo"))          => nil
    (buffer-live-p (lambda () (message "foo")))  => nil

Eli, Stefan, WDYT?




bug Marked as fixed in versions 31.1. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 02 Mar 2025 04:05:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75557; Package emacs. (Sun, 02 Mar 2025 04:32:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Pranshu Sharma <pranshu <at> bauherren.ovh>,
 75557 <at> debbugs.gnu.org
Subject: Re: bug#75557: gnus-highlight-selected-tree is broken (fix)
Date: Sat, 01 Mar 2025 23:30:55 -0500
> My only question is if we should perhaps make `buffer-live-p` throw an
> error in case it is passed something of the wrong type.  Yes, it is a
> backwards-incompatible change, but OTOH it would catch real bugs like
> the above, instead of silently returning nil.
>
> For example, we can currently do all of this nonsense:
>
>     (buffer-live-p 123)                          => nil
>     (buffer-live-p [foo])                        => nil
>     (buffer-live-p (make-symbol "foo"))          => nil
>     (buffer-live-p (lambda () (message "foo")))  => nil
>
> Eli, Stefan, WDYT?

I'm pretty sure it would introduce bugs because I know I wrote code
which relies on `buffer-live-p` behaving "like a type check"
(i.e. accepting any object).
I'd be surprised if I was the only one.


        Stefan "who doesn't like the tendency of ELisp functions to
                accept buffer names in place of buffer objects."





Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sun, 02 Mar 2025 04:34:02 GMT) Full text and rfc822 format available.

Notification sent to Pranshu Sharma <pranshu <at> bauherren.ovh>:
bug acknowledged by developer. (Sun, 02 Mar 2025 04:34:03 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Pranshu Sharma <pranshu <at> bauherren.ovh>,
 75557-done <at> debbugs.gnu.org
Subject: Re: bug#75557: gnus-highlight-selected-tree is broken (fix)
Date: Sat, 1 Mar 2025 20:32:59 -0800
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> My only question is if we should perhaps make `buffer-live-p` throw an
>> error in case it is passed something of the wrong type.  Yes, it is a
>> backwards-incompatible change, but OTOH it would catch real bugs like
>> the above, instead of silently returning nil.
>>
>> For example, we can currently do all of this nonsense:
>>
>>     (buffer-live-p 123)                          => nil
>>     (buffer-live-p [foo])                        => nil
>>     (buffer-live-p (make-symbol "foo"))          => nil
>>     (buffer-live-p (lambda () (message "foo")))  => nil
>>
>> Eli, Stefan, WDYT?
>
> I'm pretty sure it would introduce bugs because I know I wrote code
> which relies on `buffer-live-p` behaving "like a type check"
> (i.e. accepting any object).
> I'd be surprised if I was the only one.

OK, then I guess there's not much more to do here.

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 30 Mar 2025 11:24:29 GMT) Full text and rfc822 format available.

This bug report was last modified 133 days ago.

Previous Next


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