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

2024-04-24 Thread Pedro Andres Aranda Gutierrez
Hopefully all remarks addressed..
Best, /PA

On Wed, 24 Apr 2024 at 19:05, Ihor Radchenko  wrote:

> Pedro Andres Aranda Gutierrez  writes:
>
> > Oops, you are right. My local copy got a bit messed up.
> >
> > Here is a hopefully clean patch. I have tried it out on a local
> test-patch
> > branch of current main and it applied.
>
> Thanks!
> May you also add NEWS entry?
>
> Also, a few comments inline.
>
> > Subject: [PATCH] Allow biblatex package options natively
>
> Please, prefix the first line with oc-biblatex library name.
>
> > lisp/oc-biblatex.el: detect and allow biblatex package options
> >   in key=val,key=val,... format. 

[PATCH] updating org-plot.org on worg, was Re: Can we add PLOT to org-element-multiple-keywords?

2024-04-24 Thread Leo Butler
I looked at the documentation on worg for org-plot and much of it is
out-of-date and/or no longer works (e.g. dead links, non-working
examples). Attached is a patch for the first half of the documentation.
The patch ends at the end of the section on 2d graphs.

Comments are appreciated. I also ask for advice on later sections, below.

From 4e262898feb349dad2f5b5afe8960c8e09723862 Mon Sep 17 00:00:00 2001
From: Leo Butler 
Date: Wed, 24 Apr 2024 12:57:58 -0500
Subject: [PATCH] org-tutorials/org-plot.org: update documentation and examples

- Replace dead link to org-plot.el with link to it on the Org
repository.
- Put discussion of keybinding into a subsection distinct from
installation.  Replace instructions about an idiosyncratic keybinding
with mention of the established keybinding for org-plot/gnuplot.
- Restructure ``2d plots'' section.
   - Put lines example in one subsection, histogram example in a
   second.
   - Show the #+PLOT options that are used to create each example.
   - Fix internal link.
   - Add names/captions to tables.
   - Remove the second histogram example, because the instructions are
 incorrect and it does not work.
---
 org-tutorials/org-plot.org | 70 +-
 1 file changed, 39 insertions(+), 31 deletions(-)

diff --git a/org-tutorials/org-plot.org b/org-tutorials/org-plot.org
index a0f3564b..98401fd3 100644
--- a/org-tutorials/org-plot.org
+++ b/org-tutorials/org-plot.org
@@ -43,38 +43,46 @@ following
 First we need to make sure that org-plot is on your system and
 available to emacs.  If you have a recent version of org-mode (version
 6.07 or later) then org-plot is already included.  Otherwise you can
