From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 2GiOHKfgZl/RawAA0tVLHw (envelope-from ) for ; Sun, 20 Sep 2020 04:55:03 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id WLFRGKfgZl+EHQAAbx9fmQ (envelope-from ) for ; Sun, 20 Sep 2020 04:55:03 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7856C940238 for ; Sun, 20 Sep 2020 04:55:02 +0000 (UTC) Received: from localhost ([::1]:51146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJrNN-0007hw-EL for larch@yhetil.org; Sun, 20 Sep 2020 00:55:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJrN0-0007hn-9X for emacs-orgmode@gnu.org; Sun, 20 Sep 2020 00:54:38 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:62538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJrMx-00085t-Dq; Sun, 20 Sep 2020 00:54:37 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id EABD48002D; Sun, 20 Sep 2020 00:54:32 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:date:message-id:mime-version:content-type; s=sasl; bh=rmEBkGNttAGDVUE5Y/x4ctV6M9w=; b=xKtiUzb54MAdGNnry6zv +y65N3zfzz2+LUTPJ9ux3b+qA9W6YQh0qOOr67Ap1ux/5mmzV/VCf80aCXnLk7s+ FcVmjniDbkggmyOrqoihpQNCygxi5Cc6/5SRSv67sXR3ifRT81dm4dyTbkjYtRyX 6Y4sG1NtByQDKldM0X+ALzU= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id E24758002C; Sun, 20 Sep 2020 00:54:32 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:date:message-id:mime-version:content-type; s=mesmtp; bh=q9J1uysAS1Rp6cjV1gp8u8TEIvOj9L9hqfRct61A6R0=; b=duTbKGvhkkG1Q1lN+VZ88Onn2B5YSgBu5d9C3veYGNOFQkJTqqOcYagD55sgMozAdAHcP/Y7NNxtFzyfAc5YNVEYyw0NhdVCK5MalbAMwooDKqUMFe6XozpWmeseJisYXI9bVa1ZGlNtqKz5I2ibjEzbcrr2L5gmemKZHGi4afI= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 0D8028002B; Sun, 20 Sep 2020 00:54:32 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: "James N. V. Cash" Subject: Re: eldoc recursion error In-Reply-To: <878sd88mz4.fsf@gmail.com> Date: Sun, 20 Sep 2020 00:54:31 -0400 Message-ID: <87tuvtvyig.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 5F4C137A-FAFD-11EA-ADE6-2F5D23BA3BAF-24757444!pb-smtp2.pobox.com Received-SPF: pass client-ip=64.147.108.71; envelope-from=kyle@kyleam.com; helo=pb-smtp2.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 00:54:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bzg@gnu.org, emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=pobox.com header.s=sasl header.b=xKtiUzb5; dkim=fail (rsa verify failed) header.d=kyleam.com header.s=mesmtp header.b=duTbKGvh; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.01 X-TUID: p4TcG0CG6k5u James N. V. Cash writes: > Kyle Meyer writes: >> Okay, so when eldoc-documentation-functions is defined (Emacs >=28), we >> take the first function and go with it. That might not be exactly what >> you'd see in the native buffer, depending on whether there are other >> members of eldoc-documentation-functions and how they interact. (I'm >> being vague, because I don't really know anything about eldoc, but it >> seems like that must be the case.) Anyway, I'd guess it will be good >> enough in most cases, and it's certainly better than the recursion >> error. > > Ah yes, very true. I've attached another patch, which tries to better > preserve how the new eldoc strategy works, by passing through the > callback to the mode-local eldoc function if available, which will be a > closure over the configured documentation strategy with > eldoc-documentation-functions bound to the appropriate mode-local value. Thanks, sounds good. > Subject: [PATCH] Address org-eldoc-recursion issue [...] > @@ -116,8 +116,13 @@ > (when (fboundp mode-func) > (with-temp-buffer > (funcall mode-func) > - (setq doc-func (and eldoc-documentation-function > - (symbol-value 'eldoc-documentation-function))) > + (setq doc-func (if (boundp 'eldoc-documentation-functions) > + (lexical-let ((doc-funs (symbol-value 'eldoc-documentation-functions))) Using lexical-let here is problematic because it's obsolete since Emacs 24. Taking a quick glance, I don't see any issues with switching this file over to lexical binding by adding " -*- lexical-binding: t; -*-" to the first line. Also, why use (doc-funs (symbol-value 'eldoc-documentation-functions)) rather than (doc-funs eldoc-documentation-functions) ? > + (lambda () > + (let ((eldoc-documentation-functions doc-funs)) > + (funcall eldoc-documentation-strategy)))) > + (and eldoc-documentation-function > + (symbol-value 'eldoc-documentation-function)))) nit: Please switch this to the Elisp style of indenting the `else' arm less than the `then' arm. > (puthash lang doc-func org-eldoc-local-functions-cache)) > doc-func) > cached-func))) > @@ -127,7 +132,7 @@ > (declare-function php-eldoc-function "php-eldoc" ()) > (declare-function go-eldoc--documentation-function "go-eldoc" ()) > > -(defun org-eldoc-documentation-function (&rest _ignored) > +(defun org-eldoc-documentation-function (&optional callback) Perhaps even with the callback parameter the &rest should stay around. The docstring of eldoc-documentation-functions makes me nervous because it says "each hook function is called with _at least_ one argument" (my emphasis). > "Return breadcrumbs when on a headline, args for src block header-line, > calls other documentation functions depending on lang when inside src body." > (or > @@ -161,7 +166,12 @@ > (string= lang "golang")) (when (require 'go-eldoc nil t) > (go-eldoc--documentation-function))) > (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))) > - (when (functionp doc-fun) (funcall doc-fun)))))))) > + (when (functionp doc-fun) > + (if (functionp callback) > + (condition-case nil > + (funcall doc-fun callback) > + (wrong-number-of-arguments (funcall doc-fun))) > + (funcall doc-fun))))))))) Hmm, I think the more complete approach you put together for org-eldoc-get-mode-local-documentation-function, along with your change to consider the callback parameter here, means we don't need to bother with the condition-case/wrong-number-of-arguments dance. The callback alone should be a reliable indication we're on Emacs 28, in which case we can expect the function to accept a callback argument (even if they ignore it like python-eldoc-function does). Thanks again for working on this.