unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Kangas <stefan@marxist.se>
Cc: 30660@debbugs.gnu.org, "積丹尼 Dan Jacobson" <jidanni@jidanni.org>
Subject: bug#30660: mention describe-bindings on (info "(emacs) Keymaps")
Date: Fri, 23 Aug 2019 18:46:19 -0700 (PDT)	[thread overview]
Message-ID: <831b5f34-28c7-4753-bed9-0a28de484aa8@default> (raw)
In-Reply-To: <CADwFkmm_=x8YzqN9Fcnbq5XZohJh-yBLNgCCRNhW+KDT9bj3Fw@mail.gmail.com>

> > Non-interactively:
> > * KEYMAP can be such a keymap variable or a keymap.
> > * Non-nil optional arg SEARCH-SYMBOLS-P means that if KEYMAP is not a
> >   symbol then search all variables for one whose value is KEYMAP."
> 
> Is the purpose of SEARCH-SYMBOLS-P just to allow for calling it like
> this:
>     (describe-keymap 'my-keymap t)
>     (describe-keymap my-keymap t)
> 
> And have it work automatically?  Or am I missing something?  Also see
> below.

KEYMAP can be a keymap, instead of a symbol.

(This was not the case originally.  I added handling
this case later, as it was requested and turned out
to be useful.  It's not rare to have a keymap object
ready-to-hand and without its variable.  This lets
you not only see the bindings but also identify the
keymap.)

If it's not a symbol there might still be a symbol
that has it as value.  Non-nil SEARCH-SYMBOLS-P
means try to find such a symbol.

If such a symbol is found then the help is better -
it tells you more about the keymap and its context,
by (1) providing its doc (in addition to listing the
key bindings) and even just (2) providing its name,
letting you know (typically) what mode or other
context defines it.

If the search finds no symbol with KEYMAP as its
value then the behavior is the same as if no search
was made (except for the time wasted on a failed
search): a symbol is generated for the map (just to
use the same code path).  The other difference is
that because you provided SEARCH-SYMBOLS-P you know
that a search turned up no symbol - more information.

> I admit that I find this code a bit hard to follow.  If I understand
> correctly, then most of this can be removed if we don't want to
> support SEARCH-SYMBOLS-P, and instead just require that the KEYMAP
> argument is a symbol.  Is that correct or am I missing something?

Who's "we"?  If a _user_ or calling code doesn't
want to search existing symbols then SEARCH-SYMBOLS-P
is supplied.  Nothing is lost by having it as a
behavior option, and something (quite a lot, actually)
is gained by making it available.  Putting a name on
a keymap object can be quite helpful.

The case where a user (or calling code) has a keymap
but no variable for it is not uncommon, even if it
is not the most common case.  Being able to find the
variable and see its doc is helpful.

> I'm sort of leaning towards simplifying this by removing the
> SEARCH-SYMBOLS-P argument, but I might not understand the use case
> here.  If I'm missing something, could you please briefly describe the
> use case for that and if and why it's important to keep?

See above.

> >   (let* ((name  (symbol-name keymap))
> >          (doc   (let ((raw-doc  (documentation-property keymap
> 'variable-documentation 'RAW)))
> >                   (substitute-command-keys raw-doc)))
> 
> Why not just say (documentation-property keymap 'variable-
> documentation)
> without the 'RAW argument?  That should have the same effect as
> passing the 'RAW argument and then calling substitute-command-keys on
> the result, AFAICT.

Yes; sorry.  My code uses `help-documentation-property'
and `help-substitute-command-keys'.  I too quickly
substituted the body of `help-documentation-property',
changing its occurrence of `help-substitute-command-keys'
to just `substitute-command-keys'.  None of `h-d-p' is
needed here if you don't have `h-s-c-k'.

IOW, if neither of those is available then yes, all
you need is (documentation-property keymap
'variable-documentation).  Sorry about that mistake.

You might want to take a look at the full code,
in help-fns+.el, to see what the differences are.
Some are to support older Emacs versions too, others
are to provide additional features.

> > (doc   (and (not (equal "" doc))  doc)))
> 
> Is this to allow us to simply say (when doc ...) below

Yes.  It makes DOC be either nil or real doc.

> instead of (when (not (equal "" doc)) ...)

[aka (unless (equal "" doc)...)]

No.  That's not the same.  That does `...' when doc
is nil.  The code should do `...' only when doc is
non-nil and not "".





  reply	other threads:[~2019-08-24  1:46 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 20:25 bug#30660: mention describe-bindings on (info "(emacs) Keymaps") 積丹尼 Dan Jacobson
2018-02-28 23:29 ` Drew Adams
2019-08-23  7:18 ` Stefan Kangas
2019-08-23 18:44   ` Drew Adams
2019-08-23 22:40     ` Stefan Kangas
2019-08-24  1:46       ` Drew Adams [this message]
2019-08-24  3:01         ` Stefan Kangas
2019-08-24 15:06           ` Drew Adams
2019-10-16 22:42             ` Stefan Kangas
2019-10-14 20:28           ` Lars Ingebrigtsen
2019-10-14 20:33             ` Eli Zaretskii
2019-10-17  9:39               ` Stefan Kangas
2019-10-17  9:42                 ` Stefan Kangas
2019-10-17 12:07                   ` Robert Pluim
2019-10-17 13:10                     ` Eli Zaretskii
2019-10-17 13:30                       ` Stefan Kangas
2019-11-07  0:18                         ` Stefan Kangas
2019-11-07  0:40                           ` Drew Adams
2019-10-17 13:00                 ` Eli Zaretskii
2019-11-07  1:00                   ` Stefan Kangas
2019-11-11 15:04                     ` Stefan Kangas
2019-11-14 11:12                       ` Eli Zaretskii
2019-11-17 20:36                         ` Stefan Kangas
2019-11-18 16:23                           ` Eli Zaretskii
2019-11-19  6:07                           ` Richard Stallman
2019-11-19 16:04                             ` Eli Zaretskii
2019-11-17 20:51                         ` Stefan Kangas
2019-11-18 16:20                           ` Eli Zaretskii
2019-11-19 14:14                             ` Stefan Kangas
2019-11-19 17:03                               ` Eli Zaretskii
     [not found]                                 ` <87zhen2h81.fsf@marxist.se>
2020-01-17  8:07                                   ` Eli Zaretskii
2020-01-18  2:16                                     ` Stefan Kangas
2020-01-18  8:31                                       ` Eli Zaretskii
2020-01-18  9:12                                         ` Stefan Kangas
2020-01-18  9:41                                           ` Eli Zaretskii
2020-01-18 23:42                                             ` Stefan Kangas
2020-01-19  2:09                                               ` Drew Adams
2020-01-31 10:15                                               ` Eli Zaretskii
2020-02-04  1:32                                                 ` Stefan Kangas
2019-10-14 20:50             ` Drew Adams
2019-10-16 22:48               ` Stefan Kangas

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=831b5f34-28c7-4753-bed9-0a28de484aa8@default \
    --to=drew.adams@oracle.com \
    --cc=30660@debbugs.gnu.org \
    --cc=jidanni@jidanni.org \
    --cc=stefan@marxist.se \
    /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).