emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: "James N. V. Cash" <james.nvc@gmail.com>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>, emacs-orgmode@gnu.org
Subject: [PATCH] org-eldoc: Fix compatibility with Emacs 28
Date: Fri, 17 Jul 2020 01:41:17 -0400	[thread overview]
Message-ID: <874kq6g0le.fsf@kyleam.com> (raw)
In-Reply-To: <87d04vjzp4.fsf@gmail.com>

James N. V. Cash writes:

> Kyle Meyer <kyle@kyleam.com> writes:
>
>> Basil L. Contovounesios writes:
>>> How involved would it be to make org-eldoc work in
>>> non-"backwards-compatibility" mode?
>>
>> I think we can do that, while still supporting Org's minimum Emacs
>> version, by following python.el.  Here's what it does:
>> ...
>>
>> ... org-eldoc-documentation-function's signature could be changed to
>> (&rest _ignored), like python-eldoc-function's.
>
> This makes the most sense to me; I missed that the default documentation
> strategy also allows the function to ignore the callback & just return a
> docstring directly.

All right, thanks.  Here's that in patch form.  I briefly tested with
Emacs 26, 27, and 28, and things seemed to work fine (though I'm not an
org-eldoc user).

I'll plan to apply it in a day or two unless there are objections.

-- >8 --
Subject: [PATCH] org-eldoc: Fix compatibility with Emacs 28

* contrib/lisp/org-eldoc.el (org-eldoc-documentation-function): Accept
and ignore additional arguments for compatibility with Emacs 28.
(org-eldoc-load): Use add-function to register
org-eldoc-documentation-function for Emacs versions 25 through 27, as
documented in eldoc-documentation-function.

See Emacs's fd020a2931 (eldoc: modify `eldoc-documentation-function'
using `add-function', 2014-12-05) and c0fcbd2c11 (Expose ElDoc
functions in a hook (Bug#28257), 2020-02-25) for more information on
the Emacs 25 and Emacs 28 changes, respectively.
---
 contrib/lisp/org-eldoc.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 72b10a1fb..b89eb0918 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -127,7 +127,7 @@ (declare-function css-eldoc-function "css-eldoc" ())
 (declare-function php-eldoc-function "php-eldoc" ())
 (declare-function go-eldoc--documentation-function "go-eldoc" ())
 
-(defun org-eldoc-documentation-function ()
+(defun org-eldoc-documentation-function (&rest _ignored)
   "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,11 +161,17 @@ (defun org-eldoc-documentation-function ()
 (defun org-eldoc-load ()
   "Set up org-eldoc documentation function."
   (interactive)
-  (if (boundp 'eldoc-documentation-functions)
-      (add-hook 'eldoc-documentation-functions
-		#'org-eldoc-documentation-function nil t)
-    (setq-local eldoc-documentation-function
-		#'org-eldoc-documentation-function)))
+  ;; This approach is taken from python.el.
+  (with-no-warnings
+    (if (null eldoc-documentation-function)
+	;; Emacs<25
+	(setq-local eldoc-documentation-function
+		    #'org-eldoc-documentation-function)
+      (if (boundp 'eldoc-documentation-functions)
+	  (add-hook 'eldoc-documentation-functions
+		    #'org-eldoc-documentation-function nil t)
+	(add-function :before-until (local 'eldoc-documentation-function)
+		      #'org-eldoc-documentation-function)))))
 
 ;;;###autoload
 (add-hook 'org-mode-hook #'org-eldoc-load)

base-commit: e62ca4a1bf576a2c498f47536d3f12cd698e3ac0
-- 
2.27.0



  reply	other threads:[~2020-07-17  5:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10 16:22 [PATCH] Make org-eldoc work " James N. V. Cash
2020-07-13 16:23 ` Nicolas Goaziou
     [not found]   ` <87zh83l66q.fsf@gmail.com>
2020-07-13 16:41     ` James N. V. Cash
2020-07-16  1:20 ` Basil L. Contovounesios
2020-07-16  4:29   ` Kyle Meyer
2020-07-16 14:34     ` James N. V. Cash
2020-07-17  5:41       ` Kyle Meyer [this message]
2020-07-17 10:12         ` [PATCH] org-eldoc: Fix compatibility " Basil L. Contovounesios
2020-07-17 16:13           ` Eric Abrahamsen
2020-07-17 22:11           ` Kyle Meyer
2020-07-17 11:24         ` Joseph Mingrone
2020-07-19  0:20           ` Kyle Meyer

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874kq6g0le.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=contovob@tcd.ie \
    --cc=emacs-orgmode@gnu.org \
    --cc=james.nvc@gmail.com \
    --subject='Re: [PATCH] org-eldoc: Fix compatibility with Emacs 28' \
    /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

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).