Re: [PATCH] Add option to export mixed Setext and ATX-style Markdown headlines

2024-05-11 Thread Lee Thompson
Hi Ihor,

> But isn't (setq org-md-headline-style 'setext) do exactly what you describe?
My apologies, I should have included an example. What I'm trying to
achieve is that instead of this: (set to setext)
> One
> ===
>
>
> Two
> ---
>
> 1.  Three
>
> 1.  Four

Or even something like this: (atx assuming #+options: h:4)

# One


## Two


### Three


 Four


Setting `org-md-headline-style' to `'mixed' would produce the following:
(again assuming #+options: h:4)

One
===


Two
---


### Three


 Four

> AFAIK, headlines below level 2 simply cannot be exported with setext
> style, so Org mode already falls back to atx in >2 levels.
Unless I'm doing something wrong or I've been hacking away with older
code I haven't observed this. It may be that I'm getting mixed up in
terminology and what you've demonstrated in your example is indeed
setext falling back to atx, but my understanding is that in your example
the first two headlines are in setext style and the third and
fourth-level headlines have been converted to Markdown lists.

What I am proposing is a style where setext-style underlined headlines
are generated for levels 1 and 2, atx-style repeated hash characters for
levels 3 to 6, and then converted to lists for deeper levels. To
demonstrate:

#+options: toc:nil h:6
* One

** Two
*** Three
 Four
* Five
** Six
*** Seven
 Eight

Exports to:

One
===


Two
---


### Three


 Four


# Five


## Six

1.  Seven

1.  Eight


I hope this explains more clearly what I'm trying to achieve, do let me
know if not.



Re: [PATCH] Add option to export mixed Setext and ATX-style Markdown headlines

2024-05-11 Thread Ihor Radchenko
Lee Thompson  writes:

> This patch adds a new option `'mixed' to `org-md-headline-style' that
> when enabled allows for exporting the first two headline levels in
> Setext-style, and the rest in ATX-style. I like the mixed style for
> certain situations, and I couldn't find a way to export in this manner.

But isn't (setq org-md-headline-style 'setext) do exactly what you describe?

I just tried with
#+options: toc:nil
* 1
** 2
*** 3
 4

It exports to

One
===


Two
---

1.  Three

1.  Four

AFAIK, headlines below level 2 simply cannot be exported with setext
style, so Org mode already falls back to atx in >2 levels.

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



[PATCH] Add option to export mixed Setext and ATX-style Markdown headlines

2024-05-11 Thread Lee Thompson
Greetings all,

This patch adds a new option `'mixed' to `org-md-headline-style' that
when enabled allows for exporting the first two headline levels in
Setext-style, and the rest in ATX-style. I like the mixed style for
certain situations, and I couldn't find a way to export in this manner.

I've added what I think is appropriate in the news file and the manual,
but this is my first time doing so, please let me know if this needs any
improvements/tweaks.

Thanks,
Lee
>From 6b281412c3d3522f445fd1d5b43aa1141ff0b531 Mon Sep 17 00:00:00 2001
From: Lee Thompson 
Date: Sat, 11 May 2024 18:40:15 +0100
Subject: [PATCH] lisp/ox-md.el: Added mixed-style option to
 org-md-headline-style

* lisp/ox-md.el (org-md-headline-style): New setting `'mixed' allows
for mixing Setext and ATX-style headlines when exporting to Markdown.
* doc/org-manual.org (Header and sectioning structure): Documented
`mixed' headline style.
* etc/ORG-NEWS (New option added to custom setting
~org-md-headline-style~ to mix ATX and Setext style headlines):
Documented the new feature.

When exporting to Markdown, there was previously no obvious way of
mixing Setext-style and ATX-style headlines.  Via the
`org-md-headline-style' custom setting, headlines could be exported as
either all-Setext or all-ATX, but not as a mix.

With this change setting `org-md-headline-style' to `'mixed' will
export the first two headline levels as Setext-style Markdown
headlines and the rest as ATX-style.

TINYCHANGE
---
 doc/org-manual.org |  8 +---
 etc/ORG-NEWS   |  6 ++
 lisp/ox-md.el  | 15 ++-
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 3c60f3268f..e3a2c9b708 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -14788,9 +14788,11 @@ https://en.wikipedia.org/wiki/Markdown for more details.
 #+vindex: org-md-headline-style
 Based on ~org-md-headline-style~, Markdown export can generate
 headlines of both /atx/ and /setext/ types.  /setext/ limits headline
-levels to two whereas /atx/ limits headline levels to six.  Beyond
-these limits, the export backend converts headlines to lists.  To set
-a limit to a level before the absolute limit (see [[*Export Settings]]).
+levels to two whereas /atx/ limits headline levels to six.  /mixed/
+exports headline levels one and two in /setext/-style, and headline
+levels three through six as /atx/-style headlines.  Beyond these
+limits, the export backend converts headlines to lists.  To set a
+limit to a level before the absolute limit (see [[*Export Settings]]).
 
 ** OpenDocument Text Export
 :PROPERTIES:
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 978882a7ad..0bff6e0608 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1148,6 +1148,12 @@ blocks that do not specify any ~:formatter~ parameter. Its default
 value (the new function ~org-columns-dblock-write-default~) yields the
 previous (fixed) formatting behaviour.
 
+*** New option added to custom setting ~org-md-headline-style~ to mix ATX and Setext style headlines
+
+Setting ~org-md-headline-style~ to ~'mixed~ will export headline
+levels one and two as Setext style headlines, and headline levels
+three through six will be exported as ATX style headlines.
+
 ** New features
 *** =ob-lua=: Support all types and multiple values in results
 
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 48a3e8387b..de4c572b29 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -47,11 +47,15 @@
 
 (defcustom org-md-headline-style 'atx
   "Style used to format headlines.
-This variable can be set to either `atx' or `setext'."
+This variable can be set to either `atx', `setext', or `mixed'.
+
+Mixed style uses Setext style markup for the first two headline levels
+and uses ATX style markup for the remaining four levels."
   :group 'org-export-md
   :type '(choice
 	  (const :tag "Use \"atx\" style" atx)
-	  (const :tag "Use \"Setext\" style" setext)))
+	  (const :tag "Use \"Setext\" style" setext)
+  (const :tag "Use \"mixed\" style" mixed)))
 
 
  Footnotes
