Re: org-clock-report on headings and subheadings or for the whole file?

2022-11-14 Thread Uwe Brauer

> Uwe Brauer  writes:

> 8.4.2 The clock table:

>The ‘#+BEGIN’ line contains options to define the scope, structure,
> and formatting of the report.  Defaults for all these options can be
> configured in the variable ‘org-clocktable-defaults’.


thanks
-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/


smime.p7s
Description: S/MIME cryptographic signature


Re: org-clock-report on headings and subheadings or for the whole file?

2022-11-14 Thread Uwe Brauer

> Uwe Brauer  writes:

> What about the attached patch?

Sounds good to me
> From a5dff6d46044db868dd95f6b57c28dffb202c308 Mon Sep 17 00:00:00 2001
> Message-Id: 
> 
> From: Ihor Radchenko 
> Date: Tue, 15 Nov 2022 09:35:47 +0800
> Subject: [PATCH] org-clock-report: Improve docstring

> * lisp/org-clock.el (org-clock-report): Clarify :scope when called
> from inside a heading or before first heading.  Separate :scope
> description into a separate paragraph.

> Reported-by: Uwe Brauer 
> Link: https://orgmode.org/list/87h6z2c8pf@mat.ucm.es
> ---
>  lisp/org-clock.el | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)

> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 9dacc050d..604b5481c 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -2146,10 +2146,12 @@ (defun org-clock-report ( arg)
>  Otherwise, insert a new one.
 
>  The new table inherits its properties from the variable
> -`org-clock-clocktable-default-properties'.  The scope of the
> -clocktable, when not specified in the previous variable, is
> -`subtree' when the function is called from within a subtree, and
> -`file' elsewhere.
> +`org-clock-clocktable-default-properties'.
> +
> +The scope of the clocktable, when not specified in the previous
> +variable, is `subtree' of the current heading when the function is
> +called from inside heading, and `file' elsewhere (before the first
> +heading).
 
>  When called with a prefix argument, move to the first clock table
>  in the buffer and update it."
> -- 
> 2.35.1

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/


smime.p7s
Description: S/MIME cryptographic signature


[RFC] :var x=list-name should be resolved into simple lists (item1 item2 ...); not nested ((item1) (item2) ...) (was: 2 'echo' bash instructions produce a table)

2022-11-14 Thread Ihor Radchenko
Ihor Radchenko  writes:

>> In section 16.4 (Environment of a Code Block)
>>
>> A simple named list.
>>
>>   #+NAME: example-list
>>   - simple
>> - not
>> - nested
>>   - list
>>
>>   #+BEGIN_SRC emacs-lisp :var x=example-list
>> (print x)
>>   #+END_SRC
>>
>>   #+RESULTS:
>>   | simple | list |
>>
>> But if I evaluate the code, I get
>>
>>   #+RESULTS:
>>   | simple | (unordered (not) (nested)) |
>>   | list   ||
>
> Confirmed. Need to look into this.

The attached is a fix for this discrepancy with the manual.

However, it looks like at least ob-java already tried to work around the
erroneous return value of org-babel-read-list.

Hence, we at least need to announce this fix in ORG-NEWS.

Or maybe there are other objections?

>From cc1dbc5ca61d04e8a52598feb031e24102575f0d Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Tue, 15 Nov 2022 13:52:04 +0800
Subject: [PATCH] ob-core: Resolve named list references to simple lists

* lisp/ob-core.el (org-babel-read-list): Return a simple list instead
of list of lists.  Document this in the docstring.
* testing/lisp/test-ob-java.el (ob-java/read-return-list):
(ob-java/read-list-return-array):
(ob-java/read-return-list-with-package): Fix tests assuming previous
behavior.
* testing/lisp/test-ob.el (test-ob/simple-variable-resolution): Add
new tests.
* etc/ORG-NEWS (List references in source block variable assignments
are now proper lists): Document the change.

This commit fixes the broken promise in the manual section 16.4
Environment of a Code Block where the named references to lists should
be converted to simple lists consisting of the top-level items.

The inconsistency existed for a while and possibly lurked into some
third-party packages.  So, announcement in NEWS is required.

