From 57618ecf3358e49ab3c380330e82ca8d2078cc63 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 8 Nov 2012 23:10:16 -0500 Subject: New property dynamic-docstring-function for docstrings. * src/doc.c (Fdocumentation): Handle new property dynamic-docstring-function to replace the old ad-advice-info. * lisp/emacs-lisp/advice.el: Use new dynamic docstrings. (ad-make-advised-definition-docstring, ad-advised-definition-p): Use dynamic-docstring-function instead of ad-advice-info. (ad--make-advised-docstring): New function extracted from ad-make-advised-docstring. (ad-make-advised-docstring): Use it. * lisp/progmodes/sql.el (sql--make-help-docstring): New function, extracted from sql-help. (sql-help): Use it with dynamic-docstring-function. --- src/ChangeLog | 5 +++++ src/doc.c | 35 ++++++++++++++++------------------- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 42c63b21e95..9bd6ccec017 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-11-09 Stefan Monnier + + * doc.c (Fdocumentation): Handle new property + dynamic-docstring-function to replace the old ad-advice-info. + 2012-11-09 Paul Eggert * fns.c (Qeql, hashtest_eq): Now static. diff --git a/src/doc.c b/src/doc.c index 9ead1addfba..1d3d1e64442 100644 --- a/src/doc.c +++ b/src/doc.c @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see . */ #include #include -#include /* Must be after sys/types.h for USG*/ +#include /* Must be after sys/types.h for USG. */ #include #include @@ -42,7 +42,7 @@ static ptrdiff_t get_doc_string_buffer_size; static unsigned char *read_bytecode_pointer; -/* readchar in lread.c calls back here to fetch the next byte. +/* `readchar' in lread.c calls back here to fetch the next byte. If UNREADFLAG is 1, we unread a byte. */ int @@ -338,15 +338,9 @@ string is passed through `substitute-command-keys'. */) doc = Qnil; - if (SYMBOLP (function)) - { - Lisp_Object tem = Fget (function, Qfunction_documentation); - if (!NILP (tem)) - return Fdocumentation_property (function, Qfunction_documentation, - raw); - } - fun = Findirect_function (function, Qnil); + if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) + fun = XCDR (fun); if (SUBRP (fun)) { if (XSUBR (fun)->doc == 0) @@ -400,8 +394,6 @@ string is passed through `substitute-command-keys'. */) else return Qnil; } - else if (EQ (funcar, Qmacro)) - return Fdocumentation (Fcdr (fun), raw); else goto oops; } @@ -411,16 +403,19 @@ string is passed through `substitute-command-keys'. */) xsignal1 (Qinvalid_function, fun); } - /* Check for an advised function. Its doc string - has an `ad-advice-info' text property. */ + /* Check for a dynamic docstring. These come with + a dynamic-docstring-function text property. */ if (STRINGP (doc)) { - Lisp_Object innerfunc; - innerfunc = Fget_text_property (make_number (0), - intern ("ad-advice-info"), + Lisp_Object func + = Fget_text_property (make_number (0), + intern ("dynamic-docstring-function"), doc); - if (! NILP (innerfunc)) - doc = call1 (intern ("ad-make-advised-docstring"), innerfunc); + if (!NILP (func)) + /* Pass both `doc' and `function' since `function' can be needed, and + finding `doc' can be annoying: calling `documentation' is not an + option because it would infloop. */ + doc = call2 (func, doc, function); } /* If DOC is 0, it's typically because of a dumped file missing @@ -528,6 +523,8 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset) { tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTEGERP (XCAR (tem))) + /* FIXME: This modifies typically pure hash-cons'd data, so its + correctness is quite delicate. */ XSETCAR (tem, make_number (offset)); } else if (EQ (tem, Qmacro)) -- cgit v1.2.1