Re: [Patch] Align baseline of latex fragments and surrounding text

2024-01-19 Thread Timothy
Hi Matt,

> However, I noticed that there appears to be another (large) patch in the
> works that also does this (email subject line “Overhaul of the LaTeX
> preview system”). That’s a long thread and I haven’t followed it. Is
> there still scope for my change? Is it worth getting this in?

So, in the large patch (actually ~150 patches in a branch), we actually
have had baseline alignment implemented for the last ~year 🙂.

Currently it’s just being polished up so it’s good to merge, you can see a list
of todo tasks we’d like to get sorted first here:


All the best,
Timothy

-- 
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at .
Support Org development at ,
or support my work at .


[PATCH] Patches for problems discovered with interactive testing

2024-01-19 Thread gerard . vermeulen

This patch addresses a number of glitches discovered during interactive
testing and contains possible fixes (sub-patch test-ob-maxima fixes
batch testing on my system, but not interactive testing).

The test-ob-maxima patch may be due to a different Maxima version, but
I do not think so.  In batch testing test-ob-maxima passes contrary to
interactive mode.

The test-ob-python patch unsets org-src-preserve-indentation which I
have set.

The test-ob patch also unsets org-src-preserve-indentation.

The test-org-element patch indicates something weird on my system, I
want to report.  Should not be applied.

The test-org patch also unsets org-src-preserve-indentation.  This
reduces the number of failures to 2 while testing test-org
interactively.

Sorry to put them all together, but I do not know how to handle (ma)git
to keep the patches apart.

Regards -- Gerard



0001-Patches-for-problems-discovered-with-interactive-tes.patch
Description: Binary data


Slowness of org-agenda-redo in org 9.7 vs 9.6.7

2024-01-19 Thread dark . key8799
I've been running 9.7 for a few weeks and I've noticed a slowdown in 
`org-agenda-redo'. I finally ran some benchmarks.

I can reproduce it with a minimal org config (bare init.el with only 
straight.el and a short org config) with my full `org-agenda-files' (~450 
files). In my regular conf, both are faster than the report below (I suppose 
because of gc collection parameters), about ~10s and ~1s respectively.

