Function: cl--describe-class-slots

cl--describe-class-slots is a byte-compiled function defined in cl-extra.el.gz.

Signature

(cl--describe-class-slots CLASS)

Documentation

Print help description for the slots in CLASS.

Outputs to the current buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-extra.el.gz
(defun cl--describe-class-slots (class)
  "Print help description for the slots in CLASS.
Outputs to the current buffer."
  (let* ((slots (cl--class-slots class))
         (metatype (type-of class))
         ;; ¡For EIEIO!
         (cslots (condition-case nil
                     (cl-struct-slot-value metatype 'class-slots class)
                   (cl-struct-unknown-slot nil))))
    (if (and (null slots) (eq metatype 'built-in-class))
        (insert "This is a built-in type.\n")

      (insert (propertize "Instance Allocated Slots:\n\n"
			  'face 'bold))
      (let* ((has-doc nil)
             (slots-strings
              (mapcar
               (lambda (slot)
                 (list (cl-prin1-to-string (cl--slot-descriptor-name slot))
                       (let ((type (cl--slot-descriptor-type slot)))
                         (cond
                          ((eq type t) "")
                          ((and type (symbolp type) (cl--find-class type))
                           (make-text-button (symbol-name type) nil
                                             'type 'help-type
                                             'help-args (list type)))
                          (t (cl-prin1-to-string type))))
                       (cl-prin1-to-string (cl--slot-descriptor-initform slot))
                       (let ((doc (alist-get :documentation
                                             (cl--slot-descriptor-props slot))))
                         (if (not doc) ""
                           (setq has-doc t)
                           (substitute-command-keys doc)))))
               slots)))
        (cl--print-table `("Name" "Type" "Default") slots-strings has-doc)))
    (insert "\n")
    (when (> (length cslots) 0)
      (insert (propertize "\nClass Allocated Slots:\n\n" 'face 'bold))
      (mapc #'cl--describe-class-slot cslots))))