diff options
| author | Artur Malabarba | 2015-04-13 13:13:36 +0100 |
|---|---|---|
| committer | Artur Malabarba | 2015-04-13 20:51:14 +0100 |
| commit | 13634dec038d613c3b618d70cd64d6d63561f2eb (patch) | |
| tree | 4723e8a78972cb6bf9caaf9717b686916e2d19bd | |
| parent | 84e0b7dad6f1a8e53261f9b96f5a9080fea681a4 (diff) | |
| download | emacs-13634dec038d613c3b618d70cd64d6d63561f2eb.tar.gz emacs-13634dec038d613c3b618d70cd64d6d63561f2eb.zip | |
* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Implement docstrings
Adding a string after a constructor's argument list will use
that string as the constructor function docstring. If this string
is absent but the struct itself was given a docstring, use that as
the constructor's docstring.
Fixes (bug#17284).
| -rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 41435b8b7b1..5bab84ed312 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el | |||
| @@ -2726,12 +2726,16 @@ non-nil value, that slot cannot be set via `setf'. | |||
| 2726 | constrs)) | 2726 | constrs)) |
| 2727 | (while constrs | 2727 | (while constrs |
| 2728 | (let* ((name (caar constrs)) | 2728 | (let* ((name (caar constrs)) |
| 2729 | (args (cadr (pop constrs))) | 2729 | (rest (cdr (pop constrs))) |
| 2730 | (args (car rest)) | ||
| 2731 | (doc (cadr rest)) | ||
| 2730 | (anames (cl--arglist-args args)) | 2732 | (anames (cl--arglist-args args)) |
| 2731 | (make (cl-mapcar (function (lambda (s d) (if (memq s anames) s d))) | 2733 | (make (cl-mapcar (function (lambda (s d) (if (memq s anames) s d))) |
| 2732 | slots defaults))) | 2734 | slots defaults))) |
| 2733 | (push `(cl-defsubst ,name | 2735 | (push `(cl-defsubst ,name |
| 2734 | (&cl-defs (nil ,@descs) ,@args) | 2736 | (&cl-defs (nil ,@descs) ,@args) |
| 2737 | ,@(if (stringp doc) (list doc) | ||
| 2738 | (if (stringp docstring) (list docstring))) | ||
| 2735 | ,@(if (cl--safe-expr-p `(progn ,@(mapcar #'cl-second descs))) | 2739 | ,@(if (cl--safe-expr-p `(progn ,@(mapcar #'cl-second descs))) |
| 2736 | '((declare (side-effect-free t)))) | 2740 | '((declare (side-effect-free t)))) |
| 2737 | (,(or type #'vector) ,@make)) | 2741 | (,(or type #'vector) ,@make)) |