(use-package org
  ;:straight (:type built-in)
  :custom
  (org-agenda-inhibit-startup t)
  (org-agenda-dim-blocked-tasks nil)
  (org-agenda-window-setup 'current-window)
  (org-agenda-restore-windows-after-quit t)
  (org-agenda-show-future-repeats nil)
  (org-agenda-todo-ignore-scheduled 'all)
  (org-agenda-tags-todo-honor-ignore-options t)
  (org-agenda-tags-column 0)
  (org-tags-exclude-from-inheritance '("project"))
  (org-agenda-files
   '("~/Documents/Notes/" "~/Documents/Notes/org-roam/" 
"~/Documents/Notes/org-roam/daily/")))

Here's a truncated comparison of elp outputs
  calls9_7  
elapsed9_7average9_7  calls9_6_7  elapsed9_6_7  average9_6_7  diff_calls  
diff_elapsed
function

  
org-agenda-redo  1   
34.677843  3.467784e+01   1  6.764364  6.764364e+00   0 
27.913479
org-agenda-run-series1   
34.672858  3.467286e+01   1  6.763294  6.763294e+00   0 
27.909564
org-element-cache-map 5904   
31.591816  5.350917e-035904  5.696144  9.647940e-04   0 
25.895672
org-tags-view6   
30.645603  5.107601e+00   6  5.897457  9.829095e-01   0 
24.748146
org-scan-tags 2952   
30.300860  1.026452e-022952  5.590151  1.893683e-03   0 
24.710709
org-agenda-get-day-entries1476
3.594734  2.435457e-031476  0.606745  4.110738e-04   0  
2.987989
org-agenda-list  1
3.621574  3.621574e+00   1  0.665955  6.659550e-01   0  
2.955619
org-element-lineage-map  38658
2.356579  6.095000e-05   0  0.00  0.00e+00   38658  
2.356579
org-element--property   706448
1.981798  2.805000e-06   0  0.00  0.00e+00  706448  
1.981798
org-agenda-get-scheduled  1476
1.947263  1.319284e-031476  0.241429  1.635697e-04   0  
1.705834
org-entry-get-with-inheritance   37938
3.647018  9.613000e-05   37938  2.436293  6.421000e-05   0  
1.210725
org-agenda-get-deadlines  1476
1.323156  8.964471e-041476  0.154018  1.043482e-04   0  
1.169138
org-element-begin   570514
0.980263  1.718000e-06   0  0.00  0.00e+00  570514  
0.980263
org-element-property-inherited   40114
0.881786  2.198000e-05   0  0.00  0.00e+00   40114  
0.881786
org-element-type   2805984
0.888528  3.166000e-07  154150  0.054403  3.529000e-07 2651834  
0.834125
org-element--cache-key  164988
0.789725  4.786000e-06   0  0.00  0.00e+00  164988  
0.789725
org-element-parent  255728
0.771416  3.016000e-06   0  0.00  0.00e+00  255728  
0.771416
org-element-at-point238169
0.788185  3.309000e-068429  0.229212  2.719000e-05  229740  
0.558973
org--property-local-values  116449
1.657522  1.423000e-05  115973  1.238066  1.067000e-05 476  
0.419456
org-element--parse-to 9564
0.480723  5.026000e-059611  0.079269  8.247000e-06 -47  
0.401454
org--get-local-tags  38172
0.242883  6.362000e-06 234  0.001800  7.692000e-06   37938  
0.241083
org-element--cache-find   9540
0.272448  2.855000e-059587  0.053306  5.56e-06 -47  
0.219142
org-agenda-prepare   

[PATCH] Make command org-babel-detangle work interactively

2024-01-19 Thread gerard . vermeulen

Hi,

org-babel-detangle is an interactive command but
M-x org-babel-detangle always replies "Detangled 0 code blocks"
This patch makes org-babel-detangle prompt for a source code file.

Obviously, I got bitten by this.

The patch contains
(user-error "Source code file does %S not exist" source-code-file)
so it may break code that uses org-babel-detangle in a loop.

I prefer an user-error, but others may not.

Regards -- Gerard


0001-Make-command-org-babel-detangle-work-interactively.patch
Description: Binary data


Re: [PATCH] Patches for problems discovered with interactive testing

2024-01-19 Thread Ihor Radchenko
gerard.vermeu...@posteo.net writes:

> This patch addresses a number of glitches discovered during interactive
> testing and contains possible fixes (sub-patch test-ob-maxima fixes
> batch testing on my system, but not interactive testing).

Thanks for your interest in improving Org mode tests!

> The test-ob-maxima patch may be due to a different Maxima version, but
> I do not think so.  In batch testing test-ob-maxima passes contrary to
> interactive mode.

On my side, Maxima tests pass both interactively and non-interactively.
I use Maxima 5.47.0
What is your version?

> The test-ob-python patch unsets org-src-preserve-indentation which I
> have set.
>
> The test-ob patch also unsets org-src-preserve-indentation.

> The test-org patch also unsets org-src-preserve-indentation.  This
> reduces the number of failures to 2 while testing test-org
> interactively.

It is generally not expected that Org tests will pass when you try to
run them on Emacs instance with your personal config. This is because
you can have arbitrary customizations, hooks, or advices that change the
Org mode defaults.

let-binding a couple of variables cannot fix this general problem for
all scenarios. So, I do not see any reason to accept patches that make
the tests run with personal config of a single user.

What might be useful, however, is making sure that tests do not fail
interactively with a clean Emacs config (make repro).
Check out testing/README file.

>  (ert-deftest ob-maxima/string-input ()
>"Test of string input"
>(org-test-at-id "b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8"
>  (org-babel-next-src-block 2)
> -(should (equal "- sin(x)" (org-babel-execute-src-block)
> +(should (equal '(("(linenum:0," "") ("-" "sin(x)"))
> +   (org-babel-execute-src-block)

The test in question is testing the output of

#+begin_src maxima :var fun="sin(x)" :var q=2 :results silent
print(diff(fun, x, q))$
#+end_src

It is certainly not expected that such code block returns "linenum:0".

Tests in Org mode are verifying that Org mode behaves correctly. It
makes no sense to change the test when Org mode result is not correct -
we should instead fix Org mode.

In the majority of cases, if the test is failing, it is not something
wrong with the test, but something wrong with Org mode code that test is
verifying.

>  (ert-deftest test-ob/does-not-replace-a-block-with-the-results ()
>(org-test-with-temp-text "#+NAME: foo
> diff --git a/testing/lisp/test-org-element.el 
> b/testing/lisp/test-org-element.el
> index ca7d77e28..f0958ff59 100644
> --- a/testing/lisp/test-org-element.el
> +++ b/testing/lisp/test-org-element.el
> @@ -4457,7 +4457,7 @@ Text
>   '(paragraph nil "  Two spaces\n\n \n  Two spaces"))
>  '(paragraph nil "Two spaces\n\n\nTwo spaces")))
>(should
> -   (equal
> +   (equal ;; Fails in test. Why? (equal ...) form works in ielm.

It would help if you provided the error ERT displayed when the test failed.

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



Re: Slowness of org-agenda-redo in org 9.7 vs 9.6.7

2024-01-19 Thread Ihor Radchenko
dark.key8...@151e.ai writes:

> I've been running 9.7 for a few weeks and I've noticed a slowdown in
> `org-agenda-redo'. I finally ran some benchmarks.

Thanks!

> I can reproduce it with a minimal org config (bare init.el with only
> straight.el and a short org config) with my full `org-agenda-files'
> (~450 files). In my regular conf, both are faster than the report
> below (I suppose because of gc collection parameters), about ~10s and
> ~1s respectively.
>
> Here's a truncated comparison of elp outputs

May you please redo the benchmarks using
1. M-x profiler-start  cpu 
2. Run agenda
3. M-x profiler-report
4. M-x profiler-report-write-profile  profile.el 
5. Share two saved profiles, repeating the above steps with newer and
   older Org mode.

ELP benchmarks on the whole Org mode are useless - they create huge
overheads on frequently called fast functions, completely messing up the
information.

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



Re: Developing Moodle resources/sites with Org Mode

2024-01-19 Thread Doolittle, Edward


"Fraga, Eric" e.fr...@ucl.ac.uk writes:



> This sounds very good!  I am particularly impressed with being able to

> use maxima to create questions that have a random element.  I wish I'd

> had what you have done back at the start of the pandemic when I had to

> create quizzes for my moduless.



Thanks!  I have been thinking about getting something like this going

for a while.  WebWork sort of does some of this, but I like Moodle/STACK

so much better.



When I came across Org Mode it was quite a revelation.  Like you, I wish

I had done something some time ago: I should have learned about Org Mode

years ago.  It is very close to being exactly what I want: a rich

environment for creating and previewing randomizable test questions that

can be used to automatically generate paper tests or STACK questions for

Moodle.



I've started a GitHub site: https://github.com/edoolittle/org-moodle

I've posted the final exam to the site.  Lots of work needs to be done

on it still: in particular the full solutions need to be added, and the

randomization needs to be implemented.  Currently versions are

varied/randomized manually by adjusting the Parameters section at the

beginning of each question.  Finally, I have just copy/pasted from one

version to another but that needs to be redesigned.  There should be

only one copy of the test in the master file, and versions could be

created by exporting Org to Org (so that the parameters chosen for the

version are stored in the secondary Org file).



> In answer to your actual question: no, I do not believe you are off the

> mark.  I no longer have a need for what you are doing but I'm sure

> others would benefit greatly if they have to interact with moodle and

> its xml formats etc.



Thank you for the assessment.  I moved very quickly into this space, but

I was fortunate to be able to have 3 full days free over the holidays to

get up to speed.  Lots of fumbling around but I have been pleased with

how it all turned out.



Going forward, I am most confused about whether to transform Org to XML

and then to Moodle XML, or whether to export from Org directly to Moodle

XML.  In the short term the first will be easier for me, I think.



Edward


[BUG] Invalid search bound (wrong side of point) [9.6.6 (release_9.6.6 @ c:/Program Files/Emacs/emacs-29.1/share/emacs/29.1/lisp/org/)]

2024-01-19 Thread Christof . Jung
Hello, 

I got this when starting up emacs :  

 

 ■  Warning (org-element-cache): org-element--cache: Org parser error in CalnArch17.txt::#. Resetting.
 The error was: (error "Invalid search bound (wrong side of point)")
 Backtrace:
nil
 Please report this to Org mode mailing list (M-x org-submit-bug-report).
 ■  Warning (org-element-cache): org-element--cache: Org parser error in CalnArch18.txt::#. Resetting.
 The error was: (error "Invalid search bound (wrong side of point)")
 Backtrace:
nil
 Please report this to Org mode mailing list (M-x org-submit-bug-report).
 

Sorry, 

I had to delete some private information from my config

and I cannot send my private files, and I can't imagine how to reproduce this with anonymized data

but if somebody is interested in looking at this error, I am willing to answer questions 

 

Regards

Chris


 



Emacs  : GNU Emacs 29.1 (build 2, x86_64-w64-mingw32)
 of 2023-08-02
Package: Org mode version 9.6.6 (release_9.6.6 @ c:/Program Files/Emacs/emacs-29.1/share/emacs/29.1/lisp/org/)

current state:
==
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-bibtex-headline-format-function #[257 "\300�\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
 org-agenda-files '(" here I have about 20 Org-files between 2 KByte and 2 MByte ")
 org-replace-disputed-keys t
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-default-notes-file "k:/upload/Sync_with_Nokia/Org/notes.org"
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-odt-format-inlinetask-function 'org-odt-format-inlinetask-default-function
 org-ascii-format-drawer-function #[771 "�\207" [] 4 "\n\n(fn NAME CONTENTS WIDTH)"]
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
          org-cycle-optimize-window-after-visibility-change org-cycle-display-inline-images)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207"
           [add-hook change-major-mode-hook org-fold-show-all append local] 5]
         #[0 "\300\301\302\303\304$\207"
           [add-hook change-major-mode-hook org-babel-show-result-all append local] 5]
         org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-latex-format-headline-function 'org-latex-format-headline-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 outline-isearch-open-invisible-function 'outline-isearch-open-invisible
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-tags-exclude-from-inheritance '(" here I have 7 Tags ")
 org-todo-keywords '((sequence "TODO" "|" "DONE" "BACKLOG" "CANCELED" "ARCHIVE"))
 org-support-shift-select t
 org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate)
 org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-use-property-inheritance t
 org-fold-core-isearch-open-function 'org-fold-core--isearch-reveal
 org-latex-format-inlinetask-function 'org-latex-format-inlinetask-default-function
 org-persist-before-write-hook '(org-element--cache-persist-before-write)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-link-shell-confirm-function 'yes-or-no-p
 org-babel-pre-tangle-hook '(save-buffer)
 org-agenda-loop-over-headlines-in-active-region nil
 org-occur-hook '(org-first-headline-recenter)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("attachment" :follow org-attach-follow :complete org-attach-complete-link)
               ("eww" :follow org-eww-open :store org-eww-store-link)
               ("rmail" :follow org-rmail-open :store org-rmail-store-link)
               ("mhe" :follow org-mhe-open :store org-mhe-store-link)
               ("irc" :follow org-irc-visit :store org-irc-store-link :export org-irc-export)
               ("info" :follow org-info-open :export org-info-export :store
            org-info-store-link :insert-description org-info-description-as-command)
               ("gnus" :follow org-gnus-open :store org-gnus-store-link)
               ("docview" :follow org-docview-open :export org-docview-export :store
            org-docview-store-link)
               ("bibtex" :follow org-bibtex-open :store org-bibtex-sto

Re: [PATCH] Silently remove lockfiles from org-agenda-files

2024-01-19 Thread Ihor Radchenko
Joseph Turner  writes:

> My Emacs setup broke today due to the presence of a lockfile inside
> "~/.local/share/org/todo".  I use EXWM, and I show org-agenda on startup:
>
> (add-hook 'after-init-hook
> (lambda () (org-agenda nil "t")))
> (setq initial-buffer-choice (lambda () (get-buffer "*Org Agenda*")))
>
> org-agenda-files contained a non-existent file, so org-check-agenda-file
> attempted to prompt me.  For some reason (maybe EXWM didn't fully load),
> Emacs simply hung without prompting, leaving me with a black screen.

You may consider reporting the hang to Emacs or EXWM bug tracker.

> My configuration contains the equivalent of
>
> (setopt org-agenda-files
>(directory-files-recursively "~/.local/share/org/todo" ".org$"))

I'd recommend using a different approach - use org-agenda-file-regexp
instead of ".org$"; or use #'file-directory-p as predicate - Org mode
then select Org files inside all the listed directories by itself.

> The attached patch silently removes lockfiles from org-agenda-files.

> -  "Make sure FILE exists.  If not, ask user what to do."
> +  "Make sure FILE exists.  If not, ask user what to do.
> +Automatically exclude lockfiles."
>(unless (file-exists-p file)
> +(when (string-match-p (rx bos ".#") file) ; Exclude lockfiles
> +  (org-remove-file file)
> +  (throw 'nextfile t))

I feel slightly reluctant about this patch:

1. You are only working around the actual problem with agenda file being
   deleted from disk while Emacs is loading. So, the patch is not
   solving a real Org mode problem - Org mode prompting about
   non-existing file is not wrong; your bug has nothing to do with Org
   mode itself.

2. In theory, there might be users with actual Org files starting from
   ".#" for whatever reason. The probability is not high, but if users
   choose to set org-agenda-files directly, file-by-file, that's a
   choice we should better respect in order to not create a blocker.

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



Re: Patch to allow adjusting latex fragment display scale factor

2024-01-19 Thread Ihor Radchenko
Matt Huszagh  writes:

> Bringing this back up. Ihor, I've added you to the thread directly
> (hope that's ok).
>
> Any thoughts? I have not yet updated it for the most recent changes to
> main, but I can do that.

As you found in another thread, we have a WIP overhaul of the whole
LaTeX preview system. I hope that it can be merged in the coming few
months.

AFAIU, the new system will allow setting the scale factor - see
https://git.tecosaur.net/tec/org-mode/src/branch/dev/lisp/org-latex-preview.el#L57
Although, it does not look like a function is accepted as an allowed
value.

CCing Timothy and Karthik - they may have comments on the possibility to
allow function as :scale value.

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



Re: Slowness of org-agenda-redo in org 9.7 vs 9.6.7

2024-01-19 Thread dark . key8799
On Fri, Jan 19, 2024, at 20:57, Ihor Radchenko wrote:
> May you please redo the benchmarks using
> 1. M-x profiler-start  cpu 
> 2. Run agenda
> 3. M-x profiler-report
> 4. M-x profiler-report-write-profile  profile.el 
> 5. Share two saved profiles, repeating the above steps with newer and
>older Org mode.

Please find attached.

> ELP benchmarks on the whole Org mode are useless - they create huge
> overheads on frequently called fast functions, completely messing up the
> information.

I found the profiler-reports harder to read because of the (native-compiled?) 
lambda that show up and harder to compare since the metric is relative with no 
absolute reference but well noted and will remember.

-- 
Alexandre Avanian

cpu-profile-org-9_6_7.el
Description: Binary data


cpu-profile-org-9_7.el
Description: Binary data


Re: Slowness of org-agenda-redo in org 9.7 vs 9.6.7

2024-01-19 Thread Ihor Radchenko
dark.key8...@151e.ai writes:

> Please find attached.

Thanks!

> I found the profiler-reports harder to read because of the (native-compiled?) 
> lambda that show up and harder to compare since the metric is relative with 
> no absolute reference but well noted and will remember.

Yeah. For some reason, the profiler report in Org 9.7 looks strange.
May you open org-agenda.el and org-element.el and M-x eval-buffer in
these two files before generating the report? It should make the results
more readable.

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



Re: Developing Moodle resources/sites with Org Mode

2024-01-19 Thread Devin Prater
I don't like Moodle's interface at all. Just a web page edit field to 
type into. So, I have everything in Markdown on Github, and I link to 
that with Moodle URL type lessons. I'd love more support for Moodle in 
other software, since a folder of files is tons easier than tons of web 
pages. I'm not a programmer, but I can manage to use Emacs and the 
command line.


On 1/17/2024 7:25 PM, Doolittle, Edward wrote:

"Fraga, Eric" e.fr...@ucl.ac.uk  writes:

 > This sounds very good!  I am particularly impressed with being able to

 > use maxima to create questions that have a random element.  I wish I'd

 > had what you have done back at the start of the pandemic when I had to

 > create quizzes for my moduless.

Thanks!  I have been thinking about getting something like this going

for a while.  WebWork sort of does some of this, but I like Moodle/STACK

so much better.

When I came across Org Mode it was quite a revelation.  Like you, I wish

I had done something some time ago: I should have learned about Org Mode

years ago.  It is very close to being exactly what I want: a rich

environment for creating and previewing randomizable test questions that

can be used to automatically generate paper tests or STACK questions for

Moodle.

I've started a GitHub site: https://github.com/edoolittle/org-moodle 



I've posted the final exam to the site.  Lots of work needs to be done

on it still: in particular the full solutions need to be added, and the

randomization needs to be implemented.  Currently versions are

varied/randomized manually by adjusting the Parameters section at the

beginning of each question.  Finally, I have just copy/pasted from one

version to another but that needs to be redesigned.  There should be

only one copy of the test in the master file, and versions could be

created by exporting Org to Org (so that the parameters chosen for the

version are stored in the secondary Org file).

 > In answer to your actual question: no, I do not believe you are off the

 > mark.  I no longer have a need for what you are doing but I'm sure

 > others would benefit greatly if they have to interact with moodle and

 > its xml formats etc.

Thank you for the assessment.  I moved very quickly into this space, but

I was fortunate to be able to have 3 full days free over the holidays to

get up to speed.  Lots of fumbling around but I have been pleased with

how it all turned out.

Going forward, I am most confused about whether to transform Org to XML

and then to Moodle XML, or whether to export from Org directly to Moodle

XML.  In the short term the first will be easier for me, I think.

Edward



--
Devin Prater



Re: [PATCH] Patches for problems discovered with interactive testing

2024-01-19 Thread gerard . vermeulen




On 19.01.2024 13:50, Ihor Radchenko wrote:

gerard.vermeu...@posteo.net writes:

This patch addresses a number of glitches discovered during 
interactive

testing and contains possible fixes (sub-patch test-ob-maxima fixes
batch testing on my system, but not interactive testing).


Thanks for your interest in improving Org mode tests!


The test-ob-maxima patch may be due to a different Maxima version, but
I do not think so.  In batch testing test-ob-maxima passes contrary to
interactive mode.


On my side, Maxima tests pass both interactively and non-interactively.
I use Maxima 5.47.0
What is your version?

The same: maxima --version
Maxima 5.47.0

In batch testing without the patch I get:

Test ob-maxima/batch+verbatim condition:
(ert-test-failed
 ((should
   (equal (org-babel-execute-src-block)
  "(assume(z > 0),integrate(exp(-t)*t^z,t,0,inf))\n
gamma(z + 1)"))
  :form
  (equal
   "(linenum:0,\n(assume(z > 0),integrate(exp(-t)*t^z,t,0,inf))\n
 gamma(z + 1)"
   "(assume(z > 0),integrate(exp(-t)*t^z,t,0,inf))\n 
gamma(z + 1)")

  :value nil :explanation
  (arrays-of-different-length 104 92
  "(linenum:0,\n(assume(z > 
0),integrate(exp(-t)*t^z,t,0,inf))\n 
gamma(z + 1)"
  "(assume(z > 
0),integrate(exp(-t)*t^z,t,0,inf))\n 
gamma(z + 1)"

  first-mismatch-at 1)))
   FAILED   162/1252  ob-maxima/batch+verbatim (0.694916 sec) at 
../lisp/test-ob

-maxima.el:71

I do not know where the difference comes from.  I am not a Maxima user
and not inclined to track this down unless you tell me it is important.



The test-ob-python patch unsets org-src-preserve-indentation which I
have set.

The test-ob patch also unsets org-src-preserve-indentation.



The test-org patch also unsets org-src-preserve-indentation.  This
reduces the number of failures to 2 while testing test-org
interactively.


It is generally not expected that Org tests will pass when you try to
run them on Emacs instance with your personal config. This is because
you can have arbitrary customizations, hooks, or advices that change 
the

Org mode defaults.

let-binding a couple of variables cannot fix this general problem for
all scenarios. So, I do not see any reason to accept patches that make
the tests run with personal config of a single user.



Before I made the patch, I had reverted changes that worked 
interactively

in my personal config but caused failures with make test.

Because of the Maxima test failure (also in batch), I was not sure that 
all

tests pass on a reference system.


What might be useful, however, is making sure that tests do not fail
interactively with a clean Emacs config (make repro).
Check out testing/README file.



I have a super-weird system where make repro opens Emacs with
as default-directory my home directory.  So I have to make symbolic
links from my home to the testing and lisp directories.
But make test works.

Because of testing my 
0001-org-babel-demarcate-block-split-using-element-API.patch

interactively in my personal config (before make test which takes
quite some time), I figured out that it would guess to suppress false
failures.



 (ert-deftest ob-maxima/string-input ()
   "Test of string input"
   (org-test-at-id "b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8"
 (org-babel-next-src-block 2)
-(should (equal "- sin(x)" (org-babel-execute-src-block)
+(should (equal '(("(linenum:0," "") ("-" "sin(x)"))
+   (org-babel-execute-src-block)


The test in question is testing the output of

#+begin_src maxima :var fun="sin(x)" :var q=2 :results silent
print(diff(fun, x, q))$
#+end_src

It is certainly not expected that such code block returns "linenum:0".


I would say that it is an unexplained difference, I still get (with 
"linenum:0") :


#+header: :wrap "src text -n"
#+name: lst:maxima-example
#+begin_src maxima -n :batch batch :cmdline --quiet :exports both 
:results raw

rat(1/(x+1) + x/(x-1));
#+end_src

#+name: lst:maxima-example-results
#+results: lst:maxima-example
#+begin_src text -n
(%i1) (linenum:0,
(%i1) rat(1/(x+1)+x/(x-1))
  2
 x  + 2 x - 1
(%o1)/R/ 
 2
x  - 1
#+end_src



Tests in Org mode are verifying that Org mode behaves correctly. It
makes no sense to change the test when Org mode result is not correct -
we should instead fix Org mode.

In the majority of cases, if the test is failing, it is not something
wrong with the test, but something wrong with Org mode code that test 
is

verifying.


 (ert-deftest test-ob/does-not-replace-a-block-with-the-results ()
   (org-test-with-temp-text "#+NAME: foo
diff --git

Re: Slowness of org-agenda-redo in org 9.7 vs 9.6.7

2024-01-19 Thread dark . key8799
On Fri, Jan 19, 2024, at 22:00, Ihor Radchenko wrote:
> May you open org-agenda.el and org-element.el and M-x eval-buffer in
> these two files before generating the report? It should make the results
> more readable.

There you go, there's still some lambdas but more of the calls are explicit.

-- 
Alexandre Avanian

cpu-profile-org-9_7-v2.el
Description: Binary data


Re: Slowness of org-agenda-redo in org 9.7 vs 9.6.7

2024-01-19 Thread Ihor Radchenko
dark.key8...@151e.ai writes:

> On Fri, Jan 19, 2024, at 22:00, Ihor Radchenko wrote:
>> May you open org-agenda.el and org-element.el and M-x eval-buffer in
>> these two files before generating the report? It should make the results
>> more readable.
>
> There you go, there's still some lambdas but more of the calls are explicit.

Thanks!
I think that the missing lambdas should come from org.el.
So, may you M-x eval-buffer org-agenda.el, org-element.el, and org.el.

And do the same in Org 9.6. (there are also cryptic lambdas there in the
profile)

(In theory, you should not need to do this M-x eval-buffer trick if you
run Org mode from "make repro" command line in the git repo. Not sure if
it is easier for you or not)

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



Re: [BUG] Invalid search bound (wrong side of point) [9.6.6 (release_9.6.6 @ c:/Program Files/Emacs/emacs-29.1/share/emacs/29.1/lisp/org/)]

2024-01-19 Thread Ihor Radchenko
christof.j...@gmx.de writes:

> Hello, 
> I got this when starting up emacs :  
>  
>  ■  Warning (org-element-cache): org-element--cache: Org parser error in 
> CalnArch17.txt::# in CalnArch17.txt>. Resetting.
>  Please report this to Org mode mailing list (M-x org-submit-bug-report).

Thanks for reporting!

> Sorry, 
> I had to delete some private information from my config
> and I cannot send my private files, and I can't imagine how to reproduce this 
> with anonymized data
> but if somebody is interested in looking at this error, I am willing to 
> answer questions 

No problem. Before we look into details, may you please upgrade Org mode
to the latest version and check if the problem persists?

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



Re: [PATCH] Make command org-babel-detangle work interactively

2024-01-19 Thread Ihor Radchenko
gerard.vermeu...@posteo.net writes:

> org-babel-detangle is an interactive command but
> M-x org-babel-detangle always replies "Detangled 0 code blocks"
> This patch makes org-babel-detangle prompt for a source code file.
>
> Obviously, I got bitten by this.

I suspect that you may have some misunderstanding about how
`org-babel-detangle' works. Its docstring says:

   Propagate changes in source file back original to Org file.

So, it is expected to run from the tangled file; not from the Org file.

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



Re: [possible patch] Remove the '\\[0pt]' string from the last line of a verse block in LaTeX export

2024-01-19 Thread Juan Manuel Macías
Ihor Radchenko writes:

> This turned out to be a lot easier than I thought.
> See the attached patch.
>
>>> \command
>>> [unrelated text]
>>>
>>> If there are, we may actually want to consider pandoc's approach
>>> seriously.
>>
>> In principle, any environment that takes an optional argument in a
>> "dangerous" position. Just do a simple test. Something like this:
>>
>> #+begin_figure
>> [lorem] ipsum
>> #+end_figure
>>
>> will throw an error like ''LaTeX Error: Unknown float option...''
>>
>> Of course, putting an empty line after #+begin... usually solves it. But
>> the user may not know it.
>>
>> There are also a number of commands with an optional argument. For
>> example \pagebreak. Something like this will give an error:
>>
>> lorem @@latex:\pagebreak@@ [ipsum]
>>
>> \item is another typical example, but in this case org adds \relax.
>
> With the patch, I am getting the following:
>
> * This is test
> lorem @@latex:\pagebreak@@ [ipsum]
>
> #+begin_figure
> [lorem] figure
> #+end_figure
>
> | [foo] | 2 |
> | [bar] | 3 |
>
> - [bax]
> - [aur]
>
> exports to
>
> lorem \pagebreak {[}ipsum]
>
> \begin{figure}
> {[}lorem] figure
> \end{figure}
>
> \begin{center}
> \begin{tabular}{lr}
> {[}foo] & 2\\[0pt]
> {[}bar] & 3\\[0pt]
> \end{tabular}
> \end{center}
>
> \begin{itemize}
> \item {[}bax]
> \item {[}aur]
> \end{itemize}

Great! Simple and effective. And more surgical than pandoc's global
solution. But now a question arises... Your code clearly solves the
problem that led to the declaration of org-latex-line-break-safe,
without foreseeing any unwanted effects, since it is the solution that
is usually recommended from LaTeX. So, if this code is included in Org,
what is the future of org-latex-line-break-safe?

Best regards,

Juan Manuel 



Re: [PATCH] Make command org-babel-detangle work interactively

2024-01-19 Thread gerard . vermeulen




On 19.01.2024 16:20, Ihor Radchenko wrote:

gerard.vermeu...@posteo.net writes:


org-babel-detangle is an interactive command but
M-x org-babel-detangle always replies "Detangled 0 code blocks"
This patch makes org-babel-detangle prompt for a source code file.

Obviously, I got bitten by this.


I suspect that you may have some misunderstanding about how
`org-babel-detangle' works. Its docstring says:

   Propagate changes in source file back original to Org file.

So, it is expected to run from the tangled file; not from the Org file.


Yes, I misunderstood this and I see that my patch breaks this.

I think there is a typo in the docstring: "original to" must become "to 
original"

so that it ends with "back to original Org file".





Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2024-01-19 Thread Matt Huszagh
Hi Timothy,

Thanks for your work on this.

I've run into an issue related to the change you made in
209e5f5f4047a34db27c3b5dff4077bb1da9ceed that makes org-latex-compile
asynchronous.

This breaks the org-babel-latex-pdf-svg-process functionality I
introduced in commit ae35a345903c640397a8d29812112d72a9f8494a.

To reproduce the issue, you can create an org file with the following
single latex source block:

#+header: :file "out.svg"
#+begin_src latex :hidden
\begin{equation}\tag{1.6.3.1}
  \mathbf{F} = q \mathbf{E},
\end{equation}
#+end_src

If you execute this with C-c C-c, it complains about the PDF file not
being present. The problem can be found starting in line 182 of
ob-latex.el of your current (as of this writing) feature branch commit
8384289762b41b26e75d2e80c37ec84bcc552d32. The issue is that
org-babel-latex-tex-to-pdf (which delegates to org-latex-compile)
creates the PDF after org-compile-file (in line 185) tries to generate
an SVG file from it. In fact, I was initially confused because I
couldn't reproduce the issue with edebug (obviously, because that gave a
long enough delay for the file to be created before attempting the svg
creation).

org-latex-compile seems like it could be a dangerous function to change
to be asynchronous, as it's used in a lot of places and its very
possible that other people (like myself) were relying on it being
synchronous when they made some change that used it. I haven't looked at
its other invocations, but I wouldn't be surprised if this breaks other
things too. I hesitate to suggest alternatives because I don't know
enough about your use case. But, maybe you could achieve what you want
through a new org-latex-compile-async function, or add a nondefault
option to org-latex-compile?

Matt



Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2024-01-19 Thread Matt Huszagh
Timothy,

Another minor issue I've encountered. Using different delimiters results
in images of slightly different sizes.

For example, in a file containing:

```
Using first delimiters: \(F=ma\).

Using other delimiters: $F=ma$.
```

The snippet with dollar sign delimiters is slightly larger than the one
using \(\).

Matt



Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2024-01-19 Thread Matt Huszagh
Matt Huszagh  writes:

> Another minor issue I've encountered. Using different delimiters results
> in images of slightly different sizes.
>
> For example, in a file containing:
>
> ```
> Using first delimiters: \(F=ma\).
>
> Using other delimiters: $F=ma$.
> ```
>
> The snippet with dollar sign delimiters is slightly larger than the one
> using \(\).

The following code, where you compute the ascent value, seems relevant
to this observation:

;; The baseline seems to tend to sit slightly
;; lower than it should be, and a very mild
;; bias seems to improve the visual result.
;; From testing with a collecting of LaTeX
;; maths fonts (cm, cmbright, arev, pxfonts,
;; notomath, nextxsf, eulervm) decreacing the
;; depth measurement by 0.02pt in the baseline
;; calculation seems to work well.
;; I have yet to come across any situation
;; where this results in a negative depth,
;; however we may as well ensure that never
;; occurs.
(round (* 100 (- 1 (/ (max 0.0 (- depth 0.02))
  height

When using \(\) delimiters, using a depth adjustment of 0 (instead of
0.02) looks correct to me. I checked this by blowing up the fragment
with a very large scale factor (eg 10) and then baseline misalignments
become more obvious. This is how I ensured my baseline computation was
correct when I wrote that patch aligning the baseline several years
ago. I /think/ that's a valid method, and I've been using my code for
the last couple years and the baseline has always looked correct.

Anyway, can you explain more why you came to the conclusion of that
slight depth adjustment? Are you using $$ delimiters? That also appears
to produce other visual imperfections. For $F=ma$, I see the bottom of
the "m" and "a" cut off slightly. I wonder why different delimiters
produce different results. I used slightly different settings for
dvisvgm in my implementation (including --exact-bbox). I wonder if that
has any relevance... I also used a different document class - standalone
in preview mode. Now that I think about it, IIRC that was to address
another corner case I ran into, which is that for large images, article
will crop it before it gets to dvisvgm. It's been a while since I did
this and my memory is hazy, but I think that's why I used standalone. I
can try to investigate that with a minimal issue.

Matt