unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46662: [PATCH] cl-extra: Fix docstring retrieval
@ 2021-02-20 11:42 Julian Scheid
  2021-02-22 15:06 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Julian Scheid @ 2021-02-20 11:42 UTC (permalink / raw)
  To: 46662


[-- Attachment #1.1: Type: text/plain, Size: 1146 bytes --]

Given

  (require 'cl-macs)
  (cl-defstruct foobar
    (baz nil :documentation "an important piece of information"))

Now, (describe-symbol 'foobar-baz) will include "an important piece of
information".

However, (describe-symbol 'foobar) will not:

Name Type Default
———— ———— ———————
baz t nil

... even though the intention to include it can be seen by looking for
the string ':documentation' in `cl--describe-class-slots`.

This is because `cl--describe-class-slots` accidentally uses
`alist-get` instead of `plist-get`.

With the attached patch, (describe-symbol 'foobar) works as intended:

Name Type Default Doc
———— ———— ——————— ———
baz t nil an important piece of information

Note: `cl--describe-class-slot' (a different function) appears to have
the same bug, but I have no idea how one would go about adding class
slots to a struct and therefore no way of testing any changes to this
other function.

Could it be a code path that is never executed anyway?  I decided to
leave it alone, this patch should be an improvement regardless.

[-- Attachment #1.2: Type: text/html, Size: 1296 bytes --]

[-- Attachment #2: cl--describe-class-slots_plist-get.patch --]
[-- Type: application/octet-stream, Size: 1263 bytes --]

From d9b67052a595d03f228c61d05b0906ea74b0ee4e Mon Sep 17 00:00:00 2001
From: Julian Scheid <julians37@gmail.com>
Date: Sun, 21 Feb 2021 00:15:52 +1300
Subject: [PATCH] cl-extra: Fix docstring retrieval

* lisp/emacs-lisp/cl-extra.el (cl--describe-class-slots): Fix
  docstring retrieval.
---
 lisp/emacs-lisp/cl-extra.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 28ce6b115a..84199c1612 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -898,8 +898,8 @@ cl--describe-class-slots
                (list (cl-prin1-to-string (cl--slot-descriptor-name slot))
                      (cl-prin1-to-string (cl--slot-descriptor-type slot))
                      (cl-prin1-to-string (cl--slot-descriptor-initform slot))
-                     (let ((doc (alist-get :documentation
-                                           (cl--slot-descriptor-props slot))))
+                     (let ((doc (plist-get (cl--slot-descriptor-props slot)
+                                           :documentation)))
                        (if (not doc) ""
                          (setq has-doc t)
                          (substitute-command-keys doc)))))
-- 
2.30.1


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

* bug#46662: [PATCH] cl-extra: Fix docstring retrieval
  2021-02-20 11:42 bug#46662: [PATCH] cl-extra: Fix docstring retrieval Julian Scheid
@ 2021-02-22 15:06 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-22 15:06 UTC (permalink / raw)
  To: Julian Scheid; +Cc: 46662

Julian Scheid <julians37@gmail.com> writes:

> With the attached patch, (describe-symbol 'foobar) works as intended:
>
> Name Type Default Doc
> ———— ———— ——————— ———
> baz t nil an important piece of information

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-02-22 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-20 11:42 bug#46662: [PATCH] cl-extra: Fix docstring retrieval Julian Scheid
2021-02-22 15:06 ` Lars Ingebrigtsen

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