Re: [PATCH] org-preview-latex-fragment dvipng fix for packages in org-latex-packages-alist breaking 'latex' command

2020-09-20 Thread Sébastien Miquel

Hi,

If I've understood your problem correctly, simply using ("" "fontspec" 
nil) in org-latex-packages-alist should fix your issue.


Per the documentation, this third argument stops the package from being 
used when compiling preview fragments.


Regards,

Sébastien



Gabriel S. X. Smith writes:

This is where my fix starts to come in. When org mode does the small

export of the latex fragment it would include the contents of
org-latex-packages-alist in the LaTex headers. Some packages (namely
'fontspec,' used for xelatex) would lead to a failure to create the
dvi file when the .tex file was compiled with the necessary
'latex' command.

To alleviate this problem I designed this wrapper function which
sets org-latex-packages-alist to nil just before executing the
org-latex-preview function.



Re: Cycling through TODO workflow joins the next line onto the current one

2020-09-20 Thread Nicholas Savage
I'm having a hard time reproducing this on the latest master, although it's 
clear from your image that something is going wrong. How are you marking the 
tasks as DONE? When I use C-c C-t to mark them as done, it doesn't add the 
"CLOSED" tag by default under emacs -Q, so I'm wondering if it's something 
about your or the spacemacs configuration that's causing this?

On Sun, Sep 20, 2020, at 02:37, Krishan Kharagjitsing wrote:
> Hello, I found the following weird behaviour. I first reported it to the 
> spacemacs github (https://github.com/syl20bnr/spacemacs/issues/13901) but 
> they confirmed that it is an upstream bug.

> When I set some tasks to DONE and fold the headings with TAB, then when I 
> cycle back from DONE to TODO it joins the next line with the current one.

> 

> org_mode_bug 
> 

> Reproduction guide

>  * Make two TODO headings in org mode
>  * Cycle both TODO items to DONE
>  * Fold the headings (so the dots appear, because the timestamp gets folded 
> with the heading)
>  * Cycle the first DONE heading

> *Observed behaviour:* 
> The next line gets joined on the current one.


> *Expected behaviour:* 
> No joining of lines.

> System Info 

>  * OS: gnu/linux (WSL2, connected via X410 to Windows)
>  * Emacs: 28.0.50 (also tested it on 26.1, same behaviour observed)
>  * Graphic display: t
>  * Distribution: spacemacs
>  * Editing style: vim
>  * Completion: helm
>  * Layers:
> (helm auto-completion emacs-lisp org themes-megapack treemacs)
>  * System configuration features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM 
> DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE 
> HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES 
> THREADS PDUMPER LCMS2


Re: [patch suggestion] Mitigating the poor Emacs performance on huge org files: Do not use overlays for PROPERTY and LOGBOOK drawers

2020-09-20 Thread Kévin Le Gouguec
Hi!

Ihor Radchenko  writes:

> The current version of the patch (against master) is in
> https://gist.github.com/yantar92/6447754415457927293acda43a7fcaef

I'm probably missing something obvious, but when applying your patch on
top of master[1], make fails when generating manuals:

> emacs  -Q -batch --eval '(setq vc-handled-backends nil org-startup-folded 
> nil)' \
>   --eval '(add-to-list '"'"'load-path "../lisp")' \
>   --eval '(load "../mk/org-fixup.el")' \
>   --eval '(org-make-manuals)'
> Loading /home/peniblec/Downloads/sources/emacs-meta/org-mode/mk/org-fixup.el 
> (source)...
> Before first headline at position 760959 in buffer org-manual.org<2>
> make[1]: *** [Makefile:31: org.texi] Error 255

I've tried going to doc/, running 

emacs -Q --eval '(setq vc-handled-backends nil org-startup-folded nil)' \
  --eval '(add-to-list '"'"'load-path "../lisp")' \
  --eval '(load "../mk/org-fixup.el")'

then M-x toggle-debug-on-error and M-: (org-make-manuals), but I can't
get a stacktrace.  I'm guessing this is because this error (which IIUC
originates from org-back-to-heading in org.el) is a user-error; however,
if I change the function to raise a "regular error", then everything
compiles fine… 


[1] git apply --3way, on top of commit b64ba64fe.

