GNU bug report logs - #65128
30.0.50; Strange code in help-fns.el

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Mon, 7 Aug 2023 16:31:01 UTC

Severity: normal

Found in version 30.0.50

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 65128 in the body.
You can then email your comments to 65128 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#65128; Package emacs. (Mon, 07 Aug 2023 16:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> posteo.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 07 Aug 2023 16:31:02 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; Strange code in help-fns.el
Date: Mon, 07 Aug 2023 16:30:56 +0000
Hi,

I am looking at lisp/help-fns.el:describe-keymap and seeing

 (let ((sym nil))
    (unless sym
    ...

It looks like an oversight - sym will always be nil there.

In GNU Emacs 30.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2023-08-04 built on localhost
Repository revision: ce48073f1597ceecb82800e71c89b53badc9f9d0
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: Gentoo Linux

Configured using:
 'configure --with-native-compilation=aot'


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65128; Package emacs. (Mon, 07 Aug 2023 17:13:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>,
 Stefan Kangas <stefankangas <at> gmail.com>
Cc: 65128 <at> debbugs.gnu.org
Subject: Re: bug#65128: 30.0.50; Strange code in help-fns.el
Date: Mon, 07 Aug 2023 20:12:39 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Date: Mon, 07 Aug 2023 16:30:56 +0000
> 
> Hi,
> 
> I am looking at lisp/help-fns.el:describe-keymap and seeing
> 
>  (let ((sym nil))
>     (unless sym
>     ...
> 
> It looks like an oversight - sym will always be nil there.

Adding Stefan, who wrote that function.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Tue, 08 Aug 2023 01:45:01 GMT) Full text and rfc822 format available.

Notification sent to Ihor Radchenko <yantar92 <at> posteo.net>:
bug acknowledged by developer. (Tue, 08 Aug 2023 01:45:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ihor Radchenko <yantar92 <at> posteo.net>, 65128-done <at> debbugs.gnu.org
Subject: Re: bug#65128: 30.0.50; Strange code in help-fns.el
Date: Tue, 8 Aug 2023 03:43:53 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> > I am looking at lisp/help-fns.el:describe-keymap and seeing
> >
> >  (let ((sym nil))
> >     (unless sym
> >     ...
> >
> > It looks like an oversight - sym will always be nil there.
>
> Adding Stefan, who wrote that function.

Thanks, now fixed on master.

PS. For the record, this function was originally written by Drew, and
integrated into Emacs by me.  I do get credit for the stylistic
mistake here, however.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65128; Package emacs. (Tue, 08 Aug 2023 15:51:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Kangas <stefankangas <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: Ihor Radchenko <yantar92 <at> posteo.net>,
 "65128-done <at> debbugs.gnu.org" <65128-done <at> debbugs.gnu.org>
Subject: RE: [External] : bug#65128: 30.0.50; Strange code in help-fns.el
Date: Tue, 8 Aug 2023 15:50:12 +0000
> > > I am looking at lisp/help-fns.el:describe-keymap and seeing
> > >  (let ((sym nil))
> > >     (unless sym ...
> > >
> > > It looks like an oversight - sym will always be nil there.
> >
> > Adding Stefan, who wrote that function.
> 
> Thanks, now fixed on master.
> 
> PS. For the record, this function was originally written by Drew, and
> integrated into Emacs by me.  I do get credit for the stylistic
> mistake here, however.

;-) Thanks for the attribution and mea culpa.

Yes, I wrote `describe-keymap'.  My version
is in library `help-fns+.el':

 https://www.emacswiki.org/emacs/download/help-fns%2b.el

My code differs here: it tests SYM because
there's conditional code that can set it:

(let ((sym nil))
  (when search-symbols-p ; <==================
    (setq sym (catch 'describe-keymap ; <====
                (mapatoms 
                 (lambda (symb) 
                   (when (and (boundp symb)
                              (eq (symbol-value symb) keymap)
                              (not (eq symb 'keymap))
                              (throw 'describe-keymap symb)))))
                nil)))
  (unless sym ; <=============================
    (setq sym  (cl-gentemp "KEYMAP OBJECT (no variable) "))
    (set sym keymap))
  (setq keymap  sym))

Vanilla code:

(let ((sym nil))
        (unless sym
          (setq sym (cl-gentemp "KEYMAP OBJECT (no variable) "))
          (setq used-gentemp t)
          (set sym keymap))
        (setq keymap sym))

In my code, `describe-keymap' takes optional arg
SEARCH-SYMBOLS-P.  That's used non-interactively
to search all vars for one whose value is KEYMAP,
when KEYMAP isn't a symbol.  It tells you a var
(if there is one) that corresponds to the KEYMAP.
It's a feature that was suggested by a user.

Vanilla Emacs didn't want/include the feature, so
yes, the `(unless sym' test there is gratuitous
(but harmless).

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

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

Previous Next


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