[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling eldoc-message directly
From: |
Stefan Monnier |
Subject: |
Re: Calling eldoc-message directly |
Date: |
Wed, 09 May 2018 22:01:38 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> 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