I get a conflict in org.el, on the hunk where org-reveal-location
and org-show-context-detail are defined; since your patch just
deletes them, I resolve this with:

git checkout --theirs -- lisp/org.el




Cycling through TODO workflow joins the next line onto the current one

2020-09-20 Thread Krishan Kharagjitsing
Hello, I found the following weird behaviour. I first reported it to the
spacemacs github (https://github.com/syl20bnr/spacemacs/issues/13901) but
they confirmed that it is an upstream bug.

When I set some tasks to DONE and fold the headings with TAB, then when I
cycle back from DONE to TODO it joins the next line with the current one.

[image: org_mode_bug]

Reproduction guide

   - Make two TODO headings in org mode
   - Cycle both TODO items to DONE
   - Fold the headings (so the dots appear, because the timestamp gets
   folded with the heading)
   - Cycle the first DONE heading

*Observed behaviour:*
The next line gets joined on the current one.

*Expected behaviour:*
No joining of lines.
System Info

   - OS: gnu/linux (WSL2, connected via X410 to Windows)
   - Emacs: 28.0.50 (also tested it on 26.1, same behaviour observed)
   - Graphic display: t
   - Distribution: spacemacs
   - Editing style: vim
   - Completion: helm
   - Layers:

(helm auto-completion emacs-lisp org themes-megapack treemacs)


   - System configuration features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND
   GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2
   FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE
   XIM MODULES THREADS PDUMPER LCMS2


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!



Bug: latex nested environments are failed on preview and export [9.3.8 (9.3.8-1-g13dfab-elpaplus @ /home/sd/.emacs.d/elpa/26.3/develop/org-plus-contrib-20200914/)]

2020-09-20 Thread Сергей Олегович
I want to use a matrix environment that is included in an outer
environment, so:

```
Environment:
\begin{equation*}
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
\end{equation*}

Display--math:
\[
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
\]

Inline--math:
\(
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
\)
```

But for the second and third cases (display-math and inline-math) the
preview and export to latex are failed:

exported LaTeX:

```
Environment:
\begin{equation*}
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
\end{equation*}

Display--math:
$\backslash$[
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
$\backslash$]

Inline--math:
$\backslash$(
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
$\backslash$)
\end{document}
```

org-mode preview:

[image: preview.png]

Emacs  : GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14)
 of 2020-03-26, modified by Debian
Package: Org mode version 9.3.8 (9.3.8-1-g13dfab-elpaplus @
/home/sd/.emacs.d/elpa/26.3/develop/org-plus-contrib-20200914/)

It is reproduces with Org mode 9.4 also
https://emacs.stackexchange.com/q/60765/13323


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: Custom block agendas: Set buffer name

2020-09-20 Thread Nathan Neff
I found it in this section of the docs:
https://orgmode.org/manual/Setting-options.html#Setting-options

I had unbalanced parenthesis in Feb. and gave up.  I was finally able to
find the right
place to put the options for all the commands (see org-agenda-buffer-name)
below.

I create variables and used functions to modularize my code - otherwise the
parenthesis
become unbearable IMHO.

