Re: [FR] ob-awk.el specifying a delimeter argument in for output

2023-03-05 Thread Jeremie Juste


Hello Ihor,

>> I guess we might add an option to tell Org which separator to use when
>> parsing output when :results table header argument is provided (see 16.6
>> Results of Evaluation section of Org manual). However, you can achieve
>> the same now, using :post header argument, replacing the separators with
>> something Org can understand.

Thanks again for the suggestion, after giving your solution more thoughts, I 
could
achieve the desired output. 

# file test.csv
# 123;0;123

#+NAME: specific-delim
#+BEGIN_SRC emacs-lisp :var tbl="" delim=";"
(format "|%s"  (replace-regexp-in-string delim  "|" tbl))
#+end_src

#+RESULTS: specific-delim
: |



#+begin_src awk :in-file test.csv :cmd-line -F ";" :post 
specific-delim(*this*,";") :results raw
 {print $0}
#+end_src

#+RESULTS:
| 123 | 0 | 123 |


Best regards,
Jeremie



Re: [FR] ob-awk.el specifying a delimeter argument in for output

2023-03-05 Thread Jeremie Juste


Hello Ihor,


> Org knows nothing about your output, by default.
> You could as well do something like {print $1+-+$2+-+$3}
> What should Org do in such case?
>
> Currently, Org tries to guess the type of arbitrary output. If the
> output looks like a table, with fields separated by tabs, commas, or
> spaces, it converts the output to table. Otherwise, it is treated as
> string.

Many thanks for the insights.  Ok, I guess this it likely to take some
time, but it would be a great feature in my option.

>
> I guess we might add an option to tell Org which separator to use when
> parsing output when :results table header argument is provided (see 16.6
> Results of Evaluation section of Org manual). However, you can achieve
> the same now, using :post header argument, replacing the separators with
> something Org can understand.

Thanks for the suggestion. I tried using post replacing semi columns by
commas but was surprised by the output.

# file test.csv
# 123;0;123

#+NAME: specific-delim
#+BEGIN_SRC emacs-lisp :var tbl=""
(replace-regexp-in-string ";" "," tbl)
#+end_src

#+RESULTS: specific-delim



#+begin_src awk :in-file test.csv :cmd-line -F ";" :post specific-delim(*this*)
 {print $0}
#+end_src

#+RESULTS:
: 123,0,123



After a short investigation, I notice that the function
org-babel-import-elisp-from-file, is the function making the call wheter
the result should be a table or not i.e before the :post argument. Have
I understood correctly?

If it is the case, then I would have to not just replace the delimeter
but convert the entire results to an org-table.

Best regards,
Jeremie



Re: [PATCH] Async evaluation in ob-shell

2023-03-05 Thread Matt


  On Sun, 05 Mar 2023 07:14:21 -0500  Ihor Radchenko  wrote --- 
 > > Matt m...@excalamus.com> writes:
 > >
 > > Sorry for missing that.  The issue is that when I replaced
 > > `org-babel-sh-prompt' with `comint-prompt-regexp', the regexp no
 > > longer matches the output and grabs the next prompt.  It looks like
 > > the reason is `comint-prompt-regexp' is set to "^org_babel_sh_prompt>
 > > *" (with two spaces between the '>' and '*').  Attached is a revised
 > > patch which removes one of the spaces by changing how
 > > `org-babel-sh-initiate-session' sets the `comint-prompt-regexp'.
 > > Another place this could be done is in the defvar for
 > > `org-babel-sh-prompt' itself (which ends with a space).  However, I
 > > think it's customary to leave a trailing space for prompts?
 > 
 > The actual prompt is "org_babel_sh_prompt> ".

Agreed.

 > And we want to skip leading spaces in addition.
 
What do you mean by this?

 > Adding " *" does not make the prompt match 2 spaces, but 1+.
 
Agreed.  

It's not clear to me what pattern you're looking to match.

 > >  > > +  (let ((uuid (org-id-uuid)))
 > >  > 
 > >  > Do you need to use `org-id-uuid' here? ob-python directly uses `md5'.
 > >  > If you still prefer org-id-uuid, we probably need to move it to
 > >  > org-macs.el
 > >
 > > I just need a random string.  `md5' would work for that.  However,
 > > might it be better to update ob-R and ob-python to use `org-id-uuid'?
 > > Both of those manually declare the randomness.  It's conceivable that
 > > someone may delete or mistype the number (1), resulting in a
 > > lower entropy.  An md5 is also not a uuid, strictly speaking.  Of
 > > course, the chance of collision is still basically zero and the cost
 > > of collision about the same.  Using `org-id-uuid' would only provide a
 > > consistent way to do things.
 > 
 > `md5' will be slightly faster compared to `org-id-uuid'. But it should
 > not matter.
 > 
 > If we want use `org-id-uuid', lets move it to org-macs.el. Requiring the
 > whole org-id.el must not be done. It has side effects of defining id:
 > links.

In the next revision (once we figure out the regex), I can create a separate 
commit moving `org-id-uuid' to org-macs.el and updating ob-R and ob-python from 
`md5' to `org-id-uuid' (assuming that's not an issue for the maintainers of 
those).  If you think speed is a concern, however, I can switch ob-shell.el to 
use plain `md5'.

 > 
 > >  (concat "^" (regexp-quote org-babel-sh-prompt)
 > > -" *"))
 > > +"*"))
 > 
 > This is wrong. It unconditionally makes the last char in
 > `org-babel-sh-prompt' 0+. (Imagine it is changed to non-space in
 > future).

