* bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases
@ 2014-04-03 16:40 Josh
2014-04-03 17:37 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Josh @ 2014-04-03 16:40 UTC (permalink / raw)
To: 17180
[-- Attachment #1: Type: text/plain, Size: 2115 bytes --]
I noticed that eldoc doesn't currently show docstrings for variable
aliases such as `inhibit-splash-screen'. The attached patch against
the eldoc.el in trunk fixes the behavior and also cleans up the
surrounding code a bit. If the latter is objectionable, the only
functional change is passing `sym' through `indirect-variable' on the
way to `documentation-property' as `describe-variable' does.
Incidentally, I wondered whether this would be better addressed
within `documentation-property' itself but I wasn't sure it would be
correct to preclude the possibility of unique docstrings between
aliases and their targets.
=== modified file 'lisp/emacs-lisp/eldoc.el'
--- lisp/emacs-lisp/eldoc.el 2014-03-31 01:31:17 +0000
+++ lisp/emacs-lisp/eldoc.el 2014-04-03 16:14:43 +0000
@@ -418,18 +418,19 @@
;; Return a string containing a brief (one-line) documentation string for
;; the variable.
(defun eldoc-get-var-docstring (sym)
- (when sym
- (cond ((and (eq sym (aref eldoc-last-data 0))
- (eq 'variable (aref eldoc-last-data 2)))
- (aref eldoc-last-data 1))
- (t
- (let ((doc (documentation-property sym 'variable-documentation
t)))
- (cond (doc
- (setq doc (eldoc-docstring-format-sym-doc
- sym (eldoc-docstring-first-line doc)
- 'font-lock-variable-name-face))
- (eldoc-last-data-store sym doc 'variable)))
- doc)))))
+ (if (and (eq sym (aref eldoc-last-data 0))
+ (eq 'variable (aref eldoc-last-data 2)))
+ (aref eldoc-last-data 1)
+ (let ((doc
+ (documentation-property (indirect-variable sym)
+ 'variable-documentation t)))
+ (when doc
+ (setq doc
+ (eldoc-docstring-format-sym-doc sym
+ (eldoc-docstring-first-line
doc)
+
'font-lock-variable-name-face))
+ (eldoc-last-data-store sym doc 'variable))
+ doc)))
(defun eldoc-last-data-store (symbol doc type)
(aset eldoc-last-data 0 symbol)
[-- Attachment #2: Type: text/html, Size: 2444 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases
2014-04-03 16:40 bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases Josh
@ 2014-04-03 17:37 ` Stefan Monnier
2019-06-26 14:27 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2014-04-03 17:37 UTC (permalink / raw)
To: Josh; +Cc: 17180
> 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.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases
2014-04-03 17:37 ` Stefan Monnier
@ 2019-06-26 14:27 ` Lars Ingebrigtsen
2019-06-26 14:35 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-26 14:27 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Josh, 17180
Stefan Monnier <monnier@IRO.UMontreal.CA> 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases
2019-06-26 14:27 ` Lars Ingebrigtsen
@ 2019-06-26 14:35 ` Stefan Monnier
2019-06-26 14:37 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2019-06-26 14:35 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Josh, 17180
> + /* 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);
> + }
In theory documentation-property can be used for any property, so it's
not necessarily specific to variables. IOW I think we should only do
that if `prop` is `variable-documentation`.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases
2019-06-26 14:35 ` Stefan Monnier
@ 2019-06-26 14:37 ` Lars Ingebrigtsen
0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-26 14:37 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Josh, 17180
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> + /* 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);
>> + }
>
> In theory documentation-property can be used for any property, so it's
> not necessarily specific to variables. IOW I think we should only do
> that if `prop` is `variable-documentation`.
Ah, makes sense. I'll fix that up...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-26 14:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-03 16:40 bug#17180: [PATCH] eldoc doesn't find docstrings for variable aliases Josh
2014-04-03 17:37 ` Stefan Monnier
2019-06-26 14:27 ` Lars Ingebrigtsen
2019-06-26 14:35 ` Stefan Monnier
2019-06-26 14:37 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.