Dear Maintainers,

first of all, thank you all very much for your work.

while working with org-roam I detected the following bug:

Create an org file with the following info:

* heading

* heading 2

#+begin_src emacs-lisp   :exports both
(org-map-region
 (lambda ()
   (message "%S" (point)
            ))
 (point-min) (point-max)
 )

#+end_src


Then run the babel block and inspect the results.

You will note that the location of the first heading is off (it is
reported as starting after the space after the asterisks)


This patch addresses that:

The current logic of org-map-region uses two searches.

In the first, the point is left after the asterisks of the
heading.

In the subsequent, the point is correctly set before the asterisks
of the headline (this is one outline-next-heading

Add a call to goto-char to go to the beginning of the match

I tried to run the tests, but they failed in the python async section.
I was only able to run and pass 301/1260

Please let me know if you need anything else from me.

thank you again,

--daniel


>From 0335937442f0aa050b6c089395a2ca26c7970f46 Mon Sep 17 00:00:00 2001
From: Daniel M German <d...@turingmachine.org>
Date: Thu, 5 Jun 2025 10:11:27 -0700
Subject: [PATCH] Get org-map-region to properly set the point in first heading

The current logic of org-map-region uses two searches.

In the first, the point is left after the asterisks of the
heading.

In the subsequent, the point is correctly set before the asterisks
of the headline (this is one outline-next-heading

Add a call to goto-char to go to the beginning of the match
---
 lisp/org.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/org.el b/lisp/org.el
index 174c4c8e5..bf5d10ed4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7005,6 +7005,7 @@ After top level, it switches back to sibling level."
       (goto-char beg)
       (when (and (re-search-forward org-outline-regexp-bol nil t)
 		 (< (point) end))
+        (goto-char (match-beginning 0))
 	(funcall fun))
       (while (and (progn
 		    (outline-next-heading)
-- 
2.49.0






--
Daniel M. German                  "The "people" who exercise the
                                   power, are not always the same
                                   people with those over whom
   John Stuart Mill ->             it is exercised."
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .

Reply via email to