-grab the latest org-plot.el from [[http://github.com/eschulte/org-plot/tree/master][github/eschulte/org-plot]].  Once you
-have org-plot loaded it may be useful to bind the main plotting
-command =org-plot/gnuplot= to a key chord, I use =C-M-g= for the
-mnemonic "graph" which can be done by executing the following elisp
-snippet.  This command will be the only org-plot command needed for
-the remainder of this tutorial.
+grab the latest ~org-plot.el~ from the [[https://git.sr.ht/~bzg/org-mode/tree/main/item/lisp/org-plot.el][Org repository]].
 
-[[elisp:(local-set-key "\M-\C-g" 'org-plot/gnuplot)]]
-
-Alright, we're now ready to start generating some graphs.
+** Keybinding
+The main plotting command, =org-plot/gnuplot=, is bound to the
+key-chord =C-c " g=.  This is the only org-plot command used in this
+tutorial.
 
 * Examples
 ** 2d plots (lines and histograms)
+*** Lines
 
-First, to plot the following table use the key sequence defined above
-=C-M-g=.  This will call =org-plot/gnuplot= which finds and plots the
-nearest table.  The options specified in any =#+PLOT= lines above the
-table are read and applied to the plot.  Notice that the second
-=#+PLOT:= line specifies labels for each column, if this line is
-removed the labels will default to the column headers in the table,
-try removing this line and re-plotting.
+To plot [[org-plot-example-1][Table 1]], execute the =org-plot/gnuplot= command.  This command
+finds and plots the nearest table.  The result, saved as a =png= file,
+is displayed in [[org-plot-example-1-plot][Figure 1]].
 
+#+NAME: org-plot-example-1-plot
+#+CAPTION: Plot of Table 1.
 [[file:../images/org-plot/example-1.png]]
 
+The options specified in any =#+PLOT= lines above the table are read
+and applied to the plot.  Notice that the second =#+PLOT= line
+specifies labels for each column; if this line is removed the labels
+will default to the column headers in the table. Here are the =#+PLOT=
+lines used to create Figure 1.
+
+#+NAME: org-plot-example-1-plot-options
+#+BEGIN_EXAMPLE
+#+PLOT: title:"example table" ind:1 type:2d with:lines
+#+PLOT: labels:("first new label" "second column" "last column")
+#+END_EXAMPLE
+
 For a complete list of all of the options and their meanings see the
-[[options]] section at the end of this file.  For more information on
+[[options][options]] section at the end of this file.  For more information on
 gnuplot options see [[http://gnuplot.sourceforge.net/documentation.html][the gnuplot documentation]], nearly all gnuplot
 options should be accessible through org-plot.
 
+#+NAME: org-plot-example-1
+#+CAPTION: Data used to plot Figure 1.
 #+PLOT: title:"example table" ind:1 type:2d with:lines
 #+PLOT: labels:("first new label" "second column" "last column")
-#+TBLNAME:org-plot-example-1
 | independent var | first dependent var | second dependent var |
 |-+-+--|
 | 0.1 |   0.425 |0.375 |
@@ -107,14 +115,22 @@ options should be accessible through org-plot.
 | 2.8 |   0.1598214 |   0.18928565 |
 | 2.9 |  0.15603453 |0.1844828 |
 
+*** Historgrams
+Org-plot can also produce histograms from 2d data.  [[org-plot-example-2-plot][Figure 

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

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

> [...]
>>> If you can, please add some more tests like mine checking
>>> `org-columns--clean-item'.
> [...]

I have added one test for each new feature (headline linkification, and
formatting function). Also, there's a third patch, which moves the call
to `org-quote-vert' to the cleanup function `org-columns--clean-item' as
you suggested.

Updated patches below.


One more thing caught my eye in `org-dblock-write:columnview' though.
When running the currently (i.e. before my patches) last test in
test-org-colview.el, the one with `org-columns-default-format' set to
"%ITEM %DEADLINE(d) %SCHEDULED(s) %TIMESTAMP(t)", `org-with-wide-buffer'
appears to modify the buffer and advances point by one (before the call
point is at 97, after the call at 98). In all other tests,
`org-with-wide-buffer' does not move point. In
`org-dblock-write:columnview' I have thus moved the sampling of point
for passing to the formatting function to after the call to
`org-with-wide-buffer'.


Many thanks and looking forward to your thoughts,

  --alexander


>From 2bb19d9000f29d56295b70754f89f927e7a5740c Mon Sep 17 00:00:00 2001
From: Alexander Adolf 
Date: Sun, 14 Apr 2024 18:14:05 +0200
Subject: [PATCH 1/3] lisp/org-colview.el: Add formatter parameter to colview
 dynamic block

* lisp/org-colview.el (org-dblock-write:column view): Factor out the
existing formatting code to new function
`org-columns-dblock-write-default', and honour new dblock parameter
:formatter for specifying a different formatting function.
(org-columns-dblock-write-default): New function with current
formatting code.
(org-columns--capture-view): Amend docstring to better explain the
format of the data being passed to the formatting function.
(org-clock-clocktable-formatter): New option to define a global
default formatting function, defaulting to the current behaviour.
* testing/lisp/test-org-colview.el (test-org-colview/dblock): New test
for formatting function.
(test-org-colview/dblock-formatter): New function used in formatting
test.
* doc/org-manual.org (Capturing column view): Describe new :formatter
parameter.
* etc/ORG-NEWS (New option ~org-columns-dblock-formatter~): Announce
new option.
(=colview= dynamic block supports custom formatting function):
Describe new custom formatting function feature.
---
 doc/org-manual.org   |  7 ++
 etc/ORG-NEWS | 29 
 lisp/org-colview.el  | 38 +++-
 testing/lisp/test-org-colview.el | 20 +
 4 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index d24230568..000783772 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -6014,6 +6014,13 @@ This dynamic block has the following parameters:
   Specify a column attribute (see [[*Column attributes]]) for the dynamic
   block.
 
+- =:formatter= ::
+
+  #+cindex: @samp{formatter}, dynamic block parameter
+  #+vindex: org-columns-dblock-formatter
+  A function to format column view data and insert it into the buffer.
+  See the option ~org-columns-dblock-formatter~.
+
 The following commands insert or update the dynamic block:
 
 - ~org-columns-insert-dblock~ ::
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index dbf849422..84ea7cde9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -999,6 +999,16 @@ 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 ~org-columns-dblock-formatter~
+
+=colview= dynamic blocks now understand a new ~:formatter~ parameter
+to use a specific function for formatting and inserting the contents
+of the dynamic block. This new option can be used to set the global
+default formatting function that will be used for =colview= dynamic
+blocks that do not specify any ~:formatter~ parameter. Its default
+value (the new function ~org-columns-dblock-write-default~) yields the
+previous (fixed) formatting behaviour.
+
 ** New features
 *** ~org-paste-subtree~ now handles =C-u= and =C-u C-u= prefix arguments specially
 
@@ -1035,6 +1045,25 @@ Example:
 : | PROYECTO EMACS |
 : #+END:
 
+*** =colview= dynamic block supports custom formatting function
+
+The =colview= dynamic block understands a new ~:formatter~ parameter,
+which specifies a user-supplied function to format and insert the data
+in the dynamic block.
+
+A global default formatting function for =colview= dynamic blocks can
+be set via the new option ~org-columns-dblock-formatter~ which
+defaults to the new function ~org-columns-dblock-write-default~, that
+implements the previous (fixed) formatting behaviour. Hence, the
+default behaviour is identical to previous versions.
+
+The global default function can be overridden for any given =colview=
+dynamic block individually by specifying a custom formatter function
+using the new ~:formatter~ parameter on 

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

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

> Oops, you are right. My local copy got a bit messed up.
>
> Here is a hopefully clean patch. I have tried it out on a local test-patch
> branch of current main and it applied.

Thanks!
May you also add NEWS entry?

Also, a few comments inline.

> Subject: [PATCH] Allow biblatex package options natively

Please, prefix the first line with oc-biblatex library name.

> lisp/oc-biblatex.el: detect and allow biblatex package options
>   in key=val,key=val,... format. 

Re: [BUG] No space after footnote with org-export-with-footnotes set to nil [9.6.1 ( @ /Users/test/.emacs.d/elpa/28.0/develop/org-9.6.1/)]

2024-04-24 Thread Max Nikulin

On 27/03/2023 21:16, Ihor Radchenko wrote:

+++ b/etc/ORG-NEWS
@@ -145,6 +145,27 @@ execution completes.  The new ~:async~ header allows users 
to continue
  editing with Emacs while a ~:session~ block executes.
  
  ** Miscellaneous

+*** Blank lines after removed objects are not retained during export


I have realized that this change affects *space characters*, not *blank 
lines*.





Re: FAILED test-ob-shell/bash-uses-assoc-arrays

2024-04-24 Thread Max Nikulin

On 24/04/2024 19:54, Ihor Radchenko wrote:

Max Nikulin  writes:


On 15/04/2024 23:46, Alexander Adolf wrote:

 FAILED  test-ob-shell/bash-uses-assoc-arrays  ((should (equal "two"
(org-trim (org-babel-execute-src-block :form (equal "two" "three")
:value nil :explanation (arrays-of-different-length 3 5 "two" "three"
first-mismatch-at 1))
 FAILED  test-ob-shell/bash-uses-assoc-arrays-with-lists  ((should
(equal "20 cm" (org-trim (org-babel-execute-src-block :form (equal
"20 cm" "50 dl") :value nil :explanation (array-elt 0 (different-atoms
(50 "#x32" "?2") (53 "#x35" "?5"


My guess is that GPLv2 BASH on macOS does not support associative
arrays. Perhaps these tests should be skipped if BASH_VERSION is not
fresh enough (not supplied by Apple).


I guess so. Which bash versions should we cut off?


/usr/share/doc/bash/NEWS.gz

This is a terse description of the new features added to bash-4.0 since
the release of bash-3.2.  As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.

[...]

ii. The shell provides associative array variables, with the appropriate
support to create, delete, assign values to, and expand them.


it is consistent with license change discussions
https://news.ycombinator.com/item?id=20102597





Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-24 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> May you create a test for this with expected failure?

Sure!  Here is one:

  (should
   (equal "{B}"
  (org-test-with-temp-text
  "src_lua{return string.match('A {B} C', '%b{}')}"
(org-babel-execute-src-block

The return value from 'string.match' is the substring "{B}", which Babel
misjudges to be a list and signals the error:

  (user-error "Inline error: list result cannot be used")

> Applied, onto main, after [...]

Thank you, Ihor!

Rudy
-- 
"I do not fear death.  I had been dead for billions and billions of
years before I was born, and had not suffered the slightest
inconvenience from it."  --- Mark Twain, paraphrased

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



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-24 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> P.S. #1
>
> We still have an old bug where
>
>   src_lua{return string.match("A {B} C", "%b{}")}
>
> is misjudged to be a table:
>
>   org-babel-insert-result: Inline error: list result cannot be used

May you create a test for this with expected failure?

> P.S. #2
>
> I did not update any session-related code.
>
> Currently,
>
>   #+BEGIN_SRC lua :session x
>   print 1
>   #+END_SRC
>
> gives
>
>   ... Sessions currently not supported, work in progress
>
> This is also documented in the header
>
>   ;; Requirements:
>   ;; for session support, lua-mode is needed.
>   ;; [...]
>   ;; However, sessions are not yet working.
>
> This half-finished session support should be removed, IMHO.

+1

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



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-24 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> * etc/ORG-NEWS
> (New and changed options): Describe the new option
> 'org-babel-lua-multiple-values-separator'.
> (New features): Describe the main change, as per the title of this
> commit message.

Thanks!
Applied, onto main, after removing redundant :version keyword from
defcustom.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=252cc0be0

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



Re: FAILED test-ob-shell/bash-uses-assoc-arrays

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

> On 15/04/2024 23:46, Alexander Adolf wrote:
>> FAILED  test-ob-shell/bash-uses-assoc-arrays  ((should (equal "two"
>> (org-trim (org-babel-execute-src-block :form (equal "two" "three")
>> :value nil :explanation (arrays-of-different-length 3 5 "two" "three"
>> first-mismatch-at 1))
>> FAILED  test-ob-shell/bash-uses-assoc-arrays-with-lists  ((should
>> (equal "20 cm" (org-trim (org-babel-execute-src-block :form (equal
>> "20 cm" "50 dl") :value nil :explanation (array-elt 0 (different-atoms
>> (50 "#x32" "?2") (53 "#x35" "?5"
>
> My guess is that GPLv2 BASH on macOS does not support associative 
> arrays. Perhaps these tests should be skipped if BASH_VERSION is not 
> fresh enough (not supplied by Apple).

I guess so. Which bash versions should we cut off?


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



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

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

>> +shell-file-name
> ...
>> +(list shell-command-switch
>> +  (concat (file-local-name script-file)  " " 
>> cmdline
>
> Using `shell-command-switch' unconditionally may lead to executing 
> /bin/sh instead of shell specified by `shell-file-name' for script files 
> having no shebang, see
>
> https://superuser.com/questions/502984/writing-shell-scripts-that-will-run-on-any-shell-using-multiple-shebang-lines

Good point.

> I believe, multiple arguments should be specified as '(1 a "b c").

Yes, but we do not, in general, know how to split them.

> With shebang (as header arg or as part of the body) command should be
>  /path/to/script [ARGUMENT]...
> when there is no shebang
>  /shell/executable /path/to/script [ARGUMENT]...

Maybe instead of `process-file' we can simply use `shell-command'?

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



Re: [BUG] Exporting to text fails when there are broken links

2024-04-24 Thread Ihor Radchenko
Pablo Aguado  writes:

> #+NAME: source-broken-links-mark
> #+begin_src org
>   ,#+OPTIONS: broken-links:mark
>
>   ,* Some title
>
> ...
>   5. This [[{filename}test-nonexistent-file.org][link5]] is NOT exported 
> correctly to text.
> #+end_src
>
> #+begin_src elisp :results output
>   (org-src-to-text "source-broken-links-mark")
> #+end_src
>
> #+RESULTS:
> : [BROKEN LINK: {filename}test-nonexistent-file.org]
>
>
> NOTE THAT ONLY THE BROKEN LINK IS SHOWN HERE! BUT NOT THE REST OF THE TEXT.

Thanks for reporting!
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d6353b283

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



keeping subtree heading on export

2024-04-24 Thread Matt Price
I'm writing a primitive exporter for jupyter-book
, which is a neat way to
maintain static documentation and executable jupyter notebooks from the
same source files.  The source files are written in Myst flavored markdown
, so I started with a simpleminded fork of the gfm
exporter . What I'd really like,
though is something more like ox-hugo
, which maintains a whole blog in a
single org file.  For this to work, I need to export each individual page
of the "book" to its own markdown page.  However, jupyter-book expects to
find the title of the page in the initial first-level heading.  So I'd like
to retain the subtree "title" as a first-level heading, and demote the
remaining headings to their original state within the larger org document.

Does anyone know of an existing exporter that already does this, from which
I can steal? Or if not, how would you suggest I go about doing this?

Thanks,

Matt


FAILED test-ob-shell/bash-uses-assoc-arrays

2024-04-24 Thread Max Nikulin

On 15/04/2024 23:46, Alexander Adolf wrote:

FAILED  test-ob-shell/bash-uses-assoc-arrays  ((should (equal "two"
(org-trim (org-babel-execute-src-block :form (equal "two" "three")
:value nil :explanation (arrays-of-different-length 3 5 "two" "three"
first-mismatch-at 1))
FAILED  test-ob-shell/bash-uses-assoc-arrays-with-lists  ((should
(equal "20 cm" (org-trim (org-babel-execute-src-block :form (equal
"20 cm" "50 dl") :value nil :explanation (array-elt 0 (different-atoms
(50 "#x32" "?2") (53 "#x35" "?5"


My guess is that GPLv2 BASH on macOS does not support associative 
arrays. Perhaps these tests should be skipped if BASH_VERSION is not 
fresh enough (not supplied by Apple).




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

2024-04-24 Thread Max Nikulin

On 23/04/2024 17:28, Ihor Radchenko wrote:


I propose the attached patch.



+++ b/lisp/ob-shell.el
@@ -322,14 +322,12 @@ (defun org-babel-sh-evaluate (session body  
params stdin cmdline)
  (with-temp-buffer
 (with-connection-local-variables
  (apply #'process-file
-(if shebang (file-local-name script-file)
-  shell-file-name)
+shell-file-name
stdin-file
 (current-buffer)
 nil
-(if shebang (when cmdline (list cmdline))
-  (list shell-command-switch
-(concat (file-local-name script-file)  " " 
cmdline)
+(list shell-command-switch
+  (concat (file-local-name script-file)  " " 
cmdline


Using `shell-command-switch' unconditionally may lead to executing 
/bin/sh instead of shell specified by `shell-file-name' for script files 
having no shebang, see


https://superuser.com/questions/502984/writing-shell-scripts-that-will-run-on-any-shell-using-multiple-shebang-lines

The kernel refuses to execute such scripts and returns ENOEXEC, so the
exact behavior depends on the program you run such a script /from/.

- bash 4.2.39 -- uses itself
- busybox-ash 1.20.2 -- uses itself
- dash 0.5.7 -- runs /bin/sh
- fish 1.23.1 -- complains about ENOEXEC, then blames the wrong file
- AT ksh 93u+2012.08.01 -- uses itself
- mksh R40f -- runs /bin/sh
- pdksh 5.2.14 -- runs /bin/sh
- sh-heirloom 050706 -- uses itself
- tcsh 6.18.01 -- runs /bin/sh
- zsh 5.0.0 -- runs /bin/sh
- cmd.exe 5.1.2600 -- looks at you funny

I am not going to spend time testing current versions.

I believe, multiple arguments should be specified as '(1 a "b c").

With shebang (as header arg or as part of the body) command should be
/path/to/script [ARGUMENT]...
when there is no shebang
/shell/executable /path/to/script [ARGUMENT]...