unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Kangas <stefankangas@gmail.com>, Eli Zaretskii <eliz@gnu.org>
Cc: Ihor Radchenko <yantar92@posteo.net>,
	"65128-done@debbugs.gnu.org" <65128-done@debbugs.gnu.org>
Subject: bug#65128: 30.0.50; Strange code in help-fns.el
Date: Tue, 8 Aug 2023 15:50:12 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488179469CF8CCC7145ACF0F30DA@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <CADwFkm=3n2OTboyba_GCcPzo=Vhp+qUB460KSQ0P=8iGgqX2-A@mail.gmail.com>

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

      reply	other threads:[~2023-08-08 15:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR10MB5488179469CF8CCC7145ACF0F30DA@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=65128-done@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stefankangas@gmail.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).