Re: Export of deadline status via ~org-batch-agenda-csv~

2022-10-20 Thread Ihor Radchenko
"Stefan van der Walt"  writes:

> I am trying to process all of my TODOs in a script, and therefore use 
> ~org-batch-agenda-csv~ to export them to CSV.
>
> I am running into two problems:
>
> 1. It seems to be impossible to get deadline/schedule information for tasks 
> that have been marked as DONE and
> 2. There exists a ~type~ value ~past-scheduled~ for when a task's scheduled 
> date has been missed, but there is no equivalent for ~past-deadline~.
>
> (See =org-agenda.el=, docstring for ~defmacro org-batch-agenda-csv~).
>
> I think (2) can be fixed fairly easily by adding a "past-deadline" type.  I'm 
> not sure how to address (1).  Any thoughts?

Sorry for the late reply.
Could you please provide more details?
It is not very clear for me what you are trying to achieve.

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



Re: [BUG] Beamer export fails with async export [9.5.3 (9.5.3-g4197fc @ /home/thomas/.emacs.d/straight/build/org/)]

2022-10-20 Thread Ihor Radchenko
Thomas Freeman  writes:

> When exporting a LaTeX beamer presentation as an asynchronous process
> (by using C-a prior to selecting the export option), the export fails with 
> the following error:
>
> (error "Unknown \"nil\" back-end: Aborting export")

Could you please provide detailed steps how to reproduce the problem
together with a sample beamer presentation file?
See https://orgmode.org/manual/Feedback.html#Feedback

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



Re: Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]

2022-10-20 Thread Ihor Radchenko
Vikas Kumar  writes:

> Here is a patch with the fix.

Thanks, and sorry for the late reply.
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e7005787993f521f76e99f00e8a04d87703c493f

You are now listed as an Org contributor
https://git.sr.ht/~bzg/worg/commit/d0d3287e851a7365069b9dd8970ae5756e20240d

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



Re: Bug: org-clock-select-task reuses reserved characters [9.3 (release_9.3 @ /home/unhammer/PREFIX/emacs/share/emacs/28.0.50/lisp/org/)]

2022-10-20 Thread Ihor Radchenko
Kevin Brubeck Unhammer  writes:

> If your org-clock-history has 44 or more elements, then the "c"
> character will no longer go to the current task, but to the 44th clocked
> in task. Similarly for [d]efault and [i]nterrupted.
>
> The function first adds (?c . marker-to-current-task) to the sel-list,
> then goes through org-history and uses 0-9 and A-Z and then keeps going
> through lower case letters without caring about whether the letter was
> already in there.

Thanks for reporting, and sorry for the late reply.
Fixed on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=85ab64c2b3487b1e16d3174448ff980b56007e80

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



Re: [BUG] org-timer-start doesn't seem to take the timer string at point [9.5.5 (release_9.5.5 @ z:/emacs-i686/share/emacs/28.2/lisp/org/)]

2022-10-20 Thread Ihor Radchenko
Ihor Radchenko  writes:

> From 1efdf049475dfa9d4cdf219d665c4afcb32ed7cc Mon Sep 17 00:00:00 2001
> Message-Id: 
> <1efdf049475dfa9d4cdf219d665c4afcb32ed7cc.1664765817.git.yanta...@gmail.com>
> From: Ihor Radchenko 
> Date: Mon, 3 Oct 2022 10:55:33 +0800
> Subject: [PATCH] org-manual: Clarify `org-timer-start' command description

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=cce846e5f7a4900cc97d2c10b16abf3cf7f9056c

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



Re: Bug: ODT export of Chinese text inserts spaces for line breaks

2022-10-20 Thread Ihor Radchenko
Ihor Radchenko  writes:

> I am attaching the fix that leverages `fill-region' to handle all the
> complexities for us. It is the easiest way and I see no reason to look
> deeper.

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3502ce2dbb29b70cdbb978d144322d48cb00f26d

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



Re: Org 9.6-pre and Bash sessions

2022-10-20 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Rudolf Adamkovič  writes:
>
>> :
>> : > > hello
>>
>> on the subsequent runs.
>>
>> Better than the new version but still wrong. :)
>
> And this is what drove me crazy during debugging. I do not understand
> the logic of all that ob-comint code.
>
> I have identified that the hang happens because Org does not change PS2
> prompt. Just PS1. But fixing this would yield to
>
> : org_babel_sh_prompt> org_babel_sh_prompt> hello
>
> Then, I tried to see how the original code works. And it does not
> :facepalm:
>
> I asked emacs-devel
> https://yhetil.org/emacs-devel/87y1tgqhmc.fsf@localhost/T/#u

See the attached tentative patch.
I'd appreciate some testing. Hopefully, I did not break anything.
Comint is tricky.

