Re: [BUG] Re: 98e168b48 Add compatibility wrapper for string-clean-whitespace (Emacs 26 compatibility) [9.6-pre (release_9.5.5-920-g057193 @ /home/yantar92/.emacs.d/straight/build/org/)]

2022-10-07 Thread Max Nikulin

On 07/10/2022 12:14, Ihor Radchenko wrote:


The following commit adds `string-trim', which is not yet available in
Emacs 26.


It is available in Emacs-26, however (require 'subr-x) should be added.

There is `org-trim' and despite it is less generic, likely it can be 
used if subr-x is avoided for some reason.




Re: [BUG] "args out of range" on link heading completion [9.5 (9.5-gd361c7 @ /Users/carlos/.emacs.d/straight/build/org/)]

2022-10-07 Thread Ihor Radchenko
Carlos Pita  writes:

> I believe the problem is in:
>
> (defun pcomplete/org-mode/searchhead ()
>...
>   ;; When completing a bracketed link, i.e., "[[*", argument
>   ;; starts at the star, so remove this character.
>   (substring pcomplete-stub 1  <-- trailing ]] not removed!
>
> Changing the last line to (substring pcomplete-stub 1 -2) fixes it in my
> example. I don't know if one is supposed to do [[*prefix]] or
> [[*prefix as is implied by the code, but better to support both,
> specially considering electric pairs, don't you think?

And finally fixed on main using a different approach.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=1a62cd94cfc92c3ce6eadb2ffc1d6a18e8caee86

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 

Fixed.



Re: Bug: html-postamble string does not allow space [9.4.4 (release_9.4.4 @ /usr/local/share/emacs/27.2/lisp/org/)]

2022-10-07 Thread Ihor Radchenko
Tim Cross  writes:

> Confirm.
>
> I am able to reproduce this issue with 

I might be missing something, but does
`org-export--parse-option-keyword' even support spaces inside values?

> I also feel the manual page could be improved as it doesn't actually
> mention setting the html-postamble to a string (that is only mentioned
> in the variable docstring).

The manual does even mention the "html-postamble" option. Just the
variable. I am confused. Was it removed at some point? (I do not see any
commits doing so)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[PATCH] Re: [BUG] Tables with square brackets do not compile in PDF (latex) export [9.5 (release_9.5-59-g52e6f1 @ /home/sjt015/repo/emacs/lisp/org/)]

2022-10-07 Thread Ihor Radchenko
Max Nikulin  writes:

> On 10/11/2021 23:16, Stewart Thomas wrote:
>> 
>> A table in which a first column begins with square brackets is not
>> compiling. The square bracket is interpreted by latex as an argument
>> to the preceding line break.
>
> Confirmed
>
> To fix the bug newline (in tables and paragraphs) should be exported as 
> "\\\relax" or "\\{}". I do not suggest curly brackets in the beginning 
> of line to avoid issues with spurious spaces. Percent character 
> (comment) at the end of line should be considered for a fix since it is 
> usually used in the opposite way: to suppress newline character and 
> spaces at the beginning of next source line.

I am attaching a tentative patch to fix this.
However, I am not sure if I replaced \\ with \\\relax in the right
places.

Daniel, can you please check?

>From 43d643197883e10a6c6551489d37053c2c89b4dd Mon Sep 17 00:00:00 2001
Message-Id: <43d643197883e10a6c6551489d37053c2c89b4dd.1665131437.git.yanta...@gmail.com>
From: Ihor Radchenko 
Date: Fri, 7 Oct 2022 16:24:32 +0800
Subject: [PATCH] ox-latex: Protect [...] after \\ to be interpreted as LaTeX
 argument

* lisp/ox-latex.el (org-latex-linebreak-safe): New constant holding
safe version of LaTeX line break.
(org-latex-table-matrix-macros):
(org-latex-clock):
(org-latex-line-break):
(org-latex-plain-text):
(org-latex-planning):
(org-latex--org-table):
(org-latex--math-table):
(org-latex-table-row):
(org-latex-verse-block): Use the new constant.

* testing/lisp/test-org-table.el (test-org-table/to-latex): Update
tests.

Reported-by: Stewart Thomas 
Link: https://orgmode.org/list/ce760fc3-5aae-144d-2d02-7dea215f7...@gmail.com
---
 lisp/ox-latex.el   | 47 --
 testing/lisp/test-org-table.el |  6 ++---
 2 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 34ff52b81..127637ccf 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -278,10 +278,23 @@ (defconst org-latex-language-alist
 
 - `:lang-name' the actual name of the language.")
 
+(defconst org-latex-linebreak-safe "\\relax"
+  "Linebreak protecting the following [...].
 
-(defconst org-latex-table-matrix-macros '(("bordermatrix" . "\\cr")
+Without \"\\relax\" it would be interpreted as an optional argument to
+the .
+
+This constant, for example, makes the below code not err:
+
+\\begin{tabular}{c|c}
+[t] & s\\relax
+[I] & A\\relax
+[m] & kg
+\\end{tabular}")
+
+(defconst org-latex-table-matrix-macros `(("bordermatrix" . "\\cr")
 	  ("qbordermatrix" . "\\cr")
-	  ("kbordermatrix" . ""))
+	  ("kbordermatrix" . ,org-latex-linebreak-safe))
   "Alist between matrix macros and their row ending.")
 
 (defconst org-latex-math-environments-re
@@ -2062,7 +2075,7 @@ (defun org-latex-clock (clock _contents info)
 	   (concat (org-timestamp-translate (org-element-property :value clock))
 		   (let ((time (org-element-property :duration clock)))
 		 (and time (format " (%s)" time)
-   ""))
+   org-latex-linebreak-safe))
 
 
  Code
@@ -2659,7 +2672,7 @@  Line Break
 (defun org-latex-line-break (_line-break _contents _info)
   "Transcode a LINE-BREAK object from Org to LaTeX.
 CONTENTS is nil.  INFO is a plist holding contextual information."
-  "\n")
+  (concat org-latex-linebreak-safe "\n"))
 
 
  Link
@@ -3005,7 +3018,9 @@ (defun org-latex-plain-text (text info)
 ;; Handle break preservation if required.
 (when (plist-get info :preserve-breaks)
   (setq output (replace-regexp-in-string
-		"\\(?:[ \t]*\\)?[ \t]*\n" "\n" output nil t)))
+		"\\(?:[ \t]*\\)?[ \t]*\n"
+(concat org-latex-linebreak-safe "\n")
+output nil t)))
 ;; Return value.
 output))
 
@@ -3041,7 +3056,7 @@ (defun org-latex-planning (planning _contents info)
 		(format (plist-get info :latex-active-timestamp-format)
 			(org-timestamp-translate scheduled)))
 " ")
-   ""))
+   org-latex-linebreak-safe))
 
 
  Property Drawer
@@ -3821,11 +3836,11 @@ (defun org-latex--org-table (table contents info)
 		(format "\\begin{%s}%s{%s}\n" table-env width alignment)
 		(and above?
 		 (org-string-nw-p caption)
-		 (concat caption "\n"))
+		 (concat caption org-latex-linebreak-safe "\n"))
 		contents
 		(and (not above?)
 		 (org-string-nw-p caption)
-		 (concat caption "\n"))
+		 (concat caption org-latex-linebreak-safe "\n"))
 		(format "\\end{%s}" table-env)
 		(and fontsize "}"
  (t
@@ -3910,7 +3925,7 @@ (defun org-latex--math-table (table info)
 		 (lambda (cell)
 		   (substring (org-element-interpret-data cell) 0 -1))
 		 (org-element-map row 'table-cell #'identity info) "&")
-		(or (cdr (assoc env org-latex-table-matrix-macros)) "")
+		(or (cdr (assoc env org-latex-table-matrix-macros)) org-latex-linebreak-safe)
 		"\n")))
 	   (org-element-map table 'table-row #'identity info) "")))
   

Re: The Org mode in the Org Git does not export

2022-10-07 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Rudolf, please kindly confirm that the export performance is back to
> satisfactory on the latest main.

Performance back to normal!  Though, I noticed two issues.

*** ISSUE 1: Error when exporting. ***

While exporting, I see the error:

"Org mode fontification error in # at 10"

The error does not bother me, but I mention it in the case it relates to
the next issue.

*** ISSUE 2: Problems re-opening the notebook. ***

Reproduction steps:

1. open 'notebook.org' (C-x C-f ~/notebook.org RET)
2. export to HTML and open (C-c C-e h o)
3. kill the notebook buffer (C-x k RET)
4. re-open notebook (C-x C-f ~/notebook.org RET)

Expected:

'notebook.org' opens

Actual:

*Org HTML Export LaTeX* opens, with the following content:

\begin{align*}
  \frac{dy}{dx}
  & = y \left( -1 - 2 \tan x - \frac{2x + 1}{x^2 + x + 1} \right)
  \\
  & = \frac{e^{-x} {\cos}^2 x}{x^2 + x + 1}
\left( -1 - 2 \tan x - \frac{2x + 1}{x^2 + x + 1} \right)
\end{align*}

P.S. The original file remains intact, but given the way we implement
exports in Org, I think we should add two tests to the test suite to
verify that:

(1) re-opening the file after export always re-opens it, and
(2) no corruption happens to the original file after export.

Rudy
-- 
"Genius is 1% inspiration and 99% perspiration."
-- Thomas Alva Edison, 1932

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: The Org mode in the Org Git does not export

2022-10-07 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> Rudolf, please kindly confirm that the export performance is back to
>> satisfactory on the latest main.
>
> Performance back to normal!  Though, I noticed two issues.
>
> *** ISSUE 1: Error when exporting. ***
>
> While exporting, I see the error:
>
> "Org mode fontification error in # at 10"
>
> The error does not bother me, but I mention it in the case it relates to
> the next issue.

I do not see how it is related.
Do you see the error with your config or with clean Emacs?

> *** ISSUE 2: Problems re-opening the notebook. ***
>
> Reproduction steps:
>
> 1. open 'notebook.org' (C-x C-f ~/notebook.org RET)
> 2. export to HTML and open (C-c C-e h o)
> 3. kill the notebook buffer (C-x k RET)
> 4. re-open notebook (C-x C-f ~/notebook.org RET)
>
> Expected:
>
> 'notebook.org' opens
>
> Actual:
>
> *Org HTML Export LaTeX* opens, with the following content:
>
> \begin{align*}
>   \frac{dy}{dx}
>   & = y \left( -1 - 2 \tan x - \frac{2x + 1}{x^2 + x + 1} \right)
>   \\
>   & = \frac{e^{-x} {\cos}^2 x}{x^2 + x + 1}
> \left( -1 - 2 \tan x - \frac{2x + 1}{x^2 + x + 1} \right)
> \end{align*}

Oops. Another side-effect of `buffer-file-name'. Fixed now.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=86b6d843f6e8d33c0dcf414f7fda2b1ac6492550

> P.S. The original file remains intact, but given the way we implement
> exports in Org, I think we should add two tests to the test suite to
> verify that:

> (2) no corruption happens to the original file after export.

Done.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3de74bbeff704a1e297d0f8c445790928e71344f

> (1) re-opening the file after export always re-opens it, and

I am not sure how to test this part.
I instead documented the caveats in `org-export-copy-buffer' docstring
and in the `org-html-format-latex'.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=17708ab3fa4f2a0f118bf86cebd4753f50e8bb26
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=86b6d843f6e8d33c0dcf414f7fda2b1ac6492550

Though maybe the code in `org-html-format-latex' should be factored out
into a separate macro like `org-export-with-persistent-buffer-copy'. The
macro will accept buffer name as an argument and do everything necessary
to not keep the `buffer-file-name' around.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Interest in an Org video meetup?

2022-10-07 Thread Juan Manuel Macías
Russell Adams writes:

>> Even if there is a recording, where can we publish the recorded videos?
>
> Exactly.
>
> Recording brings with it extra logistics, which is why I deferred the
> issue. ;]

I was just asking, out of curiosity, if it was planned to be published.
I really don't know where it could be published. I know PeerTube exists,
but I don't know how it works.

There is the YouTube option, which I imagine no one would like (me
neither). The only thing in its favor is that Invidious can be used to
watch the videos. BTW, I watch YT videos through Invidious in Emacs,
with the Ytel package and EMMS/MPV.

Best regards,

Juan Manuel 

-- 
--
--
Juan Manuel Macías 

https://juanmanuelmacias.com

https://lunotipia.juanmanuelmacias.com

https://gnutas.juanmanuelmacias.com



watch YT videos through in Emacs [Was: Interest in an Org video meetup?]

2022-10-07 Thread Quiliro Ordóñez
Hola Juan Manuel.

> There is the YouTube option, which I imagine no one would like (me
> neither). The only thing in its favor is that Invidious can be used to
> watch the videos. BTW, I watch YT videos through Invidious in Emacs,
> with the Ytel package and EMMS/MPV.

Nice.  Is there a guide to do this specificly?



Re: [PATCH] Re: [BUG] Tables with square brackets do not compile in PDF (latex) export [9.5 (release_9.5-59-g52e6f1 @ /home/sjt015/repo/emacs/lisp/org/)]

2022-10-07 Thread Max Nikulin

On 07/10/2022 15:31, Ihor Radchenko wrote:


I am attaching a tentative patch to fix this.
However, I am not sure if I replaced \\ with \\\relax in the right
places.


Ihor, thank you for looking into this issue. I have not read your patch 
with enough attention to check that regular paragraphs, list entries and 
other elements are handled as well. Just a couple of notes:



+(defconst org-latex-linebreak-safe "\\relax"


Is there a reason why you did not add \n at the end? It could help to 
avoid a lot of `concat' calls.



-   (equal "\\begin{tabular}{l}\n\\(x\\)\n\\end{tabular}"
+   (equal "\\begin{tabular}{l}\n\\(x\\)\\relax\n\\end{tabular}"


May be left as is since the line next to \\ does not start from square 
brackets.





Re: test-org-table/sort-lines: Failing test on macOS

2022-10-07 Thread Max Nikulin

On 07/10/2022 03:15, Rudolf Adamkovič wrote:


If I understand, "a" should be less than "B" when under "C" locale when
ignoring case (nil) , right?  Yet, I get the following:

(string-collate-lessp "a" "B" "C" nil)  ; => nil


When case is not ignored (4th argument is nil) locale-dependent 
collation rules are used, so you get the expected result.


$ printf 'a\nB\n' | LC_COLLATE=C sort
B
a
$ printf 'a\nB\n' | LC_COLLATE=en_US.UTF-8 sort
a
B


[FYI: If I replace nil with t, the procedure returns nil too.]

Tested on Emacs 29 (adaa2fc90e) and Org 9.5.5 (580f28614).


Strange. Emacs-26, Linux

(string-collate-lessp "a" "B" "C" t)
t

If libc is sane (assuming that sort is linked to the same libc)

printf 'a\nb\n' | LC_COLLATE=C sort
printf 'b\na\n' | LC_COLLATE=C sort
printf 'A\nB\n' | LC_COLLATE=C sort
printf 'B\nA\n' | LC_COLLATE=C sort
printf 'a\nb\n' | LC_COLLATE=C.UTF-8 sort
printf 'b\na\n' | LC_COLLATE=C.UTF-8 sort
printf 'A\nB\n' | LC_COLLATE=C.UTF-8 sort
printf 'B\nA\n' | LC_COLLATE=C.UTF-8 sort

then you might face an Emacs bug.

P.S. Example of a subtle issue with sorting: significant space added to 
some locales like es_ES & Co, pl_PL:


Maxim Nikulin. Re: [Patch] to correctly sort the items with emphasis 
marks in a list. Fri, 16 Apr 2021 21:59:51 +0700. 
https://list.orgmode.org/s5c8p9$97n$1...@ciao.gmane.io





Re: Interest in an Org video meetup?

2022-10-07 Thread George Mauer
I would try to join.

One thing I always mention when conversations about recording come up is
that if you promote recordings as a resource, it is considered good form to
have transcription available. I'm pretty sure a community effort like this
world be under no ADA obligations (unlike company meetings) but still good
form.

On Fri, Oct 7, 2022, 05:45 Juan Manuel Macías 
wrote:

> Russell Adams writes:
>
> >> Even if there is a recording, where can we publish the recorded videos?
> >
> > Exactly.
> >
> > Recording brings with it extra logistics, which is why I deferred the
> > issue. ;]
>
> I was just asking, out of curiosity, if it was planned to be published.
> I really don't know where it could be published. I know PeerTube exists,
> but I don't know how it works.
>
> There is the YouTube option, which I imagine no one would like (me
> neither). The only thing in its favor is that Invidious can be used to
> watch the videos. BTW, I watch YT videos through Invidious in Emacs,
> with the Ytel package and EMMS/MPV.
>
> Best regards,
>
> Juan Manuel
>
> --
> --
> --
> Juan Manuel Macías
>
> https://juanmanuelmacias.com
>
> https://lunotipia.juanmanuelmacias.com
>
> https://gnutas.juanmanuelmacias.com
>
>


Update Org to MathJax 3

2022-10-07 Thread Rudolf Adamkovič
Hello smart people!

With all the talk about Emacs 29, I figured we should update Org Mode to
use MathJax 3, to catch up with the rest of the world.

>From the documentation (for MathJax 3.0 released in 2019):

> Version 3.0 of MathJax is a complete rewrite of MathJax from the
> ground up, and its usage and configuration is significantly different
> from that of MathJax version 2.

In practice, MathJax 3.2 renders mathematics faster and better, plus it
significantly improves LaTeX support.  For instance, one can typeset
calculus with the built-in (!) 'physics' package, like in LaTeX.

More information on the recent progress (made in 2019-2021):

https://docs.mathjax.org/en/latest/upgrading/whats-new-3.0.html
https://docs.mathjax.org/en/latest/upgrading/whats-new-3.1.html
https://docs.mathjax.org/en/latest/upgrading/whats-new-3.2.html

See the attached [working, but WIP] patch.

My question for you:

How do we change the 'org-html-mathjax-options'?

- 'scale' has now the value in [0, 1] and not in [0, 100]
- 'scale' should exist as a number and not string
- 'font' did not make it to MathJax 3 [*]
- 'linebreaks' did not make it to MathJax 3 [*]
- 'autonumber' has the values in lowercase now
- 'autonumber' became 'tags' in MathJax terminology

[*] coming in MathJax 4, currently in alpha

How does Org mode approach these kind of breaking changes?

Rudy

>From ca2eaf5bcc9ea01e764f6088e37d74ec2be6e426 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Use MathJax 3 instead of 2.7

* lisp/ox-html.el (org-html-mathjax-options): WIP
* lisp/ox-html.el (org-html-mathjax-template): WIP
---
 lisp/ox-html.el | 51 +
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 9b77e4f8d..c6242d4bc 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -1166,12 +1166,12 @@ See `format-time-string' for more information on its components."
  Template :: Mathjax
 
 (defcustom org-html-mathjax-options
-  '((path "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"; )
-(scale "100")
+  '((path "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js";)
+(scale "1") ;; TODO: 0-1 AND NOT 0-100; NUMBER AND NOT STRING
 (align "center")
-(font "TeX")
-(linebreaks "false")
-(autonumber "AMS")
+(font "TeX") ;; TODO: NOT SUPPORTED
+(linebreaks "false") ;; TODO: NOT SUPPORTED
+(autonumber "ams") ;; TODO: NOW CALLED TAGS AND IN LOWERCASE
 (indent "0em")
 (multlinewidth "85%")
 (tagindent ".8em")
@@ -1244,27 +1244,28 @@ For further information about MathJax options, see the MathJax documentation:
 			 (const "right")
 
 (defcustom org-html-mathjax-template
-  "
-MathJax.Hub.Config({
-displayAlign: \"%ALIGN\",
-displayIndent: \"%INDENT\",
-
-\"HTML-CSS\": { scale: %SCALE,
-linebreaks: { automatic: \"%LINEBREAKS\" },
-webFont: \"%FONT\"
-   },
-SVG: {scale: %SCALE,
-  linebreaks: { automatic: \"%LINEBREAKS\" },
-  font: \"%FONT\"},
-NativeMML: {scale: %SCALE},
-TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
-   MultLineWidth: \"%MULTLINEWIDTH\",
-   TagSide: \"%TAGSIDE\",
-   TagIndent: \"%TAGINDENT\"
- }
-});
+  "