(setq org-agenda-custom-commands '())
(defun njn-define-block-agenda()
(setq njn-agenda '(("h" "Agenda and Projects (Home)"
((agenda )
 (tags "-projectA-projectB-projectC/next\|started"
((org-agenda-todo-ignore-with-date nil)))
 (tags "projectA-inactive/-cancelled-done"
((org-agenda-prefix-format " %?-12t% s")
 (org-agenda-sorting-strategy (quote (priority-down)
 (tags "projectA-inactive/-cancelled-done"
((org-agenda-prefix-format " %-16(njn-get-proj-property)
%?-12t% s")
 (org-tags-exclude-from-inheritance (remove "projectA"
org-tags-exclude-from-inheritance))
 (org-agenda-group-by-property "PROJ"
 ((org-agenda-buffer-name "Home")
(setq org-agenda-custom-commands (append njn-agenda
org-agenda-custom-commands)))
(njn-define-block-agenda)

I realize this is opening a can of worms -- does anyone have
recommendations for formatting
Lisp code?  The above code is legible for me *right now* but in about 3
months the code will once
again be a paren-fest.

Thanks,
--Nate

On Wed, Feb 12, 2020 at 5:49 PM Nathan Neff  wrote:

> Hello all,
>
> I'm playing with block agendas and I'm wondering how to set a
> specific buffer
> name.
>
> In non-block agendas, I can set the buffer name like this:
> (setq org-agenda-custom-commands (append
>   '(
>  ("p" "Simple list of active projects" tags-todo
> "PRIORITY<\"C\"+project-inactive/-cancelled-done"
>((org-agenda-prefix-format " %?-12t% s")
> (org-agenda-buffer-name "Top Level Active Projects")
> (org-agenda-sorting-strategy (quote (priority-down)
>
> But I can't find where to specify org-agenda-buffer-name in a custom block
> agenda - for example,
> in the docs:
> https://orgmode.org/manual/Block-agenda.html
>
> Where would I add the org-agenda-buffer-name?
>
> Thanks,
> --Nate
>


Re: eldoc recursion error

2020-09-20 Thread Kyle Meyer
This was resolved by the thread at
.  Although the first
message in that thread had an In-Reply-To header pointing to a message
in this thread, it didn't have a proper References header, so I don't
think  will pick up on the "X-Woof-Bug:
fixed" header in .
Hence this message...



Re: Bug: latex nested environments are failed on preview and export [9.3.8 (9.3.8-1-g13dfab-elpaplus @ /home/sd/.emacs.d/elpa/26.3/develop/org-plus-contrib-20200914/)]

2020-09-20 Thread Nicolas Goaziou
Hello,

Сергей Олегович  writes:

> I want to use a matrix environment that is included in an outer
> environment, so:
>
> ```
> Environment:
> \begin{equation*}
> \left|
> \begin{matrix}
> a_1 & b_1\\
> a_2 & b_2
> \end{matrix}
> \right|
> \end{equation*}
>
> Display--math:
> \[
> \left|
> \begin{matrix}
> a_1 & b_1\\
> a_2 & b_2
> \end{matrix}
> \right|
> \]
>
> Inline--math:
> \(
> \left|
> \begin{matrix}
> a_1 & b_1\\
> a_2 & b_2
> \end{matrix}
> \right|
> \)
> ```
>
> But for the second and third cases (display-math and inline-math) the
> preview and export to latex are failed:

This is not a bug. \[...\] and \(...\) are inline elements within
a paragraph. However, \begin{...}...\end{...} environments are blocks,
and they break paragraphs. IOW, you cannot nest them.

The following should work however

  \(
  \left|\begin{matrix}
  a_1 & b_1\\
  a_2 & b_2
  \end{matrix}\right|
  \)

because \begin{matrix} doesn't start the line, and therefore is not seen
as starting a new LaTeX block.

As a rule of thumb, Org has limited support for raw LaTeX in a document.
This is not AucTeX. For specific needs, you may want to use LaTeX
blocks, i.e., #+begin_export latex...


Regards,
-- 
Nicolas Goaziou



Re: eldoc recursion error

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

> Kyle Meyer  writes:
>
>> 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.

Okay.  Testing with the current Emacs master branch, I saw what I
thought were the expected messages, but perhaps I wasn't testing
complicated enough python blocks on my end:

#+begin_src python
  print("ok")
  int(1)
#+end_src

Either way ...

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

... this sounds fine to me.  Lightly testing your latest patch with
Emacs 27 and 28, things work on my end.

Pushed (c20cb0993).  Thanks.



Re: eldoc recursion error

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

> 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.
[...]
> @@ -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))

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

diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index b86ad1f39..06dcd6fe2 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -118,10 +118,9 @@ (defun org-eldoc-get-mode-local-documentation-function 
(lang)
(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
+(lambda ()
+  (let ((eldoc-documentation-functions 
doc-funs))
+(eldoc-print-current-symbol-info
 (and eldoc-documentation-function
  (symbol-value 
'eldoc-documentation-function
(puthash lang doc-func org-eldoc-local-functions-cache))
@@ -133,7 +132,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 ( args)
+(defun org-eldoc-documentation-function ( _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
@@ -166,12 +165,9 @@ (defun org-eldoc-documentation-function ( args)
  (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))
-   (callback (car args)))
+   (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function 
lang)))
 (when (functionp doc-fun)
- (if (functionp callback)
- (funcall doc-fun callback)
-   (funcall doc-fun)
+ (funcall doc-fun
 
 ;;;###autoload
 (defun org-eldoc-load ()



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



[PATCH] (org-remove-occur-highlights) Implements option to remove highlights between points

2020-09-20 Thread Nicholas Savage
I realize now that I messed up sending this patch yesterday so it didn't show 
up on updates.orgmode.org. I just wanted to repost it with a correct subject to 
make sure it didn't get lost. My original message follows.

--

I posted earlier about why org-remove-occur-highlights ignored it's options of 
beg and end. I'm fairly sure it was so they could be implemented later. I 
wanted to use this functionality, so I've implemented it. This should not 
change any current behaviour. If beg and end are nil, it will run the same way 
as before. This is called as part of org-sparse-tree, and my changes do not 
affect that. When beg and end are non-nil, it checks which overlays are between 
those two points and deletes them. I've ensured that 'make test' still passes 
and believe I've formatted my changelog entry as required.

If I'm missing something about how this should be working, please let me know.

My copyright paperwork with FSF is currently in progress, but I wanted to put 
this out there to get comments as necessary.

Thanks,
NickFrom 3213a8d50af0a99be43bf1f91c5621a6474548dd Mon Sep 17 00:00:00 2001
From: nick 
Date: Thu, 17 Sep 2020 21:49:43 -0400
Subject: [PATCH] org.el: Implements option to remove highlights between points

* lisp/org.el (org-remove-occur-highlights): Implements BEG and END in
order to allow the option of removing highlights between a range of
points and adjust the shown context.

org-remove-occur-highlights has long had two options, BEG and END,
that were ignored. This change checks first 1) are BEG and END are
nil (as would be expected with the vast majority of current
behaviour)? If yes, there is no change in behaviour. Otherwise, it
removes only the highlights between BEG and END and updates
org-occur-highlights to contain the remaining highlights.
---
 lisp/org.el | 41 -
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 053635c85..f509b8049 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11106,18 +11106,41 @@ match is found."
 (overlay-put ov 'org-type 'org-occur)
 (push ov org-occur-highlights)))
 
-(defun org-remove-occur-highlights ( _beg _end noremove)
+(defun org-remove-occur-highlights ( beg end noremove)
   "Remove the occur highlights from the buffer.
-BEG and END are ignored.  If NOREMOVE is nil, remove this function
-from the `before-change-functions' in the current buffer."
+When BEG and END are set, removes the overlay and hides the items
+between those two points. It does this by going through each overlay
+and comparing whther or not they are within the two points. If BEG and
+END are not set, erases all overlays and sets related variables to
+nil. If NOREMOVE is nil, remove this function from the
+`before-change-functions' in the current buffer."
   (interactive)
   (unless org-inhibit-highlight-removal
-(mapc #'delete-overlay org-occur-highlights)
-(setq org-occur-highlights nil)
-(setq org-occur-parameters nil)
-(unless noremove
-  (remove-hook 'before-change-functions
-		   'org-remove-occur-highlights 'local
+; if only one of BEG and END are set, set both to nil
+(when (or (and beg (not end)) (and (not beg) end))
+  (setq beg nil end nil))
+(cond
+ ((and (not beg) (not end))
+  (mapc #'delete-overlay org-occur-highlights)
+  (setq org-occur-highlights nil)
+  (setq org-occur-parameters nil)
+  (unless noremove
+	(remove-hook 'before-change-functions
+		 'org-remove-occur-highlights 'local)))
+ ((> end beg)
+  (org-overview)
+  (setq temp-overlays '())
+  (dolist (overlay org-occur-highlights)
+	(let ((overlay-point (overlay-start overlay)))
+
+	  (if (and (> overlay-point beg) (< overlay-point end))
+	  (delete-overlay overlay)
+	(progn
+	  (save-excursion
+		(goto-char overlay-point)
+		(org-show-set-visibility 'ancestors)
+		(add-to-list 'temp-overlays overlay))
+  (setq org-occur-highlights temp-overlays)
 
  Priorities
 
-- 
2.20.1