summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2019-07-29 11:56:11 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2019-07-29 11:56:11 -0400
commit75361be63fcd42497dd1eb93cab3255833334475 (patch)
treeb67e1dda5333f799e5df850765e1d68e8d1c77dd /lisp/emacs-lisp
parentb47ca8125b39b871328da114637449a86050baa5 (diff)
downloademacs-75361be63fcd42497dd1eb93cab3255833334475.tar.gz
emacs-75361be63fcd42497dd1eb93cab3255833334475.tar.bz2
emacs-75361be63fcd42497dd1eb93cab3255833334475.zip
* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Add slot option :documentation
Use it to improve the docstring of the accessor functions. * doc/misc/cl.texi: Rename menu entry to "CL-Lib". (Structures): Add ':documentation' and mention ':type' as well, which we don't completely ignore any more.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/cl-macs.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 8b9224bd1b7..1ae72666244 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2722,8 +2722,10 @@ node `(cl)Structures' for the description of the options.
Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where
SDEFAULT is the default value of that slot and SOPTIONS are keyword-value
pairs for that slot.
-Currently, only one keyword is supported, `:read-only'. If this has a
-non-nil value, that slot cannot be set via `setf'.
+Supported keywords for slots are:
+- `:read-only': If this has a non-nil value, that slot cannot be set via `setf'.
+- `:documentation': this is a docstring describing the slot.
+- `:type': the type of the field; currently unused.
\(fn NAME &optional DOCSTRING &rest SLOTS)"
(declare (doc-string 2) (indent 1)
@@ -2902,14 +2904,17 @@ non-nil value, that slot cannot be set via `setf'.
defaults))
(if (assq slot descp)
(error "Duplicate slots named %s in %s" slot name))
- (let ((accessor (intern (format "%s%s" conc-name slot))))
+ (let ((accessor (intern (format "%s%s" conc-name slot)))
+ (default-value (pop desc))
+ (doc (plist-get desc :documentation)))
(push slot slots)
- (push (pop desc) defaults)
+ (push default-value defaults)
;; The arg "cl-x" is referenced by name in eg pred-form
;; and pred-check, so changing it is not straightforward.
(push `(,defsym ,accessor (cl-x)
- ,(format "Access slot \"%s\" of `%s' struct CL-X."
- slot name)
+ ,(format "Access slot \"%s\" of `%s' struct CL-X.%s"
+ slot name
+ (if doc (concat "\n" doc) ""))
(declare (side-effect-free t))
,@(and pred-check
(list `(or ,pred-check