Re: [BUG] setting org-element-use-cache to nil doesn't seem to disable element cache [9.7.3 (release_9.7.3 @ /usr/share/emacs/30.0.50/lisp/org/)]

2024-06-21 Thread Platon Pronko

Thanks!
This appears to be an old bug in the parser.
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=9f4f7338d

Not for bugfix release as I do not want to break the parser accidentally
without testing, and the problem appears to rare enough to not call it
critical.


Tested the fix, the problem seems to be gone. Thank you!

However, regarding the original problem about cache seemingly being active - I 
do often notice that there are other issues with text highlighting (dates/todo 
markers/etc) and indentation breaking seemingly without reason. I will keep 
looking for these issues, but making a reliable reproducer for them is hard.

--
Best regards,
Platon Pronko
PGP 2A62D77A7A2CB94E




Re: [BUG] setting org-element-use-cache to nil doesn't seem to disable element cache [9.7.3 (release_9.7.3 @ /usr/share/emacs/30.0.50/lisp/org/)]

2024-06-21 Thread Ihor Radchenko
Platon Pronko  writes:

> However, regarding the original problem about cache seemingly being
> active - I do often notice that there are other issues with text
> highlighting (dates/todo markers/etc) and indentation breaking
> seemingly without reason. I will keep looking for these issues, but
> making a reliable reproducer for them is hard.

To be 100% clear, cache might get activated for short periods even when
you set org-element-use-cache to nil. But that happens only for the
duration of a single (expensive) command and the cache is discarded
immediately after. It may theoretically cause problems when you perform
some kinds of commands that edit multiple headings/other objects in
region: org-encrypt-entries, org-decrypt-entries, setting tags in
region, setting deadlines/scheduled in region, and archiving.

Text highlighting in particular should not be affected, AFAIK.

If there are problems with fontification, you may try setting
`backtrace-on-redisplay-error'. If there are any problems during
fontification, the last one will be recorded in *Redisplay-trace* buffer
(the buffer itself is not auto-displayed, you need to switch to it
manually).

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



Re: [PATCH] oc-csl: New custom option `org-cite-csl-sentence-case-bibtex-titles'

2024-06-21 Thread Max Nikulin

On 19/06/2024 16:27, András Simonyi wrote:

On Wed, 15 May 2024 at 13:48, Max Nikulin wrote:


I had a hope that it might alleviate the issue and to make things
working out of the box for more users.

[...]

Of course it could be checked whether
a CSL style contains explicit instructions about how to format titles
and skip  sentence-case conversion of input for those but this
probably would not
solve the problems of users who do not want the conversion at all.


Do you mean using title (original) case despite some style requites 
sentence case for English entries? I believed that fields should be 
surrounded with double braces {{...}} this case and the only issue is 
difference of original capitalization and result of conversion to 
sentence case and then back to title case.



