(displayed_window_lines): Take empty lines at
[bpt/emacs.git] / src / doc.c
index 6aa79dc..e875190 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -43,6 +43,8 @@ Boston, MA 02111-1307, USA.  */
 
 Lisp_Object Vdoc_file_name, Vhelp_manyarg_func_alist;
 
+Lisp_Object Qfunction_documentation;
+
 extern char *index ();
 
 extern Lisp_Object Voverriding_local_map;
@@ -309,12 +311,17 @@ string is passed through `substitute-command-keys'.")
   Lisp_Object funcar;
   Lisp_Object tem, doc;
 
+  if (SYMBOLP (function)
+      && (tem = Fget (function, Qfunction_documentation),
+         !NILP (tem)))
+    return Fdocumentation_property (function, Qfunction_documentation, raw);
+  
   fun = Findirect_function (function);
-
   if (SUBRP (fun))
     {
-      if (XSUBR (fun)->doc == 0) return Qnil;
-      if ((EMACS_INT) XSUBR (fun)->doc >= 0)
+      if (XSUBR (fun)->doc == 0)
+       return Qnil;
+      else if ((EMACS_INT) XSUBR (fun)->doc >= 0)
        doc = build_string (XSUBR (fun)->doc);
       else
        doc = get_doc_string (make_number (- (EMACS_INT) XSUBR (fun)->doc),
@@ -379,12 +386,15 @@ string is passed through `substitute-command-keys'.")
   return doc;
 }
 
-DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 3, 0,
+DEFUN ("documentation-property", Fdocumentation_property,
+       Sdocumentation_property, 2, 3, 0,
   "Return the documentation string that is SYMBOL's PROP property.\n\
-This is like `get', but it can refer to strings stored in the\n\
-`etc/DOC' file; and if the value is a string, it is passed through\n\
-`substitute-command-keys'.  A non-nil third argument RAW avoids this\n\
-translation.")
+Third argument RAW omitted or nil means pass the result through\n\
+`substitute-command-keys' if it is a string.\n\
+\n\
+This is differs from `get' in that it can refer to strings stored in the\n\
+`etc/DOC' file; and that it evaluates documentation properties that\n\
+aren't strings.")
   (symbol, prop, raw)
      Lisp_Object symbol, prop, raw;
 {
@@ -393,8 +403,12 @@ translation.")
   tem = Fget (symbol, prop);
   if (INTEGERP (tem))
     tem = get_doc_string (XINT (tem) > 0 ? tem : make_number (- XINT (tem)), 0, 0);
-  else if (CONSP (tem))
+  else if (CONSP (tem) && INTEGERP (XCDR (tem)))
     tem = get_doc_string (tem, 0, 0);
+  else if (!STRINGP (tem))
+    /* Feval protects its argument.  */
+    tem = Feval (tem);
+  
   if (NILP (raw) && STRINGP (tem))
     tem = Fsubstitute_command_keys (tem);
   return tem;
@@ -780,6 +794,9 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int
 void
 syms_of_doc ()
 {
+  Qfunction_documentation = intern ("function-documentation");
+  staticpro (&Qfunction_documentation);
+  
   DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name,
     "Name of file containing documentation strings of built-in symbols.");
   Vdoc_file_name = Qnil;