aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2023-01-13 17:56:04 -0500
committerStefan Monnier2023-01-13 17:56:04 -0500
commitf5d8aa6edacc8f4d06bb78010e408034b83f98e0 (patch)
tree8d3431fcbbca2820f264b64e7292114d41fb9f11 /src
parentf56fea2fcc0a3fbb261628ad887a0bbee72820e3 (diff)
downloademacs-f5d8aa6edacc8f4d06bb78010e408034b83f98e0.tar.gz
emacs-f5d8aa6edacc8f4d06bb78010e408034b83f98e0.zip
(function-documentation): Make it work for the remaining cases
* lisp/simple.el (function-documentation): Use `internal-subr-documentation` and make it work also with symbols and macros. * src/doc.c (Fsubr_documentation): New function, extracted from Fdocumentation. (syms_of_doc): defsubr it. (Fdocumentation): Don't handle subrs and module functions here.
Diffstat (limited to 'src')
-rw-r--r--src/doc.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/doc.c b/src/doc.c
index df57f84603e..174341523d7 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -330,19 +330,7 @@ string is passed through `substitute-command-keys'. */)
330 xsignal1 (Qvoid_function, function); 330 xsignal1 (Qvoid_function, function);
331 if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) 331 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
332 fun = XCDR (fun); 332 fun = XCDR (fun);
333#ifdef HAVE_NATIVE_COMP 333 doc = call1 (Qfunction_documentation, fun);
334 if (!NILP (Fsubr_native_elisp_p (fun)))
335 doc = native_function_doc (fun);
336 else
337#endif
338 if (SUBRP (fun))
339 doc = make_fixnum (XSUBR (fun)->doc);
340#ifdef HAVE_MODULES
341 else if (MODULE_FUNCTIONP (fun))
342 doc = module_function_documentation (XMODULE_FUNCTION (fun));
343#endif
344 else
345 doc = call1 (Qfunction_documentation, fun);
346 334
347 /* If DOC is 0, it's typically because of a dumped file missing 335 /* If DOC is 0, it's typically because of a dumped file missing
348 from the DOC file (bug in src/Makefile.in). */ 336 from the DOC file (bug in src/Makefile.in). */
@@ -371,6 +359,25 @@ string is passed through `substitute-command-keys'. */)
371 return doc; 359 return doc;
372} 360}
373 361
362DEFUN ("internal-subr-documentation", Fsubr_documentation, Ssubr_documentation, 1, 1, 0,
363 doc: /* Return the raw documentation info of a C primitive. */)
364 (Lisp_Object function)
365{
366#ifdef HAVE_NATIVE_COMP
367 if (!NILP (Fsubr_native_elisp_p (function)))
368 return native_function_doc (function);
369 else
370#endif
371 if (SUBRP (function))
372 return make_fixnum (XSUBR (function)->doc);
373#ifdef HAVE_MODULES
374 else if (MODULE_FUNCTIONP (function))
375 return module_function_documentation (XMODULE_FUNCTION (function));
376#endif
377 else
378 return Qt;
379}
380
374DEFUN ("documentation-property", Fdocumentation_property, 381DEFUN ("documentation-property", Fdocumentation_property,
375 Sdocumentation_property, 2, 3, 0, 382 Sdocumentation_property, 2, 3, 0,
376 doc: /* Return the documentation string that is SYMBOL's PROP property. 383 doc: /* Return the documentation string that is SYMBOL's PROP property.
@@ -713,6 +720,7 @@ compute the correct value for the current terminal in the nil case. */);
713 /* Initialized by ‘main’. */ 720 /* Initialized by ‘main’. */
714 721
715 defsubr (&Sdocumentation); 722 defsubr (&Sdocumentation);
723 defsubr (&Ssubr_documentation);
716 defsubr (&Sdocumentation_property); 724 defsubr (&Sdocumentation_property);
717 defsubr (&Ssnarf_documentation); 725 defsubr (&Ssnarf_documentation);
718 defsubr (&Stext_quoting_style); 726 defsubr (&Stext_quoting_style);