>From 4c6eead351cbdce1b9210a738c65b3a139d1cc0c Mon Sep 17 00:00:00 2001
Message-Id: <4c6eead351cbdce1b9210a738c65b3a139d1cc0c.1666330028.git.yanta...@posteo.net>
From: Ihor Radchenko 
Date: Fri, 21 Oct 2022 13:21:57 +0800
Subject: [PATCH] ob-shell: Fix multi-line scripts in sessions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ob-comint.el (org-babel-comint-with-output): Cleanup empty
output.  Such output is spitted unnecessarily for multi-line scripts.
* lisp/ob-shell.el (org-babel-shell-set-prompt-commands): Disable
PS2 and equivalent prompts.  Make sure that PROMPT_COMMAND does not
interfere with PS1 setting in POSIX shells.
(org-babel-sh-evaluate): Do not send input line-by-line.  Instead, let
`org-babel-coming-with-output' handle waiting for the output as well
as recording it.  Update to the new `org-babel-coming-with-output'
behavior of cleaning empty outputs.
* testing/lisp/test-ob-shell.el (test-ob-shell/session): Add test.

Reported-by: Rudolf Adamkovič 
Link: https://list.orgmode.org/orgmode/m2r0zboix1@me.com/
---
 lisp/ob-comint.el |  2 +-
 lisp/ob-shell.el  | 29 ++---
 testing/lisp/test-ob-shell.el |  6 +-
 3 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index 36a55d36c..ec7d3f6c9 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -109,7 +109,7 @@ (defmacro org-babel-comint-with-output (meta &rest body)
 		  "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
 		 string-buffer))
 	   (setq string-buffer (substring string-buffer (match-end 0
-	 (split-string string-buffer comint-prompt-regexp)
+ (delete "" (split-string string-buffer comint-prompt-regexp))
 
 (defun org-babel-comint-input-command (buffer cmd)
   "Pass CMD to BUFFER.
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 4d579ae87..d38d2d335 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -47,10 +47,15 @@ (defvar org-babel-default-header-args:shell '())
 (defvar org-babel-shell-names)
 
 (defconst org-babel-shell-set-prompt-commands
-  '(("fish" . "function fish_prompt\n\techo \"%s\"\nend")
-("csh" . "set prompt=\"%s\"")
+  '(;; Fish has no PS2 equivalent.
+("fish" . "function fish_prompt\n\techo \"%s\"\nend")
+;; prompt2 is like PS2 in POSIX shells.
+("csh" . "set prompt=\"%s\"\nset prompt2=\"\"")
+;; PowerShell, similar to fish, does not have PS2 equivalent.
 ("posh" . "function prompt { \"%s\" }")
-(t . "PS1=\"%s\""))
+;; PROMPT_COMMAND can override PS1 settings.  Disable it.
+;; Disable PS2 to avoid garbage in multi-line inputs.
+(t . "PROMPT_COMMAND=;PS1=\"%s\";PS2="))
   "Alist assigning shells with their prompt setting command.
 
 Each element of the alist associates a shell type from
@@ -299,20 +304,14 @@ (defun org-babel-sh-evaluate (session body &optional params stdin cmdline)
 	 #'org-babel-sh-strip-weird-long-prompt
 	 (mapcar
 	  #'org-trim
-	  (butlast
+	  (butlast ; Remove eoe indicator
 	   (org-babel-comint-with-output
 		   (session org-babel-sh-eoe-output t body)
-		 (dolist (line (append (split-string (org-trim body) "\n")
-   (list org-babel-sh-eoe-indicator)))
-		   (insert line)
-		   (comint-send-input nil t)
-		   (while (save-excursion
-			(goto-char comint-last-input-end)
-			(not (re-search-forward
-  comint-prompt-regexp nil t)))
-		 (accept-process-output
-		  (get-buffer-process (current-buffer))
-	   2))
+ (insert (org-trim body) "\n"
+ org-babel-sh-eoe-indicator)
+		 (comint-send-input nil t))
+   ;; Remove `org-babel-sh-eoe-indicator' output line.
+	   1))
 	 "\n"))
 	   ;; External shell script, with or without a predefined
 	   ;; shebang.
diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index a0d5a8d22..05c369174 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -46,7 +46,11 @@ (ert-deftest test-ob-shell/session ()
 ob-comint.el, which was not previously tested."
   (let ((res (org-babel-execute:sh "echo 1; echo 2" '((:session . "yes")
 (sho

Re: [BUG] S- Overridden by windmove.el [9.5.2 (release_9.5.2-3-geb9f34 @ /usr/local/share/emacs/28.0.91/lisp/org/)]

2022-10-20 Thread Ihor Radchenko
Yingnan Cui  writes:

> What if I want to use windmove outside of org-mode?

How do you enable windmove?

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



Re: org-persist-write slow when pp-use-max-width is t

2022-10-20 Thread Ihor Radchenko
Michael Eliachevitch  writes:

> I was wondering why kill-emacs emacs takes over a minute and after some 
> profiling I found out that the call to org-persist-write-all takes long when 
> pp-use-max-width is set to t and pp-max-width is also set (in my case to t, 
> the window-width), which enables line folding in pp. The pp-call happens in 
> org-persist--write-elisp-file when it is called by org-persist-write:index 
> with the pp-parameter set to t. Maybe it's clearer with the following excerpt 
> of my CPU-profile:
>
>38009  96%  - org-persist-write-all
>38009  96%   - org-persist-write
>37703  95%- mapcar
>37703  95% - #
>37703  95%  - org-persist-write:index
>37703  95%   - org-persist--write-elisp-file
>37703  95%- pp
>37703  95% - pp-to-string
>37703  95%  - pp-emacs-lisp-code
>37687  95%   + pp--insert-lisp
>
> Setting pp-use-max-width to nil made the function call almost instantanteous.
>
> I had enabled pp-use-max-width in the past when pretty-printing the results 
> of interactive elisp sessions (like pp-eval-last-sexp). I didn't think this 
> would affect how other packages would save their data and I didn't expect 
> this would result in such a performance hit. Possibly this is not an issue 
> with org-mode or pp but just my own mistake of not being aware that pp is 
> used as a library by other packages and thus customizing its behaviour has 
> global effects.
>
> Not sure if the org mailing list is the best place to report this 
> observation. What org could do is to use a let-binding to temporarily set 
> pp-use-max-width to nil to disable line folding. Or do you think that some 
> users might care that their cache files are formatted prettily according to 
> their customization options?
>
> If you think this is not an issue with org-mode, maybe I/we could forward 
> this to the pp-maintainers, as it's in emacs core possibly to emacs-devel? I 
> think at least a warning in the variable documentation about performance hits 
> might have been helpful.

Thanks for reporting!
pp-max-width has been introduced in Emacs 29.
The fact that pp becomes too slow is likely something to be fixed before
the next Emacs release.

While we can work around this issue on Org side, I'd prefer to ask Emacs
developers first and see if they can come up with a fix.

I suggest you to file a bug report to Emacs.
You may provide the contents of your org-persist-index-file inside
org-persist-directory. AFAIU, it is what is taking a lot of time to
print.

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



Re: [PATCH] ob-java: Define the list of all supported header arguments

2022-10-20 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Hello smart folks!
>
> The Org linter warns about *correct* Java source block arguments.  The
> attached patch fixes that.

Thanks!
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ee3dbb0fdb6e119207f13a165e90b878b741cf49

> P.S. I originally had two regression tests, not one.  The other test
> checked the '#+property:' version, e.g.
>
> #+property: header-args:java+ :dir /tmp
> #+property: header-args:java+ :classname com.example.Example
> #+property: header-args:java+ :imports com.example.OtherExample
> #+property: header-args:java+ :cmpflag -classpath .:/tmp/example/
> #+property: header-args:java+ :cmdline -classpath .:/tmp/example/
> #+property: header-args:java+ :cmdarg -verbose
>
> However, the linter rejects these as unknown header arguments.  From
> what I understand, that look like a separate issue.

Fixed.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d98a49648066ce80f1193d36accb81253a4027df

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



Re: Line breaks and brackets in LaTeX export

2022-10-20 Thread Ihor Radchenko
Max Nikulin  writes:

> On 20/10/2022 12:07, Ihor Radchenko wrote:
>> When transcoding children (e.g. table rows), the sibling rows can always
>> be accessed using org-export-get-previous-element and
>> org-export-get-next-element.
>
> Decision if escaping is necessary should be based on export result, not 
> on the source element.

I am not sure. The export result may originate from constructs like

#+MACRO: pagebreak @@latex:\\@@

Some paragraph {{{pagebreak}}}
src_elisp[:results raw]{(format "@@latex:[%dpt]@@" (or my-spacing-value 0))}

The point is: it can be done on purpose for some reason.

>> I am not sure what you are referring to. If modifying exported string,
>> it will suffer from the same problems as your idea with comment.
>
> It is a brain storm idea, I still unsure it is feasible.
>
> I mean info "(elisp) Text Properties". I do not think they are usually 
> ignored by filters. \\ substrings added by ox-latex may have some unique 
> property. Export filter searches for occurrences of \\ to check if 
> escaping is necessary, but it ignores particular location if the text 
> does not have the specific property. I would prefer to mark output of 
> export snippets with another property value and do not escape them. It 
> is a kind of out of band communication. Unsure if text properties may be 
> lost due to string operations in an exporter or vice versa to propagate 
> to the source buffer.

I see. I feel like it is too fragile to rely upon. At least, I'd use it
only if there are no better options.

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



Re: Line breaks and brackets in LaTeX export

2022-10-20 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> I've had a look at the thread. What do you think of that
> \NewTableCommand\empty{} workaround mentioned at
> https://github.com/lvjr/tabularray/discussions/321#discussioncomment-3920957?
>
> Since the \empty option only has problems in tabularray, maybe we could
> keep it, and put in the documentation some recommendations for
> tabularray users. I imagine they would have to add a @@latex:\empty@@
> before each row that follows a line. A bit laborious, I'm afraid.

I see the tabularray issue simply as an example that \empty is not as
reliable as we thought. There might be other LaTeX packages throwing
errors on \\\empty.

The proposed workaround may be enough for tabularray, but may not be for
other packages.

> Another possibility that occurs to me is that the string reserved for
> \empty, [0pt], etc., is a defcustom, with a value of \empty by default.
> So the user would choose what suits him best.

I do not think that users will clearly understand the purpose of such
defcustom. It is solving some very narrow edge case, and it is unclear
why we would need to advertise changing it in customize interface.

I'd prefer to keep it as defconst, but maybe mention in the docstring
that it can still be set to "\\empty" as another semi-safe value. At the
user's own risk.

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



Re: Error during PDF export but the PDF file is exported

2022-10-20 Thread Ihor Radchenko
Max Nikulin  writes:

> On 20/10/2022 12:12, Ihor Radchenko wrote:
>> 
>> What I wanted to say is that
>> `current-time' is good enough if we export to local file.
>
> Since the patch was not posted to the mailing list, I may be wrong due 
> to some rather wild assumption.
>
> Paul Eggert convinced me that generally it is a bad idea to compare wall 
> (system) time and file time. They may have different resolution or may 
> have significant offset.  Notice that the following pending patch 
> modifies time handling in `org-compile-file', however I have not tested 
> it for remote files:
>
> Max Nikulin. [PATCH v2] org-macs.el: Do not compare wall time and file 
> modification time. Sun, 9 Oct 2022 15:18:04 +0700. 
> https://list.orgmode.org/thu03t$16vt$1...@ciao.gmane.io
>
> I am sorry that I did not join to this thread earlier.

You are right, that patch should fix this problem as well.
For some reason, I only remembered that patch as something that concerns
tangling. Now, applied.

Pascal, could you please try the latest main and see if the problem is fixed?

-- 
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-macs.el: Do not compare wall time and file modification time

2022-10-20 Thread Ihor Radchenko
Max Nikulin  writes:

> Subject: [PATCH v2] org-macs.el: Do not compare wall time and file
>  modification time
> To: emacs-orgmode@gnu.org

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=deb1517fe909fe9ba2b753c0a7fd6146a0550460

Thanks for the reminder.

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



Re: [BUG] Mention #+PRINT_BIBLIOGRAPHY in the Org manual

2022-10-20 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> BTW, speaking of citations, I wonder why Org inserts
> [cite/text:@author-year] and not [cite/text: @author-year], with a space
> character, to avoid strangely filled paragraphs (as seen here).

Feel free to submit a patch for org-cite-make-insert-processor.

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



Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-20 Thread Ihor Radchenko
Max Nikulin  writes:

> I am apologizing if my comments make no sense. I remember a thread on 
> improper handling on id links in ox-html, so I am a bit surprised that a 
> link to the whole file (if I got the goal of the patch correctly, of 
> course) is the only problem with ODT.

It is likely not the only problem. But this thread is about one
particular problem that should also be fixed regardless of others.
If you find other problems, please report them.

> - ox-html may transform file suffix from .org to .html. Have I missed 
> the same code for ox-odt?

ox-html does it according to org-html-link-org-files-as-html. ox-odt
does not provide such feature. If people need it, it can be added.

Here, we at least fix the export error. So that people can at least get
some exported .odt file.

> - Doesn't destination should be passed through some quoting-escaping 
> function to avoid characters in file names that may make XML invalid? 
> (Perhaps id links between .org files will be broken earlier.)
>
> Max Nikulin. Re: Internal link broken when publishing (was org-id with 
> ox-html) Tue, 14 Sep 2021 23:33:43 +0700. 
> https://list.orgmode.org/shqit9$8ds$1...@ciao.gmane.io

It should be. But, similar to ox-html, it is not escaped.
Patches welcome.

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



Re: Haskell code blocks

2022-10-20 Thread Ihor Radchenko
Bruno Barbier  writes:

> I've attached the patch that I've used to fix ob-haskell.
>
> Should I submit a patch for ob-haskell ?
>
> Bruno
>
>
> From f2e91a62469e84ce1d3036216ae3eca4084f3b94 Mon Sep 17 00:00:00 2001
> From: Bruno BARBIER 
> Date: Wed, 19 Oct 2022 19:44:42 +0200
> Subject: [PATCH] org-babel-interpret-haskell: Don't remove outputs that match
>  inputs

Thanks! Could you also create testing/lisp/test-ob-haskell.el file and
add your examples as tests in there?

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



Re: Problems running ob-julia tests (testing/test-ob-julia.el)

2022-10-20 Thread Christian Köstlin
On Wed, Oct 19, 2022 at 3:32 AM Ihor Radchenko  wrote:
>
> Pedro Bruel  writes:
>
> > I believe the ob-julia version we have on orgmode does not support sessions.
>
> There is definitely session support in lisp/ob-julia.el. ob-julia does
> define org-babel-load-session:julia and org-babel-prep-session:julia.
>
> Session support is even tested in testing/lisp/test-ob-julia.el
> For example, in test-ob-julia/session-multiline.
>
> ob-julia documentation also declares full session support:
> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-julia.html
>
> For context, Christian is helping us to setup automatic CI tests for Org
> and we are now experiencing some issues with tests for babel languages.
> Those tests are normally disabled as they require external packages,
> which is why the problem was not noticed in the past.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 

I looked some more into testing/lisp/test-ob-julia.el. And it
seems for me, that the file was not completely ported over from python.
There are still python examples in it + some of the tests, are only
there, because they we're written for python (e.g.
test-ob-julia/insert-necessary-blank-line-when-sending-code-to-interpreter).

I could get hello worlds without session running (:reports output).
When I try :reports value I do not get good results.

ATM I am testing with emacs28 and julia 1.4.1 and org-mode master

Kind regards,
Christian



org-persist-write slow when pp-use-max-width is t

2022-10-20 Thread Michael Eliachevitch

I was wondering why kill-emacs emacs takes over a minute and after some 
profiling I found out that the call to org-persist-write-all takes long when 
pp-use-max-width is set to t and pp-max-width is also set (in my case to t, the 
window-width), which enables line folding in pp. The pp-call happens in 
org-persist--write-elisp-file when it is called by org-persist-write:index with 
the pp-parameter set to t. Maybe it's clearer with the following excerpt of my 
CPU-profile:

  38009  96%  - org-persist-write-all
  38009  96%   - org-persist-write
  37703  95%- mapcar
  37703  95% - #
  37703  95%  - org-persist-write:index
  37703  95%   - org-persist--write-elisp-file
  37703  95%- pp
  37703  95% - pp-to-string
  37703  95%  - pp-emacs-lisp-code
  37687  95%   + pp--insert-lisp

Setting pp-use-max-width to nil made the function call almost instantanteous.

I had enabled pp-use-max-width in the past when pretty-printing the results of 
interactive elisp sessions (like pp-eval-last-sexp). I didn't think this would 
affect how other packages would save their data and I didn't expect this would 
result in such a performance hit. Possibly this is not an issue with org-mode 
or pp but just my own mistake of not being aware that pp is used as a library 
by other packages and thus customizing its behaviour has global effects.

Not sure if the org mailing list is the best place to report this observation. 
What org could do is to use a let-binding to temporarily set pp-use-max-width 
to nil to disable line folding. Or do you think that some users might care that 
their cache files are formatted prettily according to their customization 
options?

If you think this is not an issue with org-mode, maybe I/we could forward this 
to the pp-maintainers, as it's in emacs core possibly to emacs-devel? I think 
at least a warning in the variable documentation about performance hits might 
have been helpful.

Best regards,
Michael Eliachevitch



[PATCH] ob-java: Define the list of all supported header arguments

2022-10-20 Thread Rudolf Adamkovič
Hello smart folks!

The Org linter warns about *correct* Java source block arguments.  The
attached patch fixes that.

P.S. I originally had two regression tests, not one.  The other test
checked the '#+property:' version, e.g.

#+property: header-args:java+ :dir /tmp
#+property: header-args:java+ :classname com.example.Example
#+property: header-args:java+ :imports com.example.OtherExample
#+property: header-args:java+ :cmpflag -classpath .:/tmp/example/
#+property: header-args:java+ :cmdline -classpath .:/tmp/example/
#+property: header-args:java+ :cmdarg -verbose

However, the linter rejects these as unknown header arguments.  From
what I understand, that look like a separate issue.

Rudy

>From 54f008cdfcf4680b3d3bc7107aa640596d5a91bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Thu, 20 Oct 2022 21:31:37 +0200
Subject: [PATCH] ob-java: Define the list of all supported header arguments

* lisp/ob-java.el (org-babel-header-args:java): Complete the list of
header arguments supported for Java source blocks.
* testing/lisp/test-ob-java.el (ob-java/lint-header-arguments): Test
that the linter approves of all the supported arguments.
---
 lisp/ob-java.el  |  8 +++-
 testing/lisp/test-ob-java.el | 17 +
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index 832214f5c..395dbd20d 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -53,7 +53,13 @@ directory, so we keep that as the default behavior.
 
 [1] https://orgmode.org/manual/Results-of-Evaluation.html";)
 
-(defconst org-babel-header-args:java '((imports . :any))
+(defconst org-babel-header-args:java
+  '((dir   . :any)
+(classname . :any)
+(imports   . :any)
+(cmpflag   . :any)
+(cmdline   . :any)
+(cmdarg. :any))
   "Java-specific header arguments.")
 
 (defcustom org-babel-java-command "java"
diff --git a/testing/lisp/test-ob-java.el b/testing/lisp/test-ob-java.el
index 215f1cb51..a62d66557 100644
--- a/testing/lisp/test-ob-java.el
+++ b/testing/lisp/test-ob-java.el
@@ -21,9 +21,26 @@
 ;; along with this program.  If not, see .
 
 ;;; Code:
+
 (require 'org-test "../testing/org-test")
 (require 'ob-core)
 
+;;; No Java required
+
+(ert-deftest ob-java/lint-header-arguments ()
+  (org-test-with-temp-text "
+#+header: :dir /tmp
+#+header: :classname com.example.Example
+#+header: :imports com.example.OtherExample
+#+header: :cmpflag -classpath .:/tmp/example/
+#+header: :cmdline -classpath .:/tmp/example/
+#+header: :cmdarg -verbose
+#+begin_src java
+#+end_src"
+(should-not (org-lint '(wrong-header-argument)
+
+;;; Java required
+
 (org-test-for-executable "java")
 (org-test-for-executable "javac")
 (unless (featurep 'ob-java)
-- 
2.38.0

-- 
"The whole science is nothing more than a refinement of everyday
thinking."
-- Albert Einstein, 1879-1955

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


Re: size restriction on columnview?

2022-10-20 Thread Uwe Brauer
>>> "IR" == Ihor Radchenko  writes:

> Uwe Brauer  writes:
>> The following columnview will indeed display all the properties of all
>> the headings in table form.
>> 
>> #+BEGIN: columnview :maxlevel 2 :skip-empty-rows t :hlines 1 :indent
>> nil :format "%5TODO(Status) %SUMMARY(Sum) %5NR(Nr) %5ITEM(Stuff)
>> %5RG-Date(R-Date) %5Amount(Amount) %5User1(User1){X/}
>> %5User2(User2){X/} %5An_Company1(An Company1) %5An_Firm(An Firm)
>> %5Von_Company1(Von Company1) %5Geld_Company1(EUR Company1)
>> %5Von_Firm(Von Firm) %5Geld_Firm(EUR Firm) %5All(All)
>> %5Author(Autor) %5Diff(Diff)"
>> 
>> However when I add *one* property more to the columnview format entry
>> then the resulting table will only show around 15 headings (that is the
>> table has only 15 rows).
>> 
>> Any comments? I am really puzzled.

> The comment is: it does not make sense.
> A reproducer would help a lot.

I checked it again, now with the recent master/main the problem does not occur.

Thanks


-- 
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. 


smime.p7s
Description: S/MIME cryptographic signature


Re: Error during PDF export but the PDF file is exported

2022-10-20 Thread Max Nikulin

On 20/10/2022 12:12, Ihor Radchenko wrote:


What I wanted to say is that
`current-time' is good enough if we export to local file.


Since the patch was not posted to the mailing list, I may be wrong due 
to some rather wild assumption.


Paul Eggert convinced me that generally it is a bad idea to compare wall 
(system) time and file time. They may have different resolution or may 
have significant offset.  Notice that the following pending patch 
modifies time handling in `org-compile-file', however I have not tested 
it for remote files:


Max Nikulin. [PATCH v2] org-macs.el: Do not compare wall time and file 
modification time. Sun, 9 Oct 2022 15:18:04 +0700. 
https://list.orgmode.org/thu03t$16vt$1...@ciao.gmane.io


I am sorry that I did not join to this thread earlier.



Re: Line breaks and brackets in LaTeX export

2022-10-20 Thread Max Nikulin
An argument in favor of \\[0pt] escaping. Unlike \empty, [0pt] is rather 
artificial, so such pattern may be removed (I hope in a safe way) by an 
export filter if it is not followed by a bracket or a star.


On 20/10/2022 12:07, Ihor Radchenko wrote:

When transcoding children (e.g. table rows), the sibling rows can always
be accessed using org-export-get-previous-element and
org-export-get-next-element.


Decision if escaping is necessary should be based on export result, not 
on the source element.



Max Nikulin writes:



As another approach text properties may be used as a communication
channel unless they are stripped by ox.


I am not sure what you are referring to. If modifying exported string,
it will suffer from the same problems as your idea with comment.


It is a brain storm idea, I still unsure it is feasible.

I mean info "(elisp) Text Properties". I do not think they are usually 
ignored by filters. \\ substrings added by ox-latex may have some unique 
property. Export filter searches for occurrences of \\ to check if 
escaping is necessary, but it ignores particular location if the text 
does not have the specific property. I would prefer to mark output of 
export snippets with another property value and do not escape them. It 
is a kind of out of band communication. Unsure if text properties may be 
lost due to string operations in an exporter or vice versa to propagate 
to the source buffer.





Re: Weird behavior of org-element-object-lex

2022-10-20 Thread Max Nikulin

On 20/10/2022 21:15, Damien Cassou wrote:


After a quick chat with yantar92 on IRC, I understood that the easiest
solution is to fix the paragraph transcoder to inject the "- " when its
parent is an item. The item transcoder can just return CONTENTS.


Why are you trying to avoid item list marker standard for odt in favor 
of plain text?







Re: Line breaks and brackets in LaTeX export

2022-10-20 Thread Juan Manuel Macías
Max Nikulin writes:

> A workaround for tabularray:
>
> \NewTableCommand\empty{}
>
> I am unsure if we should use it.

Ah, I had just commented on this in the email I just sent...

>> By the way, now I remember that the package verse adds a series of
>> extra
>> arguments to \\ (p. 6 in the documentation:
>
> \\! command between stanzas to get proper line count makes things a
> bit more complicated. I believed that some TeX trick may be used
> instead of requirement of the explicit command.

In my custom code that I commented on in another email, \\! is
automatically inserted if verse numbering is active. My intention is to
incorporate that into my patch (work-in-progress) over the spaces between
verses.





Re: Line breaks and brackets in LaTeX export

2022-10-20 Thread Juan Manuel Macías
Max Nikulin writes:

> I have started a discussion requesting for a \\-like command without
> optional arguments. Maybe somebody will suggest a better workaround
> instead.
> https://github.com/lvjr/tabularray/discussions/321

I've had a look at the thread. What do you think of that
\NewTableCommand\empty{} workaround mentioned at
https://github.com/lvjr/tabularray/discussions/321#discussioncomment-3920957?

Since the \empty option only has problems in tabularray, maybe we could
keep it, and put in the documentation some recommendations for
tabularray users. I imagine they would have to add a @@latex:\empty@@
before each row that follows a line. A bit laborious, I'm afraid.

Another possibility that occurs to me is that the string reserved for
\empty, [0pt], etc., is a defcustom, with a value of \empty by default.
So the user would choose what suits him best.

By the way (a little digression), I was curious to see if these age-old
LaTeX problems with line breaking exist in ConTeXt as well. Since I'm
completely unfamiliar with ConTeXt, the quickest thing to do has been to
see what code ox-context returns for the org tables. The answer is that
there are no such problems, and one can safely put a square bracket at
the beginning of a row. It is also true that the table syntax in ConTeXt
is radically different from that in LaTeX. And there is also no problem
if I put @@context:a\[b]@@. Some screenshots:

https://i.imgur.com/2k1TaU9.png

https://i.imgur.com/8i9qlEH.png

Many times I've been tempted to give ConTeXt a try, but I've always run
into two things: ConTeXt's perennially experimental status and a
horrible lack of documentation. In addition, backward compatibility is
not usually respected, since ConTeXt, although it is free software, does
not have community development as a priority, but rather the company
behind it, Pragma.

>> I've tried all the packages involved in tables that I can think of
>> (longtable, siunitx, tabularx, booktabs, array, and I don't know if I
>> forgot any) and in all of them the \empty solution works fine. It seems
>> that tabularray is the black sheep here.
>
> I think tabularray is unique with a regexp-based parser. I had a hope
> that new approach does not allow newline between \\ and its arguments,
> but unfortunately compatibility with older code is preserved in this
> aspect.
>
> From LaTeX companion I remember supertabular as an alternative for
> longtable, but I am unsure if it is alive yet.

True, I had forgotten about this package (I don't think I've ever used
it). It looks like it has a 2020 new version:

@manual{supertabular,
  title = {The \texttt{supertabular} package},
  subtitle = {A multi-page tables package},
  author = {Johannes L. Braams},
  date = {2020-02-02},
  version = {4.1g},
  license = {lppl1.3c},
  url = {https://mirror.ctan.org/macros/latex/contrib/supertabular},
  pkgurl = {https://ctan.org/pkg/supertabular},
  }

(bibtex entry obtained from: https://www.ctan.org/pkg/ctan-bibdata)



Re: [BUG] Mention #+PRINT_BIBLIOGRAPHY in the Org manual

2022-10-20 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> For record, the manual now contains a dedicated section for printing
> the bibliography and additional options that can passed to it.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/doc/org-manual.org#n17095

Oh, fantastic!  Thank you for letting me know.

BTW, speaking of citations, I wonder why Org inserts
[cite/text:@author-year] and not [cite/text: @author-year], with a space
character, to avoid strangely filled paragraphs (as seen here).

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

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



Re: Weird behavior of org-element-object-lex

2022-10-20 Thread Damien Cassou
Damien Cassou  writes:
> Ihor Radchenko  writes:
>> Damien Cassou  writes:
>>>   (defun ox-linuxmag--item (item contents info)
>>> ...
>>> The reason `ox-linuxmag--item` has to parse ITEM again is because
>>> CONTENTS contains "item 1 ;"
>>> which misses the initial dash "-" character: i.e., I would like "- item
>>> 1 ;" in the paragraph instead.

After a quick chat with yantar92 on IRC, I understood that the easiest
solution is to fix the paragraph transcoder to inject the "- " when its
parent is an item. The item transcoder can just return CONTENTS.

Here is the corresponding code:

(defun ox-linuxmag--paragraph (paragraph contents info)
  "Transcode a PARAGRAPH element from Org to ODT.
CONTENTS is the contents of the paragraph, as a string.  INFO is
the plist used as a communication channel."
  (let* ((parent (org-export-get-parent paragraph))
 (parent-type (org-element-type parent))
 (prefix (when (eq parent-type 'item) "- ")))
(org-odt--format-paragraph
 paragraph
 (concat prefix contents)
 info
 (or (org-element-property :style paragraph) "Normal")
 ""
 "")

Thank you so much for your help.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill



Re: Weird behavior of org-element-object-lex

2022-10-20 Thread Damien Cassou
Ihor Radchenko  writes:
> Damien Cassou  writes:
>>   (defun ox-linuxmag--item (item contents info)
>> ...
>> The reason `ox-linuxmag--item` has to parse ITEM again is because
>> CONTENTS contains "item 1 ;"
>> which misses the initial dash "-" character: i.e., I would like "- item
>> 1 ;" in the paragraph instead.
>
> Just use ITEM.
> You can access the contents of ITEM with org-element-contents.
> If you just need to append the bullet, use (org-element-property :bullet item)

I don't understand your solution. `org-element-contents` returns a
paragraph element. What should I do with it? I can't just export it
because that would result in a 'item
1 ;' string which misses the initial "- ".

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill



Re: [BUG] S- Overridden by windmove.el [9.5.2 (release_9.5.2-3-geb9f34 @ /usr/local/share/emacs/28.0.91/lisp/org/)]

2022-10-20 Thread Yingnan Cui
What if I want to use windmove outside of org-mode?

Yingnan

On Wed, Oct 19, 2022 at 11:38 PM Ihor Radchenko  wrote:

> Yingnan Cui  writes:
>
> > It seems that org-mode's S- is overriden by windmove.el even
> > though I'm adding the following configurations according to the org
> > manual:
> > ```emacs-lisp
> > ;; Make windmove work in Org mode:
> > (add-hook 'org-shiftup-final-hook 'windmove-up)
> > (add-hook 'org-shiftleft-final-hook 'windmove-left)
> > (add-hook 'org-shiftdown-final-hook 'windmove-down)
> > (add-hook 'org-shiftright-final-hook 'windmove-right)
> > ```
>
> Just do not activate windmove-mode.
> The above suggestion will directly call windmove without a need in
> windmove-mode being active.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-20 Thread Max Nikulin

On 19/10/2022 17:36, Ihor Radchenko wrote:


--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2737,6 +2737,12 @@ (defun org-odt-link (link desc info)
   (format "%s"
   (org-export-get-reference destination info)
   (or desc (org-export-get-ordinal destination info
+  ;; Link to a file, corresponding to string return value of
+  ;; `org-export-resolve-id-link'.
+  (plain-text
+   (format "%s"
+  destination
+  (or desc (org-export-get-ordinal destination info


I am apologizing if my comments make no sense. I remember a thread on 
improper handling on id links in ox-html, so I am a bit surprised that a 
link to the whole file (if I got the goal of the patch correctly, of 
course) is the only problem with ODT.


- ox-html may transform file suffix from .org to .html. Have I missed 
the same code for ox-odt?
- Doesn't destination should be passed through some quoting-escaping 
function to avoid characters in file names that may make XML invalid? 
(Perhaps id links between .org files will be broken earlier.)


Max Nikulin. Re: Internal link broken when publishing (was org-id with 
ox-html) Tue, 14 Sep 2021 23:33:43 +0700. 
https://list.orgmode.org/shqit9$8ds$1...@ciao.gmane.io






Re: Weird behavior of org-element-object-lex

2022-10-20 Thread Ihor Radchenko
Damien Cassou  writes:

>   (defun ox-linuxmag--item (item contents info)
> ...
> The reason `ox-linuxmag--item` has to parse ITEM again is because
> CONTENTS contains "item 1 ;"
> which misses the initial dash "-" character: i.e., I would like "- item
> 1 ;" in the paragraph instead.

Just use ITEM.
You can access the contents of ITEM with org-element-contents.
If you just need to append the bullet, use (org-element-property :bullet item)

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



Re: PATCH: Re: Reading the parameters of a special-block

2022-10-20 Thread Ihor Radchenko
[adding Org ML back to CC]

Bruno Barbier  writes:

>> Thanks! LGTM.
>>
>
>> Now, can you also make a patch against https://git.sr.ht/~bzg/worg
>> adding the new parameter to 
>> https://orgmode.org/worg/dev/org-element-api.html?
>
> Sure. Let me know if the attached patch is good enough.

Applied onto main branch of Org and master branch of WORG.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7d1e3dc38ea7fcd9ff57ace883370de1d5f902d8
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=98cae03b7d9a612334d5ea461e73ac0b37b0285d
https://git.sr.ht/~bzg/worg/commit/dd8e6fc4393ccf72bda957544079c6e00802b742

Thanks for your contribution!

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



Re: inconsistent behavior for completion of links inside [[ ]]

2022-10-20 Thread Ihor Radchenko
"Majzoub, Eric"  writes:

> emacs: 29.0.50 build 7
> org: 9.6-gcbe3f2 snapshot from 20220402
> I use company for completion.
>
> The issue is very simple to reproduce. Open a new .org file and
> input (for example)
>
> [[/home/]]
>
> and see if an auto-complete menu pops up.
>
> Do this both INSIDE your org-directory and OUTSIDE your org-directory.
> For me this fails inside my org-directory (at any depth within ~/org).

company completion works on my side.
Maybe something with your setup?

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



Re: org-return not being given 't' for INDENT parameter

2022-10-20 Thread Ihor Radchenko
jebb Bungo  writes:

> I am having an odd behavior with org-return. I use hard indents, and I have
> set 'org-adapt-indentation' to t in my .emacs file. However, I have noticed
> that sometimes when I press RET under a heading, instead of getting an
> indent to match the indentation of the heading after the *'s, point is set
> right at 0. For example, the expected behavior of pressing RET at the end
> of the line '* Heading' would be that point is placed on the next line
> below the heading, at column 2.
>
> I am having an issue pinpointing what is causing the error, however, as I
> haven't found any consistency. Sometimes RET works as expected in my files,
> othertimes it does not. The bug does seem to only 'fix' in between
> instances of Emacs. I run Emacs as a daemon, and I noticed that sometimes
> the files will work and other times not work, but only between instances of
> the daemon/between system boots.

Sorry for the late reply.
Are you still seeing the problem?

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



Re: Bug: table odt export ignores relative column width hints [9.4.6 (9.4.6-13-g4be129-elpa @ /home/hp/.emacs.d/elpa/org-20210920/)]

2022-10-20 Thread Ihor Radchenko
hpgislero...@bluewin.ch writes:

> Let the content of a file 'test.org' be the following:
>
>
>   |  |  |
>   |--+---|
>   |  2   | 10|
>
>
> Observed behavior:
> test.odt with identical column widths - note, that  vs.  seems to work
>
>  
>   |+-|
>   |2   | 10  |
>
>
> Expected behavior:
> test.odt width ratio 1/5
>
>   |---+-|
>   | 2 | 10  |

I am unable to reproduce on the latest main.
I am seeing the expected 1/5 width ratio.

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