When you say "imagine it is changed to non-space...", do you refer to 
`org-babel-sh-prompt'?

Honestly, it's not clear to me what pattern(s) we need to match.



Re: [PATCH] Fix ob-latex.el command injection vulnerability.

2023-03-05 Thread lux
On Sat, 2023-02-18 at 11:43 +, Ihor Radchenko wrote:
> lux  writes:
> 
> > -  (shell-command (format "mv %s %s" img-out out-
> > file)
> > +  (rename-file img-out out-file
> 
> I think should be (rename-file img-out out-file t)
> 

Fixed, thank you.
From adc0c558b1b091bb4bef77901633f31344b7391a Mon Sep 17 00:00:00 2001
From: Xi Lu 
Date: Sat, 18 Feb 2023 18:03:28 +0800
Subject: [PATCH] * lisp/ob-latex.el (org-babel-execute:latex): Fix command
 injection vulnerability.

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

diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index 428907a27..0d0a37a02 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -180,7 +180,7 @@ This function is called by `org-babel-execute-src-block'."
 	 tmp-pdf
  (list org-babel-latex-pdf-svg-process)
  extension err-msg log-buf)))
-  (shell-command (format "mv %s %s" img-out out-file)
+  (rename-file img-out out-file t
  ((string-suffix-p ".tikz" out-file)
 	  (when (file-exists-p out-file) (delete-file out-file))
 	  (with-temp-file out-file
-- 
2.30.2



Re: [PATCH] org-src: Improve the name of source editing buffers

2023-03-05 Thread Rudolf Adamkovič
I had a little bit of spare time today to refine the patch.

Changes:

- The patch now comes with a test to avoid regressions.
- The patch has a slightly better commit message.

Please see the attached file.

Thank you!

Rudy
>From a831b9014b3aaef16846dca049882a485ebf1dd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Sun, 5 Mar 2023 22:21:40 +0100
Subject: [PATCH] org-src: Improve naming of source editing buffers

* lisp/org-src.el (org-src--construct-edit-buffer-name): Fix the name
given to a source editing buffer.  The original format was documented
as "ORG-BUFFER-NAME [ LANG ]" but in reality it was "ORG-BUFFER-NAME[
LANG ]", with different spacing.  We make the format more standard and
more compact, as well as, make the documentation match reality.
* testing/lisp/test-org-src.el (test-org-src/buffer-name): Test the
buffer name used for 'org-edit-special'.
---
 lisp/org-src.el  |  4 ++--
 testing/lisp/test-org-src.el | 13 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9e4392811..bb894de9c 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -315,8 +315,8 @@ is 0.")
 
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer.
-Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
-  (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
+Format is \"*Org Src ORG-BUFFER-NAME [LANG]*\"."
+  (concat "*Org Src " org-buffer-name " [" lang "]*"))
 
 (defun org-src--edit-buffer (beg end)
   "Return buffer editing area between BEG and END.
diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el
index 2a45ba66e..8829ce306 100644
--- a/testing/lisp/test-org-src.el
+++ b/testing/lisp/test-org-src.el
@@ -491,6 +491,19 @@ This is a tab:\t.
   (should (equal "#" (org-unescape-code-in-string "#")))
   (should (equal "," (org-unescape-code-in-string ","
 
+;;; Other
+
+(ert-deftest test-org-src/buffer-name ()
+  "Buffer has the correct name."
+  (org-test-with-temp-text "
+#+begin_src emacs-lisp
+  (message hello)
+#+end_src"
+(rename-buffer "Buffy")
+(org-edit-special)
+(should (equal "*Org Src Buffy [emacs-lisp]*"
+   (buffer-name)))
+(org-edit-src-exit)))
 
 (provide 'test-org-src)
 ;;; test-org-src.el ends here
-- 
2.39.2

-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

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


Re: [PATCH] Fix LaTeX misspelled as Latex

2023-03-05 Thread Rudolf Adamkovič
Please, see the updated patch attached to this message.

It has

(1) a unified commit message with the similar BibTeX patch, and
(2) a more correct change-log [*].

[*] For some reason Org breaks change log generation with "user-error: Cannot
move further down".

Rudy
>From 42964b65d94cf17514b1b3362d61126facec3414 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Sun, 5 Mar 2023 22:01:11 +0100
Subject: [PATCH] Fix LaTeX spelled as Latex

etc/ORG-NEWS (Non-floating minted listings in LaTeX export): Spell LaTeX
correctly.
* lisp/ob-latex.el: (org-babel-execute:latex): Spell LaTeX correctly.
* lisp/org-element.el: Spell LaTeX correctly.
* lisp/ox-ascii.el: Spell LaTeX correctly.
* lisp/ox-html.el: Spell LaTeX correctly.
* lisp/ox-latex.el: Spell LaTeX correctly.
* lisp/ox-md.el: Spell LaTeX correctly.
* lisp/ox-odt.el: Spell LaTeX correctly.
* testing/examples/ob-maxima-test.org (LaTeX output): Spell LaTeX correctly.
* testing/lisp/test-org-element.el (test-org-element/cache): Spell LaTeX
correctly.
---
 etc/ORG-NEWS| 4 ++--
 lisp/ob-latex.el| 2 +-
 lisp/org-element.el | 4 ++--
 lisp/ox-ascii.el| 4 ++--
 lisp/ox-html.el | 4 ++--
 lisp/ox-latex.el| 4 ++--
 lisp/ox-md.el   | 4 ++--
 lisp/ox-odt.el  | 4 ++--
 testing/examples/ob-maxima-test.org | 2 +-
 testing/lisp/test-org-element.el| 6 +++---
 10 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 988dfea93..388aa07a3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -437,7 +437,7 @@ When the block type starts from the upper case, structure template
 will now insert =#+BEGIN_TYPE=.  Previously, lower-case =#+begin_type= was inserted unconditionally.
 *** New ox-latex tabbing support for tables.
 
-Latex tables can now be exported to the latex tabbing environment
+LaTeX tables can now be exported to the latex tabbing environment
 tabbing environment]].
 This is done by adding =#+ATTR_LATEX: :mode tabbing= at the top
 of the table.
@@ -4388,7 +4388,7 @@ parameters specific to some pre-defined translators, e.g.,
 ~:environment~ and ~:booktabs~ for ~orgtbl-to-latex~.  See translators
 docstrings (including ~orgtbl-to-generic~) for details.
 
-*** Non-floating minted listings in Latex export
+*** Non-floating minted listings in LaTeX export
 
 It is not possible to specify =#+attr_latex: :float nil= in conjunction
 with source blocks exported by the minted package.
diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index 428907a27..730da01b9 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -141,7 +141,7 @@ exporting the literal LaTeX source."
   (org-trim body))
 
 (defun org-babel-execute:latex (body params)
-  "Execute a block of Latex code with Babel.
+  "Execute a block of LaTeX code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (setq body (org-babel-expand-body:latex body params))
   (if (cdr (assq :file params))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index f8442511c..7ccdb103d 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -2469,7 +2469,7 @@ CDR is a plist containing `:key', `:value', `:begin', `:end',
 	  (org-element-property :value keyword)))
 
 
- Latex Environment
+ LaTeX Environment
 
 (defconst org-element--latex-begin-environment
   "^[ \t]*begin{\\([A-Za-z0-9*]+\\)}"
@@ -3419,7 +3419,7 @@ CONTENTS is the contents of the object."
   (format "/%s/" contents))
 
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-element-latex-fragment-parser ()
   "Parse LaTeX fragment at point, if any.
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e5bdf92cb..e267b004b 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1549,7 +1549,7 @@ information."
keyword info)
 
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-ascii-latex-environment (latex-environment _contents info)
   "Transcode a LATEX-ENVIRONMENT element from Org to ASCII.
@@ -1561,7 +1561,7 @@ information."
  latex-environment info)))
 
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-ascii-latex-fragment (latex-fragment _contents info)
   "Transcode a LATEX-FRAGMENT object from Org to ASCII.
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 37c474409..82e266dde 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2968,7 +2968,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	 ((string= "listings" value) (org-html-list-of-listings info))
 	 ((string= "tables" value) (org-html-list-of-tables info
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-html-format-latex (latex-frag processing-type info)
   "Format a LaTeX fragment LATEX-FRAG into HTML.
@@ -3085,7 +3085,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	 info caption label)
  (t 

[PATCH] Fix BibTeX spelled as Bibtex

2023-03-05 Thread Rudolf Adamkovič
* lisp/ol-bibtex.el: Spell BibTeX correctly
* etc/ORG-NEWS (Org-BibTeX -- major improvements): Spell BibTeX correctly
---
 etc/ORG-NEWS  |  2 +-
 lisp/ol-bibtex.el | 22 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 988dfea93..fcb4d2af0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -6644,7 +6644,7 @@ that Calc formulas can operate on them.
 
 *** Hyperlinks
 
- Org-Bibtex -- major improvements
+ Org-BibTeX -- major improvements
 
  Provides support for managing bibtex bibliographical references
  data in headline properties.  Each headline corresponds to a
diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 7d6ed8534..fd9517233 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -86,8 +86,8 @@
 ;;   the active region, then call `org-bibtex-write' in a .org file to
 ;;   insert a heading for the read bibtex entry
 ;;
-;; - All Bibtex information is taken from the document compiled by
-;;   Andrew Roberts from the Bibtex manual, available at
+;; - All BibTeX information is taken from the document compiled by
+;;   Andrew Roberts from the BibTeX manual, available at
 ;;   https://www.andy-roberts.net/res/writing/latex/bibentries.pdf
 ;;
 ;;; History:
@@ -99,7 +99,7 @@
 ;; and then implemented by Bastien Guerry.
 ;;
 ;; Eric Schulte eventually added the functions for translating between
-;; Org headlines and Bibtex entries, and for fleshing out the Bibtex
+;; Org headlines and BibTeX entries, and for fleshing out the BibTeX
 ;; fields of existing Org headlines.
 ;;
 ;; Org mode loads this module by default - if this is not what you want,
@@ -144,7 +144,7 @@
 (declare-function org-search-view "org-agenda" ( todo-only string 
edit-at))
 
 
-;;; Bibtex data
+;;; BibTeX data
 (defvar org-bibtex-types
   '((:article
  (:description . "An article from a journal or magazine")
@@ -202,7 +202,7 @@
  (:description . "A document having an author and title, but not formally 
published.")
  (:required :author :title :note)
  (:optional :month :year :doi :url)))
-  "Bibtex entry types with required and optional parameters.")
+  "BibTeX entry types with required and optional parameters.")
 
 (defvar org-bibtex-fields
   '((:address  . "Usually the address of the publisher or other type of 
institution.  For major publishing houses, van Leunen recommends omitting the 
information entirely.  For small publishers, on the other hand, you can help 
the reader by giving the complete address.")
@@ -231,7 +231,7 @@
 (:url  . "Uniform resource locator.")
 (:volume   . "The volume of a journal or multi-volume book.")
 (:year . "The year of publication or, for an unpublished work, the 
year it was written.  Generally it should consist of four numerals, such as 
1984, although the standard styles can handle any year whose last four 
nonpunctuation characters are numerals, such as '(about 1984)'"))
-  "Bibtex fields with descriptions.")
+  "BibTeX fields with descriptions.")
 
 (defvar org-bibtex-entries nil
   "List to hold parsed bibtex entries.")
@@ -439,7 +439,7 @@ at point."
 (error "Field:%s is not known" field))
   (save-window-excursion
 (let* ((name (substring (symbol-name field) 1))
-  (buf-name (format "*Bibtex Help %s*" name)))
+  (buf-name (format "*BibTeX Help %s*" name)))
   (with-output-to-temp-buffer buf-name
(princ (cdr (assoc field org-bibtex-fields
   (with-current-buffer buf-name (visual-line-mode 1))
@@ -496,7 +496,7 @@ With optional argument OPTIONAL, also prompt for optional 
fields."
 (org-bibtex-autokey)))
 
 
-;;; Bibtex link functions
+;;; BibTeX link functions
 (org-link-set-parameters "bibtex"
 :follow #'org-bibtex-open
 :store #'org-bibtex-store-link)
@@ -593,13 +593,13 @@ ARG, when non-nil, is a universal prefix argument.  See
 (add-hook 'org-execute-file-search-functions 
'org-execute-file-search-in-bibtex)
 
 
-;;; Bibtex <-> Org headline translation functions
+;;; BibTeX <-> Org headline translation functions
 (defun org-bibtex (filename)
   "Export each headline in the current file to a bibtex entry.
 Headlines are exported using `org-bibtex-headline'."
   (interactive
(list (read-file-name
- "Bibtex file: " nil nil nil
+ "BibTeX file: " nil nil nil
  (let ((file (buffer-file-name (buffer-base-buffer
(and file
 (file-name-nondirectory
@@ -619,7 +619,7 @@ Headlines are exported using `org-bibtex-headline'."
 nil
 (when error-point
   (goto-char error-point)
-  (message "Bibtex error at %S" (nth 4 (org-heading-components))
+  (message "BibTeX error at %S" (nth 4 (org-heading-components))
 
 (defun org-bibtex-check ( optional)
   "Check the current headline for required fields.
-- 
2.39.2




[PATCH] Fix LaTeX misspelled as Latex

2023-03-05 Thread Rudolf Adamkovič
* etc/ORG-NEWS (Non-floating minted listings in LaTeX export): Spell LaTeX
correctly.
* lisp/ob-latex.el: (org-babel-execute:latex): Spell LaTeX correctly.
* lisp/org-element.el (org-element-latex-fragment-parser): Spell LaTeX
correctly.
* lisp/ox-ascii.el (org-ascii-latex-fragment): Spell LaTeX correctly.
* lisp/ox-html.el (org-html-latex-fragment): Spell LaTeX correctly.
* lisp/ox-latex.el (org-latex-latex-fragment): Spell LaTeX correctly.
* lisp/ox-md.el (org-md-latex-fragment): Spell LaTeX correctly.
* lisp/ox-odt.el: Spell LaTeX correctly.
* testing/examples/ob-maxima-test.org (LaTeX output): Spell LaTeX correctly.
* testing/lisp/test-org-element.el (test-org-element/cache): Spell LaTeX
correctly.
---
 etc/ORG-NEWS| 4 ++--
 lisp/ob-latex.el| 2 +-
 lisp/org-element.el | 4 ++--
 lisp/ox-ascii.el| 4 ++--
 lisp/ox-html.el | 4 ++--
 lisp/ox-latex.el| 4 ++--
 lisp/ox-md.el   | 4 ++--
 lisp/ox-odt.el  | 4 ++--
 testing/examples/ob-maxima-test.org | 2 +-
 testing/lisp/test-org-element.el| 6 +++---
 10 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 988dfea93..388aa07a3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -437,7 +437,7 @@ When the block type starts from the upper case, structure 
template
 will now insert =#+BEGIN_TYPE=.  Previously, lower-case =#+begin_type= was 
inserted unconditionally.
 *** New ox-latex tabbing support for tables.
 
-Latex tables can now be exported to the latex tabbing environment
+LaTeX tables can now be exported to the latex tabbing environment
 tabbing environment]].
 This is done by adding =#+ATTR_LATEX: :mode tabbing= at the top
 of the table.
@@ -4388,7 +4388,7 @@ parameters specific to some pre-defined translators, e.g.,
 ~:environment~ and ~:booktabs~ for ~orgtbl-to-latex~.  See translators
 docstrings (including ~orgtbl-to-generic~) for details.
 
-*** Non-floating minted listings in Latex export
+*** Non-floating minted listings in LaTeX export
 
 It is not possible to specify =#+attr_latex: :float nil= in conjunction
 with source blocks exported by the minted package.
diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index 428907a27..730da01b9 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -141,7 +141,7 @@ exporting the literal LaTeX source."
   (org-trim body))
 
 (defun org-babel-execute:latex (body params)
-  "Execute a block of Latex code with Babel.
+  "Execute a block of LaTeX code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (setq body (org-babel-expand-body:latex body params))
   (if (cdr (assq :file params))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index f8442511c..7ccdb103d 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -2469,7 +2469,7 @@ CDR is a plist containing `:key', `:value', `:begin', 
`:end',
  (org-element-property :value keyword)))
 
 
- Latex Environment
+ LaTeX Environment
 
 (defconst org-element--latex-begin-environment
   "^[ \t]*begin{\\([A-Za-z0-9*]+\\)}"
@@ -3419,7 +3419,7 @@ CONTENTS is the contents of the object."
   (format "/%s/" contents))
 
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-element-latex-fragment-parser ()
   "Parse LaTeX fragment at point, if any.
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e5bdf92cb..e267b004b 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1549,7 +1549,7 @@ information."
keyword info)
 
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-ascii-latex-environment (latex-environment _contents info)
   "Transcode a LATEX-ENVIRONMENT element from Org to ASCII.
@@ -1561,7 +1561,7 @@ information."
  latex-environment info)))
 
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-ascii-latex-fragment (latex-fragment _contents info)
   "Transcode a LATEX-FRAGMENT object from Org to ASCII.
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 37c474409..82e266dde 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2968,7 +2968,7 @@ CONTENTS is nil.  INFO is a plist holding contextual 
information."
 ((string= "listings" value) (org-html-list-of-listings info))
 ((string= "tables" value) (org-html-list-of-tables info
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-html-format-latex (latex-frag processing-type info)
   "Format a LaTeX fragment LATEX-FRAG into HTML.
@@ -3085,7 +3085,7 @@ CONTENTS is nil.  INFO is a plist holding contextual 
information."
 info caption label)
  (t (org-html--wrap-latex-environment latex-frag info caption label)
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-html-latex-fragment (latex-fragment _contents info)
   "Transcode a LATEX-FRAGMENT object from Org to HTML.
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index dc2062df5..b84fe89db 100644

Re: [PATCH] org-clock: Add a trailing space to the mode line string

2023-03-05 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Thanks!
> Applied, onto bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3d817c52c

Why not the one with the correct Info link, as per Max's excellent nitpick?

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

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



[BUG] org-element-at-point rx error on large file [9.6.1 (release_9.6.1-34-geea8da @ /home/dericbytes/installs/share/emacs/30.0.50/lisp/org/)]

2023-03-05 Thread Deric Bytes
Expected:

   Running `org-element-at-point' on large empty file returns nil.

How to replicate:

emacs -q
(require 'org)
(newline 20)
(org-element-at-point)

Actual response

⛔ Warning (org-element-cache): org-element--cache: Org parser error in
*scratch*::24. Resetting.
 The error was: (error "rx ‘**’ range error")
 Backtrace:
"  backtrace-to-string(nil)
  org-element-at-point()
  (progn (org-element-at-point))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)
"
 Please report this to Org mode mailing list (M-x
 org-submit-bug-report).


emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0)
 of 2023-02-28
Package: Org mode version 9.6.1 (release_9.6.1-34-geea8da @
/home/dericbytes/installs/share/emacs/30.0.50/lisp/org/)

current state:
==
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe
   org-babel-header-arg-expand)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees
 org-cycle-show-empty-lines
 org-cycle-optimize-window-after-visibility-change
org-cycle-display-inline-images)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207"
  [add-hook change-major-mode-hook
   org-fold-show-all append local]
  5]
#[0 "\300\301\302\303\304$\207"
  [add-hook change-major-mode-hook
   org-babel-show-result-all append local]
  5]
org-babel-result-hide-spec
org-babel-hide-all-hashes)
 org-confirm-shell-link-function 'yes-or-no-p
 outline-isearch-open-invisible-function 'outline-isearch-open-invisible
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-speed-command-hook '(org-speed-command-activate
 org-babel-speed-command-activate)
 org-persist-directory "/tmp/org-persist-ohZeX1"
 org-fold-core-isearch-open-function 'org-fold-core--isearch-reveal
 org-persist-before-write-hook '(org-element--cache-persist-before-write)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
 org-babel-header-arg-expand)
 org-link-shell-confirm-function 'yes-or-no-p
 org-babel-pre-tangle-hook '(save-buffer)
 org-agenda-loop-over-headlines-in-active-region nil
 org-occur-hook '(org-first-headline-recenter)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("attachment" :follow org-attach-follow
:complete org-attach-complete-link)
  ("eww" :follow org-eww-open :store
org-eww-store-link)
  ("rmail" :follow org-rmail-open :store
org-rmail-store-link)
  ("mhe" :follow org-mhe-open :store
org-mhe-store-link)
  ("irc" :follow org-irc-visit :store
org-irc-store-link :export org-irc-export)
  ("info" :follow org-info-open :export
org-info-export :store
org-info-store-link :insert-description
org-info-description-as-command)
  ("gnus" :follow org-gnus-open :store
org-gnus-store-link)
  ("docview" :follow org-docview-open
:export org-docview-export :store
org-docview-store-link)
  ("bibtex" :follow org-bibtex-open :store
org-bibtex-store-link)
  ("bbdb" :follow org-bbdb-open :export
org-bbdb-export :complete
org-bbdb-complete-link :store
org-bbdb-store-link)
  ("w3m" :store org-w3m-store-link)
  ("doi" :follow org-link-doi-open :export
org-link-doi-export)
  ("id" :follow org-id-open) ("file+sys")
  ("file+emacs")
  ("shell" :follow org-link--open-shell)
  ("news" :follow
#[514 "\301\300\302 Q \"\207"
 ["news" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("mailto" :follow
#[514 "\301\300\302 Q \"\207"
 ["mailto" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("https" :follow
#[514 "\301\300\302 Q \"\207"
 ["https" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("http" :follow
#[514 "\301\300\302 Q \"\207"
 ["http" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("ftp" :follow
#[514 "\301\300\302 Q \"\207"
 ["ftp" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("help" :follow org-link--open-help :store
org-link--store-help)
  ("file" :complete org-link-complete-file)
  ("elisp" :follow org-link--open-elisp))
 org-metaup-hook '(org-babel-load-in-session-maybe)
 )


Re: [ANN] orgtbl-fit

2023-03-05 Thread tbanelwebmin




On 3/3/23 16:13, Ihor Radchenko wrote:



 BTW, the dollar replacement is something org-table can benefit from---a
 number of people are confused because "$" is treated specially by Calc.

I'm not sure what you mean. The dollar in spreadsheet formulas? Like:
#+TBLFM: $6=$5+1

Which means that I misread the sources. I was referring to
  | 2$ | 3$| #ERROR |
  #+tblfm: $3=$2+$1

Error in the above is because Calc handles "$" specially.


Org or Calc was waiting for something after the $, as in the last row of 
this table:


| |    | sum    | error message   |
|-+++-|
| 2$  | 3$ | #ERROR | $'s not allowed in this context |
| 2_  | 3_ | #ERROR | Expected a number   |
| 2€  | 3€ | #ERROR | Expected `)'    |
| 2㍐ | 3¥ | #ERROR | Expected `)'    |
| 2£  | 3£ | #ERROR | Expected `)'    |
| 2*  | 3+ | #ERROR | Expected a number   |
| 2   | 3  | 5  | |
| $2  | 3  | 6  | |
| 2$2 | 3  | 9  | |
 #+tblfm: $3=$2+$1




 We can, but it should be first and foremost added to GNU Calc. On Org
 side, we just need appropriate integration. Maintaining generic data
 analysis code in Org is out of Org's scope.

Absolutely

Although the latest Calc release seams to be 2.02f, dating back in January 
1992. Has it reached perfection 31
years ago?

No. It became a part of Emacs, AFAIU.
New (small) things are being added to Calc as a part of Emacs development.



Good!
So, what you said makes sense: adding features to Calc, and then giving 
access to them from Org.








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/)]

2023-03-05 Thread Ihor Radchenko
Andrea Lazzarini  writes:

> If some languages require it and some not, as you correctly say, couldn't the 
> behaviour be customizable? 

Maybe. But we are not only talking about footnotes.
Consider

* Heading [0/1] text

Or

Text with newline\\
[footnote]  more text.

or

Text (parens[footnote] ).

It might be enough to use spaces if and only if there are no preceding
spaces. Or not. One may think of other edge cases.

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



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/)]

2023-03-05 Thread Andrea Lazzarini
If some languages require it and some not, as you correctly say, couldn't the 
behaviour be customizable? 

> Il giorno 5 mar 2023, alle ore 13:42, Ihor Radchenko  ha 
> scritto:
> 
> 
> Andrea Lazzarini  writes:
>> Consider the fact that I had to put an extra space before the footnote 
>> exactly to have a space (not an extra one) in the result.
>> 
>> As you say, couldn't it be replaced with:
>> 
>>> maybe with number of spaces equal to :post-blank ?
> 
> Sure, but footnotes are expected to have space before in some languages:
> 
> Sentence. [footnote] Another sentence.
> 
> Keeping the space after will leave us with _two_ spaces:
> 
> Sentence.  Another sentence.
> 
> Not ideal when exporting to, say, ASCII.
> 
> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 




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/)]

2023-03-05 Thread Ihor Radchenko


Andrea Lazzarini  writes:
> Consider the fact that I had to put an extra space before the footnote 
> exactly to have a space (not an extra one) in the result.
>
> As you say, couldn't it be replaced with:
>
>> maybe with number of spaces equal to :post-blank ?

Sure, but footnotes are expected to have space before in some languages:

 Sentence. [footnote] Another sentence.

Keeping the space after will leave us with _two_ spaces:

 Sentence.  Another sentence.

Not ideal when exporting to, say, ASCII.

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



Re: [FR] ob-awk.el specifying a delimeter argument in for output

2023-03-05 Thread Ihor Radchenko
Jeremie Juste  writes:

> * Request 
>
> However If I have a csv file with say semi column delimited values (;)
> I don't get the org table as output
>
> #+begin_src awk :in-file test1.csv :cmd-line -F ";"
> {print $0}
> #+end_src
>
> #+RESULTS:
> : 123;0;123

> In my opinion, this could be fixed if we could read the :cmd-line
> parameter -F  and use the delimeter argument ; as a parameter to the
> following function

Org knows nothing about your output, by default.
You could as well do something like {print $1+-+$2+-+$3}
What should Org do in such case?

Currently, Org tries to guess the type of arbitrary output. If the
output looks like a table, with fields separated by tabs, commas, or
spaces, it converts the output to table. Otherwise, it is treated as
string.

I guess we might add an option to tell Org which separator to use when
parsing output when :results table header argument is provided (see 16.6
Results of Evaluation section of Org manual). However, you can achieve
the same now, using :post header argument, replacing the separators with
something Org can understand.

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



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/)]

2023-03-05 Thread Andrea Lazzarini
Consider the fact that I had to put an extra space before the footnote exactly 
to have a space (not an extra one) in the result.

As you say, couldn't it be replaced with:

> maybe with number of spaces equal to :post-blank ?



> Il giorno 5 mar 2023, alle ore 13:06, Ihor Radchenko  ha 
> scritto:
> 
> Max Nikulin  writes:
> 
>> In my opinion, the filter removing footnotes should transfer afterspaces 
>> to preceding objects.
> 
> I am not sure.
> 
> Consider text like "Pellentesque dapibus suscipit ligula. [fn:1] Donec 
> posuere augue in quam."
> with space before the footnote. If we replace the footnote with space,
> two spaces will be exported. I am not sure if it is expected.
> 
> Also, should we replace footnote with a single space or with the number
> of spaces after?
> 
> Further, this bug is actually not just about footnotes. The footnotes
> are removed in `org-export--prune-tree':
> 
>(if (org-export--skip-p data info selected excluded)
> (if (memq type '(table-cell table-row)) (push data ignore)
>   (org-element-extract-element data))
> 
> The extracted objects can be latex-fragment, statistics-cookie,
> timestamp, and footnote.
> 
> Will it be safe to replace all the above with space? Or maybe with
> number of spaces equal to :post-blank? Something else?
> 
> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 




Re: [PATCH] org-clock: Add a trailing space to the mode line string

2023-03-05 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Please see the attached patch, revised as follows:
>
> - no leading space in the mode line element to make it completely correct
> - a clear explanation (with a citation) to avoid pointless discussions
> - two new automated tests to avoid future regressions
> - a clearer commit message
>

Thanks!
Applied, onto bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3d817c52c

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



Re: [PATCH] Async evaluation in ob-shell

2023-03-05 Thread Ihor Radchenko
Matt  writes:

>   On Fri, 03 Mar 2023 09:52:09 -0500  Ihor Radchenko  wrote --- 
>  > I tried the patch, and I am getting failed tests:
>  > 
>  > 1 unexpected results:
>
> Sorry for missing that.  The issue is that when I replaced
> `org-babel-sh-prompt' with `comint-prompt-regexp', the regexp no
> longer matches the output and grabs the next prompt.  It looks like
> the reason is `comint-prompt-regexp' is set to "^org_babel_sh_prompt>
> *" (with two spaces between the '>' and '*').  Attached is a revised
> patch which removes one of the spaces by changing how
> `org-babel-sh-initiate-session' sets the `comint-prompt-regexp'.
> Another place this could be done is in the defvar for
> `org-babel-sh-prompt' itself (which ends with a space).  However, I
> think it's customary to leave a trailing space for prompts?

The actual prompt is "org_babel_sh_prompt> ".
And we want to skip leading spaces in addition.

Adding " *" does not make the prompt match 2 spaces, but 1+.

Prompts with no single space are not prompts.

>
>  > > +  (let ((uuid (org-id-uuid)))
>  > 
>  > Do you need to use `org-id-uuid' here? ob-python directly uses `md5'.
>  > If you still prefer org-id-uuid, we probably need to move it to
>  > org-macs.el
>
> I just need a random string.  `md5' would work for that.  However,
> might it be better to update ob-R and ob-python to use `org-id-uuid'?
> Both of those manually declare the randomness.  It's conceivable that
> someone may delete or mistype the number (1), resulting in a
> lower entropy.  An md5 is also not a uuid, strictly speaking.  Of
> course, the chance of collision is still basically zero and the cost
> of collision about the same.  Using `org-id-uuid' would only provide a
> consistent way to do things.

`md5' will be slightly faster compared to `org-id-uuid'. But it should
not matter.

If we want use `org-id-uuid', lets move it to org-macs.el. Requiring the
whole org-id.el must not be done. It has side effects of defining id:
links.

>  (concat "^" (regexp-quote org-babel-sh-prompt)
> -" *"))
> +"*"))

This is wrong. It unconditionally makes the last char in
`org-babel-sh-prompt' 0+. (Imagine it is changed to non-space in
future).

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



Re: PATCH] orgcard.tex: Fix `org-force-cycle-archived' binding

2023-03-05 Thread Ihor Radchenko
Max Nikulin  writes:

> During discussion in the following thread I realized that the refcard 
> was not updated when `org-force-cycle-archived' binding was changed from 
> C-TAB to C-c C- to avoid conflict with switching of tabs.

Thanks!
Applied, onto bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=233a8479c

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



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/)]

