Re: tags-todo agenda shoud not ignore DONE items

2020-09-15 Thread James N V Cash

Bastien  writes:

> Confirming this as an issue, if someone wants to fix it.

I've tried taking a shot at addressing this issue via the patch attached.

As mentioned in the thread, might potentially cause issues by changing how it 
matches -- should there be an option? Or is the idea just that if you really do 
want to exclude done tags, you'd query like "/!DONE"?

diff --git a/lisp/org.el b/lisp/org.el
index 020cfc873..3db1add8b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11691,7 +11691,7 @@ See also `org-scan-tags'."
 		   `(and ,tagsmatcher ,todomatcher)
 		 (or tagsmatcher todomatcher t
   (when org--matcher-tags-todo-only
-	(setq matcher `(and (member todo org-not-done-keywords) ,matcher)))
+	(setq matcher `(and (member todo org-todo-keywords-1) ,matcher)))
   (cons match0 `(lambda (todo tags-list level) ,matcher)
 
 (defun org--tags-expand-group (group tag-groups expanded)


Re: eldoc recursion error

2020-09-15 Thread James N V Cash

I've attached a patch that addresses the recursion issue with Emacs 28
and shows eldoc properly with example python. It presumably should act
the same with older versions of Emacs, although I haven't tested.

diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 3b0999340..ccc23b523 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -116,9 +116,12 @@
 (when (fboundp mode-func)
   (with-temp-buffer
 (funcall mode-func)
-(setq doc-func (and eldoc-documentation-function
-(symbol-value 'eldoc-documentation-function)))
-(puthash lang doc-func org-eldoc-local-functions-cache))
+	(setq doc-func (if (boundp 'eldoc-documentation-functions)
+			   (car eldoc-documentation-functions)
+			   (and eldoc-documentation-function
+(symbol-value 'eldoc-documentation-function
+
+	(puthash lang doc-func org-eldoc-local-functions-cache))
   doc-func)
   cached-func)))
 


Re: Bug: Occasional error with recurring tasks in agenda [9.4 (release_9.4-3-ge6021b @ /home/james/.config/emacs/straight/build/org-plus-contrib/)]

2020-09-23 Thread James N . V . Cash
Ihor Radchenko  writes:

>> It seems to always work properly from the org buffer itself, so I assume
>> it's something happening in the agenda, but I'm not sure where to look.
>> I've tried debugging `org-agenda-todo`, but I can't see anything in
>> askance there. Any advice as to what I should be looking for?
>
> I had similar issue. As I recall, the problem was with some custom
> function in org-trigger-hook that threw an error because it did not
> expect to be ran with point in agenda buffer. Do you have any
> customisation related to todo triggers?

Hm, it looks like org-trigger-hook and the various other
org-trigger-*-hook variables are nil in org-agenda buffers, but that
seems like a good place to look. I'll try to see if I have any other org
hooks that might be interferring with this.



Re: Bug: Occasional error with recurring tasks in agenda [9.4 (release_9.4-3-ge6021b @ /home/james/.config/emacs/straight/build/org-plus-contrib/)]

2020-09-25 Thread James N . V . Cash


>>> It seems to always work properly from the org buffer itself, so I assume
>>> it's something happening in the agenda, but I'm not sure where to look.
>>> I've tried debugging `org-agenda-todo`, but I can't see anything in
>>> askance there. Any advice as to what I should be looking for?

Trying to do more work to track this down and I'm perhaps more confused than I 
was before.

I can consistently make this happen by opening my todo.org file which
contains two recurring tasks, call them A and B.

I start by putting the cursor on task A, then running org-agenda and
using that to complete task B. This then results in task A showing twice
in the agenda list and refreshing the agenda/checking the file shows
task A completed & rescheduled to the next day and task B marked DONE
and not repeated.

Trying to track this down, I see in `org-todo`, the point moves from
where org-agenda-todo positioned it in task B to inside where I had the
cursor originally in the todo.org buffer, in task A. Strangely, I see
the point changing when the `next` variable is printed out via
`message` (I can also see the point changing after logging out org-state).

If I print out either of those variables with the "%S" format string
instead of "%s", the point doesn't move.

This doesn't happen with emacs -Q, so presumably there's something in my
config that's making this happen, but I have no idea what I should be
looking for. Any suggestions?

James



Bug: Occasional error with recurring tasks in agenda [9.4 (release_9.4-3-ge6021b @ /home/james/.config/emacs/straight/build/org-plus-contrib/)]

2020-09-22 Thread James N V Cash



I've started seeing an issues as of a couple of days ago, after upgrading to 
org 9.4.

When I mark a task with a recurring deadline done from the agenda view,
sometimes it doesn't recur, but instead marks the task as done.

I haven't yet been able to isolate why -- just now I marked a task as
done from the agenda, it didn't recur; I went to the org file, undid
from there, then tried marking it complete from the agenda again and
that time it worked.

It seems to always work properly from the org buffer itself, so I assume
it's something happening in the agenda, but I'm not sure where to look.
I've tried debugging `org-agenda-todo`, but I can't see anything in
askance there. Any advice as to what I should be looking for?

James Cash





Emacs  : GNU Emacs 28.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, 
cairo version 1.16.0)
 of 2020-08-14
Package: Org mode version 9.4 (release_9.4-3-ge6021b @ 
/home/james/.config/emacs/straight/build/org-plus-contrib/)

current state:
==
(setq
 org-duration-format 'h:mm
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-pdftools-get-desc-function 'org-pdftools-get-desc-default
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-pdftools-markup-pointer-function 'pdf-annot-add-underline-markup-annotation
 org-refile-targets '((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9))
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-notmuch-open-function 'org-notmuch-follow-link
 org-agenda-files "~/org/dir"
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-modules '(ol-info ol-eshell org-notify ol-notmuch)
 org-mode-hook '(evil-org-mode
 (closure (t) nil
  (let ((default-pred electric-pair-inhibit-predicate))
   (set (make-local-variable 'electric-pair-inhibit-predicate) 
#'(lambda (c) (if (char-equal c 60) t default-pred
  (visual-line-mode 1))
 (closure (t) nil (set (make-local-variable 
'company-dabbrev-downcase) nil)) cogent/fix-org-yasnippet-hook
 #[0 "\301\211.\207" [imenu-create-index-function 
org-imenu-get-tree] 2]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-show-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes 
org-eldoc-load)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-outline-path-complete-in-steps nil
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-agenda-restore-windows-after-quit t
 org-confirm-elisp-link-function 'yes-or-no-p
 org-mime-src-mode-hook '(org-mime-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-adapt-indentation 'headline-data
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-mime-html-hook '((closure (t) nil (org-mime-change-element-style 
"blockquote" "border-left: 2px solid gray; padding-left: 4px;"))
  (closure (t) nil
   (org-mime-change-element-style "pre"
(format "color: %s; background-color: %s; padding: 
0.5em;" (face-attribute 'default :foreground)
 (face-attribute 'default :background))
)
   )
  )
 org-notmuch-search-open-function 'org-notmuch-search-follow-link
 org-babel-pre-tangle-hook '(save-buffer)
 org-file-apps '((auto-mode . emacs) (directory . emacs) ("\\.mm\\'" . default) 
("\\.x?html?\\'" . default) ("\\.pdf\\'" . emacs))
 org-tab-first-hook '(yas/org-very-safe-expand 
org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-hide-leading-stars t
 org-babel-load-languages '((sql . t) (ruby . t) (js . t))
 org-load-hook '(org-pdftools-setup-link)
 org-hide-emphasis-markers t
 org-agenda-ignore-properties '(effort appt category)
 org-ascii-format-drawer-function #[771 ".\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
 org-use-fast-todo-selection t
 org-agenda-loop-over-headlines-in-active-region nil
 org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" . php) 
("C" . c) ("C++" . c++) ("asymptote" . asy) ("bash" . sh)
  ("beamer" . latex) ("calc" . fundamental) ("cpp" . c++) 
("ditaa" . artist) ("dot" . fundamental) ("elisp" . emacs-lisp)
  ("ocaml" . tuareg) ("screen" . shell-script) ("shell" . 
sh) ("sqlite" . sql))
 org-catch-invisible-edits 

Re: eldoc recursion error

2020-09-17 Thread James N . V . Cash

Kyle Meyer  writes:
> Thanks for the patch!  For information about the expected commit message
> format, please see <https://orgmode.org/worg/org-contribute.html>.

Ah will do, thanks! I'm still learning how to work with the email &
patch-based workflow.

> 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.

>From 4c2042c9e3820d88cd655cf01d572b9686a40d31 Mon Sep 17 00:00:00 2001
From: "James N. V. Cash" 
Date: Thu, 17 Sep 2020 10:51:13 -0400
Subject: [PATCH] Address org-eldoc-recursion issue

* org-eldoc.el (org-eldoc-get-mode-local-documentation-function,
org-eldoc-documentation-function): Support Emacs 28-style eldoc, where
instead of a single function, the eldoc-documentation-functions hook
has a list of functions, which may optionally take a callback.
---
 contrib/lisp/org-eldoc.el | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 3b0999340..85e238e64 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -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)))
+ (lambda ()
+   (let ((eldoc-documentation-functions doc-funs))
+ (funcall eldoc-documentation-strategy
+			   (and eldoc-documentation-function
+(symbol-value 'eldoc-documentation-function
 (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 ( _ignored)
+(defun org-eldoc-documentation-function ( callback)
   "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)
 
 ;;;###autoload
 (defun org-eldoc-load ()
-- 
2.25.1



Re: eldoc recursion error

2020-09-20 Thread James N . V . Cash
Kyle Meyer  writes:

> 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.

Cool, will do. I was concerned that the lexical-binding stanza was
missing for a reason, but I'll give it a shot.

> Also, why use
>
> (doc-funs (symbol-value 'eldoc-documentation-functions))
>
> rather than
>
> (doc-funs eldoc-documentation-functions)
>
> ?

Good question...I was doing that just because the original code does
~(symbol-value 'eldoc-documentation-function)~ and I assumed there was
some reason I didn't understand for doing so.

>> + (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.

Oops, will do.

>> -(defun org-eldoc-documentation-function ( _ignored)
>> +(defun org-eldoc-documentation-function ( callback)
>
> Perhaps even with the callback parameter the  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).

Good call, will do.

> 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).

I was just thinking more about this, and I'm concerned I might need to
change things around a little bit more. The closure that
org-eldoc-get-mode-local-documentation-function now returns under Emacs
28 doesn't take any arguments and instead lets the
eldoc-documentation-strategy function create its own new callback.

I think the current approach will appear to work when the documentation
function returns a value directly, but if it uses the callback, then I
think that it won't, since it invokes a new, separate callback.

I will take another crack at addressing this and send another patch shortly.

> Thanks again for working on this.

My pleasure!



Re: eldoc recursion error

2020-09-20 Thread James N . V . Cash
James N. V. Cash  writes:

> I was just thinking more about this, and I'm concerned I might need to
> change things around a little bit more. The closure that
> org-eldoc-get-mode-local-documentation-function now returns under Emacs
> 28 doesn't take any arguments and instead lets the
> eldoc-documentation-strategy function create its own new callback.
>
> I think the current approach will appear to work when the documentation
> function returns a value directly, but if it uses the callback, then I
> think that it won't, since it invokes a new, separate callback.
>
> I will take another crack at addressing this and send another patch shortly.

Indeed, testing with an eldoc backend (a personally hacked-up version of
clojure's cider) that actually uses the callback, it wasn't working with
the previous approach. I've attached a patch that addresses the
previously-mentioned issues as well as this.

>From 028675e460d12711ba4b91bf576b35e307a0e640 Mon Sep 17 00:00:00 2001
From: "James N. V. Cash" 
Date: Thu, 17 Sep 2020 10:51:13 -0400
Subject: [PATCH] Address org-eldoc-recursion issue

* org-eldoc.el (org-eldoc-get-mode-local-documentation-function,
org-eldoc-documentation-function): Support Emacs 28-style eldoc, where
instead of a single function, the eldoc-documentation-functions hook
has a list of functions, which may optionally take a callback.
---
 contrib/lisp/org-eldoc.el | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 3b0999340..b86ad1f39 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -1,4 +1,4 @@
-;;; org-eldoc.el --- display org header and src block info using eldoc
+;;; org-eldoc.el --- display org header and src block info using eldoc -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2014-2020 Free Software Foundation, Inc.
 
@@ -114,11 +114,17 @@
 doc-func)
 (if (eq 'empty cached-func)
 (when (fboundp mode-func)
-  (with-temp-buffer
-(funcall mode-func)
-(setq doc-func (and eldoc-documentation-function
-(symbol-value 'eldoc-documentation-function)))
-(puthash lang doc-func org-eldoc-local-functions-cache))
+	  (with-temp-buffer
+	(funcall mode-func)
+	(setq doc-func (if (boundp 'eldoc-documentation-functions)
+			   (let ((doc-funs eldoc-documentation-functions))
+ (lambda (callback)
+   (let ((eldoc-documentation-functions doc-funs)
+	 (eldoc--make-callback (lambda (_ignored) callback)))
+ (funcall eldoc-documentation-strategy
+			 (and eldoc-documentation-function
+  (symbol-value 'eldoc-documentation-function
+	(puthash lang doc-func org-eldoc-local-functions-cache))
   doc-func)
   cached-func)))
 
@@ -127,7 +133,7 @@
 (declare-function php-eldoc-function "php-eldoc" ())
 (declare-function go-eldoc--documentation-function "go-eldoc" ())
 
-(defun org-eldoc-documentation-function ( _ignored)
+(defun org-eldoc-documentation-function ( args)
   "Return breadcrumbs when on a headline, args for src block header-line,
   calls other documentation functions depending on lang when inside src body."
   (or
@@ -160,8 +166,12 @@
  (string= lang "go")
  (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
+   (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))
+		(callback (car args)))
+(when (functionp doc-fun)
+		  (if (functionp callback)
+		  (funcall doc-fun callback)
+		(funcall doc-fun)
 
 ;;;###autoload
 (defun org-eldoc-load ()
-- 
2.25.1



Re: eldoc recursion error

2020-09-20 Thread James N . V . Cash
Kyle Meyer  writes:

> All right, so we can't get by without using eldoc--make-callback here?
> Relying on a symbol marked with "--" makes me uneasy, and I'd like to
> avoid it if possible.

Yeah, good point. I was doing that so I could honour the setting of
eldoc-documentation-strategy. I don't know if that's going to be a
concern in practice though.

> Does your cider test case above break if we use
> eldoc-print-current-symbol-info without relaying the callback?  That is,
> this squashed into your patch:

My concern with using the eldoc-print-current-symbol-info is that it's
now somewhat subverting the actual eldoc documentation function -- i.e.
the invocation of org-eldoc-documentation-function now "fails" and
instead it prints out the actual documentation as a side-effect. Indeed,
applying that patch makes the eldoc for python code blocks not work
correctly.

The below patch which essentially just inlines the definition of
eldoc-documentation-default, so it's not messing around with any private
variables in eldoc, although it now won't honour the documentation
strategy. It remains to be seen if that will be an issue in practice,
but if necessary we could just check the value of
eldoc-documentation-strategy and behave appropriately.

>From 7d59ecadbea429626bae90464d76f01b60c8d67f Mon Sep 17 00:00:00 2001
From: "James N. V. Cash" 
Date: Thu, 17 Sep 2020 10:51:13 -0400
Subject: [PATCH] Address org-eldoc-recursion issue

* org-eldoc.el (org-eldoc-get-mode-local-documentation-function,
org-eldoc-documentation-function): Support Emacs 28-style eldoc, where
instead of a single function, the eldoc-documentation-functions hook
has a list of functions, which may optionally take a callback.
---
 contrib/lisp/org-eldoc.el | 29 -
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 3b0999340..946a57273 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -1,4 +1,4 @@
-;;; org-eldoc.el --- display org header and src block info using eldoc
+;;; org-eldoc.el --- display org header and src block info using eldoc -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2014-2020 Free Software Foundation, Inc.
 
@@ -114,11 +114,18 @@
 doc-func)
 (if (eq 'empty cached-func)
 (when (fboundp mode-func)
-  (with-temp-buffer
-(funcall mode-func)
-(setq doc-func (and eldoc-documentation-function
-(symbol-value 'eldoc-documentation-function)))
-(puthash lang doc-func org-eldoc-local-functions-cache))
+	  (with-temp-buffer
+	(funcall mode-func)
+	(setq doc-func (if (boundp 'eldoc-documentation-functions)
+			   (let ((doc-funs eldoc-documentation-functions))
+ (lambda (callback)
+   (let ((eldoc-documentation-functions doc-funs))
+ (run-hook-with-args-until-success
+  'eldoc-documentation-functions
+  callback
+			 (and eldoc-documentation-function
+  (symbol-value 'eldoc-documentation-function
+	(puthash lang doc-func org-eldoc-local-functions-cache))
   doc-func)
   cached-func)))
 
@@ -127,7 +134,7 @@
 (declare-function php-eldoc-function "php-eldoc" ())
 (declare-function go-eldoc--documentation-function "go-eldoc" ())
 
-(defun org-eldoc-documentation-function ( _ignored)
+(defun org-eldoc-documentation-function ( args)
   "Return breadcrumbs when on a headline, args for src block header-line,
   calls other documentation functions depending on lang when inside src body."
   (or
@@ -160,8 +167,12 @@
  (string= lang "go")
  (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
+   (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))
+		(callback (car args)))
+(when (functionp doc-fun)
+		  (if (functionp callback)
+		  (funcall doc-fun callback)
+		(funcall doc-fun)
 
 ;;;###autoload
 (defun org-eldoc-load ()
-- 
2.25.1



Re: [PATCH] Make org-eldoc work with Emacs 28

2020-07-13 Thread James N . V . Cash


Nicolas Goaziou  writes:

> Do we need another variable for that? Could
> org-eldoc-documentation-function catch wrong-number-of-arguments error,
> and try another call instead?

I believe that the issue is org-eldoc-documentation-function itself is
called with the wrong number of arguments; the new behaviour of
eldoc-mode is to call the documentation functions with a callback
argument, that the documentation function invokes to return its value,
unless the strategy is a function.

>From the docstring for eldoc-documentation-strategy:

> ...
> For backward compatibility to the "old" protocol, this variable
> can also be set to a function that returns nil or a doc string,
> depending whether or not there is documentation to display at
> all.

Another approach would be to, I suppose, make
org-eldoc-documentation-function take an optional callback argument
(defaulting to identity) and either wrap the whole body of
the function in a funcall of that function or pass the callback to all
the functions that org-eldoc-documentation-function calls.



[PATCH] Make org-eldoc work with Emacs 28

2020-07-12 Thread James N. V. Cash


In Emacs 28, eldoc now passes in a callback to the documentation
functions. This breaks org-eldoc as it currently is, as
org-eldoc-documentation-function gets called with the wrong number of
arguments.

This patch makes it continue to work by setting the new variable
eldoc-documentation-strategy, which puts eldoc in
"backwards-compatability" mode.


>From 5c04048c0d1ed3f80c7dd3e6477e12fc8e760675 Mon Sep 17 00:00:00 2001
From: "James N. V. Cash" 
Date: Fri, 10 Jul 2020 11:56:23 -0400
Subject: [PATCH] Make org-eldoc work with Emacs 28's new eldoc API

Still using backward-compatability to use the old style of
function. The new way is to make the documentation function take a
callback, but this approach means the fewest changes.
---
 contrib/lisp/org-eldoc.el | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 72b10a1fb..060674b24 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -161,11 +161,15 @@
 (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)))
+  (cond
+   ((boundp 'eldoc-documentation-strategy)
+(setq-local eldoc-documentation-strategy
+   #'org-eldoc-documentation-function))
+   ((boundp 'eldoc-documentation-functions)
+(add-hook 'eldoc-documentation-functions
+ #'org-eldoc-documentation-function nil t))
+   (t (setq-local eldoc-documentation-function
+ #'org-eldoc-documentation-function
 
 ;;;###autoload
 (add-hook 'org-mode-hook #'org-eldoc-load)
-- 
2.17.1



Re: [PATCH] Make org-eldoc work with Emacs 28

2020-07-16 Thread James N . V . Cash
Kyle Meyer  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
> ( _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.