Hi,

I've found that org-element-cache-map can hang when using the :to-pos option.

;;; test-final.el

(require 'org)
(require 'org-element)

(defun test-hang ()
  "Minimal reproducer for org-element-cache-map hang.
The bug requires:
1. :granularity 'element parameter
2. Following headlines after the target headline"
  (with-temp-buffer
    (org-mode)
    (insert "* Headline 1\n")
    (insert ":LOGBOOK:\n")
    (insert "Content\n")
    (insert ":END:\n")
    (insert "* Headline 2\n")
    (insert "* Headline 3\n")
    (goto-char (point-min))
    (message "Starting...")
    (let* ((elem (org-element-at-point))
           (to (org-entry-end-position)))
      (org-element-cache-map
       (lambda (e) nil)
       :granularity 'element
       :to-pos to)
      (message "Success"))))

;;; end of test-final.el


Running with latest org-mode from git (commit 
7235abfaec242d03ef8aaa7d2bbb8c27b99614b5) like this:

make repro REPRO_ARGS="-Q --batch -l test-final.el -eval \"(test-hang)\""

will hang after printing Starting... (or interactively within emacs)

It seems to work if you remove the "Content" line, or either of the following 
Headline 2/3.  It also works if you remove :to-pos or increase its value by 
one, but I don't see why it shouldn't work like this?

Thanks,
Rick

Reply via email to