From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#41531: 27.0.91; Better handle asynchronous eldoc backends Date: Tue, 02 Jun 2020 22:45:42 -0400 Message-ID: References: <875zckuet9.fsf@gmail.com> <4987863b-d390-5f87-eb1c-2cca4f4b7262@yandex.ru> <87blmbrlda.fsf@gmail.com> <87pnaqrae9.fsf@gmail.com> <877dwyr7b9.fsf@gmail.com> <871rn6r0pr.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="96703"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Christopher Wellons , Dmitry Gutov , andreyk.mad@gmail.com, 41531@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 03 04:46:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgJPt-000P3R-I8 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Jun 2020 04:46:09 +0200 Original-Received: from localhost ([::1]:35366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgJPs-0006Hy-7R for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jun 2020 22:46:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgJPm-0006Hp-Fa for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 22:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58230) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgJPm-0002NW-6l for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 22:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jgJPm-0008TU-4R for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 22:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Jun 2020 02:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41531 X-GNU-PR-Package: emacs Original-Received: via spool by 41531-submit@debbugs.gnu.org id=B41531.159115235332559 (code B ref 41531); Wed, 03 Jun 2020 02:46:02 +0000 Original-Received: (at 41531) by debbugs.gnu.org; 3 Jun 2020 02:45:53 +0000 Original-Received: from localhost ([127.0.0.1]:41543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgJPc-0008T5-NM for submit@debbugs.gnu.org; Tue, 02 Jun 2020 22:45:52 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64798) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgJPa-0008Sr-H6 for 41531@debbugs.gnu.org; Tue, 02 Jun 2020 22:45:51 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CF62E10050D; Tue, 2 Jun 2020 22:45:44 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1C3A51001CB; Tue, 2 Jun 2020 22:45:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1591152343; bh=tRAT4wE/oz9Jtp50xzy2iH1Ts+ixAfEdB++6xP6C/BA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=DYDnGwGme8tfoS01TspSPm+HuQDevgPDdrvMS1IYF2/9PjMJ6XjO66rd6bRrs0n0g DdZgp+I2hK7rYXG/I6mzSLV+USWlz5W+bAAZgggz1lBnMD+5cgroRwC3HVmDFle+46 IlJqgEiNF86nASphjeBUCGkLw5iYJZBmb+6hZtY72WbUpqanvXnogl2kl6emxDwV7U kuiolMGyuEuJGoLode2LXOnWt04JvWWN/MOsv+vVgIhGnMwU7Gmw2rxOq3ifvzqwiz nAPPY/oBD9cEamuWQ9LRfdGiE15pzz3GZr8qE1dM2Y50YVmCJiIwgvT1d4X9V2cZ/r TZXZ7S6IYgA9A== Original-Received: from alfajor (76-10-137-254.dsl.teksavvy.com [76.10.137.254]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A6CEB120328; Tue, 2 Jun 2020 22:45:42 -0400 (EDT) In-Reply-To: <871rn6r0pr.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Tue, 26 May 2020 19:49:04 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:181441 Archived-At: > --- a/lisp/emacs-lisp/eldoc.el > +++ b/lisp/emacs-lisp/eldoc.el > @@ -337,18 +337,32 @@ eldoc-display-message-no-interference-p > (not (or executing-kbd-macro (bound-and-true-p edebug-active)))) > > > +;;;; Futuristic interlude > +(cl-defstruct (eldoc-future > + (:conc-name eldoc-future--) > + (:constructor eldoc-future-make ())) ; become Yoda we? > + "" "Future object." > + (value 'eldoc-future--unset) > + callback) > + > +(defun eldoc-future-set (f v) > + "" > + (cl-assert (eq (eldoc-future--value f) 'eldoc-future--unset)) > + (setf (eldoc-future--value f) v) > + (when (eldoc-future--callback f) > + (funcall (eldoc-future--callback f) v))) > + > +(defun eldoc-future-set-callback (f c) > + "" > + (cl-assert (null (eldoc-future--callback f))) > + (setf (eldoc-future--callback f) c) > + (unless (eq (eldoc-future--value f) 'eldoc-future--unset) > + (funcall c (eldoc-future--value f)))) > + > + > (defvar eldoc-documentation-functions nil > "Hook of functions that produce doc strings. > -Each hook function should accept at least one argument CALLBACK > -and decide whether to display a doc short string about the > -context around point. If the decision and the doc string can be > -produced quickly, the hook function can ignore CALLBACK and > -immediately return the doc string, or nil if there's no doc > -appropriate for the context. Otherwise, if its computation is > -expensive or can't be performed directly, the hook function > -should arrange for CALLBACK to be asynchronously called at a > -later time, passing it either nil or the desired doc string. The > -hook function should then return a non-nil, non-string value. > + "Special hook run to get the documentation string at point. Each function is called with no argument and should return either nil or an `eldoc-future` object that should have its `value` set as soon as possible via `eldoc-future-set-value` (it can be set before returning the future or at a later time). This value should be a string, typically occupying only a single line. In case the function ends up finding no information it is allowed not to `eldoc-future-set-value` at all." > + (let ((x (run-hook-with-args-until-success 'eldoc-documentation-functions))) > + (if (eldoc-future-p x) (eldoc-future-set-callback x eldoc--callback) > + x))) I'd simplify this to: (let ((x (run-hook-with-args-until-success 'eldoc-documentation-functions))) (when x (eldoc-future-set-callback x eldoc--callback))) But I'd expect that there would be no `eldoc--callback` and that it's each `eldoc-documentation-function` which chooses its own callback rather than being chosen by their caller. Stefan