Subject: Re: bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 26 Jun 2019 16:27:03 +0200

Stefan Monnier <[email-masked]> writes:

>> Incidentally, I wondered whether this would be better addressed
>> within `documentation-property' itself
>
> Yes, it should be fixed there directly.
>
>> but I wasn't sure it would be correct to preclude the possibility of
>> unique docstrings between aliases and their targets.
>
> documentation-property should simply first check variable-documentation
> and only when that fails, follow the alias indirection.

I've now implemented this like what's below, and I hope that's what you
meant.  :-)

diff --git a/src/doc.c b/src/doc.c
index 3fa0eaac20..bc05d09df4 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -436,8 +436,20 @@ DEFUN ("documentation-property", Fdocumentation_property,
  documentation_property:
 
   tem = Fget (symbol, prop);
+
+  /* If we don't have any documentation for this symbol, try to see whether
+     it's an indirect variable and get the documentation from there instead. */
+  if (NILP (tem))
+    {
+      Lisp_Object indirect = Findirect_variable (symbol);
+      if (!NILP (indirect))
+	tem = Fget (indirect, prop);
+    }
+
   if (EQ (tem, make_fixnum (0)))
     tem = Qnil;
+
+  /* See if we want to look for the string in the DOC file. */
   if (FIXNUMP (tem) || (CONSP (tem) && FIXNUMP (XCDR (tem))))
     {
       Lisp_Object doc = tem;

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no