diff src/symbols.c @ 5789:72c5d36ba3b6

Make `define-function' accept docstring, as in GNU Emacs. 2014-01-27 Michael Sperber <mike@xemacs.org> * symbols.c (Fdefine_function): Allow optional `docstring' argument, as in GNU Emacs. * lisp.h (Qfunction_documentation): Add extern declaration. * doc.c (Fdocumentation_property): Move before its use. (Fdocumentation): Retrieve documentation from `define-function' docstring for symbols.
author Mike Sperber <sperber@deinprogramm.de>
date Mon, 27 Jan 2014 17:50:57 +0100
parents 2014ff433daf
children
line wrap: on
line diff
--- a/src/symbols.c	Mon Jan 27 17:45:03 2014 +0100
+++ b/src/symbols.c	Mon Jan 27 17:50:57 2014 +0100
@@ -749,14 +749,14 @@
 }
 
 /* FSFmacs */
-DEFUN ("define-function", Fdefine_function, 2, 2, 0, /*
+DEFUN ("define-function", Fdefine_function, 2, 3, 0, /*
 Set SYMBOL's function definition to NEWDEF, and return NEWDEF.
 Associates the function with the current load file, if any.
 If NEWDEF is a compiled-function object, stores the function name in
 the `annotated' slot of the compiled-function (retrievable using
 `compiled-function-annotation').
 */
-       (symbol, newdef))
+       (symbol, newdef, docstring))
 {
   /* This function can GC */
   Ffset (symbol, newdef);
@@ -765,6 +765,10 @@
   if (COMPILED_FUNCTIONP (newdef))
     XCOMPILED_FUNCTION (newdef)->annotated = symbol;
 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */
+
+  if (!NILP (docstring))
+    Fput (symbol, Qfunction_documentation, docstring);
+
   return newdef;
 }