2023-03-05 Thread Ihor Radchenko
Max Nikulin  writes:

> In my opinion, the filter removing footnotes should transfer afterspaces 
> to preceding objects.

I am not sure.

Consider text like "Pellentesque dapibus suscipit ligula. [fn:1] Donec posuere 
augue in quam."
with space before the footnote. If we replace the footnote with space,
two spaces will be exported. I am not sure if it is expected.

Also, should we replace footnote with a single space or with the number
of spaces after?

Further, this bug is actually not just about footnotes. The footnotes
are removed in `org-export--prune-tree':

(if (org-export--skip-p data info selected excluded)
  (if (memq type '(table-cell table-row)) (push data ignore)
(org-element-extract-element data))

The extracted objects can be latex-fragment, statistics-cookie,
timestamp, and footnote.

Will it be safe to replace all the above with space? Or maybe with
number of spaces equal to :post-blank? Something else?

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



Re: [BUG] FAQ asnwer for "How can I use arbitrary colors for words/sentences in HTML export?" is outdated

2023-03-05 Thread Max Nikulin

On 18/02/2023 17:18, Ihor Radchenko wrote:

In https://orgmode.org/worg/org-faq.html#org60202b9, the answer uses
obsolete function `org-add-link-type'. We should change it to
`org-link-set-parameters'.


Confirmed.

A newer recipe:

Juan Manuel Macías to emacs-orgmode… Re: how to export red colored TeX 
to latex. Tue, 30 Nov 2021 16:56:00 +. 
https://list.orgmode.org/87bl21vazj@posteo.net


Likely should be modified a bit to support derived backends.

The following package might be mentioned:

Colours section in org-special-block-extras
https://alhassy.com/org-special-block-extras/#Colours

Other files:
- org-tutorials/org-R/org-variables-counts.org
- org-tutorials/org-R/variable-popcon.org
Need review:
- org-hacks.org
  mid: links for org-gnus (not ol-gnus) and org-occur example
- exporters/anno-bib-template-worg.org
  citations using ebib
Outdated:
- org-tutorials/org-latex-export.org
  Org < 8.0
- org-configs/org-customization-survey.org
- org-configs/org-customization-survey-2013.org






[FR] ob-awk.el specifying a delimeter argument in for output

2023-03-05 Thread Jeremie Juste
Hello,

ob-awk has proven very valuable to me lately so many
thanks for maintaining it. 

First of all let me specify that I'm a beginner user of awk and I don't
know if I'm using ob-awk as it is intended, so I'll be glad for any
suggestions. Let me explain further:


* Default behavior

If I have a csv file with comma separated values, I get the output as an
org table.

;; test.csv
123,0,123


#+begin_src awk :in-file test.csv :cmd-line -F ","
{print $0}
#+end_src

#+RESULTS:
| 123 | 0 | 123 |

* Request 

However If I have a csv file with say semi column delimited values (;)
I don't get the org table as output

#+begin_src awk :in-file test1.csv :cmd-line -F ";"
{print $0}
#+end_src

#+RESULTS:
: 123;0;123


In my opinion, this could be fixed if we could read the :cmd-line
parameter -F  and use the delimeter argument ; as a parameter to the
following function

modified   lisp/ob-awk.el
@@ -93,7 +93,7 @@ This function is called by `org-babel-execute-src-block'."
   results
   (let ((tmp (org-babel-temp-file "awk-results-")))
 (with-temp-file tmp (insert results))
-(org-babel-import-elisp-from-file tmp)
+(org-babel-import-elisp-from-file tmp ";")


Would this be the right way to do think about this issue? 

Best regards,
Jeremie

PS Note that we have a samilar issue in ob-shell
where the delimiter is by default a comma. 

#+begin_src shell
  echo '192;168;1;200' | awk -F ";"   '{print $0}' 
#+end_src

#+RESULTS:
: 192;168;1;200



#+begin_src shell
  echo '192,168,1,200' | awk -F ","   '{print $0}' 
#+end_src

#+RESULTS:
| 192 | 168 | 1 | 200 |