Reported-by: alain.coch...@unistra.fr
Link: https://orgmode.org/list/87pmdqfao4.fsf@localhost
---
 etc/ORG-NEWS | 34 ++
 lisp/ob-core.el  | 11 +--
 testing/lisp/test-ob-java.el | 10 +-
 testing/lisp/test-ob.el  | 26 +++---
 4 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 04b5be64a..4e23ac0e3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -701,6 +701,40 @@ If you prefer to keep the keybinding, you can add it back to
 (define-key org-mode-map (kbd "C-c SPC") #'org-table-blank-field)
 #+end_src
 
+*** List references in source block variable assignments are now proper lists
+
+List representation of named lists is now converted to a simple list
+as promised by the manual section [[info:org#Environment of a Code Block][org#Environment of a Code Block]].
+Previously, it was converted to a list of lists.
+
+Before:
+
+#+begin_src org
+,#+NAME: example-list
+- simple
+  - not
+  - nested
+- list
+
+,#+BEGIN_SRC emacs-lisp :var x=example-list :results value
+(format "%S" x)
+,#+END_SRC
+
+,#+RESULTS:
+: (("simple" (unordered ("not") ("nested"))) ("list"))
+#+end_src
+
+After:
+
+#+begin_src org
+,#+BEGIN_SRC emacs-lisp :var x=example-list :results value
+(format "%S" x)
+,#+END_SRC
+
+,#+RESULTS:
+: ("simple" "list")
+#+end_src
+
 ** New features
 
 *** New citation engine
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 1259909a0..3a07c10d5 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2239,8 +2239,15 @@ (defun org-babel-read-table ()
   (org-table-to-lisp)))
 
 (defun org-babel-read-list ()
-  "Read the list at point into emacs-lisp."
-  (mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval))
+  "Read the list at point into emacs-lisp.
+
+Return the list of strings representing top level items:
+
+   (item1 item2 ...)
+
+Only consider top level items.  See Info node `(org)Environment of \
+a Code Block'."
+  (mapcar (lambda (el) (org-babel-read (car el) 'inhibit-lisp-eval))
 	  (cdr (org-list-to-lisp
 
 (defvar org-link-types-re)
diff --git a/testing/lisp/test-ob-java.el b/testing/lisp/test-ob-java.el
index 07540ed74..65b7259d3 100644
--- a/testing/lisp/test-ob-java.el
+++ b/testing/lisp/test-ob-java.el
@@ -379,8 +379,8 @@ (ert-deftest ob-java/read-return-list ()
   "#+begin_src java :dir 'nil :var a=java_list :results value silent
 import java.util.List;
 import java.util.Arrays;
-List b = Arrays.asList(a.get(0).get(0),
-   a.get(1).get(0));
+List b = Arrays.asList(a.get(0),
+   a.get(1));
 return b;
 #+end_src
 
@@ -394,7 +394,7 @@ (ert-deftest ob-java/read-list-return-array ()
   "Read a list and return an array."
   (org-test-with-temp-text
   "#+begin_src java :dir 'nil :var a=java_list :results value silent
-String[] b = {a.get(0).get(0), a.get(1).get(0)};
+String[] b = {a.get(0), a.get(1)};
 return b;
 #+end_src
 
@@ -411,8 +411,8 @@ (ert-deftest ob-java/read-return-list-with-package ()
 package pkg;
 import java.util.List;
 import 

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

2022-11-14 Thread Ihor Radchenko
Max Nikulin  writes:

>  > (string-collate-lessp "a" "B" "C" t)  ; => nil
> Actually you wrote
>> [FYI: If I replace nil with t, the procedure returns nil too.]
>  From my point of view it is a reason to file an Emacs bug because I get
>
>  (string-collate-lessp "a" "B" "C" t) ; => t

I submitted the bug report to Emacs.
See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59275

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



Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]

2022-11-14 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> Ihor Radchenko writes:
>
>> However, the PDF (see the attached) is erroneous:
>> 1. Title "Temp" is written RTL
>> 2. Year and date (numbers!) are written RTL
>> 3. The python code is written RTL!!
>>
>> Just the equation is rendered LTR as expected and the ordinary Hebrew
>> text is rendered RTL.
>
> I'd say that's expected behavior. Note that if you declare Hebrew as the
> main language, the LaTeX classes (in this case article.cls) will put
> whatever is necessary in Hebrew and use the Hebrew (and RTL) typographic
> rules where necessary, and that includes the title, the date, and the
> various literal strings as the table of contents, figure counters,
> captions, etc.

I agree about year, title, and date. However, not the code. I'd expect
code snippets to use LTR by default. Maybe with an export flag to switch
to RTL.

> To use Hebrew in another context, it would have to be declared as a
> secondary language. The latest versions of Babel allow you to associate
> languages to scripts when it comes to non-Latin alphabets (Cyrillic,
> Greek, Arabic, etc.), and also to associate fonts. In this way it would
> not be necessary to indicate the language explicitly by means of a
> \selectlanguage{} or \foreignlanguage{}{}. For example, suppose that my
> document has Spanish as its main language, but I also add parts in
> Hebrew, which would be automatically recognized by Babel, by putting
> this:
>
> #+LaTeX_Header: \usepackage{fontspec}
> #+LaTeX_Header: \setmainfont{FreeSerif}
> #+LaTeX_Header: \usepackage[AUTO,bidi=basic]{babel}
> #+LaTeX_Header: \babelprovide[onchar=ids,import]{hebrew}
> #+language: es

Should we allow #+language to have multiple values like

#+language: es en ru uk

with first value defining primary language and the rest being secondary?

Also, what does bidi=basic do?

Finally, may it be useful to provide a syntax (affiliated keyword) that
will set a language for specific paragraph?

> Perhaps a FONTS item could be added in "LaTeX specific export settings"?

Do we have #+FONTS setting? I'd say that it is worth adding.

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



Re: [PATCH v2] org-attach.el: ID to path functions may return nil

2022-11-14 Thread Ihor Radchenko
Max Nikulin  writes:

> On 14/11/2022 10:29, Ihor Radchenko wrote:
>> 
>> I went through the patch and tried to clarify the wording.
>> Especially in the defcustom docstring.
>
> I do not mind in general.
>
> Please, remove a stray space in the defcustom.

Hmm. Done.

I just have a habit to add space in the first item in a list because it
helps auto-indentation. Leading space indicates that the list is not a
function call and should not be indented as (function args...).

It is not necessary in here though.

>> I also added the dumb fallback to the default value.
>> I feel that otherwise the description of too confusing.
>
> I am unsure concerning adding it to the default value. From my point of 
> view, it is better to ask user to clarify their intention. I believe 
> that the obscure error message is the real bug, not that Org can not 
> handle too short ID by default.

We have fixed the error message in this patch as well.

Handling too short IDs is a different issue indeed, but why not to fix
it as well?

> I think, for new users default value should include just strict variants 
> of `org-attach-id-uuid-folder-format' and 
> `org-attach-id-ts-folder-format' that checks ID format as in the example 
> in ORG-NEWS. Changing of `org-id-method' will not cause non-optimal 
> subdir layout for the same value of 'org-attach-id-to-path-function-list'.
>
> It will cause a problem for users who changed `org-id-method' in the 
> past, so they have either XX/timestamp or MM/uuid subdirectories. It 
> may be solved by adding original variants of 
> `org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format', 
> but perhaps it is better to add predicates for "wrong" style (UUID or 
> Org for timestamp and vice versa) just for backward compatibility.

>> +org-attach-id-ts-folder-format
>> +
>> org-attach-id-fallback-folder-format)
>
> If strict variants of functions were used above then non-standard IDs 
> would be isolated in the directory returned by the next entry

Good point.
What about using the value you provided in the NEWS as an actual default?

> It should be responsibility of the user to setup subdirs layout for 
> non-standard ID format. The dumb fallback is intended as an example and 
> a variant for those who do not have a lot of attachments and do not care 
> where they are stored.

I'd say that the probability to get too many attachments with short IDs
is pretty low. We will help more users if we make Org handle short IDs
by default.

>> +#+begin_src emacs-lisp
>> +(setq org-attach-id-to-path-function-list
>> +  '(;; When ID looks like an UUIDs or Org internal ID, use
>> +;; `org-attach-id-uuid-folder-format'.
>> +(lambda (id)
>> +  (and (or (org-uuidgen-p id)
>> +   (string-match-p "[0-9a-z]\\{12\\}" id))
>> +   (org-attach-id-uuid-folder-format id)))
>> +;; When ID looks like a timestap-based ID. Group by year-month
>> +;; folders.
>> +(lambda (id)
>> +  (and (string-match-p "[0-9]\\{8\\}T[0-9]\\{6\\}\.[0-9]\\{6\\}" id)
>> +   (org-attach-id-ts-folder-format id)))
>> +;; Any other ID goes into "important" folder.
>> +(lambda (id) (format "important/%s/%s" (substring id 0 1) id
>
> `org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format' 
> here were added for users changed `org-id-method' in the past and so 
> having mixed subdirs layout with UUIDs in 6 character prefix directories 
> or timestamps in two characters folders.

Agree. Fixed.

See the attached updated patch.

>From 0be519670eeacdeab198a4160e48601d1fb22a49 Mon Sep 17 00:00:00 2001
Message-Id: <0be519670eeacdeab198a4160e48601d1fb22a49.1668479703.git.yanta...@posteo.net>
From: Max Nikulin 
Date: Mon, 7 Nov 2022 23:48:02 +0700
Subject: [PATCH v5] org-attach.el: ID to path functions may return nil

* lisp/org-attach.el (org-attach-dir-from-id): Ignore nil values
returned by entries from `org-attach-id-to-path-function-list'.
(org-attach-dir-get-create): Signal an error suggesting customization
of `org-attach-id-to-path-function-list' if all ID-to-path functions
return nil.
(org-attach-id-to-path-function-list): Add to the docstring examples
how to handle unusual IDs.
(org-attach-id-uuid-folder-format, org-attach-id-ts-folder-format):
Return nil if ID is too short.
(org-attach-id-fallback-folder-format): New function that may be added
as the last element of `org-attach-id-path-function-list' to handle
unexpectedly short IDs.
* etc/ORG-NEWS: Advertise the change.

Earlier an obscure error like 'org-attach-id-ts-folder-format: Args out
of range: "ftt", 0, 6' was signalled in the case of unexpectedly short
ID.

Reported-by: Janek F 
Link: https://list.orgmode.org/KC8PcypJapBpJQtJxM0kX5N7Z0THL2Lq6EQjBMzpw1-vgQf72egZ2JOIlTbPYiqAVD4MdSBhrhBZr2Ykf5DN1mocm1ANvvuKKZShlkgzKYM=@pm.me
---
 etc/ORG-NEWS   |  44 +++
 

Re: Seeing all the steps when I run an R code block

2022-11-14 Thread Ihor Radchenko
William Denton  writes:

> I've got a few problems with R source blocks that I can't figure out.  They 
> started late last month, I think.  I'm running Emacs and Org from the 
> development trees, refreshing and recompiling regularly.  ESS (the package 
> for 
> working with R) is up to date too.
>
> Here's one big problem.  I have a file, /home/wtd/books/reading/test-r.org, 
> and 
> in it is this R block:
> ...
> # -
>
>> setwd('/home/wtd/books')
>
> # -
>
> It's in the directory *above* where the Org file is!  It should be in 
> /home/wtd/books/reading/.

I tried to test with a clean config and bare ESS installation will raise
the following query:

R:2 starting project directory? /tmp/

Note the default value /tmp which is `default-directory' containing test
Org file in my testing.

You might have set some customization that overrides `default-directory'
setting in ESS.

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



Re: OrgModeClockingXBar - see a task when you clock in in your bar and not only

2022-11-14 Thread Ihor Radchenko
"Christopher M. Miles"  writes:

>> https://github.com/mmagnus/OrgModeClockingXBar
>>
>> Magnus
>
> Thanks for sharing, this is what I needed.

Do we have a page in WORG that discusses ways to display clocked task in
taskbar for Linux/Windows/Mac?

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



Re: [PATCH] ox-latex: fix `org-latex-guess-babel-language'

2022-11-14 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> If the user puts a string other than AUTO as an argument to
> `\babelprovide', it gives an error when exporting. For example:
>
> `#+LaTeX_Header: \babelprovide[]{hebrew}'
>
> I am attaching a patch to fix that behaviour.

Thanks!
Could you also add a test to testing/lisp/test-ox-latex.el?

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



Re: [BUG] A commented line breaks line numbering [9.6-pre (release_9.5.5-1058-g6ef33b @ /home/thblt/.emacs.d/lib/org/lisp/)]

2022-11-14 Thread Ihor Radchenko
Thibault Polge  writes:

> With org 9.6-pre, a commented out line breaks list numbering (even with
> `org-list-repair`), and effectively breaks a list in two distinct lists
> in exporters.  Eg:
>
>  1. Item 1
>  2. Item 2
>  # 3. Commented out item 3
>  1. Reset counter?
>
> At "Reset counter?", HTML export opens a new  there, LaTex a new
> \begin{enumerate}
>
> This may be expected behavior --- it's present in Pandoc as well

It is by design, and it was like this forever, not just in Org 9.6.
Comments are a valid structural element in Org AST. They are just not
exported.

It also means that comments can belong to a list item:

1. Item 1
2. Item 2
   # 3. Commented out item 3
3. Reset counter?

The above does not break the list into two because the comment is
considered to be a part of the "Item 2".

> --- but
> it's surprising, since I'd expect a comment line to be fully ignored
> from the comment marker to the final \n, inclusive.  I'd thus expect the
> above example to be perfectly equivalent to:
>
>  1. Item 1
>  2. Item 2
>  3. Reset counter?  
>
> And to export as a single /enumerate.

This can be done on export, but it will then create inconsistency
between Org buffer behaviour and what you see on export.

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



Re: org-clock-report on headings and subheadings or for the whole file?

2022-11-14 Thread Ihor Radchenko
Uwe Brauer  writes:

>> Uwe Brauer  writes:
>
>
>> :indent nil
>
>> See 8.4.2 The clock table
>
> Ok I read this, but I cannot see how to configure the default behavior of the 
> clocktable

8.4.2 The clock table:

   The ‘#+BEGIN’ line contains options to define the scope, structure,
and formatting of the report.  Defaults for all these options can be
configured in the variable ‘org-clocktable-defaults’.

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



Re: org-clock-report on headings and subheadings or for the whole file?

2022-11-14 Thread Ihor Radchenko
Uwe Brauer  writes:

>> This information is already in the docstring
>
>> The new table inherits its properties from the variable
>> org-clock-clocktable-default-properties.  The scope of the
>> clocktable, when not specified in the previous variable, is
>> subtree when the function is called from within a subtree, and
>> file elsewhere.
>
>> Or do you think it can be expressed better?
>
> It is the term *subtree* that I find confusing.
>
>
> * Introduction
> ** Details
>
> <-- that is for me within a subtree
>
> * Introduction
> * Details
>
> <-- that is for me within a tree
>
> So why not
>
> The scope of the clocktable, when not specified in the previous
> variable, is subtree when the function is called from within a subtree
> or tree and file elsewhere. So if you want a clocktable for the whole
> file, you should call the function before the first heading.

What about the attached patch?

>From a5dff6d46044db868dd95f6b57c28dffb202c308 Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Tue, 15 Nov 2022 09:35:47 +0800
Subject: [PATCH] org-clock-report: Improve docstring

* lisp/org-clock.el (org-clock-report): Clarify :scope when called
from inside a heading or before first heading.  Separate :scope
description into a separate paragraph.

Reported-by: Uwe Brauer 
Link: https://orgmode.org/list/87h6z2c8pf@mat.ucm.es
---
 lisp/org-clock.el | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9dacc050d..604b5481c 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -2146,10 +2146,12 @@ (defun org-clock-report ( arg)
 Otherwise, insert a new one.
 
 The new table inherits its properties from the variable
-`org-clock-clocktable-default-properties'.  The scope of the
-clocktable, when not specified in the previous variable, is
-`subtree' when the function is called from within a subtree, and
-`file' elsewhere.
+`org-clock-clocktable-default-properties'.
+
+The scope of the clocktable, when not specified in the previous
+variable, is `subtree' of the current heading when the function is
+called from inside heading, and `file' elsewhere (before the first
+heading).
 
 When called with a prefix argument, move to the first clock table
 in the buffer and update it."
-- 
2.35.1


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


Re: [PATCH v2] org-attach.el: ID to path functions may return nil

2022-11-14 Thread Max Nikulin

On 14/11/2022 10:29, Ihor Radchenko wrote:


I went through the patch and tried to clarify the wording.
Especially in the defcustom docstring.


I do not mind in general.

Please, remove a stray space in the defcustom.


I also added the dumb fallback to the default value.
I feel that otherwise the description of too confusing.


I am unsure concerning adding it to the default value. From my point of 
view, it is better to ask user to clarify their intention. I believe 
that the obscure error message is the real bug, not that Org can not 
handle too short ID by default.


I think, for new users default value should include just strict variants 
of `org-attach-id-uuid-folder-format' and 
`org-attach-id-ts-folder-format' that checks ID format as in the example 
in ORG-NEWS. Changing of `org-id-method' will not cause non-optimal 
subdir layout for the same value of 'org-attach-id-to-path-function-list'.


It will cause a problem for users who changed `org-id-method' in the 
past, so they have either XX/timestamp or MM/uuid subdirectories. It 
may be solved by adding original variants of 
`org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format', 
but perhaps it is better to add predicates for "wrong" style (UUID or 
Org for timestamp and vice versa) just for backward compatibility.


It should be responsibility of the user to setup subdirs layout for 
non-standard ID format. The dumb fallback is intended as an example and 
a variant for those who do not have a lot of attachments and do not care 
where they are stored.



+#+begin_src emacs-lisp
+(setq org-attach-id-to-path-function-list
+  '(;; When ID looks like an UUIDs or Org internal ID, use
+;; `org-attach-id-uuid-folder-format'.
+(lambda (id)
+  (and (or (org-uuidgen-p id)
+  (string-match-p "[0-9a-z]\\{12\\}" id))
+  (org-attach-id-uuid-folder-format id)))
+;; When ID looks like a timestap-based ID. Group by year-month
+;; folders.
+(lambda (id)
+  (and (string-match-p "[0-9]\\{8\\}T[0-9]\\{6\\}\.[0-9]\\{6\\}" id)
+   (org-attach-id-ts-folder-format id)))
+;; Any other ID goes into "important" folder.
+(lambda (id) (format "important/%s/%s" (substring id 0 1) id


`org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format' 
here were added for users changed `org-id-method' in the past and so 
having mixed subdirs layout with UUIDs in 6 character prefix directories 
or timestamps in two characters folders.



+#+end_src



+(defun org-attach-id-fallback-folder-format (id)
+  "Return \"__/X/ID\" folder path as a dumb fallback.
+X is the first character in the ID string.
+
+This function may be appended to `org-attach-id-path-function-list' to
+provide a fallback for non-standard ID values that other functions in
+`org-attach-id-path-function-list' are unable to handle.  For example,
+when the ID is too short for `org-attach-id-ts-folder-format'.
+
+However, we recommend to define a more specific function spreading
+entries over multiple folders.  This function may create a large
+number of entries in a single folder, which may cause issues on some
+systems."
+  (format "__/%s/%s" (substring id 0 1) id))


Additional single character subdir level should be a minor improvement, 
unless `org-id-prefix' is non-nil.



+(defcustom org-attach-id-to-path-function-list '( 
org-attach-id-uuid-folder-format

space --^


+   org-attach-id-ts-folder-format


If strict variants of functions were used above then non-standard IDs 
would be isolated in the directory returned by the next entry



+org-attach-id-fallback-folder-format)


So I do not have strong objections since default value of 
`org-attach-id-to-path-function-list' may be adjusted later. Maybe 
strict variants of ID to subdir functions should be added as named 
functions. Fortunately it does not conflict with the patch variant your 
suggested. Feel free to commit your version.




[BUG] A commented line breaks line numbering [9.6-pre (release_9.5.5-1058-g6ef33b @ /home/thblt/.emacs.d/lib/org/lisp/)]

2022-11-14 Thread Thibault Polge
Hello,

With org 9.6-pre, a commented out line breaks list numbering (even with
`org-list-repair`), and effectively breaks a list in two distinct lists
in exporters.  Eg:

 1. Item 1
 2. Item 2
 # 3. Commented out item 3
 1. Reset counter?

At "Reset counter?", HTML export opens a new  there, LaTex a new
\begin{enumerate}

This may be expected behavior --- it's present in Pandoc as well --- but
it's surprising, since I'd expect a comment line to be fully ignored
from the comment marker to the final \n, inclusive.  I'd thus expect the
above example to be perfectly equivalent to:

 1. Item 1
 2. Item 2
 3. Reset counter?  

And to export as a single /enumerate.

Regards,
Thibault



Re: org-clock-report on headings and subheadings or for the whole file?

2022-11-14 Thread Uwe Brauer

> Uwe Brauer  writes:


> :indent nil

> See 8.4.2 The clock table

Ok I read this, but I cannot see how to configure the default behavior of the 
clocktable


So in my case it is inserted the only thing that can be changed is the
scope, but other options I have to add or modify manually after I
inserted a table, right?


#+BEGIN: clocktable :scope subtree :maxlevel 2
#+CAPTION: Clock summary at [2022-11-14 08:14]
| Headline | Time   |
|--+|
| *Total time* | *0:31* |
|--+|
| Nonlinear| 0:31   |
#+END:

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/


smime.p7s
Description: S/MIME cryptographic signature


Re: org-clock-report on headings and subheadings or for the whole file?

2022-11-14 Thread Uwe Brauer
>>> "IR" == Ihor Radchenko  writes:

> Uwe Brauer  writes:
>> Correct, I did since I found it «logical» to have that table at the end of 
>> the file, but now I understand the problem with this. Thanks 
>> 
>> Ok, but I think it would not be bad to add this information to the docstring 
>> of org-clock-report!? It is not that intuitive.

> This information is already in the docstring

> The new table inherits its properties from the variable
> org-clock-clocktable-default-properties.  The scope of the
> clocktable, when not specified in the previous variable, is
> subtree when the function is called from within a subtree, and
> file elsewhere.

> Or do you think it can be expressed better?

It is the term *subtree* that I find confusing.


* Introduction
** Details

<-- that is for me within a subtree

* Introduction
* Details

<-- that is for me within a tree

So why not

The scope of the clocktable, when not specified in the previous
variable, is subtree when the function is called from within a subtree
or tree and file elsewhere. So if you want a clocktable for the whole
file, you should call the function before the first heading.


Or something like this


>> BTW when I move one heading to a subheading the table reads 
>> 
>> #+BEGIN: clocktable :scope file :maxlevel 2
>> #+CAPTION: Clock summary at [2022-11-13 08:46]
>> | Headline | Time   |  |
>> |--++--|
>> | *Total time* | *2:33* |  |
>> |--++--|
>> | Symmetric| 2:33   |  |
>> | \_  $A^0$ condition   || 0:03 |
>> #+END:
>> 
>> Is there any way to avoid \   in the tanble

> :indent nil

Thanks



-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/


smime.p7s
Description: S/MIME cryptographic signature


[FR] Allow noweb references from external files

2022-11-14 Thread Ihor Radchenko
Alexander Dinges  writes:

> Tangling a noweb src-block which is in another file does not work. See
> https://www.reddit.com/r/orgmode/comments/tb9reu/how_to_tangle_a_code_block_containing_noweb_from/
> and
> https://stackoverflow.com/questions/47058372/in-org-mode-how-to-call-code-block-to-evaluate-from-other-org-file/61580716#61580716

I agree that supporting noweb references from external files is a
reasonable feature to add.

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



Re: OrgModeClockingXBar - see a task when you clock in in your bar and not only

2022-11-14 Thread Christopher M. Miles

mag_dex  writes:

> Dear All,
>
> I designed a hack to see your clocked-in task on your bar (and not only).
>
> The hack is composed of a few elements, Emacs code that adds hooks for 
> clock-in and clock-out and a code
> for Xbar.
>
> I have been using this for 2 years, and it's pretty robust. I didn't have 
> time to share it before.
>
> The code is not perfect, if you quit your Emacs, without clocking-out the 
> content of the file will not be
> changed so you will not see any update on the bar (at least not till next 
> clocking-in or -out)
>
> https://github.com/mmagnus/OrgModeClockingXBar
>
> Magnus

Thanks for sharing, this is what I needed.

-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


signature.asc
Description: PGP signature


Re: org-clock-report on headings and subheadings or for the whole file?

2022-11-14 Thread Ihor Radchenko
Uwe Brauer  writes:

> Correct, I did since I found it «logical» to have that table at the end of 
> the file, but now I understand the problem with this. Thanks 
>
> Ok, but I think it would not be bad to add this information to the docstring 
> of org-clock-report!? It is not that intuitive.

This information is already in the docstring

The new table inherits its properties from the variable
org-clock-clocktable-default-properties.  The scope of the
clocktable, when not specified in the previous variable, is
subtree when the function is called from within a subtree, and
file elsewhere.

Or do you think it can be expressed better?

> BTW when I move one heading to a subheading the table reads 
>
> #+BEGIN: clocktable :scope file :maxlevel 2
> #+CAPTION: Clock summary at [2022-11-13 08:46]
> | Headline | Time   |  |
> |--++--|
> | *Total time* | *2:33* |  |
> |--++--|
> | Symmetric| 2:33   |  |
> | \_  $A^0$ condition   || 0:03 |
> #+END:
>
> Is there any way to avoid \   in the tanble

:indent nil

See 8.4.2 The clock table

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



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-14 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> I note that you did not mention in the news that MathJax 2 support is
>> dropped. This is a very important thing we must highlight and ring all
>> the bells about.
>
> Fixed.  See the 8th revision of the patch attached below.  Better?

Thanks! Yes, better.

>> However, it could be at least a good idea to warn the users who are
>> trying to use MathJax 2.  Would it be possible?
>
> As far as I know, we have no reliable way of knowing the version of
> MathJax without actually reading the JavaScript file, locally and
> remotely.

I see. Then, we probably cannot have automatic and full backwards
compatibility anyway.

Before we proceed with the merge, I'd like to ping Bastien in case if he
has any objections.

Bastien, this is a breaking change that potentially affects the users
who use custom path to MathJax 2 in their config. Unfortunately, there
is no way to introduce MathJax 3 yet not breaking things for such users.
Is the current news entry is sufficient? Or should we do something in
addition to announce backwards-incompatible change?

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



Re: svg file from tikz picture

2022-11-14 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Akira Kyle  writes:
>
>> I've been using the attached patch for the last few years and I've meaning 
>> to send it here/start a discussion about ob-latex.el since I used it pretty 
>> much daily to write tikz figures in org mode. So I'm glad to see this 
>> discussion has been started!

Hi Akira,

Have you had a chance to look into my comments?

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



Re: Getting X selection reliably (Re: idea for capture anywhere in x)

2022-11-14 Thread Ihor Radchenko
Max Nikulin  writes:

>> I am unsure what can be done here. AFAIU, Org just follows the %x
>> description. Nothing wrong on Org side.
>> 
>> The best we can do is alternative %?? that will do something more
>> reliable. But I am unsure what it can be.
>
> Depending of particular capture template (even with :immediate-finish t) 
> empty selection may or may not be an error. In Samuel's case it is an 
> error. Unfortunately, while the template is processed, signaled errors 
> are caught and their text is inserted into the text. That is why in my 
> example I put checks outside of `org-capture'.

Are you sure? `org-get-x-clipboard' returns nil in case of error and
`org-capture-fill-template' assigns empty string to v-x when no
clipboard value can be obtained.

> We may:
> - Add a capture template option that allows errors to pass through to 
> the caller. Then a user may add %(...) expression with all necessary checks.

I am not very sure what kind of errors you are talking about. AFAIU, we
are talking about scenarios when user explicitly wants one of
PRIMARY/CLIPBOARD/SECONDARY, don't we?

>>> 2. Jean pointed out that Emacs ignores X selection if it does not have
>>> an X frame. It was almost buried in the haystack of "SQL instead of Org"
>>> noise. It happens if Emacs is running as a daemon. I am unsure which way
>>> Samuel starts Emacs (xinit, systemd user session, systemd socket
>>> activation, manually, etc.)
>> 
>> May we modify org-get-x-clipboard adding
>> (server-select-display (getenv \"DISPLAY\")) ?
>> Will it be enough?
>
> It will work for most of users, however sometimes it is incorrect. There 
> are a number of options that should have higher priority than emacs 
> server DISPLAY environment
> - emacsclient -display command line option,
> - emacsclient process DISPLAY environment,
> - emacs -display server argument.
>
> I have no idea how to get "emacs -display" argument and I need to look 
> into emacsclient source and server.el to figure out which way client's 
> display argument is passed to the server process.

Maybe it can be considered an Emacs bug or something to improve on Emacs
side?

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



Re: [RFC] Re: Headings and Headlines

2022-11-14 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> P.S. We should also harmonize `evaluate' and `execute'; I can never tell
> which one to look for when completing.

Please open a separate thread. I am not sure which one is better.
For "execute" vs. "evaluate" we just need to rename function/variable
names and replace in text/docstrings.

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



Re: [BUG] Missing definitions for some customization groups [9.5.5 (release_9.5.5 @ /snap/emacs/current/usr/share/emacs/28.2/lisp/org/)]

2022-11-14 Thread Ihor Radchenko
Kyrylo Simonov  writes:

> Some of the customization groups in org-mode lack defgroup declaration.
> Specifically, they are:
> (org-gnus org-startup org-export-pdf org-bbdb org-babel-tangle
> org-bibtex org-plot)
>
> In the *Customize* interface, these subgroups are not accessible from
> the main Org customization page and vice versa.  To reproduce, type
> "M-x customize-group org" and witness that, for example, Org Startup
> subgroup is not listed.  Then type "M-x customize-group org-startup" and
> see that the group definition and the link to the parent group are
> missing.

Confirmed.
Would you be interested to create a patch? It is mostly a question of
adding a bunch of `defgroup' statements.

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



Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]

2022-11-14 Thread Ihor Radchenko
Juan Manuel Macías  writes:

>> ! Package polyglossia Error: The current latin font  does not contain the 
>> "Hebr
>> ew" script!
>> (polyglossia)Please define \hebrewfont with \newfontfamily 
>> comm
>> and.
>
> hmm, yes, I forgot to mention it before... It is necessary to load a
> font that has support for Hebrew script, via fontspec package, otherwise
> it will return an error, both with Polyglossia and with Babel. It should
> be added:
>
> \usepackage{fontspec}
> \setmainfont{FreeSerif}

Ok. Now, I am at least able to get the pdf. Hooray! :)

#+title: Temp
#+LATEX_COMPILER: lualatex
#+LANGUAGE: he
#+LaTeX_Header: \usepackage[AUTO]{polyglossia}
#+LaTeX_Header: \setmainfont{FreeSerif}

\begin{equation}
f(x) = \frac{8}{7}
\end{equation}

#+begin_src python :exports code
for i in range(3):
print("hello")
#+end_src

However, the PDF (see the attached) is erroneous:
1. Title "Temp" is written RTL
2. Year and date (numbers!) are written RTL
3. The python code is written RTL!!

Just the equation is rendered LTR as expected and the ordinary Hebrew
text is rendered RTL.



bug.pdf
Description: Adobe PDF document

> The use of the fontspec package (https://www.ctan.org/pkg/fontspec) is
> ubiquitous in LuaTeX or XeTeX as long as one wants to have control
> over fonts and use extended languages and characters. LuaTeX and XeTeX
> use by default (for debatable historical reasons[1]) a Unicode variant
> of the Computern Modern font, which has limited language coverage. I
> remember that it was commented in a previous thread the possibility of
> offering (for example, through a series of variables), a minimum
> coverage of fonts to ensure that the documents, at least, are compiled
> well and are readable. The user could redefine those variables to use
> their preferred fonts. Or have the option that this part of the
> preamble is not created, to have full control. I remember that I
> proposed this, but there were other interesting proposals. For
> example, Timothy commented on the possibility of using fontsets.

I hope that it can be implemented some day.
For now, we should detail important things, like setting suitable font,
in the manual.

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


Re: [BUG] org-beamer :BEAMER_ACT: ignored on columns

2022-11-14 Thread Ihor Radchenko
"Fraga, Eric"  writes:

> On Thursday, 13 Oct 2022 at 10:39, Ihor Radchenko wrote:
>> Take your time. What I do not want here is introducing new bugs. I am
>> not familiar with ox-beamer and do not want to miss anything subtle.
>
> Thank you.  I'll update you in due course.

Have you had a chance to look into this?

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



Re: 2 'echo' bash instructions produce a table

2022-11-14 Thread Ihor Radchenko
alain.coch...@unistra.fr writes:

> Ihor Radchenko writes on Mon  7 Nov 2022 02:31:
>
>  > If you want to force string output, use :results output.
>  > 
>  > By default, ob-shell tries to guess the output type.  In the case
>  > of two commands returning output, the guess is yielding the
>  > table. In the case of a single command, the guess is yielding a
>  > single string output.
>
> Thanks a lot.
>
> I find it strange, though, that the default is not as what one gets
> from running the code from a terminal.  I imagine there are good
> reasons for that, but I think this should be made clear (or at least
> clearer) in the manual.  I browsed through section 16 of the manual,
> with particular attention to 16.5 (Evaluating Code Blocks) and 16.6
> (Results of Evaluation), but still cannot see where this is said or
> hinted; if it is there, I missed it or do not know enough to
> understand it.

The manual describes generic code execution. If you do not explicitly
specify the :results header arg, it is the specific babel backend that
specifies the defaults.

Will it help if we mention this fact in "16.6 Results of Evaluation"
section?

> For the sake of newcomers, it seems to me that something along the
> line of what you write above would fit somewhere in 16.6, with a first
> short mention/warning (and reference to it) next to that excerpt in
> 16.5:
>
>Org captures the results of the code block evaluation and inserts
>them in the Org file, right after the code block.

Talking about ob-shell does not belong to this section of the manual.
Other backends have different behaviour. Have you seen examples in
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-shell.html ?
Are they not clear enough?

> In section 16.3 of the manual (Using Header Arguments):
>
>System-wide values of header arguments can be specified by
>customizing the ‘org-babel-default-header-args’ variable, which
>defaults to the following values:
>
>   :session=> "none"
>   :results=> "replace"
>   :exports=> "code"
>   :cache  => "no"
>   :noweb  => "no"
>
>
> but the docstring of 'org-babel-default-header-args' says:
>
>org-babel-default-header-args is a variable defined in ‘ob-core.el’.
>Its value is
>((:session . "none")
> (:results . "replace")
> (:exports . "code")
> (:cache . "no")
> (:noweb . "no")
> (:hlines . "no")
> (:tangle . "no"))
>
> so I was wondering if there should be
>
>:hlines  => "no"
>:tangle  => "no"
>
> added above.

It will be fixed in the next release. The online and built-in Emacs
manual are only reflecting the current stable Org version.

> PS2
>
> In section 16.6 (Results of Evaluation)
>
>[The ‘results’ header argument] accepts four classes of options
>[Collection, Type, Format, Handling]
>
>Each code block can take only one option per class:
>
> Now, the paragraphs related to Collection, Type, & Format all contain
> the statement
>
>"Choose one of the options; they are mutually exclusive".
>
> I thought this statement was saying the same thing as the "only one
> option per class" above, but then why not also repeat the statement in
> the Handling paragraph?

Makes sense.
Done on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4260f5a8d74c965fccf200aa71da0c6d338573c0

> PS3
>
> In section 16.4 (Environment of a Code Block)
>
> A simple named list.
>
>#+NAME: example-list
>- simple
>  - not
>  - nested
>- list
>
>#+BEGIN_SRC emacs-lisp :var x=example-list
>  (print x)
>#+END_SRC
>
>#+RESULTS:
>| simple | list |
>
> But if I evaluate the code, I get
>
>#+RESULTS:
>| simple | (unordered (not) (nested)) |
>| list   ||

Confirmed. Need to look into this.

> PS4
>
> In 16.5 (Evaluating Code Blocks), in this code
>
>#+NAME: random
>#+BEGIN_SRC R :cache yes
>  runif(1)
>#+END_SRC
>
> the (1) seems to be understood as a footnote in Info, at least for me.
> E.g.,  on it goes to the footnote
>
>(1) The option ‘org-babel-no-eval-on-ctrl-c-ctrl-c’ [...]
>
> and  on this (1) goes back to the above code instead of to the
> actual call
>
>"Org provides many ways to execute code blocks.  ‘C-c C-c’ or ‘C-c
>C-v e’ with the point on a code block(1)"

Confirmed, but it does not look like Org's fault.
Org correctly produces the following texinfo source:

@example
#+NAME: random
#+BEGIN_SRC R :cache yes
  runif(1)
#+END_SRC

#+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
0.4659510825295

#+NAME: caller
#+BEGIN_SRC emacs-lisp :var x=random :cache yes
  x
#+END_SRC

#+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
0.254227238707244
@end example

As you can see, no @footnote command is there.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at 

Re: [PATCH v2] org-attach.el: ID to path functions may return nil

2022-11-14 Thread Ihor Radchenko
Max Nikulin  writes:

>> However, please add NEWS entry detailing the change in
>> `org-attach-id-to-path-function-list' to the next version of the patch.
>
> See the attachment.

Thanks!

I went through the patch and tried to clarify the wording.
Especially in the defcustom docstring.

I also added the dumb fallback to the default value.
I feel that otherwise the description of too confusing.

Let me know what you think about the attached new version of the patch
with my amendments.

>From aee92ee992d9497c91a0d2bef7a1517df5a032a6 Mon Sep 17 00:00:00 2001
Message-Id: 
From: Max Nikulin 
Date: Mon, 7 Nov 2022 23:48:02 +0700
Subject: [PATCH v4] org-attach.el: ID to path functions may return nil

* lisp/org-attach.el (org-attach-dir-from-id): Ignore nil values
returned by entries from `org-attach-id-to-path-function-list'.
(org-attach-dir-get-create): Signal an error suggesting customization
of `org-attach-id-to-path-function-list' if all ID-to-path functions
return nil.
(org-attach-id-to-path-function-list): Add to the docstring examples
how to handle unusual IDs.
(org-attach-id-uuid-folder-format, org-attach-id-ts-folder-format):
Return nil if ID is too short.
(org-attach-id-fallback-folder-format): New function that may be added
as the last element of `org-attach-id-path-function-list' to handle
unexpectedly short IDs.
* etc/ORG-NEWS: Advertise the change.

Earlier an obscure error like 'org-attach-id-ts-folder-format: Args out
of range: "ftt", 0, 6' was signalled in the case of unexpectedly short
ID.

Reported-by: Janek F 
Link: https://list.orgmode.org/KC8PcypJapBpJQtJxM0kX5N7Z0THL2Lq6EQjBMzpw1-vgQf72egZ2JOIlTbPYiqAVD4MdSBhrhBZr2Ykf5DN1mocm1ANvvuKKZShlkgzKYM=@pm.me
---
 etc/ORG-NEWS   |  41 ++
 lisp/org-attach.el | 104 +
 2 files changed, 108 insertions(+), 37 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 04b5be64a..851658082 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -604,6 +604,47 @@ With the new customization option ~org-texinfo-with-latex~ set to (its
 default value) ~'detect~, if the system runs Texinfo 6.8 (3 July 2021)
 or newer, Org will export all LaTeX fragments and environments using
 Texinfo ~@math~ and ~@displaymath~ commands respectively.
+*** More flexible ~org-attach-id-to-path-function-list~
+
+List entries may return nil if they are unable to handle passed ID.
+So responsibility is passed to the next item in the list.  Default
+entries ~org-attach-id-uuid-folder-format~ and
+~org-attach-id-ts-folder-format~ now return nil in the case of too
+short ID.  Earlier it caused an obscure error.
+
+After the change, error text suggests to adjust
+~org-attach-id-to-path-function-list~ value.  The
+~org-attach-dir-from-id~ function is adapted to ignore nil values and
+to take first non-nil value instead of the value returned by first
+~org-attach-id-to-path-function-list~ item.
+
+New policy allows to mix different ID styles while keeping subfolder layout
+suited best for each one.  For example, one can use the following
+snippet to allow multiple different ID formats in Org files.
+
+#+begin_src emacs-lisp
+(setq org-attach-id-to-path-function-list
+  '(;; When ID looks like an UUIDs or Org internal ID, use
+;; `org-attach-id-uuid-folder-format'.
+(lambda (id)
+  (and (or (org-uuidgen-p id)
+	   (string-match-p "[0-9a-z]\\{12\\}" id))
+	   (org-attach-id-uuid-folder-format id)))
+;; When ID looks like a timestap-based ID. Group by year-month
+;; folders.
+(lambda (id)
+  (and (string-match-p "[0-9]\\{8\\}T[0-9]\\{6\\}\.[0-9]\\{6\\}" id)
+   (org-attach-id-ts-folder-format id)))
+;; Any other ID goes into "important" folder.
+(lambda (id) (format "important/%s/%s" (substring id 0 1) id
+#+end_src
+
+If you have 1 or 2 characters long IDs and you do not care what
+subdirs are created for longer IDs (that are neither UUIDs nor
+timestamp-based) then you may just append the
+~org-attach-id-fallback-folder-format~ to
+~org-attach-id-to-path-function-list~.  It directs attachments to
+=__=​/ID directory.
 
 * Version 9.5
 
diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index ef183474e..e956cac18 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -166,28 +166,56 @@ (defun org-attach-id-uuid-folder-format (id)
   "Translate an UUID ID into a folder-path.
 Default format for how Org translates ID properties to a path for
 attachments.  Useful if ID is generated with UUID."
-  (format "%s/%s"
-	  (substring id 0 2)
-	  (substring id 2)))
+  (and (< 2 (length id))
+   (format "%s/%s"
+   (substring id 0 2)
+   (substring id 2
 
 (defun org-attach-id-ts-folder-format (id)
   "Translate an ID based on a timestamp to a folder-path.
 Useful way of translation if ID is generated based on ISO8601
 timestamp.  Splits the attachment folder hierarchy into
 year-month, the rest."
-  

Re: [PATCH] Fast tag de-selection face

2022-11-14 Thread Ihor Radchenko
Daniel Fleischer  writes:

> Bumping a patch; it solves a minor bug in which the tags in the fast tag
> selection buffer do not toggle their face back to default after being
> selected and deselected.
>
> Attached.

For record, this patch has been applied.
Applied.

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



Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]

2022-11-14 Thread Juan Manuel Macías
Ihor Radchenko writes:

> However, the PDF (see the attached) is erroneous:
> 1. Title "Temp" is written RTL
> 2. Year and date (numbers!) are written RTL
> 3. The python code is written RTL!!
>
> Just the equation is rendered LTR as expected and the ordinary Hebrew
> text is rendered RTL.

I'd say that's expected behavior. Note that if you declare Hebrew as the
main language, the LaTeX classes (in this case article.cls) will put
whatever is necessary in Hebrew and use the Hebrew (and RTL) typographic
rules where necessary, and that includes the title, the date, and the
various literal strings as the table of contents, figure counters,
captions, etc.

To use Hebrew in another context, it would have to be declared as a
secondary language. The latest versions of Babel allow you to associate
languages to scripts when it comes to non-Latin alphabets (Cyrillic,
Greek, Arabic, etc.), and also to associate fonts. In this way it would
not be necessary to indicate the language explicitly by means of a
\selectlanguage{} or \foreignlanguage{}{}. For example, suppose that my
document has Spanish as its main language, but I also add parts in
Hebrew, which would be automatically recognized by Babel, by putting
this:

#+LaTeX_Header: \usepackage{fontspec}
#+LaTeX_Header: \setmainfont{FreeSerif}
#+LaTeX_Header: \usepackage[AUTO,bidi=basic]{babel}
#+LaTeX_Header: \babelprovide[onchar=ids,import]{hebrew}
#+language: es

(...And curiously I just realized with this example that it is necessary
to fix `org-latex-guess-babel-language', because in the current state it
returns an error if a string other than AUTO is put as argument of
babelprovide. I'll open another thread to submit a patch to fix that).

>> The use of the fontspec package (https://www.ctan.org/pkg/fontspec) is
>> ubiquitous in LuaTeX or XeTeX as long as one wants to have control
>> over fonts and use extended languages and characters. LuaTeX and XeTeX
>> use by default (for debatable historical reasons[1]) a Unicode variant
>> of the Computern Modern font, which has limited language coverage. I
>> remember that it was commented in a previous thread the possibility of
>> offering (for example, through a series of variables), a minimum
>> coverage of fonts to ensure that the documents, at least, are compiled
>> well and are readable. The user could redefine those variables to use
>> their preferred fonts. Or have the option that this part of the
>> preamble is not created, to have full control. I remember that I
>> proposed this, but there were other interesting proposals. For
>> example, Timothy commented on the possibility of using fontsets.
>
> I hope that it can be implemented some day.
> For now, we should detail important things, like setting suitable font,
> in the manual.

Perhaps a FONTS item could be added in "LaTeX specific export settings"?

Best regards,

Juan Manuel 



Re: [PATCH] lisp/ob-octave.el, was [PATCH] rfc: using ert-deftest with side-effects

2022-11-14 Thread Ihor Radchenko
Leo Butler  writes:

> The amended patch is attached. Thanks for your helpful feedback.

Thanks for the patch!
It looks good, and the tests are passing. However, there is a side effect
leaving testing/examples/octave-workspace file after running the tests.

Can something be done about this?

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



Seeing all the steps when I run an R code block

2022-11-14 Thread William Denton
I've got a few problems with R source blocks that I can't figure out.  They 
started late last month, I think.  I'm running Emacs and Org from the 
development trees, refreshing and recompiling regularly.  ESS (the package for 
working with R) is up to date too.


Here's one big problem.  I have a file, /home/wtd/books/reading/test-r.org, and 
in it is this R block:


# -

#+begin_src R :session R:testing :results value
1
#+end_src

# -

If I execute that with C-c C-c, the R session buffer starts, but in the wrong 
working directory.  This is in the R session buffer, reported by ESS:


# -


setwd('/home/wtd/books')


# -

It's in the directory *above* where the Org file is!  It should be in 
/home/wtd/books/reading/.


I copied the test file to /tmp/r/test/, and it's fine there.  The session's 
working directory is /tmp/r/test/, not /tmp/r/.


Something strange is going on, but I can't see why.  Is there some way I can 
see all the steps that are happening when I hit C-c C-c on that code block?  Or 
maybe there's some other way to figure it out?  Any suggestions welcome.


Thanks,

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada



[PATCH] ox-latex: fix `org-latex-guess-babel-language'

2022-11-14 Thread Juan Manuel Macías
If the user puts a string other than AUTO as an argument to
`\babelprovide', it gives an error when exporting. For example:

`#+LaTeX_Header: \babelprovide[]{hebrew}'

I am attaching a patch to fix that behaviour.

Best regards,

Juan Manuel 

>From 6dcba41f58b355296c3cacf97be9508581e1a10a Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias 
Date: Mon, 14 Nov 2022 23:33:16 +0100
Subject: [PATCH] lisp/ox-latex.el: fix `org-latex-guess-babel-language'

* (org-latex-guess-babel-language): If the user puts a string other
than AUTO as an argument to `\babelprovide', it gives an error when
exporting. For example:

`#+LaTeX_Header: \babelprovide[onchar=ids,import]{hebrew}'
---
 lisp/ox-latex.el | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9bdb9fb63..095f6b51c 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1669,12 +1669,13 @@ Return the new header."
 (if (not (string-match "babelprovide\\[.*\\]{\\(.+\\)}" header))
 	header
   (let ((prov (match-string 1 header)))
-	(when (equal "AUTO" prov)
-	  (replace-regexp-in-string (format
- "\\(babelprovide\\[.*\\]\\)\\({\\)%s}" prov)
-(format "\\1\\2%s}"
-	(or language language-ini-only))
-header t))
+	(if (equal "AUTO" prov)
+	(replace-regexp-in-string (format
+   "\\(babelprovide\\[.*\\]\\)\\({\\)%s}" prov)
+  (format "\\1\\2%s}"
+	  (or language language-ini-only))
+  header t)
+	  header)
 
 (defun org-latex-guess-polyglossia-language (header info)
   "Set the Polyglossia language according to the LANGUAGE keyword.
-- 
2.38.1