Re: A probable beginner's mistake

2024-04-21 Thread Mike Gauland

On 22/04/24 06:46, emm.charpent...@free.fr wrote:

Inline "throwaway" code : src_emacs-lisp((+ 2 3)). Does*not*  work.


The inline code should be enclosed in curly brackets: src_emacs-lisp{(+ 
2 3)}


Re: Using org-latex-preview in other major modes

2024-04-21 Thread Karthik Chikmagalur
> Anyways, before I put this off for much longer, there is some more code
> attached. Live previews (and general environments) work now, and besides
> the above mentioned points there were no new surprises waiting—at least
> for getting the basic functionality to work.

Thank you for the update!  This looks promising.  I'll test it when I
have time.

> I did notice that precompilation being a bit flaky. In the end, this
> was the result of importing local packages; with the precompilation
> happening somewhere in /tmp/, access to these files wasn't given.
> haven't looked too closely into this—and it's probably a use-case
> that's specific to LaTeX-mode—but it seems worth considering

Sorry, I should have mentioned this in my original write-up.  There is a
reason for this, as explained below.  This issue should not be happening
in most cases though, so I'll need more details to help.

> (lots of people carry one big style file around that they include in
> all of their projects).

This is true of Org mode files that are intended for LaTeX export too,
but we avoid this problem in Org.

1. Why we precompile in /tmp:

   Precompilation is a blocking operation, so we want to do it as
   infrequently as possible. Imagine if LaTeX previews in every Org
   buffer/file you opened required a precompile step that blocked Emacs
   for 3 seconds.

   Precompiled dump files are identified by a hash that includes the
   preamble and a default-directory. If we precompile in /tmp (or some
   other fixed directory), we can reuse dump files for all Org buffers
   that have the same preamble, irrespective of where they're located.

   Precompiled files are stored in org-persist and don't expire for a
   long time.  So we'd like to avoid generating loads of them, and reuse
   them whenever possible.

   1a. Why is precompilation a blocking operation?

   It doesn't have to be, but including it in the async chain is a
   little annoying.  It can be made async in the future.

2. What happens if the user includes a directory-local .sty, .cls or
   other tex files in the header?

   When precompiling, we check the header to see if it has an \input{}
   or \include{} statement.  If it does, we assume that there are local
   dependencies and precompile it in the default-directory.  See
   org-latex-preview--create-tex-file for the implementation of this
   logic.

   Is there some other common way that a LaTeX file can have local
   dependencies?

3. How to force precompilation to occur in the default-directory instead
   of in /tmp:

   Based on 1 and 2, the easiest way would be to add an \input{} or
   \include{} statement to the preamble. The current test is very
   simple, you can even place it in a LaTeX comment and it should work.

Karthik



[DOC] Mismatch on doc regarding position of src block switches

2024-04-21 Thread João Pedro
Hi Org folks,

I've noticed that in (org)Literal Examples[0], when documenting the switches 
for example and source blocks, it is mentioned that they should be placed at 
the *end* of the #+BEGIN line, while both in (org)Structure of Code Blocks[1] 
and the Org Syntax document[2] the switches are documented to be placed right 
after the language (when appropriate), which is the correct placement for it.

I've also noticed that the Org Syntax for blocks (greater or lesser) don't 
mention example blocks having optional switches.

[0] https://orgmode.org/manual/Literal-Examples.html
[1] https://orgmode.org/manual/Structure-of-Code-Blocks.html
[2] https://orgmode.org/worg/org-syntax.html#Blocks

Cheers,

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)


