Re: [BUG] ox-latex produces broken references to src code listings without caption (was: [BUG] org-lint tells to move #+name to wrong place in results block)

2024-01-26 Thread gerard . vermeulen




On 25.01.2024 13:41, Ihor Radchenko wrote:

gerard.vermeu...@posteo.net writes:

I have found that CAPTION keywords  in the "name-result-example" in 
the

manual are essential to produce correct links.


It should not be essential. What you demonstrated is two bugs in Org 
mode.



In case the relevant blocks have e.g. ":exports both", Org handles
this, but:
1. HTML export requires captions to produce links with unequivocal
"link texts" which are numbers in the HTML output.


Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ea529007d


I confirm that it is fixed.




2. LaTeX export requires captions to produce captions with labels like
=\caption{\label{path}desc}=.


`org-latex-link' assumes that it is safe to use
\ref{} in order to refer to an existing src 
block.

However, it is not true.

`org-latex-src-block--engraved', `org-latex-src-block--minted',
and `org-latex-src-block--listings' only produce a label when src block
has a caption.

We should generally not need to put a caption in order to refer to a
source block listing. At least, it does not look like we need it from
https://tex.stackexchange.com/questions/438260/referencing-without-captions-appearing-but-keeping-numbering

Thoughts? Ideas?


I do not see how to put the LaTeX hypertarget inside listings where it 
is

needed, because those listings are not floating.

I looked at `org-latex-src-block--verbatim' that uses the LaTeX
captionof macro, by exporting
--- begin narrow lines below ---
#+caption: caption or comment
#+name: name
#+begin_src emacs-lisp
(+ 1 2)
#+end_src

Link \ref{name}.
--- end narrow lines above

But, I cannot get the captionof macro working after:
exporting the snippet above using `org-latex-src-block--listings'
without caption and adding the captionof macro by hand
(LuaLaTeX does not compile).




Tested on example below:
Produced by listing [[IN]].

#+name: OUT
#+RESULTS: IN
#+begin_src emacs-lisp :exports code
6
#+end_src

#+header: :wrap "src emacs-lisp :exports code"
#+name: IN
#+begin_src emacs-lisp :exports both
6
#+end_src

Listing [[IN]] produces listing [[OUT]].

 From inspecting HTML or LaTeX output using this example
for the difference between with and without captions it is
easy to see that only with captions the output is correct.


Regards -- Gerard



Re: [BUG] beamer export

2024-01-26 Thread Ihor Radchenko
Leo Butler  writes:

>> Apparently, LaTeX has really hard time processing verbatim code inside
>> beamer frames.
>
> I looked again at the solution here:
> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>
> and it errors out with a recent version of pdflatex:
>
>This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) 
> (preloaded format=pdflatex)
>
> This is, apparently, a known problem:
>
> https://github.com/josephwright/beamer/issues/360
>
> The end of that issue report includes a work-around that we might apply
> in org. I have attached a patch for your feedback. The example that
> stimulated this discussion compiles with the patch and the testsuite
> shows no errors related to it.

Thanks!
I have concerns about your approach though.

You are replacing all the frame environments with custom environment
unconditionally. However, custom environment has downsides. For example,
\againframe will stop working, as pointed earlier in the linked beamer
thread
https://github.com/josephwright/beamer/issues/360#issuecomment-708705250

Since the problem appears only when the frame contents contains
\end{frame}, it may be sufficient to replace the standard frame
environment with the workaround only in such scenario.

> +;; Needed to set-up Beamer export.
> +(defconst org-beamer--frame-environment
> +  (concat "orgframe" (org-id-uuid))
> +  "Name of the beamer frame environment.
> +This is randomized to prevent collisions.")

Please use constant name. (org-id-uuid) makes export randomized for no
good reason.

>  ;; Install a default set-up for Beamer export.
>  (unless (assoc "beamer" org-latex-classes)
>(add-to-list 'org-latex-classes
> -'("beamer"
> -  "\\documentclass[presentation]{beamer}"
> +`("beamer"
> +  ,(concat "\\documentclass[presentation]{beamer}\n"
> +  ;; Define an alias for the beamer frame environment
> + "\\newenvironment<>{"
> + org-beamer--frame-environment
> + "}[1][]{\\begin{frame}[environment="
> + org-beamer--frame-environment
> + ",#1]}{\\end{frame}}")

Please use `org-beamer-template' rather than modifying the class.
Modifying the class may confuse users.

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



Re: [BUG] Footnotes in section titles

2024-01-26 Thread Ihor Radchenko
Max Nikulin  writes:

> On 24/01/2024 19:11, Ihor Radchenko wrote:
>> The \section[...]{...} approach may work, but it is tricky - it is
>> completely up to the `org-latex-classes'. So, we may have to use regexp
>> replacement, which might be fragile.
>
> ox supports the ALT_TITLE property and ox-latex already adds it using 
> regexp. So it should possible to define this property with stripped 
> footnote by an export filter. I have not tested it, but ALT_TITLE and 
> @@latex:\protect@@ might be a workaround.

Good point.
See the attached tentative patch.
>From b4d896f7daf5e7b2cf8dabfba5b9dbf212f0c54c Mon Sep 17 00:00:00 2001
Message-ID: 
From: Ihor Radchenko 
Date: Fri, 26 Jan 2024 13:07:13 +0100
Subject: [PATCH] org-latex-headline: Prevent footnotes in TOC/footers

* lisp/ox-latex.el (org-latex-headline): When headline contains
footnotes and does not have ALT_TITLE, arrange alternative title that
will appear in TOC and footers to not have any footnotes.

Reported-by: Eric Anderson 
Link: https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093...@gmail.com
---
 lisp/ox-latex.el | 26 +++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index df20345f8..4f5258ea1 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2312,9 +2312,22 @@ (defun org-latex-headline (headline contents info)
;; with \texttt.
(code . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o
(verbatim . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o)))
+   ;; Create a temporary export backend that strips footnotes from title.
+   ;; Footnotes are not allowed in \section and similar
+   ;; commands that contribute to TOC and footers.
+   ;; See https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093...@gmail.com
+   ;; https://texfaq.org/FAQ-ftnsect
+   (section-no-footnote-backend
+(org-export-create-backend
+ :parent section-backend
+ :transcoders
+ `((footnote-reference . ignore
 	   (text
 	(org-export-data-with-backend
 	 (org-element-property :title headline) section-backend info))
+   (text-no-footnote
+(org-export-data-with-backend
+	 (org-element-property :title headline) section-no-footnote-backend info))
 	   (todo
 	(and (plist-get info :with-todo-keywords)
 		 (let ((todo (org-element-property :todo-keyword headline)))
@@ -2328,6 +2341,9 @@ (defun org-latex-headline (headline contents info)
 	   ;; The latter is required to remove tags from toc.
 	   (full-text (funcall (plist-get info :latex-format-headline-function)
 			   todo todo-type priority text tags info))
+   (full-text-no-footnote
+(funcall (plist-get info :latex-format-headline-function)
+		 todo todo-type priority text-no-footnote tags info))
 	   ;; Associate \label to the headline for internal links.
 	   (headline-label (org-latex--label headline info t t))
 	   (pre-blanks
@@ -2385,10 +2401,14 @@ (defun org-latex-headline (headline contents info)
   (string-match-p "\\" v)
   (format "\\stopcontents[level-%d]" level)
 		info t)
-	  (if (and opt-title
-		   (not (equal opt-title full-text))
+	  (if (and (or (and opt-title (not (equal opt-title full-text)))
+   ;; Heading contains footnotes.  Add optional title
+   ;; version without footnotes to avoid footnotes in
+   ;; TOC/footers.
+   (and (not (equal full-text-no-footnote full-text))
+(setq opt-title full-text-no-footnote)))
 		   (string-match "\\`\\(.+?\\){" section-fmt))
-	  (format (replace-match "\\1[%s]" nil nil section-fmt 1)
+  (format (replace-match "\\1[%s]" nil nil section-fmt 1)
 		  ;; Replace square brackets with parenthesis
 		  ;; since square brackets are not supported in
 		  ;; optional arguments.
-- 
2.43.0


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


Re: [BUG] Footnotes in section titles

2024-01-26 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> ...
> \title{Lorem ipsum dolor\thanks{blah blah}}
> ...
>
> Org does not have support for this type of notes in the #+title or
> #+author keywords. For LaTeX you can use a macro.

Hmm.
The reason footnotes are not allowed in #+title and other keywords is
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7ebe87e2d5fb6c

Inserting footnote references in parsed keywords (e.g., TITLE or
CAPTION) can lead to subtle bugs.  Indeed, it is impossible to know in
time if that particular footnote is going to be used in the output,
and, therefore, if it should count, e.g., in
`org-export-get-footnote-number'.

However, I am not sure about that line of reasoning - we generally don't
know if *any* given footnote reference is going to be used in the output
or not because export backend may skip references or whole parts of the
original Org file. Same for user filters.

So, I am leaning towards reverting that commit - that will allow things
like

#+TITLE: This is a test title[fn::This is test]

If we need special handling for footnotes in title (like using \thanks
instead of \footnote), it is easy.

> ... For backends like odt
> it is trickier. Look at this thread:
>
> https://lists.gnu.org/archive/html/emacs-humanities/2024-01/msg0.html
>
> I think it would be nice if Org had some kind of support for notes in
> #+title and #+author...

No idea about how to do it in ODT. If someone familiar with OpenDocument
spec can help, it would be welcome.

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



Re: [BUG] Footnotes in section titles

2024-01-26 Thread Juan Manuel Macías
Ihor Radchenko writes:

> Juan Manuel Macías  writes:
>
>> ...
>> \title{Lorem ipsum dolor\thanks{blah blah}}
>> ...
>>
>> Org does not have support for this type of notes in the #+title or
>> #+author keywords. For LaTeX you can use a macro.
>
> Hmm.
> The reason footnotes are not allowed in #+title and other keywords is
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7ebe87e2d5fb6c
>
> Inserting footnote references in parsed keywords (e.g., TITLE or
> CAPTION) can lead to subtle bugs.  Indeed, it is impossible to know in
> time if that particular footnote is going to be used in the output,
> and, therefore, if it should count, e.g., in
> `org-export-get-footnote-number'.
>
> However, I am not sure about that line of reasoning - we generally don't
> know if *any* given footnote reference is going to be used in the output
> or not because export backend may skip references or whole parts of the
> original Org file. Same for user filters.
>
> So, I am leaning towards reverting that commit - that will allow things
> like
>
> #+TITLE: This is a test title[fn::This is test]
>
> If we need special handling for footnotes in title (like using \thanks
> instead of \footnote), it is easy.

I completely agree. I think it would be a great improvement, since, as
Colin Baxter says, in academic articles it is a very common practice to
add foot notes to the title of the article or the name of the author.

As for the \thanks{} command, org exports the keyword #+email within a
\thanks{} command as '\author{Name\thanks{email}}0. I don't think two
\thanks macros collide within author (assuming the user adds the email
and puts a footnote in #+author. Anyway, I think the most common thing
is to put the email below the author's name, not as a footnote, but that
is another topic and also depends on the style of each publication,
journal, etc.

>> ... For backends like odt
>> it is trickier. Look at this thread:
>>
>> https://lists.gnu.org/archive/html/emacs-humanities/2024-01/msg0.html
>>
>> I think it would be nice if Org had some kind of support for notes in
>> #+title and #+author...
>
> No idea about how to do it in ODT. If someone familiar with OpenDocument
> spec can help, it would be welcome.

I don't have much idea about odt, but I think the problem comes from a
type of nesting that is not allowed in the odt xml. I think org exports
#+author inside the initial-creator tag:

(format "%s\n" author)

And within that tag the code for a footnote produces an error when
opening the document. If the footnote is placed right after
, there would be no problem.

Best regards,

Juan Manuel 
  

-- 
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño 
editorial y ortotipografía




Re: [PATCH] testing: Delete duplicate tests

2024-01-26 Thread Ihor Radchenko
Ilya Chernyshov  writes:

> Ihor Radchenko  writes:
>
>> It has been a while since the last update in this thread.
>> Ilya, do you need any help with the patch?
>
> Hi, here is the updated patch.

Thanks!

What about the attached amendment?
It should simplify things significantly.

>From b14840aa81784547a6dd03aec510e23c898d97ec Mon Sep 17 00:00:00 2001
Message-ID: 
From: Ihor Radchenko 
Date: Fri, 26 Jan 2024 14:21:55 +0100
Subject: [PATCH] test-duplicates-detector.el: Do not search duplicates inside
 progn-like forms

*
testing/lisp/test-duplicates-detector.el (test-duplicates-progn-forms):
New variable holding a list of forms equivalent to `progn'.

*
testing/lisp/test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively):
Refactor.  Skip duplicate checks inside immediate children of
`progn'-like constructs.

* testing/lisp/test-ob-R.el (test-ob-R/results-file):
* testing/lisp/test-ob-haskell-ghci.el (ob-haskell/session-named-none-means-one-shot-sessions):
* testing/lisp/test-ob-lob.el (test-ob-lob/call-with-header-arguments):
(test-ob-lob/caching-call-line):
(test-ob-lob/named-caching-call-line):
* testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1):
(test-ob/inline-src_blk-default-results-replace-line-2):
(test-ob/inline-src_blk-manual-results-replace):
(test-ob/inline-src_blk-results-silent):
(test-ob/just-one-results-block):
(test-ob/remove-inline-result):
(test-ob/goto-named-src-block):
* testing/lisp/test-ol.el (test-org-link/toggle-link-display):
* testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp):
(test-org-agenda/sticky-agenda-filter-preset):
* testing/lisp/test-org-element.el:
(test-org-element/cache-headline):
* testing/lisp/test-org-fold.el:
(test-org-fold/set-visibility-according-to-property):
* testing/lisp/test-org-list.el:
(test-org-list/list-navigation):
(test-org-list/move-item-down):
(test-org-list/move-item-up):
* testing/lisp/test-org-src.el:
(test-org-src/point-outside-block):
* testing/lisp/test-org-table.el:
(test-org-table/org-at-TBLFM-p):
(test-org-table/org-table-TBLFM-begin):
(test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines):
(test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks):
* testing/lisp/test-org.el:
(test-org/goto-sibling):
(test-org/org-ctrl-c-ctrl-c):
(test-org/forward-element):
(test-org/backward-element):
(test-org/up-element): Remove unnecessary `org-test-ignore-duplicate'.
---
 testing/lisp/test-duplicates-detector.el |  34 ---
 testing/lisp/test-ob-R.el|  21 ++--
 testing/lisp/test-ob-haskell-ghci.el |   3 +-
 testing/lisp/test-ob-lob.el  |  87 -
 testing/lisp/test-ob.el  | 117 ++-
 testing/lisp/test-ol.el  |  35 ---
 testing/lisp/test-org-agenda.el  |   9 +-
 testing/lisp/test-org-element.el |  18 ++--
 testing/lisp/test-org-fold.el|  29 +++---
 testing/lisp/test-org-list.el|  31 +++---
 testing/lisp/test-org-src.el |   3 +-
 testing/lisp/test-org-table.el   |  93 +-
 testing/lisp/test-org.el |  27 ++
 13 files changed, 232 insertions(+), 275 deletions(-)

diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el
index d39092a9e..d6f8aca5a 100644
--- a/testing/lisp/test-duplicates-detector.el
+++ b/testing/lisp/test-duplicates-detector.el
@@ -41,6 +41,14 @@ (require 'org-test "../testing/org-test")
 
  Variables
 
+(defvar test-duplicates-progn-forms
+  '( progn
+ org-test-with-temp-text
+ org-test-with-temp-text-in-file
+ org-test-ignore-duplicate)
+  "List of forms equivalent to `progn'.
+Immediate children inside these are not checked for duplicates.")
+
 (defvar test-duplicates-detector-file-path
   (expand-file-name "test-duplicates-detector.el"
 (expand-file-name "lisp" org-test-dir)))
@@ -221,22 +229,20 @@ (defun test-duplicates-detector--search-forms-recursively (form form-path)
 (symbol-1 . sexp-order-1) (symbol-2 . sexp-order-2))
 
 Write each form to `test-duplicates-detector-forms'"
-  (dotimes (iter (length form))
-(when (and
-	   (car-safe (nth iter form))
-	   (not
-	(eq (car-safe (nth iter form))
-		'org-test-ignore-duplicate)))
-  (push iter (alist-get
-		  (nth iter form)
-  (alist-get form-path test-duplicates-detector-forms
- nil nil #'equal)
-  nil nil #'equal-including-properties))
-  (unless (memq (car-safe (nth iter form))
+  (let ((idx 0))
+(dolist (sub-form form)
+  (unless (memq (car-safe sub-form) test-duplicates-progn-forms)
+(push idx (alist-get
+		   sub-form
+   (alist-get form-path test-duplicates-detector-forms
+  nil nil #'equal)
+   nil nil #'equal-including-properties)))
+  (unless (memq (car-saf

Re: New try at multi-lingual export to latex/pdf using pdflatex and babel

2024-01-26 Thread Ihor Radchenko
"Pedro A. Aranda"  writes:

> I've been reading a bit. What I propose is an alternative way to handle 
> all the tricky parts of font and character handling with fontspec in 
> lualatex and xetex. This package restricts the use of the ams* packages 
> to pdflatex, because fontenc handles that internally and produces 
> package collisions.

> Attached is the final version of the patch.

Thanks!
May you also add a comment to the code explaining the rationale right there?

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



Re: [BUG] beamer export

2024-01-26 Thread Ihor Radchenko
Leo Butler  writes:

> Attached is a second patch to de-lint the ox-beamer tutorial.

Thanks!
Applied, onto master.
https://git.sr.ht/~bzg/worg/commit/23c54e97

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



Re: On org-syntax and IANA MIME type registration

2024-01-26 Thread Ihor Radchenko
[CCing Wes Hardaker]

Timothy  writes:

> With the recent mention of the text/org mime type, and registering it as an 
> IANA
> in-tree MIME type in particular, I’d like to draw attention to this part of
> :
>
>> When review is required, a change request may be denied if it renders 
>> entities
>> that were valid under the previous definition invalid under the new 
>> definition.

AFAIU from the other instances of word "entities" in the document, it
refers to files of Org type. So, the above is meant that previously
valid Org documents cannot become invalid.

> While the org-syntax document is a work in progress to accurately describe the
> current state of affairs, there are currently supported syntactic elements 
> that
> I think are broadly seen as “would be nice if we didn’t do that”. For example:
> the special switch syntax in babel headers, and support for $-maths.

I do not think that $-math or switches are significant enough to render
Org mode documents invalid. They are minor changes.

> This does make me wonder if we should actually try to register a slightly
> different org-syntax to “what org-mode parses”, without these elements that we
> now think we’re better off without, but have org-mode still parse them.

Maybe for $...$, but not for switches. We may instead make the syntax
description broad enough to allow switches without explicitly describing
how they should be interpreted.

> My thinking is we don’t want to lock ourselves into a situation where we would
> /like/ to deprecate certain syntax over the long term, but are unable to do so
> without diverging from the IANA-registered specification, and can’t register 
> the
> change in syntax because of the paragraph I’ve quoted.

I don't think that it is going to be a major problem.

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



Re: bug#68687: [PATCH] Use text/org media type

2024-01-26 Thread Ihor Radchenko
Eli Zaretskii  writes:

>> The spec is still not fully finalized, so we are not yet initiating the
>> registration, as we will need to repeat it again if we decide to make
>> further changes (https://www.rfc-editor.org/rfc/rfc6838.html#section-5.5)
>
> I hope the process of finalizing the Org spec and moving to its
> registration will not fall between the cracks.

No worries. We are slowly working on the spec. See
https://git.sr.ht/~bzg/worg/log/master/item/org-syntax.org

But finalizing the whole thing will not be fast, given our plans to
extend Org mode syntax to better suit software manuals as requested by
RMS, and to address several long-standing issues with escaping edge
cases.

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



Re: [PATCH] org-babel-tangle: Do not allow tangling into self

2024-01-26 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> The attached patch makes Org throw an error in such scenario.
>
> This is a great feature (and it deserves a test, given it protects from
> data loss).  For what is worth, I remember making this error at least
> twice in the past year.  (Git saved me in both cases, fortunately.)

Applied, onto main; after adding a test.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ef23b4706

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



Re: [BUG] Footnotes in section titles

2024-01-26 Thread Max Nikulin

On 26/01/2024 19:53, Ihor Radchenko wrote:

So, I am leaning towards reverting that commit - that will allow things
like

#+TITLE: This is a test title[fn::This is test]


I hope, document metadata will be generated with stripped footnotes.




Re: New try at multi-lingual export to latex/pdf using pdflatex and babel

2024-01-26 Thread Pedro Andres Aranda Gutierrez
Hi,

Here you are. I hope the couple of words suffice ;-)

Best, /PA

On Fri, 26 Jan 2024 at 14:25, Ihor Radchenko  wrote:

> "Pedro A. Aranda"  writes:
>
> > I've been reading a bit. What I propose is an alternative way to handle
> > all the tricky parts of font and character handling with fontspec in
> > lualatex and xetex. This package restricts the use of the ams* packages
> > to pdflatex, because fontenc handles that internally and produces
> > package collisions.
>
> > Attached is the final version of the patch.
>
> Thanks!
> May you also add a comment to the code explaining the rationale right
> there?
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet
From cc6ea05f1fc31aafb3db737bf033086422aa770f Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" 
Date: Fri, 26 Jan 2024 18:46:14 +0100
Subject: [PATCH] Refine font management for lualatex and xetex

---
 lisp/org.el | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

lisp/org.el: Use fontspec for lualatex and xetex in 
  org-latex-default-packages-alist

diff --git a/lisp/org.el b/lisp/org.el
index 796545392..24ef515f9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3421,15 +3421,17 @@ header, or they will be appended."
 	  (default-value var)))
 
 (defcustom org-latex-default-packages-alist
-  '(("AUTO" "inputenc"  t ("pdflatex"))
+  '(("" "amsmath"   t ("lualatex" "xetex"))
+("" "fontspec"  t ("lualatex" "xetex"))
+("AUTO" "inputenc"  t ("pdflatex"))
 ("T1"   "fontenc"   t ("pdflatex"))
 ("" "graphicx"  t)
 ("" "longtable" nil)
 ("" "wrapfig"   nil)
 ("" "rotating"  nil)
 ("normalem" "ulem"  t)
-("" "amsmath"   t)
-("" "amssymb"   t)
+("" "amsmath"   t ("pdflatex"))
+("" "amssymb"   t ("pdflatex"))
 ("" "capt-of"   nil)
 ("" "hyperref"  nil))
   "Alist of default packages to be inserted in the header.
@@ -3440,6 +3442,8 @@ incompatibility with another package you are using.
 The packages in this list are needed by one part or another of
 Org mode to function properly:
 
+- fontspec: for font ans character selection in lualatex and xetex
+if you use fontspec, you need to add amsmath /before/
 - inputenc, fontenc:  for basic font and character selection
 - graphicx: for including images
 - longtable: For multipage tables
-- 
2.34.1



Re: [BUG] beamer export

2024-01-26 Thread Leo Butler
On Fri, Jan 26 2024, Ihor Radchenko  wrote:

> Leo Butler  writes:
>
>>> Apparently, LaTeX has really hard time processing verbatim code inside
>>> beamer frames.
>>
>> I looked again at the solution here:
>> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>>
>> and it errors out with a recent version of pdflatex:
>>
>>This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) 
>> (preloaded format=pdflatex)
>>
>> This is, apparently, a known problem:
>>
>> https://github.com/josephwright/beamer/issues/360
>>
>> The end of that issue report includes a work-around that we might apply
>> in org. I have attached a patch for your feedback. The example that
>> stimulated this discussion compiles with the patch and the testsuite
>> shows no errors related to it.
>
> Thanks!
> I have concerns about your approach though.
>
> You are replacing all the frame environments with custom environment
> unconditionally. However, custom environment has downsides. For example,
> \againframe will stop working, as pointed earlier in the linked beamer
> thread
> https://github.com/josephwright/beamer/issues/360#issuecomment-708705250

The comment that you are citing shows how to define the custom
environment so that \againframe works correctly. See the attachment
`beamer-example-againframe.tex' and pdf. You can see that \againframe
works with the custom environment.

>
> Since the problem appears only when the frame contents contains
> \end{frame}, it may be sufficient to replace the standard frame
> environment with the workaround only in such scenario.

Yes, that might be true. But my feeling is that it would be simpler and
more robust to use the custom frame environment in most cases.

>
>> +;; Needed to set-up Beamer export.
>> +(defconst org-beamer--frame-environment
>> +  (concat "orgframe" (org-id-uuid))
>> +  "Name of the beamer frame environment.
>> +This is randomized to prevent collisions.")
>
> Please use constant name. (org-id-uuid) makes export randomized for no
> good reason.

There is a good reason to randomize (or at least make customize-able)
the environment name: so that beamer code generated by ox-beamer can be
safely inserted into org files and exported by ox-beamer. With a fixed
name for the environment, we will have just recreated the original
source of the bug report. As a compromise, in the attached patch, I have
made the environment name customize-able.

>
>>  ;; Install a default set-up for Beamer export.
>>  (unless (assoc "beamer" org-latex-classes)
>>(add-to-list 'org-latex-classes
>> -   '("beamer"
>> - "\\documentclass[presentation]{beamer}"
>> +   `("beamer"
>> + ,(concat "\\documentclass[presentation]{beamer}\n"
>> +  ;; Define an alias for the beamer frame 
>> environment
>> + "\\newenvironment<>{"
>> + org-beamer--frame-environment
>> + "}[1][]{\\begin{frame}[environment="
>> + org-beamer--frame-environment
>> + ",#1]}{\\end{frame}}")
>
> Please use `org-beamer-template' rather than modifying the class.
> Modifying the class may confuse users.

Ok, I have done so.

The docstring of `org-latex-classes' says:

The HEADER-STRING is the header that will be inserted into the
LaTeX file.  It should contain the \documentclass macro, and
anything else that is needed for this setup.

>From that, I figured that would be the correct place to put that
\newenvironment command. I have moved it, as requested.

Please see the revised patch. I believe that I have taken into account
your suggestions.

Leo

% Created 2024-01-26 Fri 11:42
% Intended LaTeX compiler: lualatex
\documentclass[bigger]{beamer}
\newenvironment<>{OrgFrame}[1][]{\begin{frame}[environment=OrgFrame,#1]}{\end{frame}}
\usetheme{default}

\begin{document}
\begin{OrgFrame}[label=repeatit,fragile]{Verbatim inside a Special Frame Environment}
\tiny
\begin{verbatim}
\begin{frame}[label={sec:org8bc49cc}]{Two columns}
\begin{columns}
\begin{column}{0.4\columnwidth}
\begin{itemize}
\item this slide consists of two columns
\item the first (left) column has no heading and consists of text
\item the second (right) column has an image and is enclosed in an
\alert{example} block
\end{itemize}
\end{column}
\end{verbatim}
\end{OrgFrame}

\againframe<2>{repeatit}
\end{document}


beamer-example-againframe.pdf
Description: beamer-example-againframe.pdf
From bfd182b9ca86c2db5cd514cad0a11fd3f5bd8934 Mon Sep 17 00:00:00 2001
From: Leo Butler 
Date: Thu, 25 Jan 2024 09:48:20 -0600
Subject: [PATCH] lisp/ox-beamer.el:  customize the beamer frame environment
 name

* lisp/ox-beamer.el (org-beamer-frame-environment): new customize
variable that contains the name of an environment that serves as an
alias for the beamer frame environment.  The environment's definition
is appended to

Appending results from babel block

2024-01-26 Thread Ken Mankoff
Hello,

I'd like to append results from a babel block, but without the leading ":" that 
sometimes appears. Is this possible. I'm using v9.7-pre.

This works, but has leading colons:

#+BEGIN_SRC bash :results append
echo $(date)
#+END_SRC

#+RESULTS:
: Fri Jan 26 07:17:00 PM PST 2024
: Fri Jan 26 07:17:01 PM PST 2024
: Fri Jan 26 07:17:02 PM PST 2024
: Fri Jan 26 07:17:04 PM PST 2024

Setting :results append raw

prepends - understandably because 'raw' means there is no delimiter, and no way 
to know where the results end.

Weirdly,

:results append drawer

Appends result #2, but then inserts all results after the first.

Is this last behavior a bug? Any way to have true 'append' w/o ":"?

Thanks,

  -k.



Re: bug#68687: [PATCH] Use text/org media type

2024-01-26 Thread Richard Stallman
[[[ To any NSA and FBI agents reading my email: please consider]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

What is the purpose for which text/org would be used?
In what situations would we want to send files in Org format
and why would it be useful to formally label them?

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





Re: [patch] improved: add TTL as defcustom to ox-icalendar

2024-01-26 Thread Jack Kamm
Ihor Radchenko  writes:

> This does not look right. Did you try to export anything with this patch
> applied? You are passing multiple string arguments to `format'.
>
> Finally, I think that we can document the new keyword in the manual.  

I've updated the patch so that it applies cleanly onto the latest main,
and also fixed a few issues including the ones Ihor pointed out above.

Let me know if there are any issues -- otherwise I'll apply it to main
in the near future.

>From 24a6bc78c74d16a6aa7dbd081be9f626b20bbf20 Mon Sep 17 00:00:00 2001
From: Detlef Steuer 
Date: Sat, 4 Feb 2023 21:40:09 +0100
Subject: [PATCH] lisp/ox-icalendar.el: Add time-to-live functionality to
 ox-icalendar

This commit adds functionality for ox-icalendar to set X-PUBLISHED-TTL
in the exported ICS, which advises a subscriber to the exported ICS
file to reload after the given time interval.

* lisp/ox-icalendar.el (org-icalendar-ttl): New option to set
X-PUBLISHED-TTL in exported ICS
(icalendar): Add ICAL-TTL export keyword
(org-icalendar--vcalendar): Add argument for TTL
(org-icalendar-template, org-icalendar-export-current-agenda,
org-icalendar--combine-files): Pass TTL to `org-icalendar--vcalendar'

Co-authored-by: Ihor Radchenko 
Co-authored-by: Jack Kamm 
---
 doc/org-manual.org   |  9 +
 etc/ORG-NEWS | 17 
 lisp/ox-icalendar.el | 47 ++--
 3 files changed, 67 insertions(+), 6 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 7e5ac0673..8fe79ee45 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16369,6 +16369,15 @@ information.  The iCalendar standard defines three visibility classes:
 The server should treat unknown class properties the same as
 =PRIVATE=.
 
+#+cindex: @samp{ICAL-TTL}, keyword
+#+vindex: org-icalendar-ttl
+The exported iCalendar file can advise clients how often to check for
+updates.  This duration can be set globally with the
+~org-icalendar-ttl~ variable, or on a per-document basis with the
+=ICAL-TTL= keyword.  This option should be set using the iCalendar
+notation for time durations; consult the docstring of
+~org-icalendar-ttl~ for more details.
+
 Exporting to iCalendar format depends in large part on the
 capabilities of the destination application.  Some are more lenient
 than others.  Consult the Org mode FAQ for advice on specific
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 1bf7eb5b4..5a93788e9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -424,6 +424,23 @@ The change is breaking when ~org-use-property-inheritance~ is set to ~t~.
 
 The =TEST= parameter is better served by Emacs debugging tools.
 ** New and changed options
+*** New custom setting ~org-icalendar-ttl~ for the ~ox-icalendar~ backend
+
+The option ~org-icalendar-ttl~ allows to advise a subscriber to the
+exported =.ics= file to reload after the given time interval.
+
+This is useful i.e. if a calendar server subscribes to your exported
+file and that file is updated regularly.
+
+See IETF RFC 5545, Section 3.3.6 Duration and
+https://en.wikipedia.org/wiki/ICalendar#Other_component_types for
+details.
+
+Default for ~org-icalendar-ttl~ is ~nil~.  In that case the setting
+will not be used in the exported ICS file.
+
+The option may also be set using the =ICAL-TTL= keyword.
+
 *** The default value of ~org-attach-store-link-p~ is now ~attached~
 
 Now, after attaching a file, =[[attach:...]]= link to the attached file
diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index cb416a68f..584c78fcf 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -331,6 +331,32 @@ (defcustom org-icalendar-date-time-format ":%Y%m%dT%H%M%S"
 	  (const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
 	  (string :tag "Explicit format")))
 
+(defcustom org-icalendar-ttl nil
+  "Time to live for the exported calendar.
+
+Subscribing clients to the exported ics file can derive the time
+interval to read the file again from the server.  One example of such
+client is Nextcloud calendar, which respects the setting of
+X-PUBLISHED-TTL in ICS files.  Setting `org-icalendar-ttl' to \"PT1H\"
+would advise a server to reload the file every hour.
+
+See https://icalendar.org/iCalendar-RFC-5545/3-8-2-5-duration.html
+for a complete description of possible specifications of this
+option.  For example, \"PT1H\" stands for 1 hour and
+\"PT0H27M34S\" stands for 0 hours, 27 minutes and 34 seconds.
+
+The default value is nil, which means no such option is set in
+the ICS file. This option can also be set on a per-document basis
+with the ICAL-TTL export keyword."
+  :group 'org-export-icalendar
+  :type '(choice
+  (const :tag "No refresh period" nil)
+  (const :tag "One hour" "PT1H")
+  (const :tag "One day" "PT1D")
+  (const :tag "One week" "PT7D")
+  (string :tag "Other"))
+  :package-version '(Org . "9.7"))
+
 (defvar org-icalendar-after-save-hook nil
   "Hook run after an iCalendar file has been saved.
 This

Re: [PATCH] testing: Delete duplicate tests

2024-01-26 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> What about the attached amendment?
> It should simplify things significantly.

Sorry, in my previous patch the test that checks the detector itself was not
even run in 'make test' because of incorrect test prefix.

Your patch does not work as you expect. Could you please revise it?

>From 6eb03414ac4eb8b64160b24dc7fcb805bf782310 Mon Sep 17 00:00:00 2001
From: Ihor Radchenko 
Date: Fri, 26 Jan 2024 14:21:55 +0100
Subject: [PATCH] test-duplicates-detector.el: Add correct prefix to the
 deftest, check if consp

*
testing/lisp/test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively):

*
testing/lisp/test-duplicates-detector.el (test-org-tests/test-duplicates-detector-testing-find-duplicates):
Add correct prefix so that the test could be executed
---
 testing/lisp/test-duplicates-detector.el | 25 
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el
index d6f8aca5a..aed8034ee 100644
--- a/testing/lisp/test-duplicates-detector.el
+++ b/testing/lisp/test-duplicates-detector.el
@@ -231,22 +231,23 @@ FORM-PATH is list of the form:
 Write each form to `test-duplicates-detector-forms'"
   (let ((idx 0))
 (dolist (sub-form form)
-  (unless (memq (car-safe sub-form) test-duplicates-progn-forms)
-(push idx (alist-get
-		   sub-form
-   (alist-get form-path test-duplicates-detector-forms
-  nil nil #'equal)
-   nil nil #'equal-including-properties)))
-  (unless (memq (car-safe sub-form)
-		'(should-not should should-error))
-	(test-duplicates-detector--search-forms-recursively
- sub-form
- (append form-path (list (cons (car sub-form) idx)
+  (when (consp sub-form)
+(unless (memq (car-safe sub-form) test-duplicates-progn-forms)
+  (push idx (alist-get
+		 sub-form
+ (alist-get form-path test-duplicates-detector-forms
+nil nil #'equal)
+ nil nil #'equal-including-properties)))
+(unless (memq (car-safe sub-form)
+		  '(should-not should should-error))
+	  (test-duplicates-detector--search-forms-recursively
+   sub-form
+   (append form-path (list (cons (car-safe sub-form) idx))
   (cl-incf idx
 
  Testing the detector itself
 
-(ert-deftest test-duplicates-detector-testing-find-duplicates ()
+(ert-deftest test-org-tests/test-duplicates-detector-testing-find-duplicates ()
   "Test `test-duplicates-detector--find-duplicates'."
   (should
(equal
-- 
2.41.0