Subject: bug#16265: 24.3.50; re-search-forward (error "Invalid search bound (wrong side of point)")

From: Nicolas Richard <[email-masked]>
Date: Tue, 31 Dec 2013 13:07:24 +0100

Le 28/12/2013 21:44, Keith David Bershatsky a écrit :
> This example demonstrates the problem caused when `org-capture`
> damages the line numbers in the `org-agenda-files`, making it
> impossible to go to the bottom of the buffer with (goto-char
> (point-max))  --  consequently, re-search-backward fails -- other
> functions fail also, e.g., `org-sort-entries`.

Thanks for the recipe, I can indeed reproduce problems, but they are
different from what you describe. I suspect they are tied, but I'm not
sure because I don't understand them.

Here is a reduced version of your recipe which shows what I see. Run the
following snippet using emacs -Q --batch -l filenamehere :
,---- this is filenamehere.el
| (setq test-file "/tmp/foo.org")
| (setq capture-todo (mapconcat
|                     #'identity
|                     (list "** whatever"
|                           ":PROPERTIES:"
|                           ":ToodledoFolder: TASKS"
|                           ":END:")
|                     "\n"))
| (when (file-exists-p test-file) (delete-file test-file) (message "Deleted file %s" test-file))
| (find-file test-file)
| (org-mode)
| (setq org-agenda-files (list test-file))
| (setq org-capture-templates `(("n" "NextAction" entry (file+headline test-file "TASKS")
| 			       ,capture-todo)))
| (org-capture nil "n")
| (org-capture-finalize)
| (goto-char (point-min))
| (insert "It's important to insert something ; I guess it triggers something\n")
| (search-forward "Toodledo")
| (end-of-line) ; this should land us before "\n:END:" not after it
| (if (looking-at "\n:END:")
|     (message "Great!")
|   (error "Problem here."))
`----

fun facts : if you remove the (insert ...) form, it works. Also, if you
do it interactively, then the problem appears too, but not if you clone
the buffer.

I'll bisect this (I tested 24.3, it works there) and post the result
unless someone understands what's going on before the bisect finishes
(it does take quite some time to rebuild each version of emacs on my
machine).

-- 
Nicolas.