aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorStefan Monnier2015-02-05 14:28:16 -0500
committerStefan Monnier2015-02-05 14:28:16 -0500
commitad5a7c86d017ce8e9ff1312331ef09181be823bf (patch)
treef8382a7c42f6844bacf48f03d9480ba8134ba6cc /src/eval.c
parent10927c1a0f39d527d9ea1fc4605a0ef400bdff4a (diff)
downloademacs-ad5a7c86d017ce8e9ff1312331ef09181be823bf.tar.gz
emacs-ad5a7c86d017ce8e9ff1312331ef09181be823bf.zip
Add (:documentation <form>) for dynamically-generated docstrings
* lisp/emacs-lisp/bytecomp.el: (byte-compile-initial-macro-environment): Use macroexp-progn. (byte-compile-cl-warn): Don't silence use of cl-macroexpand-all. (byte-compile-file-form-defvar-function): Rename from byte-compile-file-form-define-abbrev-table. (defvaralias, byte-compile-file-form-custom-declare-variable): Use it. (byte-compile): Use byte-compile-top-level rather than byte-compile-lambda so we can compile non-values. (byte-compile-form): Add warnings for failed uses of lexical vars via quoted symbols. (byte-compile-unfold-bcf): Improve message for failed inlining. (byte-compile-make-closure): Handle new format of internal-make-closure for dynamically-generated docstrings. * lisp/emacs-lisp/cconv.el (cconv--convert-function): Add `docstring' argument. (cconv-convert): Use it to handle the new (:documentation ...) form. (cconv-analyze-form): Handle the new (:documentation ...) form. * src/eval.c (Ffunction): Handle the new (:documentation ...) form. (syms_of_eval): Declare `:documentation'.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c
index b98b224e622..e828da9288f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -575,10 +575,23 @@ usage: (function ARG) */)
575 if (!NILP (Vinternal_interpreter_environment) 575 if (!NILP (Vinternal_interpreter_environment)
576 && CONSP (quoted) 576 && CONSP (quoted)
577 && EQ (XCAR (quoted), Qlambda)) 577 && EQ (XCAR (quoted), Qlambda))
578 /* This is a lambda expression within a lexical environment; 578 { /* This is a lambda expression within a lexical environment;
579 return an interpreted closure instead of a simple lambda. */ 579 return an interpreted closure instead of a simple lambda. */
580 return Fcons (Qclosure, Fcons (Vinternal_interpreter_environment, 580 Lisp_Object cdr = XCDR (quoted);
581 XCDR (quoted))); 581 Lisp_Object tmp = cdr;
582 if (CONSP (tmp)
583 && (tmp = XCDR (tmp), CONSP (tmp))
584 && (tmp = XCAR (tmp), CONSP (tmp))
585 && (EQ (QCdocumentation, XCAR (tmp))))
586 { /* Handle the special (:documentation <form>) to build the docstring
587 dynamically. */
588 Lisp_Object docstring = eval_sub (Fcar (XCDR (tmp)));
589 CHECK_STRING (docstring);
590 cdr = Fcons (XCAR (cdr), Fcons (docstring, XCDR (XCDR (cdr))));
591 }
592 return Fcons (Qclosure, Fcons (Vinternal_interpreter_environment,
593 cdr));
594 }
582 else 595 else
583 /* Simply quote the argument. */ 596 /* Simply quote the argument. */
584 return quoted; 597 return quoted;
@@ -3668,6 +3681,7 @@ before making `inhibit-quit' nil. */);
3668 DEFSYM (Qand_rest, "&rest"); 3681 DEFSYM (Qand_rest, "&rest");
3669 DEFSYM (Qand_optional, "&optional"); 3682 DEFSYM (Qand_optional, "&optional");
3670 DEFSYM (Qclosure, "closure"); 3683 DEFSYM (Qclosure, "closure");
3684 DEFSYM (QCdocumentation, ":documentation");
3671 DEFSYM (Qdebug, "debug"); 3685 DEFSYM (Qdebug, "debug");
3672 3686
3673 DEFVAR_LISP ("inhibit-debugger", Vinhibit_debugger, 3687 DEFVAR_LISP ("inhibit-debugger", Vinhibit_debugger,