@@ -232,7 +236,7 @@ anchor tag for the section as a string.  TAGS are the tags set on
 the section."
   (let ((anchor-lines (and anchor (concat anchor "\n\n"
 ;; Use "Setext" style
-(if (and (eq style 'setext) (< level 3))
+(if (and (not (eq style 'atx)) (< level 3))
 (let* ((underline-char (if (= level 1) ?= ?-))
(underline (concat (make-string (length title) underline-char)
   "\n")))
@@ -397,9 +401,10 @@ a communication channel."
   (cond
;; Cannot create a headline.  Fall-back to a list.
((or (org-export-low-level-p headline info)
-	(not (memq style '(atx setext)))
+	(not (memq style '(atx mixed setext)))
 	(and (eq style 'atx) (> level 6))
-	(and (eq style 'setext) (> level 2)))
+	(and (eq style 'setext) (> level 2))
+	(and (eq style 'mixed) (> level 6)))
 	(let ((bullet
 	   (if (not (org-export-numbered-headline-p headline info)) 

Re: [FR] Support headline as a function for file+headline target for org-capture-templates

2024-05-11 Thread Ihor Radchenko
Nafiz Islam  writes:

> I see there are a lot of test cases for org-find-olp (which is the function
> I believe processes the outline path argument).
>
> testing/lisp/test-org.el
> 2861:(ert-deftest test-org/org-find-olp ()
> 2862:  "Test `org-find-olp' specifications."
> 2875:(should (org-find-olp '("Headline") t))
> 2876:(should-error (org-find-olp '("Headline" "Test") t))
> 2877:(should-error (org-find-olp '("Headlinealksjd") t))
> 2878:(should (org-find-olp '("Headline" "headline2") t))
> 2879:(should (org-find-olp '("Headline" "headline3") t))
> 2880:(should (org-find-olp '("Headline" "headline3" "headline4") t))
> 2881:(should-error (org-find-olp '("Headline" "headline5") t))
> 2882:(should (org-find-olp '("Headline" "headline6") t))
> 2883:(should (org-find-olp '("Headline" "headline7") t))
> 2884:(should (org-find-olp '("Headline" "headline8") t))
>
> How should I go about testing different parameter types such as function
> and symbol?

I do not think that you need to modify `org-find-olp' itself.

Instead, do what is already done for resolving the file name:

(org-find-olp (cons (org-capture-expand-file path)
(org-capture-expand-olp outline-path)))

`org-capture-expand-olp' is the new function to be implemented.

Then, all you need in terms of tests is to add a test case into
`test-org-capture/entry' and, if you want, write a new test for
`org-capture-expand-olp'.

-- 
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-05-11 Thread Ihor Radchenko
András Simonyi  writes:

> since bibtex and biblatex requires title fields to be in title case
> ...

Are you sure? AFAIK, bibtex and biblatex (depending on the bibstyle)
does not care about capitalization and instead applies its own, unless
the title explicitly protects the capitalization/case with {Curly
BracketS}.

See https://texfaq.org/FAQ-capbibtex and
https://tex.stackexchange.com/questions/20335/proper-casing-in-citation-bibliography-titles-using-biblatex-biber

> ... but CSL assumes that they are in sentence-case, citeproc-el converts
> title fields in bib(la)tex bibliography databases into sentence-case
> before processing them except for entries with an explicit non-English
> langid value...

AFAIU, the general recommendation is to use sentence case in the bib
files. Both for Bib(La)Tex (because it converts into title case if
necessary by itself) and for CSL, according to
https://citationstyles.org/authors/

Of course, not every real-life bibliography follows such suggestion,
but, as stated in https://citationstyles.org/authors/, converting from
title case to sentence case is error-prone:

>> For this reason, we recommend that you store all titles in your
>> reference database in sentence case. Our repository CSL styles that
>> need sentence case will generally just print titles as is, whereas
>> styles that need title case will use an automatic title-case
>> conversion.

Looking at https://github.com/andras-simonyi/citeproc-el/issues/119 and
https://github.com/andras-simonyi/citeproc-el/issues/142, it appears to
me that citeproc.el does not stick to the above guideline from CSL
website - unless title case is requested by the bibliography converting
to sentence case should not be done by default. Also, such conversion
should only happen in titles, AFAIU; not in other fields.

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

I see no problem with the new feature, but I'd consider flipping the
default to nil.

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



Re: [PATCH] Add support for shortdoc link type

2024-05-11 Thread Bruno Cardoso

On 2024-05-10, 18:09 +0700, Max Nikulin  wrote:

> Thank you for the explanation. Reading "lists all" I expected something 
> like list of all info manuals in the case of M-x info RET when there are 
> no info buffers yet.

I see. I replaced the term "lists all" with "shows all" to avoid this confusion.

> The following garbage in - garbage out case is a bit confusing:
> 
> => "No such documentation group "

Fixed the error handling and the error message.

> Bruno, has you signed the copyright form? This patch is above the 
> TINYCHANGE limit.
> 

I haven't yet. Will be glad to.

> It will be a bit less work for the maintainer if you attach result of 
> "git format-patch" command. It adds email-like headers allowing to 
> properly set commit author.

The attached patch is now in this format.

>From 57ab6be64e227fcab24ad4c5b84873ed4e946cff Mon Sep 17 00:00:00 2001
From: Bruno Cardoso 
Date: Sat, 11 May 2024 13:42:56 -0300
Subject: [PATCH] Add support for shortdoc link type

ol.el: Add support for `shortdoc' link type

* lisp/ol.el (org-link--open-shortdoc org-link--store-shortdoc)
(org-link--complete-shortdoc): Add support for storing and inserting links
to `shortdoc' documentation groups for Emacs Lisp functions.
* doc/org-manual.org (External Links): Add shortdoc link type
documentation.
* etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document
the new feature.
---
 doc/org-manual.org | 11 +++
 etc/ORG-NEWS   |  5 +
 lisp/ol.el | 41 +
 3 files changed, 57 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f9d4c9a3f..8e99652b5 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3382,6 +3382,15 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ shows all known
+  documentation groups.
+
+  For more information, see [[info:emacs#Name Help][Name Help]]
+  and [[info:elisp#Documentation Groups][Documentation Groups]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3423,6 +3432,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 36eeddda1..9b7ba96ba 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1428,6 +1428,11 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index 3d64b41b0..6b84957f4 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,7 +1582,47 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search string\"."
+(string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path)
+(let* ((group (match-string 1 path))
+   (str (match-string 2 path))
+   (fn (and str
+(eq ?# (string-to-char str))
+(intern-soft (substring str 1)
+  (condition-case nil
+  (progn
+(shortdoc-display-group group fn)
+(and str (not fn) (search-forward str nil t)))
+(error (message "Unknown shortdoc group or malformed link: `%s'"
+path)
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(if (and group (assoc 

Re: [PATCH] Add org-after-note-stored-hook

2024-05-11 Thread Ihor Radchenko
Joris Caravati via "General discussions about Org-mode."
 writes:

> I've been archiving tasks automatically using
> `org-after-todo-state-change-hook' but I've been recently bit with a
> note (entering a todo state configured with '@') being placed where the
> task was before its archival.
>
> This patch aims to offer a way to defer the archival after the
> note is stored. Actually, I am using it like this:
>
> #+begin_src elisp
> (add-to-list 'org-after-todo-state-change-hook
>(lambda ()
>  ;; States configured without mandatory note
>  (when (member org-state '("DONE"))
>(my/org-roam-archive-to-today))
>  ;; States configured with mandatory note
>  (when (member org-state '("CANCELLED" "READ"))
>(add-to-list 'org-after-note-stored-hook 
> 'my/org-roam-archive-to-today
> #+end_src
>
> With `my/org-roam-archive-to-today' removing itself from
> `org-after-note-stored-hook'.
>
> Hopefully I did not miss an existing way to do this.

An easier way would be forcing note earlier by calling
`org-add-log-note' from your hook.

Although, removing heading from inside
`org-after-todo-state-change-hook' is a bad idea - Org mode does not
expect the heading to disappear from under the cursor when this hook is
executed. I recommend using `org-trigger-hook' instead.

So, your patch does not seem necessary to achieve what you want.

That said, it does make sense to add a hook after storing a log note,
but not at the very end, when point may not be at the note stored:

>(with-current-buffer (marker-buffer org-log-note-return-to)
>  (goto-char org-log-note-return-to))
>(move-marker org-log-note-return-to nil)
> -  (when org-log-post-message (message "%s" org-log-post-message)))
> +  (when org-log-post-message (message "%s" org-log-post-message))
> +  (run-hooks 'org-after-note-stored-hook))

This will leave point in buffer where the note was invoked. For example,
in agenda buffer. I doubt that the users of this hook will expect such a
thing.

It will probably be better to run such new hooks right before (message "Note 
stored")
in `org-store-log-note'.

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



Re: [FR] Support headline as a function for file+headline target for org-capture-templates

2024-05-11 Thread Nafiz Islam
I see there are a lot of test cases for org-find-olp (which is the function
I believe processes the outline path argument).

testing/lisp/test-org.el
2861:(ert-deftest test-org/org-find-olp ()
2862:  "Test `org-find-olp' specifications."
2875:(should (org-find-olp '("Headline") t))
2876:(should-error (org-find-olp '("Headline" "Test") t))
2877:(should-error (org-find-olp '("Headlinealksjd") t))
2878:(should (org-find-olp '("Headline" "headline2") t))
2879:(should (org-find-olp '("Headline" "headline3") t))
2880:(should (org-find-olp '("Headline" "headline3" "headline4") t))
2881:(should-error (org-find-olp '("Headline" "headline5") t))
2882:(should (org-find-olp '("Headline" "headline6") t))
2883:(should (org-find-olp '("Headline" "headline7") t))
2884:(should (org-find-olp '("Headline" "headline8") t))

How should I go about testing different parameter types such as function
and symbol?


Re: [FR] :noweb-wrap header arg

2024-05-11 Thread Amy Grinn
Ihor Radchenko  writes:

> Amy Grinn  writes:
>
>> First of all, I would like to change (defalias) the function name
>> org-babel-noweb-wrap to org-babel-noweb-make-regexp. I think this in
>> more in line with other functions which create regular expressions.
>
> +1
> You may even use obsolete alias (add it to lisp/org-compat.el)

Here's a patch to rename org-babel-noweb-wrap to
org-babel-noweb-make-regexp.

>From b318fef6af8ae47b7e6d0371ccc87a01ed1a7755 Mon Sep 17 00:00:00 2001
From: Amy Grinn 
Date: Wed, 17 Apr 2024 16:01:40 -0400
Subject: [PATCH] lisp/ob-core.el: (org-babel-noweb-wrap): renamed to
 org-babel-noweb-make-regexp

* etc/ORG-NEWS (~org-babel-noweb-wrap~ is now
~org-babel-noweb-make-regexp~): Announce the change.
* lisp/org-compat.el: Declare org-babel-noweb-wrap to be an obselete
function alias for org-babel-noweb-make-regexp.
* lisp/ob-core.el (org-babel-noweb-make-regexp): Rename the function.
(org-babel-goto-named-src-block):
(org-babel-expand-noweb-references):
* lisp/ob-exp.el (org-babel-exp-code):
* lisp/ob-tangle.el (org-babel-tangle-clean):
(org-babel-tangle-single-block): Use the new function name.
---
 etc/ORG-NEWS   | 6 ++
 lisp/ob-core.el| 8 
 lisp/ob-exp.el | 2 +-
 lisp/ob-tangle.el  | 5 +++--
 lisp/org-compat.el | 2 +-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 978882a7a..97e2f2e3f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1563,6 +1563,12 @@ optional argument =NEW-HEADING-CONTAINER= specifies where in the
 buffer it will be added.  If not specified, new headings are created
 at level 1 at the end of the accessible part of the buffer, as before.
 
+** Removed or renamed functions and variables
+*** ~org-babel-noweb-wrap~ is now ~org-babel-noweb-make-regexp~
+
+This is more in line with other functions that return a regular
+expression.
+
 ** Miscellaneous
 *** =org-crypt.el= now applies initial visibility settings to decrypted entries
 
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index c5dd20b0e..1518d7726 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -194,7 +194,7 @@ This string must include a \"%s\" which will be replaced by the results."
   :package-version '(Org . "9.1")
   :safe #'booleanp)
 
-(defun org-babel-noweb-wrap ( regexp)
+(defun org-babel-noweb-make-regexp ( regexp)
   "Return regexp matching a Noweb reference.
 
 Match any reference, or only those matching REGEXP, if non-nil.
@@ -1976,7 +1976,7 @@ src block, then return nil."
 		   (type (org-element-type context))
 		   (noweb-ref
 		(and (memq type '(inline-src-block src-block))
-			 (org-in-regexp (org-babel-noweb-wrap)
+			 (org-in-regexp (org-babel-noweb-make-regexp)
 	  (cond
 	   (noweb-ref
 		(buffer-substring
@@ -3125,7 +3125,7 @@ block but are passed literally to the \"example-block\"."
   (not (equal (cdr v) "no"))
 	 (noweb-re (format "\\(.*?\\)\\(%s\\)"
 			   (with-current-buffer parent-buffer
-			 (org-babel-noweb-wrap)
+			 (org-babel-noweb-make-regexp)
 (unless (equal (cons parent-buffer
  (with-current-buffer parent-buffer
(buffer-chars-modified-tick)))
@@ -3175,7 +3175,7 @@ block but are passed literally to the \"example-block\"."
 	   ((guard (or org-babel-noweb-error-all-langs
 			   (member lang org-babel-noweb-error-langs)))
 	(error "Cannot resolve %s (see `org-babel-noweb-error-langs')"
-		   (org-babel-noweb-wrap ,ref)))
+		   (org-babel-noweb-make-regexp ,ref)))
 	   (_ ""
   (replace-regexp-in-string
noweb-re
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 80eaeeb27..a61b26ed5 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -419,7 +419,7 @@ replaced with its value."
   (setf (nth 1 info)
 	(if (string= "strip-export" (cdr (assq :noweb (nth 2 info
 	(replace-regexp-in-string
-	 (org-babel-noweb-wrap) "" (nth 1 info))
+	 (org-babel-noweb-make-regexp) "" (nth 1 info))
 	  (if (org-babel-noweb-p (nth 2 info) :export)
 	  (org-babel-expand-noweb-references
 	   info org-babel-exp-reference-buffer)
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 79fe6448b..4427250ae 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -412,7 +412,7 @@ references."
   (interactive)
   (goto-char (point-min))
   (while (or (re-search-forward "\\[\\[file:.*\\]\\[.*\\]\\]" nil t)
- (re-search-forward (org-babel-noweb-wrap) nil t))
+ (re-search-forward (org-babel-noweb-make-regexp) nil t))
 (delete-region (save-excursion (forward-line) (point))
(save-excursion (end-of-line 1) (forward-char 1) (point)
 
@@ -580,7 +580,8 @@ non-nil, return the full association list to be used by
 	  ;; Run the tangle-body-hook.
   (let ((body (if (org-babel-noweb-p params :tangle)
   (if (string= 

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

2024-05-11 Thread András Simonyi
Dear All,

since bibtex and biblatex requires title fields to be in title case
but CSL assumes that they are in sentence-case, citeproc-el converts
title fields in bib(la)tex bibliography databases into sentence-case
before processing them except for entries with an explicit non-English
langid value. Although this seems to be reasonable behaviour, there
were several requests in the last couple of years to make it possible
to turn this conversion off (see, e.g., citeproc issues  #119 and
#142). The attached patch introduces a new custom option to configure
when to perform the conversion.

I'm a bit unsure about naming the option:
Perhaps `org-cite-csl-sentence-case-bibtex-titles-without-langid'
would be more precise but I found it absurdly long and technical, as
most users are probably unaware of the existence of langid fields.

best wishes,
András
From 031428611c18bb4d97bbdbd11a7549ca2b96ccec Mon Sep 17 00:00:00 2001
From: Andras Simonyi 
Date: Sat, 11 May 2024 11:20:41 +0200
Subject: [PATCH] oc-csl: New custom option
 `org-cite-csl-sentence-case-bibtex-titles'

* lisp/oc-csl.el (org-cite-csl-sentence-case-bibtex-titles): New
variable.
(org-cite-csl--processor): Create the itemgetter using the new option.
* etc/ORG-NEWS (New option
~org-cite-csl-sentence-case-bibtex-titles~): Announce the change.
---
 etc/ORG-NEWS   |  9 +
 lisp/oc-csl.el | 18 +-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 36eeddda1..9ca71d0a2 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1128,6 +1128,15 @@ blocks that do not specify any ~:formatter~ parameter. Its default
 value (the new function ~org-columns-dblock-write-default~) yields the
 previous (fixed) formatting behaviour.
 
+*** New option ~org-cite-csl-sentence-case-bibtex-titles~
+
+When this option is non-nil then title fields in bibtex bibliography
+entries are converted to sentence-case before being formatted
+according to a CSL style, except for entries with a =langid= field
+specifying a non-English language.  When nil, this conversion is
+limited to entries having a =langid= field specifying a variant of
+English.  The defult value is ~t~.
+
 ** New features
 *** =ob-lua=: Support all types and multiple values in results
 
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 9bbe5e29d..7234174d0 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -321,6 +321,21 @@ in the bibliography measured in characters."
   :type 'string
   :package-version '(Org . "9.7"))
 
+(defcustom org-cite-csl-sentence-case-bibtex-titles t
+  "Convert bibtex title fields to sentence-case by default.
+
+When non-nil, title fields in bibtex bibliography entries are
+converted to sentence-case before being formatted according to a
+CSL style, except for entries with a `langid' field specifying a
+non-English language.
+
+When nil, this conversion is limited to entries having a `langid'
+field specifying a variant of English."
+  :group 'org-cite
+  :package-version '(Org . "9.7")
+  :type 'boolean
+  :safe #'booleanp)
+
 
 ;;; Internal variables
 (defconst org-cite-csl--etc-dir
@@ -584,7 +599,8 @@ property in INFO."
  (processor
   (citeproc-create
(org-cite-csl--style-file info)
-   (citeproc-hash-itemgetter-from-any bibliography)
+   (citeproc-hash-itemgetter-from-any
+bibliography (not org-cite-csl-sentence-case-bibtex-titles))
(org-cite-csl--locale-getter)
locale)))
 (plist-put info :cite-citeproc-processor processor)
-- 
2.34.1



Re: Update contact info

2024-05-11 Thread Amy Grinn
Bastien Guerry  writes:

> Ihor Radchenko  writes:
>
>> Bastien, may you check which name is used in the FSF records?
>
> I've taken this offlist.

The name in the FSF records should be correct now.

-- 
Best,

Amy



Re: [BUG] org-agenda-tree-to-indirect-buffer does not respect org-indirect-buffer-display value

2024-05-11 Thread Ihor Radchenko
JV  writes:

> `org-agenda-tree-to-indirect-buffer' does not respect the
> `org-indirect-buffer-display' value of 'current-window unless invoked 
> with a prefix arg.
>
> The function does respect all other values for
> `org-indirect-buffer-display'. And it does respect the value
> 'current-window when the function is called with a prefix arg.
> However, without prefix arg, 'current-window and 'other-window are 
> treated the same and call to `split-window' is made.

Thanks for reporting!
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=db5478108

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



Re: Flyspell process called frequently when using Org export (was: Flyspell causes severe slowdown when manipulating footnotes)

2024-05-11 Thread Ihor Radchenko
Ihor Radchenko  writes:

>>   A new Ispell process started on export.
> ...
> Confirmed.
> This is because `org-html-final-function' uses `mhtml-mode' to indent the
> resulting html file. `mhtml-mode' unconditionally runs `prog-mode-hook'
> thus starting Ispell.
>
> We may try `delay-mode-hooks' around `set-auto-mode', but it is not
> honoured by `mhtml-mode'. I guess we can report this as Emacs bug.

Fixed, on main.
The fix will only work in Emacs 30+, because it requires Emacs bug fix
described in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70671
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e36a4fe20

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



Re: [PATCH] org-manual: Rewrite opening section in Citation handling

2024-05-11 Thread Ihor Radchenko
András Simonyi  writes:

> ... Some comments on the proposed changes:
> ...

Thanks for the comments!
See the attached updated version of the patch with all your comments
addressed.

>> At least one =PRINT_BIBLIOGRAPHY= keyword must be present in the
>> document to render citations on export.
>
> That is not true in general, as the csl processor and most probably
> some others too can render citations without a bibliography; there are
> even citation styles (typically, note-based ones) that are designed to
> work without a bibliography and specify all bibliographic data in
> citations. Because of this I suggest removing or at least rewriting
> this sentence.

Right. It is only true in bibtex-based processors, and only when the
citation  command tries to create a link to (missing) bibliography
record. I removed this passage completely.

>From e16e5b2c678a18a772f338162fbfb9d2626b9317 Mon Sep 17 00:00:00 2001
Message-ID: 
From: Ihor Radchenko 
Date: Mon, 6 May 2024 11:40:18 +0300
Subject: [PATCH v2] org-manual: Add better opening description to "Citation
 handling" section

* doc/org-manual.org (Citation handling): Rewrite the opening
paragraphs describing citations using less technical description.  The
new version aims to ordinary Org mode users and avoids talking about
Elisp libraries.
(Citations): Unify markup for citation processor names (use verbatim).
Mention that at least one #+PRINT_BIBLIOGRAPHY is mandatory to render
output.  Indicate that default citation style is "nil".
---
 doc/org-manual.org | 94 +-
 1 file changed, 68 insertions(+), 26 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 3c60f3268..bf9547ae9 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -17491,30 +17491,69 @@ * Citation handling
 #+cindex: citation
 #+cindex: citation processor
 
-The =oc.el= library provides tooling to handle citations in Org via
-"citation processors" that offer some or all of the following
-capabilities:
+While [[*Hyperlinks][links]] are often sufficient to refer to external
+or internal information from Org, they have their limitations when
+referring to multiple targets or typesetting printed publications.
 
-- activate :: Fontification, tooltip preview, etc.
-- follow :: At-point actions on citations via ~org-open-at-point~.
-- insert :: Add and edit citations via ~org-cite-insert~.
-- export :: Via different libraries for different target formats.
+Org mode provides a more sophisticated markup to "cite" external
+resources.  For example, consider the following Org mode snippet
 
-To use a "citation processor", the user must load them; for example;
+: #+bibliography: citationdata.bib
+:
+: Org mode is used by various communities [cite:teaching: @orgteaching;
+: and TeX: @orgtex].  [cite/author/caps:@orgtex] uses Org mode to simplify
+: writing scientific publications, while [cite/author/caps:@orgteaching]
+: experiment with Org babel to improve teaching.
+:
+: #+print_bibliography:
 
-#+begin_src emacs-lisp
-(require 'oc-bibtex)
-#+end_src
+Org mode will gather citation metadata from the =#+bibliography=
+database and use it to typeset the exported document in arbitrary
+formats.  For example, the snippet below shows ASCII export output.
+
+: Org mode is used by various communities (teaching: Birkenkrahe, Marcus,
+: 2023, and TeX: Somma, Emmanuele F, 2023).  Somma, Emmanuele F uses Org
+: mode to simplify writing scientific publications, while Birkenkrahe,
+: Marcus experiment with Org babel to improve teaching.
+:
+: Birkenkrahe, Marcus (2023). /Teaching Data Science with Literate
+: Programming Tools/, MDPI.
+:
+: Somma, Emmanuele F (2023). /Simplifying LaTeX with ORG-mode in Emacs/,
+: TUGboat volume.
+
+In addition to export, users can use completion to search and insert
+citations from the bibliography (via ~org-cite-insert~).  Citations
+also act like ordinary links, jumping to the citation metadata when
+"following" them (~org-open-at-point~).
+
+You can customize every aspect (/capability/) of citation handling
+using built-in or external /citation processors/.
+
+Org mode ships with several built-in citation processors tailored to
+work with LaTeX export and BibTeX bibliographies (=bibtex=,
+=biblatex=, and =natbib= processors), or with more generic formats
+described using [[https://citationstyles.org/][Citation Style
+Language]] (=csl= processor).
+
+The default citation processor is =basic= - it works with arbitrary
+export formats and recognizes both BibTeX and CSL bibliographies.
+
+More citation processors are distributed as Emacs packages.
 
 #+vindex: org-cite-activate-processor
 #+vindex: org-cite-follow-processor
 #+vindex: org-cite-insert-processor
 #+vindex: org-cite-export-processor
-They can then configure them with ~org-cite-activate-processor~,
-~org-cite-follow-processor~, ~org-cite-insert-processor~, and
-~org-cite-export-processors~ respectively.
+Multiple citation processors can be mixed to meet 

Re: [PATCH] Add new option 'org-imenu-flatten'

2024-05-11 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Morgan Smith  writes:
>
>> * lisp/org/org-compat.el: Add definition of 'org-imenu-flatten'.
>> (org-imenu-get-tree): Use 'org-imenu-flatten'.
>> ---
>>
>> Hello!
>>
>> I've been using this patch for a bit and I quite like it.  One would think
>> there would be an option in imenu itself to flatten trees but that does not
>> seem to be the case.  I copied the defcustom from 'doc-view-imenu-flatten'.
>
> Have you considered adding a "flatten" option to imenu itself?
> That way, you could automatically get the functionality for free
> everywhere, not just in Org mode.

Built-in imenu in Emacs 30 will have a new `imenu-flatten' option.
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=4306aba2d0447fd79c0b749a984ccd7bdbc92361

So, we do not need a dedicated toggle on Org mode side.

Canceled.

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



Re: [DISCUSSION] Sorting strings in Org mode vs. system locale

2024-05-11 Thread Ihor Radchenko
Max Nikulin  writes:

>> 
>>> I consider the following as a kind of graceful degradation
>>>
>>> (defun org-sort-function-fallback-downcase
>>>  (a b  LOCALE IGNORE-CASE)
>>>(if ignore-case
>>>   (string-collate-lessp (downcase a) (downcase b) locale ignore-case)
>>> (string-collate-lessp a b locale ignore-case)))
>> 
>> It is indeed better than `org-sort-function-downcase'.
>
> `compare-strings' with upcase conversion under the hood may be an 
> alternative.

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=413192698
I replaced the two fallback variants with #'string< and custom downcase
function with a single fallback that uses `compare-strings'.

Closed.

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



Re: [BUG] inline src blocks in caption of not-inline src blocks do not execute

2024-05-11 Thread Ihor Radchenko
Ihor Radchenko  writes:

>>> It was a slip when the patch was applied.
>>> May you please explain more about {{{results(=value=)}}} problem?
>>> Isn't it sufficient to do src_elisp[:results verbatim]{'value} 
>>> {{{results(=value=)}}}?
>>
>> The issue is the opposite I think. Currently the default value (i.e. absent)
>> for :results does not produce {{{results(value)}}} as suggested, and instead
>> producers {{{results(=value=)}}}. ...

This is expected. The defaults for paragraph-level source blocks are the
same - to treat results as verbatim and quote them using fixed width
markup or example block.

> Thanks!
> In addition, the docstring of `org-babel-insert-result' says
>
> drawer -- results are added directly to the Org file as with
>   "raw", but are wrapped in a RESULTS drawer or results
>   macro, allowing them to later be replaced or removed
>   automatically.
>
> But not in the manual:
>
> ‘drawer’
>  Result wrapped in a ‘RESULTS’ drawer.  Useful for containing ‘raw’
>  or ‘org’ results for later scripting and automated processing.
>  Usage example: ‘:results value drawer’.

For now, I updated the manual to reflect the reality.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4deb06ea0

:results drawer is still confusing for inline src blocks, but we have
what we have. I have no good ideas what can be done to improve the
situation.

Handled.

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