all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: James N V Cash <james.cash@occasionallycogent.com>
Cc: bzg@gnu.org, emacs-orgmode@gnu.org
Subject: Re: eldoc recursion error
Date: Thu, 17 Sep 2020 00:55:05 -0400	[thread overview]
Message-ID: <87a6xp80k6.fsf@kyleam.com> (raw)
In-Reply-To: <87imcealr7.fsf@gmail.com>

James N V Cash writes:

> I've attached a patch that addresses the recursion issue with Emacs 28
> and shows eldoc properly with example python. It presumably should act
> the same with older versions of Emacs, although I haven't tested.

Thanks for the patch!  For information about the expected commit message
format, please see <https://orgmode.org/worg/org-contribute.html>.

> diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
> index 3b0999340..ccc23b523 100644
> --- a/contrib/lisp/org-eldoc.el
> +++ b/contrib/lisp/org-eldoc.el
> @@ -116,9 +116,12 @@
>          (when (fboundp mode-func)
>            (with-temp-buffer
>              (funcall mode-func)
> -            (setq doc-func (and eldoc-documentation-function
> -                                (symbol-value 'eldoc-documentation-function)))
> -            (puthash lang doc-func org-eldoc-local-functions-cache))
> +	    (setq doc-func (if (boundp 'eldoc-documentation-functions)
> +			       (car eldoc-documentation-functions)
> +			       (and eldoc-documentation-function
> +				    (symbol-value 'eldoc-documentation-function))))
> +
> +	    (puthash lang doc-func org-eldoc-local-functions-cache))
>            doc-func)
>        cached-func)))

Okay, so when eldoc-documentation-functions is defined (Emacs >=28), we
take the first function and go with it.  That might not be exactly what
you'd see in the native buffer, depending on whether there are other
members of eldoc-documentation-functions and how they interact.  (I'm
being vague, because I don't really know anything about eldoc, but it
seems like that must be the case.)  Anyway, I'd guess it will be good
enough in most cases, and it's certainly better than the recursion
error.

However, the docstring of eldoc-documentation-functions says

    Each hook function is called with at least one argument CALLBACK,
    a function, and decides whether to display a doc short string
    about the context around point.

But downstream in org-eldoc-documentation-function, the function is
called with no arguments:

    (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang)))
         (when (functionp doc-fun) (funcall doc-fun))))

That happens to work with python-eldoc-function, whose signature is
(&rest _ignored), but it may error with other valid eldoc functions.
So, at the very least, I think we should wrap the call in a
condition-case with a wrong-number-of-arguments handler.

Thoughts?


  reply	other threads:[~2020-09-17  4:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 19:22 eldoc recursion error James N V Cash
2020-09-17  4:55 ` Kyle Meyer [this message]
2020-09-17 15:03   ` James N. V. Cash
2020-09-20  4:54     ` Kyle Meyer
2020-09-20 15:35       ` James N. V. Cash
2020-09-20 15:49         ` James N. V. Cash
2020-09-20 23:38           ` Kyle Meyer
2020-09-21  1:07             ` James N. V. Cash
2020-09-21  1:36               ` Kyle Meyer
  -- strict thread matches above, loose matches on Subject: below --
2020-09-08 13:49 Matt Price
2020-09-08 14:24 ` Bastien
2020-09-08 14:49   ` Matt Price
2020-09-08 14:53     ` Bastien
2020-09-08 15:27       ` Matt Price
2020-09-08 16:19         ` Matt Price
2020-09-11  4:12           ` Kyle Meyer
2020-09-21  1:51             ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6xp80k6.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=james.cash@occasionallycogent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.