emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master dc5fe95a48f: (cl--describe-class): Improve based on dicussion in


From: Stefan Monnier
Subject: master dc5fe95a48f: (cl--describe-class): Improve based on dicussion in bug#70077
Date: Mon, 8 Apr 2024 14:00:37 -0400 (EDT)

branch: master
commit dc5fe95a48f5bff5dfac8841d05c66b300b09aab
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    (cl--describe-class): Improve based on dicussion in bug#70077
    
    * lisp/emacs-lisp/cl-extra.el (cl--describe-class): Move docstring
    after the class' slots.
    (cl--describe-class-slots): Buttonize the types.
---
 lisp/emacs-lisp/cl-extra.el | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 437dea2d6a9..4660d94ea90 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -807,13 +807,19 @@ Call `cl--find-class' to get TYPE's propname `cl--class'"
           (insert (substitute-command-keys (if ch "', " "'"))))
         (insert ".\n")))
 
+    ;; Describe all the slots in this class.
+    ;; Put it before the docstring, since the docstring may want
+    ;; to refer to the slots.
+    (cl--describe-class-slots class)
+
     ;; Type's documentation.
     (let ((doc (cl--class-docstring class)))
       (when doc
-        (insert "\n" doc "\n\n")))
-
-    ;; Describe all the slots in this class.
-    (cl--describe-class-slots class)
+        (insert (if (save-excursion
+                      (or (< (skip-chars-backward "\n") -1) (bobp)))
+                    ""
+                  "\n")
+                doc "\n\n")))
 
     ;; Describe all the methods specific to this class.
     (let ((generics (cl-generic-all-functions type)))
@@ -910,7 +916,12 @@ Outputs to the current buffer."
               (mapcar
                (lambda (slot)
                  (list (cl-prin1-to-string (cl--slot-descriptor-name slot))
-                       (cl-prin1-to-string (cl--slot-descriptor-type slot))
+                       (let ((type (cl--slot-descriptor-type slot)))
+                         (if (and type (symbolp type) (cl--find-class type))
+                             (make-text-button (symbol-name type) nil
+                                              'type 'help-type
+                                              'help-args (list type))
+                           (cl-prin1-to-string type)))
                        (cl-prin1-to-string (cl--slot-descriptor-initform slot))
                        (let ((doc (alist-get :documentation
                                              (cl--slot-descriptor-props 
slot))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]