Re: [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree (was: Make org-paste-subtree more predictable and useful)

2024-04-21 Thread Samuel Wales
to be clear, i am not suggesting violating outline mode's inability to
continue text after children, or violating levels.  let me redo.

i am ONLY saying i sometimes have the need to yank into the middle of the
text of an entry, even if what i am yanking is an entry.

it was probalby confusing that i provided 2 possibilities.  one was
removing stars, which leaves remaining questions about any descendants of
heading 1.  forget about that one.  the other was merely to yank heading 1
in the middle of heading 2's text.  both same level.

so here i go again with new decription: i am taking an entry and putting a
whole other entry into the middle of it at the same level like this:

===
* a new idea i had
regarding snicker snacks
* jabberwoky
some sophomoric comments on a poem

more sophomoric comments
===

becomes:

===
* jabberwoky
some sophomoric comments on a poem

* a new idea i had
regarding snicker snacks

more sophomoric comments
===

then i edit, probably turnign the new idea heading into a regular line.

if nobody else has this use case, then i would have to modify heading 1
before cutting and then paste it.  becauyse otherwise in my settings for
whatefer reason heading 1 ends up after heading 2.


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


Re: [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree (was: Make org-paste-subtree more predictable and useful)

2024-04-21 Thread Samuel Wales
not sure i am fully following but it seems useful.

i thought i would report on a use case thtat might or might not be
relevant.  it seems so.

i often have

===
* heading 1
text of heading 1
* heading 2
text of heading 2
|
and more text
===

where | just shows where i want to yank.

and i want to make it look like this.

===
* heading 2
text of heading 2

heading 1 [/possibly/ with star removed]
text of heading 1

and more text
===

in other words i want to combine two entries into one by cutting the first
and pasting it someplace in the middle of the second.  [or, if the star is
not removed, then i want to basically truncate heading 2 with putting
heading 1 in the middle of the text of heading 2.]

what seems to occur with my settings is that heading 1 gets inserted as a
sibling below heading 2.  which doesn't help much if heading 2 has lots of
text.  so i'd like something that can allow me to at least yank at point.
others might not have this use case.  it is rather frequent for me.


On Sunday, April 21, 2024, Ihor Radchenko  wrote:

> Philipp Kiefer  writes:
>
> > To be honest, I don't see much need for fine-grained special cases. I'd
> > be very happy with C-u yanking at the level of the heading at point and
> > C-u C-u yanking at one level below that, regardless of the exact
> > position of point. I realize that would mean C-u doubling what can
> > already be done by calling org-paste-subtree with point at the beginning
> > of a heading but accessing both options (paste as sibling or child) with
> > a single or repeat C-u seems more consistent to me than having one
> > depend on position and getting at the other via the command prefix.
>
> This feature is now implemented on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5b0b7f292
> Done.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>
>

-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


Re: Using org-latex-preview in other major modes

2024-04-21 Thread Tony Zorman
On Tue, Apr 09 2024 22:06, Tony Zorman wrote:
> As a very brief summary, one currently needs to—in addition to supplying
> a preamble and a way to recognise maths and environments—patch the
> following functions:
>
>   · org-latex-preview--place-from-elements
>   · org-latex-preview-auto--regenerate-overlay 
>   · org-latex-preview-auto--maybe-track-element-here
>   · org-latex-preview-live--ensure-overlay
>
> The last two are only needed for the "live" part of the live previews to
> work.
>
> I will clean the code up a little bit (hopefully by the weekend, but no
> promises),

Whoops!

Anyways, before I put this off for much longer, there is some more code
attached. Live previews (and general environments) work now, and besides
the above mentioned points there were no new surprises waiting—at least
for getting the basic functionality to work.

I did notice that precompilation being a bit flaky. In the end, this was
the result of importing local packages; with the precompilation
happening somewhere in /tmp/, access to these files wasn't given. I
haven't looked too closely into this—and it's probably a use-case that's
specific to LaTeX-mode—but it seems worth considering (lots of people
carry one big style file around that they include in all of their
projects).

  Tony



latex-latex-preview.el
Description: application/emacs-lisp

-- 
Tony Zorman | https://tony-zorman.com/


A probable beginner's mistake

2024-04-21 Thread emm . charpentier
I'd have sworn that org could evaluate inline "throwaway" code. But I seem to 
be mistaken.

The following :

#+options: toc:nil author:nil

For the life of me, I can't explain this:

#+name: foo
#+begin_src emacs-lisp :exports code :var x=3
  (+ 2 x)
#+end_src

Inline call to a predefined function : call_foo(x=4). Works.

Inline "throwaway" code : src_emacs-lisp((+ 2 3)). Does *not* work.

What the...



exports to (UTF8 buffer)


For the life of me, I can't explain this:

┌
│ (+ 2 x)
└

Inline call to a predefined function : `6'. Works.

Inline "throwaway" code : src_emacs-lisp((+ 2 3)). Does *not* work.

What the…



Could some kind soul explain the direction and magnitude of my mistake ?

Sincerely,

--
Emmanuel Charpentier



Re: `org-element-cache-map' misses elements at end of buffer

2024-04-21 Thread Ihor Radchenko
Morgan Smith  writes:

>> It is the time to refactor this function yet again.
>> (a tricky endeavour considering all the edge cases we can encounter when
>> there are changes in buffer while `org-element-cache-map' is mapping
>> over it).
>
> See attached for a way to break :from-pos as well.  I would like to help
> refactor but studying this function is a little dizzying for me.

At this point, it might be easier to rewrite the whole thing from
scratch, just based on the commentary (I tried my best to leave detailed
commentary explaining the intended logic). We have a decent test
coverage when mapping headings in buffer, so edge cases will be checked
by make test.

In particular, it might be a good idea to get rid of the idea of START
variable and just make use of AFTER-ELEMENT. For now, they serve kinda
the same purpose, but the latter was added because START was not enough
when the buffer is modified by FUNC.

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



Re: `org-element-cache-map' misses elements at end of buffer

2024-04-21 Thread Morgan Smith
Ihor Radchenko  writes:

>
> Hmm. :after-element keyword logic is broken. It does not account for the
> case when :after-element is past the START point.
>
> It is the time to refactor this function yet again.
> (a tricky endeavour considering all the edge cases we can encounter when
> there are changes in buffer while `org-element-cache-map' is mapping
> over it).

See attached for a way to break :from-pos as well.  I would like to help
refactor but studying this function is a little dizzying for me.


>From eb37560b9c94bed6e91d6834462173d0a6d7d44b Mon Sep 17 00:00:00 2001
From: Morgan Smith 
Date: Fri, 19 Apr 2024 10:46:28 -0400
Subject: [PATCH] test-org-element/cache-map: Add test for :from-pos

* testing/lisp/test-org-element.el (test-org-element/cache-map): Add
test for :from-pos.
---
 testing/lisp/test-org-element.el | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index ad4ff1ce9..a0dbc726e 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -4994,7 +4994,21 @@ Text
(equal
 '(org-data headline section drawer paragraph)
 (org-test-with-temp-text "* headline\n:DRAWER:\nparagraph\n:END:"
-  (org-element-cache-map #'car :granularity 'element)
+  (org-element-cache-map #'car :granularity 'element
+  (should
+   (equal
+;; This fails returning '(paragraph paragraph) because it returns
+;; the paragraph under "headline".  This is because at
+;; org-element.el:8028 we travel up the parents of drawer trying
+;; to find a paragraph.
+'(paragraph)
+(org-test-with-temp-text "* headline\nparagraph\n** subheading\n:DRAWER:\nparagraph\n:END:\n"
+  (let ((subheading (org-element-at-point)))
+(org-element-cache-map
+ #'car
+ :granularity 'element
+ :restrict-elements '(paragraph)
+ :from-pos (org-element-contents-begin subheading)))
 
 (ert-deftest test-org-element/cache ()
   "Test basic expectations and common pitfalls for cache."
-- 
2.41.0



Re: PATCH allow explicit style= in #+cite_export: biblatex

2024-04-21 Thread Pedro Andres Aranda Gutierrez
Hi Ihor,



On Sun, 21 Apr 2024 at 15:20, Ihor Radchenko  wrote:

> Pedro Andres Aranda Gutierrez  writes:
>
> > +: #+cite_export: biblatex backend=bibtex,style=numeric
>
> What about something like
>
> #+cite_export: biblatex backend=bibtex,bibstyle=numeric
>

Just tested on a work document. It generates
\usepackage[backend=bibtex,bibstyle=numeric]{biblatex}
which is a perfectly valid options string for biblatex and yes,
the PDF is generated without errors ;-)


>
> > BTW, I was thinking that maybe "\\`[^=]+=" may be better than matching
> > style= anywhere in the options string...
> > Open to discuss it...
>
> May you elaborate what exactly will be improved?
>

IMHO, the current solution of prepending "style=" forces the option string
to be

[PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline

2024-04-21 Thread Matt

  On Sat, 18 Nov 2023 16:54:39 +0100  Max Nikulin  wrote --- 
 > Hi,
 > 
 > Trying to figure out the origin of the confusion with
 > "bash -c bash /path/to/file-containing-the-source-code.sh"
 > I have faced an inconsistency with :cmdline treatment in ob-shell.el. I 
 > expect same results in the following cases:
 > 
 > #+begin_src bash :cmdline 1 2 3
 >printf "%s\n" "$1"
 > #+end_src
 > 
 > #+RESULTS:
 > : 1
 > 
 > #+begin_src bash :cmdline 1 2 3 :shebang #!/bin/bash
 >printf "%s\n" "$1"
 > #+end_src
 > 
 > #+RESULTS:
 > : 1 2 3
 > 
 > Emacs-28, Org is the current git HEAD.

AFAIU, the inconsistency is due to how the characters following :cmdline are 
interpreted when the subprocess call is made.

Consider the following, when only :cmdline is used:

# Evaluates like:
#
# bash -c "./sh-script-8GJzdG 1 2 3"
#
#+begin_src bash :cmdline 1 2 3
echo \"$1\"
#+end_src

#+RESULTS:
: 1

# Evaluates like:
#
# bash -c "./sh-script-8GJzdG \"1 2\" 3"
#
#+begin_src bash :cmdline "1 2" 3
echo \"$1\"
#+end_src

#+RESULTS:
: 1 2

For :cmdline alone, the characters following :cmdline are passed as though each 
is quoted.  That is, separate arguments are delimited by one or more spaces.  
The first example is equivalent to the following:

# Evaluates like:
#
# bash -c "./sh-script-8GJzdG \"1\" \"2\" \"3\""
#
#+begin_src bash :cmdline 1 2 3
echo \"$1\"
#+end_src

#+RESULTS:
: 1

How would you expect :cmdline "1 2 3" to be evaluated?

#+begin_src bash :cmdline "1 2 3"
echo \"$1\"
#+end_src

My expectation would be that it evaluates like:

  bash -c "./sh-script-8GJzdG \"1 2 3\""

It turns out, however, that it's evaluated exactly like :cmdline 1 2 3, or 
:cmdline "1" "2" "3".  The result is "1".

To make the block evaluate as expected requires an extra set of parentheses:

# Evaluates like:
#
# bash -c "./sh-script-8GJzdG \"1 2 3\""
#
#+begin_src bash :cmdline "\"1 2 3\""
echo \"$1\"
#+end_src

#+RESULTS:
: 1 2 3

This, however, appears to be separate from the reported issue[fn:1].

Now, consider :cmdline paired with :shebang, called with the same values as 
above.

# Evaluates like:
#
# /tmp/babel-Xd6rGS/sh-script-61jvMa "1 2 3"
#
#+begin_src bash :cmdline 1 2 3 :shebang #!/usr/bin/env bash
echo \"$1\"
#+end_src

#+RESULTS:
: 1 2 3

# Evaluates like:
#
# /tmp/babel-Xd6rGS/sh-script-61jvMa "\"1 2\" 3"
#
#+begin_src bash :cmdline "1 2" 3 :shebang #!/usr/bin/env bash
echo \"$1\"
#+end_src

#+RESULTS:
: 1 2" 3"

# Evaluates like:
#
# /tmp/babel-Xd6rGS/sh-script-61jvMa "1 2 3"
#
#+begin_src bash :cmdline "1 2 3" :shebang #!/usr/bin/env bash
echo \"$1\"
#+end_src

#+RESULTS:
: 1 2 3

# Evaluates like:
#
# /tmp/babel-Xd6rGS/sh-script-61jvMa "\"1 2 3\""
#
#+begin_src bash :cmdline "\"1 2 3\"" :shebang #!/usr/bin/env bash
echo \"$1\"
#+end_src

#+RESULTS:
: 1 2 3""

# Evaluates like:
#
# /tmp/babel-Xd6rGS/sh-script-61jvMa "\"1\" \"2\" \"3\""
#
#+begin_src bash :cmdline "1" "2" "3" :shebang #!/usr/bin/env bash
echo \"$1\"
#+end_src

#+RESULTS:
: 1" "2" "3""

An immediate observation is that the output results don't format correctly.  If 
you change the results type to "raw", however, you'll see that the Org results 
match those from a terminal, like xfce4-terminal.  The fact that raw output 
matches output from the terminal means that the formatting issue is (also) 
separate from the bug we're trying to fix.  That is, the bug we're trying to 
fix occurs in how the subprocess call is made, not in how the result is 
formatted.

In ob-shell, the subprocess call is made with 'process-file'.  Arguments are 
determined casewise:

1. shebang+cmdline
2. cmdline

The characters following :cmdline are received by the 'cmdline' argument to 
'org-babel-sh-evaluate' as a string.  Both cases put this string into a list 
for the ARGS of 'process-file':

| header   | 'org-babel-sh-evaluate' | process-file ARGS |
|  | cmdline variable value  | shebang+cmdline   |
|--+-+---|
| :cmdline 1 2 3   | "1 2 3" | ("1 2 3") |
| :cmdline "1 2" 3"| "\"1 2\" 3" | ("\"1 2\" 3") |
| :cmdline "1" "2" "3" | "\"1\" \"2\" \"3\"" | ("\"1\" \"2\" \"3\"") |

| header   | 'org-babel-sh-evaluate' | process-file ARGS |
|  | cmdline variable value  | cmdline   |
|--+-+---|
| :cmdline 1 2 3   | "1 2 3" | ("1 2 3") |
| :cmdline "1 2" 3"| "\"1 2\" 3" | ("\"1 2\" 3") |
| :cmdline "1" "2" "3" | "\"1\" \"2\" \"3\"" | ("\"1\" \"2\" \"3\"") |

Notice that the ARGS passed to 'process-file' are the same for both cases.  The 
problem is that the "block equivalent shell calls" are *not* the same.  If we 
arrange the equivalent shell calls from the blocks given above into a table, we 
see that the forms are 

Re: [FR] Please add custom command variable to org-latex-footnote-refere

2024-04-21 Thread Alexander Gogl
Dear Ihor,

you mean like this?

>From 1c7bee53ac91a8296c144f157ab8646b1a7a6595 Mon Sep 17 00:00:00 2001
From: Alexander Gogl 
Date: Wed, 17 Apr 2024 16:00:41 +0200
Subject: [PATCH] added option to customize latex footnote command in export

---
 etc/ORG-NEWS |  4 
 lisp/ox-latex.el | 14 --
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e61bd6988..a579260f5 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -999,6 +999,10 @@ even though it does not have its own ID.  By giving files top-level id
 properties, links to headlines in the file can also be made more
 robust by using the file id instead of the file path.
 
+*** New option ~latex-default-footnote-command~
+
+This new option allows you to define the LaTeX command the  org-mode footnotes are converted to (for example ~\\sidenote{%s%s}~).
+
 ** New features
 *** =colview= dynamic block now writes column width specifications
 
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5c19e1fe7..b45d13ca2 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -135,6 +135,9 @@
 (:latex-default-table-environment nil nil org-latex-default-table-environment)
 (:latex-default-quote-environment nil nil org-latex-default-quote-environment)
 (:latex-default-table-mode nil nil org-latex-default-table-mode)
+;; TODO implement options variable
+(:latex-default-footnote-command "\\footnote{%s%s}" nil org-latex-default-footnote-command)
+;;
 (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format)
 (:latex-engraved-options nil nil org-latex-engraved-options)
 (:latex-engraved-preamble nil nil org-latex-engraved-preamble)
@@ -667,6 +670,14 @@ The function result will be used in the section format string."
 
  Footnotes
 
+(defcustom org-latex-default-footnote-command "\\footnote{%s%s}"
+  "Default command used to insert footnotes.
+  Customize this command if the LaTeX class provides a different notation command like `\\sidenote{%s%s}' that you want to use."
+  :group 'org-export-latex
+  :version "24.4"  ;; FIXME enter correct version
+  :package-version '(Org . "9.7")
+  :type 'string)
+
 (defcustom org-latex-footnote-separator "\\textsuperscript{,}\\,"
   "Text used to separate footnotes."
   :group 'org-export-latex
@@ -780,7 +791,6 @@ default we use here encompasses both."
   :group 'org-export-latex
   :type 'string)
 
-
  Tables
 
 (defcustom org-latex-default-table-environment "tabular"
@@ -2239,7 +2249,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   (t
(let ((def (org-export-get-footnote-definition footnote-reference info)))
 	 (concat
-	  (format "\\footnote{%s%s}" (org-trim (org-export-data def info))
+	  (format org-latex-default-footnote-command (org-trim (org-export-data def info))
 		  ;; Only insert a \label if there exist another
 		  ;; reference to def.
 		  (cond ((not label) "")
-- 
2.41.0

>From 12d211a5f0c56faf1b829fef26f788f210a31382 Mon Sep 17 00:00:00 2001
From: Alexander Gogl 
Date: Wed, 17 Apr 2024 21:22:51 +0200
Subject: [PATCH] ox-latex: New option to customize LaTeX footnote command

* lisp/ox-latex.el (org-export-define-backend): Add option.
(org-latex-default-footnote-command): New custom variable.
(org-latex-footnote-reference): Replace string "\\footnote{%s%s}"
with custom variable.

* etc/ORG-NEWS (New and changed options): Add description to option.

Some LaTeX classes define their own footnote commands. For example,
kaobook (https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf)
has \footnotes and \sidenotes, whereby sidenotes (notes are put into
the outter margin) are the dominant form of putting notes in
kaobook. It would be great if you could make the footnote command in
the footnote function customizable. My proposal is in the attachment.

Modified from a feature request by Alexander Gogl.

TINYCHANGE
---
 etc/ORG-NEWS | 12 ++--
 lisp/ox-latex.el | 12 ++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a579260f5..571ab3c98 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -999,9 +999,17 @@ even though it does not have its own ID.  By giving files top-level id
 properties, links to headlines in the file can also be made more
 robust by using the file id instead of the file path.
 
-*** New option ~latex-default-footnote-command~
+*** New option ~latex-default-footnote-command~ to customize the LaTeX footnote command
 
-This new option allows you to define the LaTeX command the  org-mode footnotes are converted to (for example ~\\sidenote{%s%s}~).
+This new option allows you to define the LaTeX command the Org mode
+footnotes are converted to (for example ~\sidenote{%s%s}~ instead of
+the default ~\footnote{%s%s}~).
+
+The option can be customized either by
+
+a) setting the global variable in the ~org-export-latex~ customization
+   group or
+b) by setting the file local 

Re: [FR] Please add custom command variable to org-latex-footnote-refere

2024-04-21 Thread Ihor Radchenko
Alexander Gogl  writes:

> I have tested the global and buffer local options with kaoscript and the 
> article class. I could't find any problems with the option. Labels and 
> footnotes inside footnotes work.
>
> The current version of the patch (fixed a typo) is attached.

Thanks!
May you please send the final version of the patch, against main branch
rather than a series of incremental patches?

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



Re: columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM

2024-04-21 Thread Ihor Radchenko
Alexander Adolf  writes:

> Ah, `org-column--clean-item'; well spotted!
>
> Two observations:
>
> 1) As is now, I'm generating the links in the data collection function
>`org-columns--capture-view'. As `org-column--clean-item' is called
>from code that runs after the data collection,
>`org-column--clean-item' was probably never designed to be able to
>handle strings containing links. That it still did sort of "the right
>thing" seems more luck than anything else?

There is a difference between what `org-columns--clean-item' does and
stripping link paths.

`org-columns--clean-item' is cleaning up the results for insertion into
a table specifically. This is only meaningful in dynamic block, but not
in the traditional column view where nothing is actually written to
buffer - the columns are displayed on top of the existing headings.
Calling `org-columns--clean-item' is a must to create a valid table.

In contrast, the purpose of `org-link-display-format' is purely visual -
to not make the collected titles way too long. Also, it has no effect
when there is a custom `org-columns-modify-value-for-display-function'
(see `org-columns--displayed-value').

> 2) Considering what happens when I do `org-store-link' and
>`org-insert-link', it would seem more advisable to:
>
>a) move the link generation to the new formatting function
>   (re-removing it from `org-columns--capture-view');
>
>b) pass the "cleaned" string to `org-link-make-string' as both, the
>   link and the description parameter.

I do not recall seeing `org-store-link' in the patches you submitted.
So, I am not sure what you are talking about. May you elaborate?

>> We should probably also change org-clock to use
>> `org-columns--clean-item'.
>> [...]
>
> As a separate patch, or as a third commit to the patch we are discussing
> now?

Up to you.

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



Re: PATCH allow explicit style= in #+cite_export: biblatex

2024-04-21 Thread Ihor Radchenko
Pedro Andres Aranda Gutierrez  writes:

> +: #+cite_export: biblatex backend=bibtex,style=numeric

What about something like

#+cite_export: biblatex backend=bibtex,bibstyle=numeric

> BTW, I was thinking that maybe "\\`[^=]+=" may be better than matching
> style= anywhere in the options string...
> Open to discuss it...

May you elaborate what exactly will be improved?

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



Re: Trailing whitespace after export snippets without a transcoder

2024-04-21 Thread Ihor Radchenko
Max Nikulin  writes:

>> I have no clue about the rationale of this special behaviour - it dates
>> back to the days when Org export was merged. It is also not documented
>> anywhere, AFAIK.
>
> I would not expect that the space after the following export snippet is 
> ignored in the case of ox-html or ox-latex backend:
>
>  A space@@ascii:*@@ character.
>
> The space may be put inside the export snippet if the intention is to 
> omit it for output formats other than plain text. So current behavior is 
> perfectly reasonable and flexible enough.

Hmm. We actually have a similar scenario in `org-export--prune-tree'
with a slightly different logic - only keep spaces when previous object
does not have any.

I am attaching tentative patch that will duplicate the logic for export
snippets as well. And for any other object where transcoder returns nil.
WDYT?

>From 54939c4044fb407b068c0666c258ccd01e59c2af Mon Sep 17 00:00:00 2001
Message-ID: <54939c4044fb407b068c0666c258ccd01e59c2af.1713703523.git.yanta...@posteo.net>
From: Ihor Radchenko 
Date: Sun, 21 Apr 2024 15:37:18 +0300
Subject: [PATCH 1/2] org-export-data: Handle trailing spaces when transcoder
 returns nil

* lisp/ox.el (org-export-data): When transcoder returns nil, handle
trailing spaces after an object the same way `org-export--prune-tree'
does.  Remove special handling of export snippets that unconditionally
keep their trailing spaces.

Link: https://orgmode.org/list/87h6fwmgkm.fsf@localhost
---
 lisp/ox.el | 43 ---
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index fc746950d..ccc4c94ce 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -1930,15 +1930,11 @@ (defun org-export-data (data info)
 			   (eq (plist-get info :with-archived-trees) 'headline)
 			   (org-element-property :archivedp data)))
 		  (let ((transcoder (org-export-transcoder data info)))
-		(or (and (functionp transcoder)
- (if (eq type 'link)
-			 (broken-link-handler
-			  (funcall transcoder data nil info))
-   (funcall transcoder data nil info)))
-			;; Export snippets never return a nil value so
-			;; that white spaces following them are never
-			;; ignored.
-			(and (eq type 'export-snippet) ""
+		(and (functionp transcoder)
+ (if (eq type 'link)
+			 (broken-link-handler
+			  (funcall transcoder data nil info))
+   (funcall transcoder data nil info)
 		 ;; Element/Object with contents.
 		 (t
 		  (let ((transcoder (org-export-transcoder data info)))
@@ -1979,8 +1975,33 @@ (defun org-export-data (data info)
 	  (puthash
 	   data
 	   (cond
-	((not results) "")
-	((memq type '(nil org-data plain-text raw)) results)
+	((not results)
+ ;; TRANSCODER returned nil.  When DATA is an object,
+ ;; interpret this as if DATA should be ignored (see
+ ;; `org-export--prune-tree').  Keep spaces in place of
+ ;; removed element, if necessary.
+	 ;; Example: "Foo.[10%] Bar" would become
+	 ;; "Foo.Bar" if we do not keep spaces.
+ ;; Another example: "A space@@ascii:*@@ character."
+ ;; should become "A space character" in non-ASCII export.
+ (let ((post-blank (org-element-post-blank data)))
+   (or
+(unless (or (not post-blank)
+(zerop post-blank)
+(eq 'element (org-element-class data)))
+  (let ((previous (org-export-get-previous-element data info)))
+		(unless (or (not previous)
+			(pcase (org-element-type previous)
+  (`plain-text
+   (string-match-p
+(rx  whitespace eos) previous))
+  (_ (org-element-post-blank previous
+  ;; When previous element does not have
+  ;; trailing spaces, keep the trailing
+  ;; spaces from DATA.
+		  (make-string post-blank ?\s
+"")))
+((memq type '(nil org-data plain-text raw)) results)
 	;; Append the same white space between elements or objects
 	;; as in the original buffer, and call appropriate filters.
 	(t
-- 
2.44.0


> The issue is empty lines that serve as paragraph separators and that may 
> appear due to expansion of a macro or due to skipped export snippets. 
> Perhaps transcoders of other elements, e.g. links, may return empty 
> strings as well.

Right. This is a special case in MD where blank lines separate
paragraphs. Just like in ox-latex, where we fixed exactly same thing
reported in https://orgmode.org/list/tufdb6$11h2$1...@ciao.gmane.io

It is also a side effect of the fact that newlines are not considered a
part of the Org markup objects.

I do not think that we need to handle this Org mode-wide (it will be
difficult and will likely cause breaking changes). We can 

Re: [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree (was: Make org-paste-subtree more predictable and useful)

2024-04-21 Thread Ihor Radchenko
Philipp Kiefer  writes:

> To be honest, I don't see much need for fine-grained special cases. I'd 
> be very happy with C-u yanking at the level of the heading at point and 
> C-u C-u yanking at one level below that, regardless of the exact 
> position of point. I realize that would mean C-u doubling what can 
> already be done by calling org-paste-subtree with point at the beginning 
> of a heading but accessing both options (paste as sibling or child) with 
> a single or repeat C-u seems more consistent to me than having one 
> depend on position and getting at the other via the command prefix.

This feature is now implemented on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5b0b7f292
Done.

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



Re: `org-element-cache-map' misses elements at end of buffer

2024-04-21 Thread Ihor Radchenko
Morgan Smith  writes:

> So I found another bug in `org-element-cache-map'.
>
> Executing the following code just freezes up.  I am struggling to work
> through the logic of `org-element-cache-map'.  If no-one else magically
> solves my issues, I'll figure it out eventually.  But I would appreciate
> some advice on how to debug this stuff (both my issue of missing
> elements and freezing).

Hmm. :after-element keyword logic is broken. It does not account for the
case when :after-element is past the START point.

It is the time to refactor this function yet again.
(a tricky endeavour considering all the edge cases we can encounter when
there are changes in buffer while `org-element-cache-map' is mapping
over it).

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



Re: [DISCUSSION] What should we do with undocumented x^(superscript inside /round/ braces) syntax?

2024-04-21 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Upon further examination, I found that ^:{} does accept _only_ curly
> braces:
> ...
> So, round braces can be seen as another variant of DWIM behavior.
>
> I conclude that there is no reason to change the existing syntax.
>
> I will need to update `org-use-sub-superscripts' docstring and
> https://orgmode.org/worg/org-syntax.html#Subscript_and_Superscript to
> document this special case.
>
> Maybe also update the manual section 12.3 Subscripts and Superscripts.

All done on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=36d092804
https://git.sr.ht/~bzg/worg/commit/834ac25e

Closed.

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



Re: [FR] Please add custom command variable to org-latex-footnote-refere

2024-04-21 Thread Alexander Gogl
Hi Pedro,
dear community,

I have tested the global and buffer local options with kaoscript and the 
article class. I could't find any problems with the option. Labels and 
footnotes inside footnotes work.

The current version of the patch (fixed a typo) is attached.

>From 7ff2baa24dbcfa0675d8e797746f6f2965c19a8c Mon Sep 17 00:00:00 2001
From: Alexander Gogl 
Date: Sun, 21 Apr 2024 10:41:54 +0200
Subject: [PATCH 3/3] lisp/ox-latex.el: Fixed typo

* /ox-latex.el (org-latex-default-footnote-command): fixed typo in
description of option

TINYCHANGE
---
 lisp/ox-latex.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 058b5a31a..22a9595ab 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -671,7 +671,7 @@ The function result will be used in the section format string."
 (defcustom org-latex-default-footnote-command "\\footnote{%s%s}"
   "Default command used to insert footnotes.
   Customize this command if the LaTeX class provides a different
-  command like `\sidenote{%s%s}' that you want to use.
+  command like `\\sidenote{%s%s}' that you want to use.
 %s
 "
   :group 'org-export-latex
-- 
2.41.0

>From 12d211a5f0c56faf1b829fef26f788f210a31382 Mon Sep 17 00:00:00 2001
From: Alexander Gogl 
Date: Wed, 17 Apr 2024 21:22:51 +0200
Subject: [PATCH 2/3] ox-latex: New option to customize LaTeX footnote command

* lisp/ox-latex.el (org-export-define-backend): Add option.
(org-latex-default-footnote-command): New custom variable.
(org-latex-footnote-reference): Replace string "\\footnote{%s%s}"
with custom variable.

* etc/ORG-NEWS (New and changed options): Add description to option.

Some LaTeX classes define their own footnote commands. For example,
kaobook (https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf)
has \footnotes and \sidenotes, whereby sidenotes (notes are put into
the outter margin) are the dominant form of putting notes in
kaobook. It would be great if you could make the footnote command in
the footnote function customizable. My proposal is in the attachment.

Modified from a feature request by Alexander Gogl.

TINYCHANGE
---
 etc/ORG-NEWS | 12 ++--
 lisp/ox-latex.el | 12 ++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a579260f5..571ab3c98 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -999,9 +999,17 @@ even though it does not have its own ID.  By giving files top-level id
 properties, links to headlines in the file can also be made more
 robust by using the file id instead of the file path.
 
-*** New option ~latex-default-footnote-command~
+*** New option ~latex-default-footnote-command~ to customize the LaTeX footnote command
 
-This new option allows you to define the LaTeX command the  org-mode footnotes are converted to (for example ~\\sidenote{%s%s}~).
+This new option allows you to define the LaTeX command the Org mode
+footnotes are converted to (for example ~\sidenote{%s%s}~ instead of
+the default ~\footnote{%s%s}~).
+
+The option can be customized either by
+
+a) setting the global variable in the ~org-export-latex~ customization
+   group or
+b) by setting the file local variable ~LATEX_FOOTNOTE_COMMAND~
 
 ** New features
 *** =colview= dynamic block now writes column width specifications
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index b45d13ca2..058b5a31a 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -135,9 +135,7 @@
 (:latex-default-table-environment nil nil org-latex-default-table-environment)
 (:latex-default-quote-environment nil nil org-latex-default-quote-environment)
 (:latex-default-table-mode nil nil org-latex-default-table-mode)
-;; TODO implement options variable
-(:latex-default-footnote-command "\\footnote{%s%s}" nil org-latex-default-footnote-command)
-;;
+(:latex-default-footnote-command "LATEX_FOOTNOTE_COMMAND" nil org-latex-default-footnote-command t)
 (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format)
 (:latex-engraved-options nil nil org-latex-engraved-options)
 (:latex-engraved-preamble nil nil org-latex-engraved-preamble)
@@ -672,9 +670,11 @@ The function result will be used in the section format string."
 
 (defcustom org-latex-default-footnote-command "\\footnote{%s%s}"
   "Default command used to insert footnotes.
-  Customize this command if the LaTeX class provides a different notation command like `\\sidenote{%s%s}' that you want to use."
+  Customize this command if the LaTeX class provides a different
+  command like `\sidenote{%s%s}' that you want to use.
+%s
+"
   :group 'org-export-latex
-  :version "24.4"  ;; FIXME enter correct version
   :package-version '(Org . "9.7")
   :type 'string)
 
@@ -2249,7 +2249,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   (t
(let ((def (org-export-get-footnote-definition footnote-reference info)))
 	 (concat
-	  (format