all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Calling eldoc-message directly
Date: Wed, 09 May 2018 22:01:38 -0400	[thread overview]
Message-ID: <jwva7t8s2fb.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <2aba18fe-4424-6b08-b5e0-e590c039a4de@gmail.com> ("Clément Pit-Claudel"'s message of "Tue, 8 May 2018 20:57:49 -0400")

> 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



  parent reply	other threads:[~2018-05-10  2:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-05-10  2:43   ` Clément Pit-Claudel

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=jwva7t8s2fb.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=cpitclaudel@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.