unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#65128: 30.0.50; Strange code in help-fns.el
@ 2023-08-07 16:30 Ihor Radchenko
  2023-08-07 17:12 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-08-07 16:30 UTC (permalink / raw)
  To: 65128

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>





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#65128: 30.0.50; Strange code in help-fns.el
  2023-08-07 16:30 bug#65128: 30.0.50; Strange code in help-fns.el Ihor Radchenko
@ 2023-08-07 17:12 ` Eli Zaretskii
  2023-08-08  1:43   ` Stefan Kangas
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2023-08-07 17:12 UTC (permalink / raw)
  To: Ihor Radchenko, Stefan Kangas; +Cc: 65128

> From: Ihor Radchenko <yantar92@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#65128: 30.0.50; Strange code in help-fns.el
  2023-08-07 17:12 ` Eli Zaretskii
@ 2023-08-08  1:43   ` Stefan Kangas
  2023-08-08 15:50     ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Kangas @ 2023-08-08  1:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Ihor Radchenko, 65128-done

Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#65128: 30.0.50; Strange code in help-fns.el
  2023-08-08  1:43   ` Stefan Kangas
@ 2023-08-08 15:50     ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2023-08-08 15:50 UTC (permalink / raw)
  To: Stefan Kangas, Eli Zaretskii; +Cc: Ihor Radchenko, 65128-done@debbugs.gnu.org

> > > 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).

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-08 15:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 16:30 bug#65128: 30.0.50; Strange code in help-fns.el Ihor Radchenko
2023-08-07 17:12 ` Eli Zaretskii
2023-08-08  1:43   ` Stefan Kangas
2023-08-08 15:50     ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).