* Calling eldoc-message directly
@ 2018-05-09 0:57 Clément Pit-Claudel
2018-05-09 17:26 ` João Távora
2018-05-10 2:01 ` Stefan Monnier
0 siblings, 2 replies; 4+ messages in thread
From: Clément Pit-Claudel @ 2018-05-09 0:57 UTC (permalink / raw)
To: Emacs developers
Hi emacs-devel,
The changelog for Emacs 27.1 says "For ElDoc support, you should set 'eldoc-documentation-function' instead of calling 'eldoc-message' directly".
At least one of my packages calls eldoc-message directly, and I'm not sure how to get rid of it.
In that package, I use a server process to get information about the current buffer. I can use it to asynchronously retrieve documentation about identifiers, among other things. This pattern seems pretty common (I think that's how tide, elpy, cider, and multiple other modes work).
I currently have an eldoc-documentation-function that sends an asynchronous query, waits for a few milliseconds in the hope to get a quick answer, and otherwise registers a callback that calls eldoc-message directly. That callback checks that the buffer hasn't been modified and that the point hasn't moved, and if so calls eldoc-message.
Can someone recommend a proper implementation, not based on eldoc-message? (I have vague recollections of a related thread on emacs-devel, but I can't seem to find it)
Thanks,
Clément.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling eldoc-message directly
2018-05-09 0:57 Calling eldoc-message directly Clément Pit-Claudel
@ 2018-05-09 17:26 ` João Távora
2018-05-10 2:01 ` Stefan Monnier
1 sibling, 0 replies; 4+ messages in thread
From: João Távora @ 2018-05-09 17:26 UTC (permalink / raw)
To: Clément Pit-Claudel; +Cc: Emacs developers
Clément Pit-Claudel <cpitclaudel@gmail.com> writes:
> Hi emacs-devel,
>
> The changelog for Emacs 27.1 says "For ElDoc support, you should set
> 'eldoc-documentation-function' instead of calling 'eldoc-message'
> directly".
>
> At least one of my packages calls eldoc-message directly, and I'm not
> sure how to get rid of it.
I'm quite interested in a solution to this one, too.
This thread where Dmitry is suggesting something to this effect might
be relevant:
https://github.com/slime/slime/issues/400#issuecomment-329616259
João
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling eldoc-message directly
2018-05-09 0:57 Calling eldoc-message directly Clément Pit-Claudel
2018-05-09 17:26 ` João Távora
@ 2018-05-10 2:01 ` Stefan Monnier
2018-05-10 2:43 ` Clément Pit-Claudel
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2018-05-10 2:01 UTC (permalink / raw)
To: Clément Pit-Claudel; +Cc: Emacs developers
> In that package, I use a server process to get information about the current
> buffer. I can use it to asynchronously retrieve documentation about
> identifiers, among other things. This pattern seems pretty common (I think
> that's how tide, elpy, cider, and multiple other modes work).
Indeed async use is currently not supported.
Not sure how to best add support for sync-processing.
Ideally, we'd pass a "continuation" to the eldoc-documentation-function,
but that would break existing functions which wouldn't expect that extra arg.
We could pass that extra arg via a dynamically-scoped variable like
`eldoc-continuation-function`.
An alternative would be to allow eldoc-documentation-function to return
a function, which is then called with the continuation.
So you'd do something like
(defun my-eldoc-documentation-function (orig-fun)
(if (not (my-determine-if-we-should-be-in-charge))
(funcall orig-fun)
(lambda (k)
(let ((p (start-process ...)))
(set-process-sentinel p
(lambda (_p status)
(funcall k (my-get-doc-string))))))))
[...]
(add-function :around (local 'eldoc-documentation-function)
#'my-eldoc-documentation-function)
-- Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling eldoc-message directly
2018-05-10 2:01 ` Stefan Monnier
@ 2018-05-10 2:43 ` Clément Pit-Claudel
0 siblings, 0 replies; 4+ messages in thread
From: Clément Pit-Claudel @ 2018-05-10 2:43 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs developers
On 2018-05-09 22:01, Stefan Monnier wrote:
>> In that package, I use a server process to get information about the current
>> buffer. I can use it to asynchronously retrieve documentation about
>> identifiers, among other things. This pattern seems pretty common (I think
>> that's how tide, elpy, cider, and multiple other modes work).
>
> Indeed async use is currently not supported.
>
> Not sure how to best add support for sync-processing.
> Ideally, we'd pass a "continuation" to the eldoc-documentation-function,
> but that would break existing functions which wouldn't expect that extra arg.
>
> We could pass that extra arg via a dynamically-scoped variable like
> `eldoc-continuation-function`.
>
> An alternative would be to allow eldoc-documentation-function to return
> a function, which is then called with the continuation.
That would be nice. This model works pretty well in company-mode.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-05-10 2:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-09 0:57 Calling eldoc-message directly Clément Pit-Claudel
2018-05-09 17:26 ` João Távora
2018-05-10 2:01 ` Stefan Monnier
2018-05-10 2:43 ` Clément Pit-Claudel
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).