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