It is not clear for me why `org-cite-csl-sentence-case-bibtex-titles' is
a part of Org, not of citeproc-el. The only thing that Org can do is to
pass it to citeproc-el. It is not configurable per .org file and likely
it should not be. From my point of view it might be more suitable per
.bib file. Anyway it is almost unrelated to Org.


citeproc-el doesn't have customizable user options by design because
it was conceived as a relatively low level
rendering library. Also, it's used by several user-facing packages by
now in addition to Org (org-ref, citar etc.) so
I think it would be both confusing and difficult to try to keep this
type of customizations in the library.


My expectation is that to get consistent results across applications, 
they should share the same preference. However since your choice is 
conscious, I do not insist.




Re: does org mode require a separate LaTeX installation to export?

2024-06-21 Thread Max Nikulin

On 19/06/2024 19:55, Christopher W. Ryan wrote:

In other words, if a complete novice, knowing nothing about LaTeX and
not having it on their machine ever, installed emacs and created an org
mode file, could they export via latex to PDF?  Could they export to html?


For HTML export, LaTeX may be required if you need math included as 
images, some MathML converters may need LaTeX as well. On the other hand 
MathJax relies on client JavaScript in browsers.


It is possible to convert HTML to PDF e.g. by printing it from a 
browser. Chrome/chromium have command line options to do it without 
starting GUI. Default CSS is likely not optimal for this workflow. 
Unless other factors are involved, I expect better quality of documents 
generated using LaTeX.




Re: [PATCH] Ability to specify :html-head as a function

2024-06-21 Thread Nathan Nichols
> This looks like a copy-paste of `org-element-normalize-string'.
> Why not simply calling `org-element-normalize-string'?

I changed it at one point, but then changed it back and didn't realize that
it was ultimately unchanged.
Here's a patch that uses `org-element-normalize-string` instead.

> Also, may we move this discussion to Org mailing list? I prefer the
> discussions and development to be public (it helps future maintainers).

Yes, of course. I think I just forgot to hit "reply all".

On Fri, Jun 21, 2024 at 4:47 AM Ihor Radchenko  wrote:

> Nathan Nichols  writes:
>
> > Subject: [PATCH] Added ability to specify :html-head as a string or
> function
> > ...
> > +(defun org-html-normalize-str (s)
> > +  "Return S, or evaluate to a string ending with a single newline
> character.
> > +If S isn't a string or a function, return it unchanged.  If S is the
> empty
> > +string, return it.  Otherwise, return a new string with a single
> > +newline character at its end."
> > +  (cond
> > +   ((not (stringp s)) s)
> > +   ((string= "" s) "")
> > +   (t (and (string-match "\\(\n[ \t]*\\)*\\'" s)
> > +(replace-match "\n" nil nil s)
>
> This looks like a copy-paste of `org-element-normalize-string'.
> Why not simply calling `org-element-normalize-string'?
>
> Also, may we move this discussion to Org mailing list? I prefer the
> discussions and development to be public (it helps future maintainers).
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>
From 4f4f5c76a490eaab86d721a1331dcee5307687d0 Mon Sep 17 00:00:00 2001
From: Nate Nichols 
Date: Thu, 20 Jun 2024 14:25:35 -0400
Subject: [PATCH] Added ability to specify :html-head as a string or function

---
 lisp/ox-html.el  | 13 ++---
 testing/lisp/test-ox-html.el |  6 ++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index d1687cf5a..0139aa88c 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2001,15 +2001,22 @@ INFO is a plist used as a communication channel."
 		  org-html-meta-tags))
   ""
 
+(defun org-html-normalize-str-or-fn (input &rest trailing)
+  "If INPUT is a string, it is passed to `org-element-normalize-string'.
+If INPUT is a function, it is applied to arguments TRAILING, and the result is
+passed to `org-element-normalize-string'."
+  (let ((s (if (functionp input) (format "%s" (apply input trailing)) input)))
+(org-element-normalize-str s)))
+
 (defun org-html--build-head (info)
   "Return information for the .. of the HTML output.
 INFO is a plist used as a communication channel."
   (org-element-normalize-string
(concat
 (when (plist-get info :html-head-include-default-style)
-  (org-element-normalize-string org-html-style-default))
-(org-element-normalize-string (plist-get info :html-head))
-(org-element-normalize-string (plist-get info :html-head-extra))
+  (org-element-normalize-str org-html-style-default))
+(org-html-normalize-str-or-fn (plist-get info :html-head) info)
+(org-html-normalize-str-or-fn (plist-get info :html-head-extra) info)
 (when (and (plist-get info :html-htmlized-css-url)
 	   (eq org-html-htmlize-output-type 'css))
   (org-html-close-tag "link"
diff --git a/testing/lisp/test-ox-html.el b/testing/lisp/test-ox-html.el
index 0959d1441..d079cd271 100644
--- a/testing/lisp/test-ox-html.el
+++ b/testing/lisp/test-ox-html.el
@@ -996,5 +996,11 @@ entirely."
 (should (= 0 (how-many "Created: ")))
 (should (= 1 (how-many "Author=Monsieur Oeuf")))
 
+(ert-deftest ox-html/test-normalize-str-or-fn ()
+  ;; Test cases for `org-element-normalize-str-or-fn'
+  (should (string= (org-html-normalize-str-or-fn (lambda (_res) "abcdefg") nil) "abcdefg\n"))
+  (should (string= (org-html-normalize-str-or-fn "abcdefg") "abcdefg\n"))
+  (should (= (org-element-normalize-str-or-fn 123 nil) 123)))
+
 (provide 'test-ox-html)
 ;;; test-ox-html.el ends here
-- 
2.34.1