From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Calling eldoc-message directly Date: Wed, 09 May 2018 22:01:38 -0400 Message-ID: References: <2aba18fe-4424-6b08-b5e0-e590c039a4de@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1525917633 16662 195.159.176.226 (10 May 2018 02:00:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 10 May 2018 02:00:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Emacs developers To: =?windows-1252?Q?Cl=E9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 10 04:00:29 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fGase-0004FW-S5 for ged-emacs-devel@m.gmane.org; Thu, 10 May 2018 04:00:28 +0200 Original-Received: from localhost ([::1]:59750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGaul-0007fW-Pn for ged-emacs-devel@m.gmane.org; Wed, 09 May 2018 22:02:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGatt-0007fG-0n for emacs-devel@gnu.org; Wed, 09 May 2018 22:01:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGatp-0004xD-Pb for emacs-devel@gnu.org; Wed, 09 May 2018 22:01:45 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:50099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGatp-0004wv-KN for emacs-devel@gnu.org; Wed, 09 May 2018 22:01:41 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w4A21cE8010298; Wed, 9 May 2018 22:01:39 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 95EFF661B4; Wed, 9 May 2018 22:01:38 -0400 (EDT) In-Reply-To: <2aba18fe-4424-6b08-b5e0-e590c039a4de@gmail.com> (=?windows-1252?Q?=22Cl=E9ment?= Pit-Claudel"'s message of "Tue, 8 May 2018 20:57:49 -0400") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6282=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6282> : inlines <6622> : streams <1786438> : uri <2639499> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:225183 Archived-At: > 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